Skip to content

Commit c419625

Browse files
authored
Various (hopefully final) fixes (again) (#233)
* fix readme * Fix PBC * update README * remove_orphans! for all mpos * Update hard hexagon * Fix envs after optimalexpand * Fix ising example * Update haldane example * Update Ising dqpt example * Fix typo in IDMRG2 struct * Update XXZ and Haldane examples * More fixes * Fix example hubbard
1 parent 7938a7e commit c419625

File tree

28 files changed

+2576
-3993
lines changed

28 files changed

+2576
-3993
lines changed
23 Bytes
Loading

docs/src/examples/classic2d/1.hard-hexagon/index.md

Lines changed: 45 additions & 45 deletions
Large diffs are not rendered by default.

docs/src/examples/classic2d/1.hard-hexagon/main.ipynb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"cell_type": "code",
4040
"source": [
4141
"mpo = hard_hexagon()\n",
42-
"P = space(mpo.opp[1], 2)\n",
42+
"P = physicalspace(mpo, 1)\n",
4343
"function virtual_space(D::Integer)\n",
4444
" _D = round(Int, D / sum(dim, values(FibonacciAnyon)))\n",
4545
" return Vect[FibonacciAnyon](sector => _D for sector in (:I, :τ))\n",
@@ -86,7 +86,7 @@
8686
"source": [
8787
"## The scaling hypothesis\n",
8888
"\n",
89-
"The dominant eigenvector is of course only an approximation. The finite bond dimension enforces a finite correlation length, which effectively introduces a length scale in the system. This can be exploited to formulate a [scaling hypothesis](https://arxiv.org/pdf/0812.2903.pdf), which in turn allows to extract the central charge.\n",
89+
"The dominant eigenvector is of course only an approximation. The finite bond dimension enforces a finite correlation length, which effectively introduces a length scale in the system. This can be exploited to formulate a [pollmann2009](@cite), which in turn allows to extract the central charge.\n",
9090
"\n",
9191
"First we need to know the entropy and correlation length at a bunch of different bond dimensions. Our approach will be to re-use the previous approximated dominant eigenvector, and then expanding its bond dimension and re-running VUMPS.\n",
9292
"According to the scaling hypothesis we should have $S \\propto \\frac{c}{6} log(ξ)$. Therefore we should find $c$ using"
@@ -145,11 +145,11 @@
145145
"file_extension": ".jl",
146146
"mimetype": "application/julia",
147147
"name": "julia",
148-
"version": "1.11.1"
148+
"version": "1.11.2"
149149
},
150150
"kernelspec": {
151151
"name": "julia-1.11",
152-
"display_name": "Julia 1.11.1",
152+
"display_name": "Julia 1.11.2",
153153
"language": "julia"
154154
}
155155
},

docs/src/examples/quantum1d/1.ising-cft/index.md

Lines changed: 221 additions & 186 deletions
Large diffs are not rendered by default.

docs/src/examples/quantum1d/1.ising-cft/main.ipynb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"cell_type": "code",
3535
"source": [
3636
"L = 12\n",
37-
"H = periodic_boundary_conditions(transverse_field_ising(), L);"
37+
"H = periodic_boundary_conditions(transverse_field_ising(), L)"
3838
],
3939
"metadata": {},
4040
"execution_count": null
@@ -97,7 +97,7 @@
9797
"source": [
9898
"id = complex(isomorphism(ℂ^2, ℂ^2))\n",
9999
"@tensor O[-1 -2; -3 -4] := id[-1, -3] * id[-2, -4]\n",
100-
"T = periodic_boundary_conditions(DenseMPO(O), L);"
100+
"T = periodic_boundary_conditions(InfiniteMPO([O]), L)"
101101
],
102102
"metadata": {},
103103
"execution_count": null
@@ -191,11 +191,11 @@
191191
"outputs": [],
192192
"cell_type": "code",
193193
"source": [
194-
"E_ex, qps = excitations(H, QuasiparticleAnsatz(), ψ, envs; num=16)\n",
194+
"E_ex, qps = excitations(H_mps, QuasiparticleAnsatz(), ψ, envs; num=16)\n",
195195
"states_mps = vcat(ψ, map(qp -> convert(FiniteMPS, qp), qps))\n",
196196
"E_mps = map(x -> expectation_value(x, H_mps), states_mps)\n",
197197
"\n",
198-
"T_mps = periodic_boundary_conditions(DenseMPO(O), L_mps)\n",
198+
"T_mps = periodic_boundary_conditions(InfiniteMPO([O]), L_mps)\n",
199199
"momenta_mps = Float64[]\n",
200200
"append!(momenta_mps, fix_degeneracies(states[1:1]))\n",
201201
"append!(momenta_mps, fix_degeneracies(states[2:2]))\n",
@@ -232,11 +232,11 @@
232232
"file_extension": ".jl",
233233
"mimetype": "application/julia",
234234
"name": "julia",
235-
"version": "1.11.1"
235+
"version": "1.11.2"
236236
},
237237
"kernelspec": {
238238
"name": "julia-1.11",
239-
"display_name": "Julia 1.11.1",
239+
"display_name": "Julia 1.11.2",
240240
"language": "julia"
241241
}
242242
},

