|
| 1 | +using ITensors |
| 2 | +using ITensorInfiniteMPS |
| 3 | + |
| 4 | +############################################################################## |
| 5 | +# VUMPS parameters |
| 6 | +# |
| 7 | + |
| 8 | +maxdim = 64 # Maximum bond dimension |
| 9 | +cutoff = 1e-6 # Singular value cutoff when increasing the bond dimension |
| 10 | +max_vumps_iters = 100 # Maximum number of iterations of the VUMPS algorithm at each bond dimension |
| 11 | +vumps_tol = 1e-6 |
| 12 | +outer_iters = 4 # Number of times to increase the bond dimension |
| 13 | + |
| 14 | +############################################################################## |
| 15 | +# CODE BELOW HERE DOES NOT NEED TO BE MODIFIED |
| 16 | +# |
| 17 | +N = 2# Number of sites in the unit cell |
| 18 | +J = 1.0 |
| 19 | +h = 1.0; |
| 20 | + |
| 21 | +function space_shifted(q̃sz) |
| 22 | + return [QN("SzParity", 1 - q̃sz, 2) => 1, QN("SzParity", 0 - q̃sz, 2) => 1] |
| 23 | +end |
| 24 | + |
| 25 | +space_ = fill(space_shifted(1), N); |
| 26 | +s = infsiteinds("S=1/2", N; space=space_) |
| 27 | +initstate(n) = "↑" |
| 28 | +ψ = InfMPS(s, initstate); |
| 29 | + |
| 30 | +model = Model("ising"); |
| 31 | +H = InfiniteITensorSum(model, s; J=J, h=h); |
| 32 | +#to test the case where the range is larger than the unit cell size |
| 33 | +for x in 1:N |
| 34 | + H.data[x] = H.data[x] * delta(prime(s[x + 3]), dag(s[x + 3])) |
| 35 | +end |
| 36 | + |
| 37 | +@show norm(contract(ψ.AL[1:N]..., ψ.C[N]) - contract(ψ.C[0], ψ.AR[1:N]...)); |
| 38 | + |
| 39 | +vumps_kwargs = (tol=vumps_tol, maxiter=max_vumps_iters) |
| 40 | +subspace_expansion_kwargs = (cutoff=cutoff, maxdim=maxdim) |
| 41 | +ψ_0 = vumps(H, ψ; vumps_kwargs...) |
| 42 | + |
| 43 | +for j in 1:outer_iters |
| 44 | + println("\nIncrease bond dimension") |
| 45 | + ψ_1 = subspace_expansion(ψ_0, H; subspace_expansion_kwargs...) |
| 46 | + println("Run VUMPS with new bond dimension") |
| 47 | + ψ_0 = vumps(H, ψ_1; vumps_kwargs...) |
| 48 | +end |
| 49 | + |
| 50 | +function ITensors.expect(ψ::InfiniteCanonicalMPS, o, n) |
| 51 | + return (noprime(ψ.AL[n] * ψ.C[n] * op(o, s[n])) * dag(ψ.AL[n] * ψ.C[n]))[] |
| 52 | +end |
| 53 | + |
| 54 | +function ITensors.expect(ψ::InfiniteCanonicalMPS, h::ITensor) |
| 55 | + l = linkinds(only, ψ.AL) |
| 56 | + r = linkinds(only, ψ.AR) |
| 57 | + s = siteinds(only, ψ) |
| 58 | + δˢ(n) = δ(dag(s[n]), prime(s[n])) |
| 59 | + δˡ(n) = δ(l[n], prime(dag(l[n]))) |
| 60 | + δʳ(n) = δ(dag(r[n]), prime(r[n])) |
| 61 | + ψ′ = prime(dag(ψ)) |
| 62 | + |
| 63 | + ns = sort(findsites(ψ, h)) |
| 64 | + nrange = ns[end] - ns[1] + 1 |
| 65 | + idx = 2 |
| 66 | + temp_O = δˡ(ns[1] - 1) * ψ.AL[ns[1]] * h * ψ′.AL[ns[1]] |
| 67 | + for n in (ns[1] + 1):(ns[1] + nrange - 1) |
| 68 | + if n == ns[idx] |
| 69 | + temp_O = temp_O * ψ.AL[n] * ψ′.AL[n] |
| 70 | + idx += 1 |
| 71 | + else |
| 72 | + temp_O = temp_O * ψ.AL[n] * δˢ(n) * ψ′.AL[n] |
| 73 | + end |
| 74 | + end |
| 75 | + temp_O = temp_O * ψ.C[ns[end]] * δʳ(ns[end]) * ψ′.C[ns[end]] |
| 76 | + return temp_O[] |
| 77 | +end |
| 78 | + |
| 79 | +function ITensors.expect(ψ::InfiniteCanonicalMPS, h::InfiniteITensorSum) |
| 80 | + return [expect(ψ, h[(j, j + 1)]) for j in 1:nsites(ψ)] |
| 81 | +end |
| 82 | + |
| 83 | +Sz = [expect(ψ_0, "Sz", n) for n in 1:N] |
| 84 | +energy_infinite = expect(ψ_0, H) |
| 85 | + |
| 86 | +Nfinite = 100 |
| 87 | +sfinite = siteinds("S=1/2", Nfinite; conserve_szparity=true) |
| 88 | +Hfinite = MPO(model, sfinite; J=J, h=h) |
| 89 | +ψfinite = randomMPS(sfinite, initstate; linkdims=10) |
| 90 | +@show flux(ψfinite) |
| 91 | +sweeps = Sweeps(15) |
| 92 | +setmaxdim!(sweeps, maxdim) |
| 93 | +setcutoff!(sweeps, cutoff) |
| 94 | +energy_finite_total, ψfinite = dmrg(Hfinite, ψfinite, sweeps) |
| 95 | + |
| 96 | +nfinite = Nfinite ÷ 2 |
| 97 | +Sz_finite = expect(ψfinite, "Sz")[nfinite:(nfinite + N - 1)] |
| 98 | + |
| 99 | +@show ( |
| 100 | + energy_infinite, |
| 101 | + energy_finite_total / Nfinite, |
| 102 | + reference(model, Observable("energy"); J=J, h=h, J₂=J₂), |
| 103 | +) |
| 104 | + |
| 105 | +@show (Sz, Sz_finite) |
0 commit comments