Skip to content

Commit

Permalink
Update documentation examples
Browse files Browse the repository at this point in the history
  • Loading branch information
lkdvos committed Nov 27, 2023
1 parent db36b5e commit 0299778
Show file tree
Hide file tree
Showing 22 changed files with 4,136 additions and 1,089 deletions.
1 change: 1 addition & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ makedocs(;
),
),
),
size_threshold=512000,
),
pages=[
"Home" => "index.md",
Expand Down
92 changes: 45 additions & 47 deletions docs/src/examples/classic2d/1.hard-hexagon/index.md

Large diffs are not rendered by default.

12 changes: 5 additions & 7 deletions docs/src/examples/classic2d/1.hard-hexagon/main.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
"outputs": [],
"cell_type": "code",
"source": [
"using MPSKit, MPSKitModels, TensorKit, Plots, Polynomials\n",
"import TensorOperations; TensorOperations.disable_cache(); # hide"
"using MPSKit, MPSKitModels, TensorKit, Plots, Polynomials"
],
"metadata": {},
"execution_count": null
Expand Down Expand Up @@ -107,13 +106,12 @@
" for (i, d) in enumerate(diff(Ds))\n",
" ψ, envs = changebonds(ψ, mpo, OptimalExpand(; trscheme=truncdim(d)), envs)\n",
" ψ, envs, = leading_boundary(ψ, mpo, alg, envs)\n",
" entropies[i+1] = real(entropy(ψ)[1])\n",
" correlations[i+1] = correlation_length(ψ)\n",
" entropies[i + 1] = real(entropy(ψ)[1])\n",
" correlations[i + 1] = correlation_length(ψ)\n",
" end\n",
" return entropies, correlations\n",
"end\n",
"\n",
"\n",
"bond_dimensions = 10:5:25\n",
"ψ₀ = InfiniteMPS([P], [virtual_space(bond_dimensions[1])])\n",
"Ss, ξs = scaling_simulations(ψ₀, mpo, bond_dimensions)\n",
Expand Down Expand Up @@ -143,11 +141,11 @@
"file_extension": ".jl",
"mimetype": "application/julia",
"name": "julia",
"version": "1.9.2"
"version": "1.9.4"
},
"kernelspec": {
"name": "julia-1.9",
"display_name": "Julia 1.9.2",
"display_name": "Julia 1.9.4",
"language": "julia"
}
},
Expand Down
954 changes: 689 additions & 265 deletions docs/src/examples/quantum1d/1.ising-cft/index.md

Large diffs are not rendered by default.

37 changes: 28 additions & 9 deletions docs/src/examples/quantum1d/1.ising-cft/main.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
"cell_type": "code",
"source": [
"using MPSKit, MPSKitModels, TensorKit, Plots, KrylovKit\n",
"using LinearAlgebra: eigen, diagm, Hermitian\n",
"import TensorOperations; TensorOperations.disable_cache(); # hide"
"using LinearAlgebra: eigen, diagm, Hermitian"
],
"metadata": {},
"execution_count": null
Expand Down Expand Up @@ -57,8 +56,14 @@
"outputs": [],
"cell_type": "code",
"source": [
"energies, states = exact_diagonalization(H, num=18, alg=Lanczos(krylovdim=200));\n",
"plot(real.(energies), seriestype=:scatter, legend=false, ylabel=\"energy\", xlabel=\"#eigenvalue\")"
"energies, states = exact_diagonalization(H; num=18, alg=Lanczos(; krylovdim=200));\n",
"plot(\n",
" real.(energies);\n",
" seriestype=:scatter,\n",
" legend=false,\n",
" ylabel=\"energy\",\n",
" xlabel=\"#eigenvalue\",\n",
")"
],
"metadata": {},
"execution_count": null
Expand Down Expand Up @@ -142,7 +147,14 @@
"append!(momenta, fix_degeneracies(states[13:16]))\n",
"append!(momenta, fix_degeneracies(states[17:18]))\n",
"\n",
"plot(momenta, real.(energies[1:18]), seriestype=:scatter, xlabel=\"momentum\", ylabel=\"energy\", legend=false)"
"plot(\n",
" momenta,\n",
" real.(energies[1:18]);\n",
" seriestype=:scatter,\n",
" xlabel=\"momentum\",\n",
" ylabel=\"energy\",\n",
" legend=false,\n",
")"
],
"metadata": {},
"execution_count": null
Expand Down Expand Up @@ -182,7 +194,7 @@
"outputs": [],
"cell_type": "code",
"source": [
"E_ex, qps = excitations(H, QuasiparticleAnsatz(), ψ, envs, num=16)\n",
"E_ex, qps = excitations(H, QuasiparticleAnsatz(), ψ, envs; num=16)\n",
"states_mps = vcat(ψ, map(qp -> convert(FiniteMPS, qp), qps))\n",
"E_mps = map(x -> sum(expectation_value(x, H_mps)), states_mps)\n",
"\n",
Expand All @@ -197,7 +209,14 @@
"append!(momenta_mps, fix_degeneracies(states[12:12]))\n",
"append!(momenta_mps, fix_degeneracies(states[13:16]))\n",
"\n",
"plot(momenta_mps, real.(energies[1:16]), seriestype=:scatter, xlabel=\"momentum\", ylabel=\"energy\", legend=false)"
"plot(\n",
" momenta_mps,\n",
" real.(energies[1:16]);\n",
" seriestype=:scatter,\n",
" xlabel=\"momentum\",\n",
" ylabel=\"energy\",\n",
" legend=false,\n",
")"
],
"metadata": {},
"execution_count": null
Expand All @@ -218,11 +237,11 @@
"file_extension": ".jl",
"mimetype": "application/julia",
"name": "julia",
"version": "1.9.2"
"version": "1.9.4"
},
"kernelspec": {
"name": "julia-1.9",
"display_name": "Julia 1.9.2",
"display_name": "Julia 1.9.4",
"language": "julia"
}
},
Expand Down
451 changes: 253 additions & 198 deletions docs/src/examples/quantum1d/2.haldane/index.md

