Skip to content

Commit 70fe465

Browse files
committed
Update XXZ and Haldane examples
1 parent ea17f00 commit 70fe465

File tree

7 files changed

+1442
-2816
lines changed

7 files changed

+1442
-2816
lines changed

docs/src/examples/quantum1d/4.xxz-heisenberg/index.md

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

docs/src/examples/quantum1d/4.xxz-heisenberg/main.ipynb

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"outputs": [],
3535
"cell_type": "code",
3636
"source": [
37-
"H = heisenberg_XXX(; spin=1 // 2);"
37+
"H = heisenberg_XXX(; spin=1 // 2)"
3838
],
3939
"metadata": {},
4040
"execution_count": null
@@ -50,8 +50,7 @@
5050
"outputs": [],
5151
"cell_type": "code",
5252
"source": [
53-
"random_data = TensorMap(rand, ComplexF64, ℂ^20 * ℂ^2, ℂ^20);\n",
54-
"state = InfiniteMPS([random_data]);"
53+
"state = InfiniteMPS(2, 20)"
5554
],
5655
"metadata": {},
5756
"execution_count": null
@@ -130,9 +129,7 @@
130129
"outputs": [],
131130
"cell_type": "code",
132131
"source": [
133-
"A = TensorMap(rand, ComplexF64, ℂ^20 * ℂ^2, ℂ^20);\n",
134-
"B = TensorMap(rand, ComplexF64, ℂ^20 * ℂ^2, ℂ^20);\n",
135-
"state = InfiniteMPS([A, B]);"
132+
"state = InfiniteMPS(fill(2, 2), fill(20, 2))"
136133
],
137134
"metadata": {},
138135
"execution_count": null
@@ -152,7 +149,7 @@
152149
"source": [
153150
"# H2 = repeat(H, 2); -- copies the one-site version\n",
154151
"H2 = heisenberg_XXX(ComplexF64, Trivial, InfiniteChain(2); spin=1 // 2)\n",
155-
"groundstate, cache, delta = find_groundstate(state, H2,\n",
152+
"groundstate, envs, delta = find_groundstate(state, H2,\n",
156153
" VUMPS(; maxiter=100, tol=1e-12));"
157154
],
158155
"metadata": {},
@@ -170,9 +167,9 @@
170167
"outputs": [],
171168
"cell_type": "code",
172169
"source": [
173-
"groundstate, cache, delta = find_groundstate(state, H2,\n",
170+
"groundstate, envs, delta = find_groundstate(state, H2,\n",
174171
" IDMRG2(; trscheme=truncdim(50), maxiter=20,\n",
175-
" tol=1e-12))\n",
172+
" tol=1e-12));\n",
176173
"entanglementplot(groundstate)"
177174
],
178175
"metadata": {},
@@ -270,11 +267,11 @@
270267
"file_extension": ".jl",
271268
"mimetype": "application/julia",
272269
"name": "julia",
273-
"version": "1.11.1"
270+
"version": "1.11.2"
274271
},
275272
"kernelspec": {
276273
"name": "julia-1.11",
277-
"display_name": "Julia 1.11.1",
274+
"display_name": "Julia 1.11.2",
278275
"language": "julia"
279276
}
280277
},

docs/src/examples/quantum1d/5.haldane-spt/index.md

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

docs/src/examples/quantum1d/5.haldane-spt/main.ipynb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@
4646
"function heisenberg_hamiltonian(; J=-1.0)\n",
4747
" s = SU2Irrep(1)\n",
4848
" ℋ = SU2Space(1 => 1)\n",
49-
" SS = TensorMap(zeros, ComplexF64, ℋ ⊗ ℋ ← ℋ ⊗ ℋ)\n",
49+
" SS = zeros(ComplexF64, ℋ ⊗ ℋ ← ℋ ⊗ ℋ)\n",
5050
" for (S, data) in blocks(SS)\n",
5151
" data .= -0.5J * (casimir(S) - casimir(s) - casimir(s))\n",
5252
" end\n",
53-
" return MPOHamiltonian(SS)\n",
53+
" return InfiniteMPOHamiltonian(SS)\n",
5454
"end\n",
55-
"H = heisenberg_hamiltonian();"
55+
"H = heisenberg_hamiltonian()"
5656
],
5757
"metadata": {},
5858
"execution_count": null
@@ -198,11 +198,11 @@
198198
"file_extension": ".jl",
199199
"mimetype": "application/julia",
200200
"name": "julia",
201-
"version": "1.11.1"
201+
"version": "1.11.2"
202202
},
203203
"kernelspec": {
204204
"name": "julia-1.11",
205-
"display_name": "Julia 1.11.1",
205+
"display_name": "Julia 1.11.2",
206206
"language": "julia"
207207
}
208208
},