docs/src/examples/quantum1d/2.haldane/index.md

Lines changed: 124 additions & 126 deletions
Large diffs are not rendered by default.

docs/src/examples/quantum1d/2.haldane/main.ipynb

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@
3636
"outputs": [],
3737
"cell_type": "code",
3838
"source": [
39-
"H = heisenberg_XXX(ComplexF64, SU2Irrep; spin=1, J=1);"
39+
"symmetry = SU2Irrep\n",
40+
"spin = 1\n",
41+
"J = 1"
4042
],
4143
"metadata": {},
4244
"execution_count": null
@@ -63,9 +65,12 @@
6365
"cell_type": "code",
6466
"source": [
6567
"L = 11\n",
68+
"chain = FiniteChain(L)\n",
69+
"H = heisenberg_XXX(symmetry, chain; J, spin)\n",
70+
"\n",
6671
"physical_space = SU2Space(1 => 1)\n",
6772
"virtual_space = SU2Space(0 => 12, 1 => 12, 2 => 5, 3 => 3)\n",
68-
"ψ₀ = FiniteMPS(rand, ComplexF64, L, physical_space, virtual_space)\n",
73+
"ψ₀ = FiniteMPS(L, physical_space, virtual_space)\n",
6974
"ψ, envs, delta = find_groundstate(ψ₀, H, DMRG(; verbosity=0))\n",
7075
"E₀ = real(expectation_value(ψ, H))\n",
7176
"En_1, st_1 = excitations(H, QuasiparticleAnsatz(), ψ, envs; sector=SU2Irrep(1))\n",
@@ -114,7 +119,8 @@
114119
"Ls = 12:4:30\n",
115120
"ΔEs = map(Ls) do L\n",
116121
" @info \"computing L = $L\"\n",
117-
" ψ₀ = FiniteMPS(rand, ComplexF64, L, physical_space, virtual_space)\n",
122+
" ψ₀ = FiniteMPS(L, physical_space, virtual_space)\n",
123+
" H = heisenberg_XXX(symmetry, FiniteChain(L); J, spin)\n",
118124
" ψ, envs, delta = find_groundstate(ψ₀, H, DMRG(; verbosity=0))\n",
119125
" En_1, st_1 = excitations(H, QuasiparticleAnsatz(), ψ, envs; sector=SU2Irrep(1))\n",
120126
" En_2, st_2 = excitations(H, QuasiparticleAnsatz(), ψ, envs; sector=SU2Irrep(2))\n",
@@ -149,6 +155,8 @@
149155
"outputs": [],
150156
"cell_type": "code",
151157
"source": [
158+
"chain = InfiniteChain(1)\n",
159+
"H = heisenberg_XXX(symmetry, chain; J, spin)\n",
152160
"virtual_space_inf = Rep[SU₂](1 // 2 => 16, 3 // 2 => 16, 5 // 2 => 8, 7 // 2 => 4)\n",
153161
"ψ₀_inf = InfiniteMPS([physical_space], [virtual_space_inf])\n",
154162
"ψ_inf, envs_inf, delta_inf = find_groundstate(ψ₀_inf, H; verbosity=0)\n",
@@ -179,11 +187,11 @@
179187
"file_extension": ".jl",
180188
"mimetype": "application/julia",
181189
"name": "julia",
182-
"version": "1.11.1"
190+
"version": "1.11.2"
183191
},
184192
"kernelspec": {
185193
"name": "julia-1.11",
186-
"display_name": "Julia 1.11.1",
194+
"display_name": "Julia 1.11.2",
187195
"language": "julia"
188196
}
189197
},