Large diffs are not rendered by default.

35 changes: 16 additions & 19 deletions docs/src/examples/quantum1d/2.haldane/main.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
"outputs": [],
"cell_type": "code",
"source": [
"using MPSKit, MPSKitModels, TensorKit, Plots, Polynomials\n",
"import TensorOperations; TensorOperations.disable_cache(); # hide"
"using MPSKit, MPSKitModels, TensorKit, Plots, Polynomials"
],
"metadata": {},
"execution_count": null
Expand All @@ -37,7 +36,7 @@
"outputs": [],
"cell_type": "code",
"source": [
"H = heisenberg_XXX(ComplexF64, SU2Irrep; spin=1, J=-1);"
"H = heisenberg_XXX(ComplexF64, SU2Irrep; spin=1, J=1);"
],
"metadata": {},
"execution_count": null
Expand All @@ -64,13 +63,13 @@
"cell_type": "code",
"source": [
"L = 10\n",
"physical_space = Rep[SU₂](1 => 1)\n",
"virtual_space = Rep[SU₂](0 => 15, 1 => 15, 2 => 10, 3 => 5)\n",
"physical_space = SU2Space(1 => 1)\n",
"virtual_space = SU2Space(0 => 12, 1 => 12, 2 => 5, 3 => 3)\n",
"ψ₀ = FiniteMPS(rand, ComplexF64, L, physical_space, virtual_space)\n",
"ψ, envs, delta = find_groundstate(ψ₀, H, DMRG(; verbose=false))\n",
"E₀ = real.(expectation_value(ψ, H))\n",
"En_1, st_1 = excitations(H, QuasiparticleAnsatz(), ψ, envs; sector=SU₂(1))\n",
"En_2, st_2 = excitations(H, QuasiparticleAnsatz(), ψ, envs; sector=SU₂(2))\n",
"En_1, st_1 = excitations(H, QuasiparticleAnsatz(), ψ, envs; sector=SU2Irrep(1))\n",
"En_2, st_2 = excitations(H, QuasiparticleAnsatz(), ψ, envs; sector=SU2Irrep(2))\n",
"ΔE_finite = real(En_2[1] - En_1[1])"
],
"metadata": {},
Expand Down Expand Up @@ -107,21 +106,20 @@
"outputs": [],
"cell_type": "code",
"source": [
"Ls = 5:5:50\n",
"Ls = 12:4:30\n",
"ΔEs = map(Ls) do L\n",
" @info \"computing L = $L\"\n",
" ψ₀ = FiniteMPS(rand, ComplexF64, L, physical_space, virtual_space)\n",
" ψ, envs, delta = find_groundstate(ψ₀, H, DMRG(; verbose=false))\n",
" En_1, st_1 = excitations(H, QuasiparticleAnsatz(), ψ, envs; sector=SU₂(1))\n",
" En_2, st_2 = excitations(H, QuasiparticleAnsatz(), ψ, envs; sector=SU₂(2))\n",
" En_1, st_1 = excitations(H, QuasiparticleAnsatz(), ψ, envs; sector=SU2Irrep(1))\n",
" En_2, st_2 = excitations(H, QuasiparticleAnsatz(), ψ, envs; sector=SU2Irrep(2))\n",
" return real(En_2[1] - En_1[1])\n",
"end\n",
"\n",
"f = fit(Ls .^ (-2), ΔEs, 1)\n",
"ΔE_extrapolated = f.coeffs[1]\n",
"p_size_extrapolation = plot(; xaxis=\"L^(-2)\", yaxis=\"ΔE\",\n",
" xlims=(0, 0.015))\n",
"plot!(p_size_extrapolation, Ls .^ (-2), ΔEs;\n",
" seriestype=:scatter, label=\"numerical\")\n",
"p_size_extrapolation = plot(; xaxis=\"L^(-2)\", yaxis=\"ΔE\", xlims=(0, 0.015))\n",
"plot!(p_size_extrapolation, Ls .^ (-2), ΔEs; seriestype=:scatter, label=\"numerical\")\n",
"plot!(p_size_extrapolation, x -> f(x); label=\"fit\")"
],
"metadata": {},
Expand All @@ -146,13 +144,12 @@
"outputs": [],
"cell_type": "code",
"source": [
"virtual_space_inf = Rep[SU₂](1 // 2 => 20, 3 // 2 => 20, 5 // 2 => 10, 7 // 2 => 10,\n",
" 9 // 2 => 5)\n",
"virtual_space_inf = Rep[SU₂](1//2 => 16, 3//2 => 16, 5//2 => 8, 7//2 => 4)\n",
"ψ₀_inf = InfiniteMPS([physical_space], [virtual_space_inf])\n",
"ψ_inf, envs_inf, delta_inf = find_groundstate(ψ₀_inf, H)\n",
"\n",
"kspace = range(0, π, 16)\n",
"Es, _ = excitations(H, QuasiparticleAnsatz(), kspace, ψ_inf, envs_inf; sector=SU₂(1))\n",
"Es, _ = excitations(H, QuasiparticleAnsatz(), kspace, ψ_inf, envs_inf; sector=SU2Irrep(1))\n",
"\n",
"ΔE, idx = findmin(real.(Es))\n",
"println(\"minimum @k = $(kspace[idx]):\\t ΔE = $(ΔE)\")\n",
Expand All @@ -177,11 +174,11 @@
"file_extension": ".jl",
"mimetype": "application/julia",
"name": "julia",
"version": "1.9.2"
"version": "1.9.4"
},
"kernelspec": {
"name": "julia-1.9",
"display_name": "Julia 1.9.2",
"display_name": "Julia 1.9.4",
"language": "julia"
}
},
Expand Down
88 changes: 70 additions & 18 deletions docs/src/examples/quantum1d/3.ising-dqpt/index.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
```@meta
EditURL = "https://github.com/maartenvd/MPSKit.jl/examples/quantum1d/3.ising-dqpt/main.jl"
EditURL = "../../../../../examples/quantum1d/3.ising-dqpt/main.jl"
```