examples/Cache.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@
44
[quantum1d]
55
"2.haldane" = "4f3e177a30df907cf7b9a47958ddf97741e4d0398ae1876e0f4977ccb93ae651"
66
"3.ising-dqpt" = "f437ac4560db51f67e3997867c02bb8844b1077731b1dd1a06c61ab7c4846e97"
7+
"5.haldane-spt" = "6443696b20d416652951c646cf78b604a7fd0d79804995588491ea53ca210d57"
78
"1.ising-cft" = "bd1253451973aa73c4fee6b64d81ee52cc2feba5b9632f87ce332eea3a05f460"
9+
"4.xxz-heisenberg" = "f8359ad29a028b01d41913014c0a442b99c3bd5cd403c23bd2a59f646a7c78cf"

examples/quantum1d/4.xxz-heisenberg/main.jl

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,13 @@ Then we specify an initial guess, which we then further optimize.
1515
Working directly in the thermodynamic limit, this is achieved as follows:
1616
"""
1717

18-
H = heisenberg_XXX(; spin=1 // 2);
18+
H = heisenberg_XXX(; spin=1 // 2)
1919

2020
md"""
2121
We then need an intial state, which we shall later optimize. In this example we work directly in the thermodynamic limit.
2222
"""
2323

24-
random_data = TensorMap(rand, ComplexF64, ℂ^20 *^2, ℂ^20);
25-
state = InfiniteMPS([random_data]);
24+
state = InfiniteMPS(2, 20)
2625

2726
md"""
2827
The groundstate can then be found by calling `find_groundstate`.
@@ -58,9 +57,7 @@ md"""
5857
Let's initialize a different initial state, this time with a 2-site unit cell:
5958
"""
6059

61-
A = TensorMap(rand, ComplexF64, ℂ^20 *^2, ℂ^20);
62-
B = TensorMap(rand, ComplexF64, ℂ^20 *^2, ℂ^20);
63-
state = InfiniteMPS([A, B]);
60+
state = InfiniteMPS(fill(2, 2), fill(20, 2))
6461

6562
md"""
6663
In MPSKit, we require that the periodicity of the hamiltonian equals that of the state it is applied to.
@@ -70,17 +67,17 @@ Alternatively, the hamiltonian can be constructed directly on a two-site unitcel
7067

7168
## H2 = repeat(H, 2); -- copies the one-site version
7269
H2 = heisenberg_XXX(ComplexF64, Trivial, InfiniteChain(2); spin=1 // 2)
73-
groundstate, cache, delta = find_groundstate(state, H2,
70+
groundstate, envs, delta = find_groundstate(state, H2,
7471
VUMPS(; maxiter=100, tol=1e-12));
7572

7673
md"""
7774
We get convergence, but it takes an enormous amount of iterations.
7875
The reason behind this becomes more obvious at higher bond dimensions:
7976
"""
8077

81-
groundstate, cache, delta = find_groundstate(state, H2,
78+
groundstate, envs, delta = find_groundstate(state, H2,
8279
IDMRG2(; trscheme=truncdim(50), maxiter=20,
83-
tol=1e-12))
80+
tol=1e-12));
8481
entanglementplot(groundstate)
8582

8683
md"""

examples/quantum1d/5.haldane-spt/main.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ casimir(s::SU2Irrep) = s.j * (s.j + 1)
3737
function heisenberg_hamiltonian(; J=-1.0)
3838
s = SU2Irrep(1)
3939
= SU2Space(1 => 1)
40-
SS = TensorMap(zeros, ComplexF64, ℋ ℋ)
40+
SS = zeros(ComplexF64, ℋ ℋ)
4141
for (S, data) in blocks(SS)
4242
data .= -0.5J * (casimir(S) - casimir(s) - casimir(s))
4343
end
44-
return MPOHamiltonian(SS)
44+
return InfiniteMPOHamiltonian(SS)
4545
end
46-
H = heisenberg_hamiltonian();
46+
H = heisenberg_hamiltonian()
4747

4848
md"""
4949
## Symmetry-Protected Topological Order

0 commit comments

Comments
 (0)