docs/src/examples/quantum1d/3.ising-dqpt/index.md

Lines changed: 25 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,21 @@ For those ``g`` we expect non-analicities to occur at ``t_n ≈ 2.35 (n + 1/2)``
3232
First we construct the hamiltonian in mpo form, and obtain the pre-quenched groundstate:
3333

3434
````julia
35-
H₀ = transverse_field_ising(; g=-0.5)
36-
3735
L = 20
38-
ψ₀ = FiniteMPS(rand, ComplexF64, L, ℂ^2, ℂ^10)
36+
H₀ = transverse_field_ising(FiniteChain(L); g=-0.5)
37+
ψ₀ = FiniteMPS(L, ℂ^2, ℂ^10)
3938
ψ₀, _ = find_groundstate(ψ₀, H₀, DMRG());
4039
````
4140

4241
````
43-
[ Info: DMRG init: obj = +9.799964091770e+00 err = 1.5223e-01
44-
[ Info: DMRG 1: obj = -2.040021714743e+01 err = 2.4038839149e-02 time = 0.09 sec
45-
[ Info: DMRG 2: obj = -2.040021715170e+01 err = 6.0313575856e-07 time = 0.07 sec
46-
[ Info: DMRG 3: obj = -2.040021773534e+01 err = 1.6799456960e-05 time = 0.14 sec
47-
[ Info: DMRG 4: obj = -2.040021786694e+01 err = 1.9058246307e-06 time = 0.09 sec
48-
[ Info: DMRG 5: obj = -2.040021786703e+01 err = 1.1474711603e-06 time = 0.05 sec
49-
[ Info: DMRG 6: obj = -2.040021786703e+01 err = 4.3837579221e-10 time = 0.02 sec
50-
[ Info: DMRG conv 7: obj = -2.040021786703e+01 err = 1.9834477158e-11 time = 0.50 sec
42+
[ Info: DMRG init: obj = +1.002387808585e+01 err = 1.4432e-01
43+
[ Info: DMRG 1: obj = -2.040021714927e+01 err = 4.0939235067e-03 time = 0.07 sec
44+
[ Info: DMRG 2: obj = -2.040021715177e+01 err = 4.1045749328e-07 time = 0.02 sec
45+
[ Info: DMRG 3: obj = -2.040021782419e+01 err = 4.0893119931e-05 time = 0.11 sec
46+
[ Info: DMRG 4: obj = -2.040021786700e+01 err = 1.5231059570e-06 time = 0.12 sec
47+
[ Info: DMRG 5: obj = -2.040021786703e+01 err = 1.1927466419e-07 time = 0.04 sec
48+
[ Info: DMRG 6: obj = -2.040021786703e+01 err = 1.0958548921e-10 time = 0.02 sec
49+
[ Info: DMRG conv 7: obj = -2.040021786703e+01 err = 2.1531775493e-12 time = 0.43 sec
5150
5251
````
5352

@@ -63,7 +62,7 @@ echo(ψ₀::FiniteMPS, ψₜ::FiniteMPS) = -2 * log(abs(dot(ψ₀, ψₜ))) / le
6362
We will initially use a two-site TDVP scheme to dynamically increase the bond dimension while time evolving, and later on switch to a faster one-site scheme. A single timestep can be done using
6463

6564
````julia
66-
H₁ = transverse_field_ising(; g=-2.0)
65+
H₁ = transverse_field_ising(FiniteChain(L); g=-2.0)
6766
ψₜ = deepcopy(ψ₀)
6867
dt = 0.01
6968
ψₜ, envs = timestep(ψₜ, H₁, 0, dt, TDVP2(; trscheme=truncdim(20)));
@@ -75,9 +74,11 @@ Putting it all together, we get
7574

7675
````julia
7776
function finite_sim(L; dt=0.05, finaltime=5.0)
78-
ψ₀ = FiniteMPS(rand, ComplexF64, L, ℂ^2, ℂ^10)
77+
ψ₀ = FiniteMPS(L, ℂ^2, ℂ^10)
78+
H₀= transverse_field_ising(FiniteChain(L); g=-0.5)
7979
ψ₀, _ = find_groundstate(ψ₀, H₀, DMRG())
8080

81+
H₁ = transverse_field_ising(FiniteChain(L); g=-2.0)
8182
ψₜ = deepcopy(ψ₀)
8283
envs = environments(ψₜ, H₁)
8384

@@ -106,27 +107,18 @@ Similarly we could start with an initial infinite state and find the pre-quench
106107

107108
````julia
108109
ψ₀ = InfiniteMPS([ℂ^2], [ℂ^10])
110+
H₀ = transverse_field_ising(; g=-0.5)
109111
ψ₀, _ = find_groundstate(ψ₀, H₀, VUMPS());
110112
````
111113

112114
````
113-
[ Info: VUMPS init: obj = +5.000419382862e-01 err = 3.8507e-01
114-
[ Info: VUMPS 1: obj = -1.062780898337e+00 err = 2.4151374798e-02 time = 1.31 sec
115-
┌ Warning: ignoring imaginary component -3.817802691569172e-6 from total weight 2.4343214394239743: operator might not be hermitian?
116-
│ α = 1.7081089443203243 - 3.817802691569172e-6im
117-
│ β₁ = 0.14004438155194618
118-
│ β₂ = 1.7287776826281838
119-
└ @ KrylovKit ~/.julia/packages/KrylovKit/xccMN/src/factorizations/lanczos.jl:170
120-
┌ Warning: ignoring imaginary component -4.33258309393697e-6 from total weight 3.290563788912538: operator might not be hermitian?
121-
│ α = 2.784222669687663 - 4.33258309393697e-6im
122-
│ β₁ = 0.13141322180957496
123-
│ β₂ = 1.7488981501547187
124-
└ @ KrylovKit ~/.julia/packages/KrylovKit/xccMN/src/factorizations/lanczos.jl:170
125-
[ Info: VUMPS 2: obj = -1.063544409753e+00 err = 1.4337063091e-05 time = 0.08 sec
126-
[ Info: VUMPS 3: obj = -1.063544409973e+00 err = 1.7048015038e-07 time = 0.01 sec
127-
[ Info: VUMPS 4: obj = -1.063544409973e+00 err = 1.7183182449e-08 time = 0.01 sec
128-
[ Info: VUMPS 5: obj = -1.063544409973e+00 err = 5.8865202016e-10 time = 0.01 sec
129-
[ Info: VUMPS conv 6: obj = -1.063544409973e+00 err = 6.8020365686e-11 time = 1.42 sec
115+
[ Info: VUMPS init: obj = +4.829091166942e-01 err = 3.8333e-01
116+
[ Info: VUMPS 1: obj = -1.062402142520e+00 err = 2.6498065851e-02 time = 0.02 sec
117+
[ Info: VUMPS 2: obj = -1.063544409278e+00 err = 2.4370573433e-05 time = 0.01 sec
118+
[ Info: VUMPS 3: obj = -1.063544409973e+00 err = 1.2541001144e-07 time = 0.01 sec
119+
[ Info: VUMPS 4: obj = -1.063544409973e+00 err = 2.2271390880e-09 time = 0.01 sec
120+
[ Info: VUMPS 5: obj = -1.063544409973e+00 err = 1.3003499540e-10 time = 0.01 sec
121+
[ Info: VUMPS conv 6: obj = -1.063544409973e+00 err = 1.2478380148e-11 time = 0.08 sec
130122
131123
````
132124

@@ -138,7 +130,7 @@ dot(ψ₀, ψ₀)
138130
````
139131

140132
````
141-
1.0000000000000018 - 7.06078012856404e-16im
133+
1.0000000000000004 + 1.6174779448250835e-16im
142134
````
143135

144136
so the loschmidth echo takes on the pleasant form
@@ -155,6 +147,7 @@ Growing the bond dimension by ``5`` can be done by calling:
155147

156148
````julia
157149
ψₜ = deepcopy(ψ₀)
150+
H₁ = transverse_field_ising(; g=-2.0)
158151
ψₜ, envs = changebonds(ψₜ, H₁, OptimalExpand(; trscheme=truncdim(5)));
159152
````
160153

@@ -183,7 +176,7 @@ function infinite_sim(dt=0.05, finaltime=5.0)
183176
if t < 50dt # if t is sufficiently small, we increase the bond dimension
184177
ψₜ, envs = changebonds(ψₜ, H₁, OptimalExpand(; trscheme=truncdim(1)), envs)
185178
end
186-
(ψₜ, envs) = timestep(ψₜ, H₁, 0, dt, TDVP(), envs)
179+
ψₜ, envs = timestep(ψₜ, H₁, 0, dt, TDVP(), envs)
187180
push!(echos, echo(ψₜ, ψ₀))
188181
end
189182

docs/src/examples/quantum1d/3.ising-dqpt/main.ipynb

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,9 @@
4444
"outputs": [],
4545
"cell_type": "code",
4646
"source": [
47-
"H₀ = transverse_field_ising(; g=-0.5)\n",
48-
"\n",
4947
"L = 20\n",
50-
"ψ₀ = FiniteMPS(rand, ComplexF64, L, ℂ^2, ℂ^10)\n",
48+
"H₀ = transverse_field_ising(FiniteChain(L); g=-0.5)\n",
49+
"ψ₀ = FiniteMPS(L, ℂ^2, ℂ^10)\n",
5150
"ψ₀, _ = find_groundstate(ψ₀, H₀, DMRG());"
5251
],
5352
"metadata": {},
@@ -83,7 +82,7 @@
8382
"outputs": [],
8483
"cell_type": "code",
8584
"source": [
86-
"H₁ = transverse_field_ising(; g=-2.0)\n",
85+
"H₁ = transverse_field_ising(FiniteChain(L); g=-2.0)\n",
8786
"ψₜ = deepcopy(ψ₀)\n",
8887
"dt = 0.01\n",
8988
"ψₜ, envs = timestep(ψₜ, H₁, 0, dt, TDVP2(; trscheme=truncdim(20)));"
@@ -105,9 +104,11 @@
105104
"cell_type": "code",
106105
"source": [
107106
"function finite_sim(L; dt=0.05, finaltime=5.0)\n",
108-
" ψ₀ = FiniteMPS(rand, ComplexF64, L, ℂ^2, ℂ^10)\n",
107+
" ψ₀ = FiniteMPS(L, ℂ^2, ℂ^10)\n",
108+
" H₀= transverse_field_ising(FiniteChain(L); g=-0.5)\n",
109109
" ψ₀, _ = find_groundstate(ψ₀, H₀, DMRG())\n",
110110
"\n",
111+
" H₁ = transverse_field_ising(FiniteChain(L); g=-2.0)\n",
111112
" ψₜ = deepcopy(ψ₀)\n",
112113
" envs = environments(ψₜ, H₁)\n",
113114
"\n",
@@ -147,6 +148,7 @@
147148
"cell_type": "code",
148149
"source": [
149150
"ψ₀ = InfiniteMPS([ℂ^2], [ℂ^10])\n",
151+
"H₀ = transverse_field_ising(; g=-0.5)\n",
150152
"ψ₀, _ = find_groundstate(ψ₀, H₀, VUMPS());"
151153
],
152154
"metadata": {},
@@ -201,6 +203,7 @@
201203
"cell_type": "code",
202204
"source": [
203205
"ψₜ = deepcopy(ψ₀)\n",
206+
"H₁ = transverse_field_ising(; g=-2.0)\n",
204207
"ψₜ, envs = changebonds(ψₜ, H₁, OptimalExpand(; trscheme=truncdim(5)));"
205208
],
206209
"metadata": {},
@@ -249,7 +252,7 @@
249252
" if t < 50dt # if t is sufficiently small, we increase the bond dimension\n",
250253
" ψₜ, envs = changebonds(ψₜ, H₁, OptimalExpand(; trscheme=truncdim(1)), envs)\n",
251254
" end\n",
252-
" (ψₜ, envs) = timestep(ψₜ, H₁, 0, dt, TDVP(), envs)\n",
255+
" ψₜ, envs = timestep(ψₜ, H₁, 0, dt, TDVP(), envs)\n",
253256
" push!(echos, echo(ψₜ, ψ₀))\n",
254257
" end\n",
255258
"\n",
@@ -282,11 +285,11 @@
282285
"file_extension": ".jl",
283286
"mimetype": "application/julia",
284287
"name": "julia",
285-
"version": "1.11.1"
288+
"version": "1.11.2"
286289
},
287290
"kernelspec": {
288291
"name": "julia-1.11",
289-
"display_name": "Julia 1.11.1",
292+
"display_name": "Julia 1.11.2",
290293
"language": "julia"
291294
}
292295
},

0 commit comments

Comments
 (0)