[![](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/maartenvd/MPSKit.jl/gh-pages?filepath=dev/examples/quantum1d/3.ising-dqpt/main.ipynb)
Expand All @@ -13,8 +13,6 @@ In this tutorial we will try to reproduce the results from

````julia
using MPSKit, MPSKitModels, TensorKit
using TensorOperations: TensorOperations;
TensorOperations.disable_cache(); # hide
````

Dynamical quantum phase transitions (DQPT in short) are signatures of equilibrium phase transitions in a dynamical quantity - the loschmidth echo.
Expand Down Expand Up @@ -42,12 +40,35 @@ L = 20
````

````
[ Info: Iteraton 0 error 0.06549008355303014
[ Info: Iteraton 1 error 3.8736052080636905e-5
[ Info: Iteraton 2 error 1.7276421455149173e-5
[ Info: Iteraton 3 error 4.6807658588611276e-8
[ Info: Iteraton 4 error 4.473231419129997e-11
[ Info: Iteraton 5 error 9.43878140025498e-13
┌ Info: DMRG iteration:
│ iter = 1
│ ϵ = 0.0020961633753540897
│ λ = -20.400216273406606 + 8.422766878640786e-16im
└ Δt = 0.536897639
┌ Info: DMRG iteration:
│ iter = 2
│ ϵ = 1.9324532268037547e-6
│ λ = -20.400217866998595 - 1.2632476413240967e-15im
└ Δt = 0.320009526
┌ Info: DMRG iteration:
│ iter = 3
│ ϵ = 4.883113394407934e-7
│ λ = -20.400217867025678 - 3.206562451130956e-15im
└ Δt = 0.064756649
┌ Info: DMRG iteration:
│ iter = 4
│ ϵ = 6.335026911022001e-10
│ λ = -20.400217867025653 - 3.741871084156128e-17im
└ Δt = 0.014713191
┌ Info: DMRG iteration:
│ iter = 5
│ ϵ = 6.289053913528775e-13
│ λ = -20.400217867025678 - 2.632644424352837e-16im
└ Δt = 0.008818727
┌ Info: DMRG summary:
│ ϵ = 2.0e-12
│ λ = -20.400217867025678 - 2.632644424352837e-16im
└ Δt = 0.980341265
````

Expand Down Expand Up @@ -110,14 +131,45 @@ Similarly we could start with an initial infinite state and find the pre-quench
````

````
[ Info: vumps @iteration 1 galerkin = 0.06601870321517138
[ Info: vumps @iteration 2 galerkin = 2.2516739036323203e-5
[ Info: vumps @iteration 3 galerkin = 3.4932735965628556e-8
[ Info: vumps @iteration 4 galerkin = 1.1714311204809937e-9
[ Info: vumps @iteration 5 galerkin = 9.49274778774588e-11
[ Info: vumps @iteration 6 galerkin = 9.53461947599348e-12
[ Info: vumps @iteration 7 galerkin = 1.0106476372085772e-12
[ Info: vumps @iteration 8 galerkin = 1.2306829064204868e-13
┌ Info: VUMPS iteration:
│ iter = 1
│ ϵ = 0.12051227031956392
│ λ = -1.0188109913987968 - 3.4277346718849837e-17im
└ Δt = 0.044219456
┌ Info: VUMPS iteration:
│ iter = 2
│ ϵ = 0.0005804392121373009
│ λ = -1.0635439538780795 - 8.36203471080629e-18im
└ Δt = 0.007141174
┌ Info: VUMPS iteration:
│ iter = 3
│ ϵ = 1.8720667377867497e-7
│ λ = -1.0635444099733329 + 9.033112781731065e-17im
└ Δt = 0.00646285
┌ Info: VUMPS iteration:
│ iter = 4
│ ϵ = 2.77487479109346e-10
│ λ = -1.0635444099733624 + 3.8230698255590467e-17im
└ Δt = 0.005835234
┌ Info: VUMPS iteration:
│ iter = 5
│ ϵ = 2.965633592874595e-11
│ λ = -1.0635444099733646 - 1.7021513375968543e-16im
└ Δt = 0.033198408
┌ Info: VUMPS iteration:
│ iter = 6
│ ϵ = 2.9750646414566318e-12
│ λ = -1.063544409973365 - 1.349628283023072e-16im
└ Δt = 0.004876971
┌ Info: VUMPS iteration:
│ iter = 7
│ ϵ = 3.154873820110237e-13
│ λ = -1.0635444099733644 - 2.0618524039270857e-17im
└ Δt = 0.004216146
┌ Info: VUMPS summary:
│ ϵ = 3.154873820110237e-13
│ λ = -1.0635444099733644 - 2.0618524039270857e-17im
└ Δt = 0.938766166
````

Expand All @@ -129,7 +181,7 @@ dot(ψ₀, ψ₀)
````

````
0.9999999999999998 + 7.851374352485397e-16im
0.9999999999999984 + 9.734886193402987e-17im
````

so the loschmidth echo takes on the pleasant form
Expand Down
8 changes: 3 additions & 5 deletions docs/src/examples/quantum1d/3.ising-dqpt/main.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
"outputs": [],
"cell_type": "code",
"source": [
"using MPSKit, MPSKitModels, TensorKit\n",
"using TensorOperations: TensorOperations;\n",
"TensorOperations.disable_cache(); # hide"
"using MPSKit, MPSKitModels, TensorKit"
],
"metadata": {},
"execution_count": null
Expand Down Expand Up @@ -284,11 +282,11 @@
"file_extension": ".jl",
"mimetype": "application/julia",
"name": "julia",
"version": "1.9.2"
"version": "1.9.4"
},
"kernelspec": {
"name": "julia-1.9",
"display_name": "Julia 1.9.2",
"display_name": "Julia 1.9.4",
"language": "julia"
}
},
Expand Down
Loading

0 comments on commit 0299778

Please sign in to comment.