From 8fead4de143f8832b8594aad382d20a2dbc93b13 Mon Sep 17 00:00:00 2001 From: darts <101638759+dartsushi@users.noreply.github.com> Date: Mon, 12 May 2025 12:31:48 +0200 Subject: [PATCH 1/4] Fix_notebook.jl --- examples/quantum1d/1.ising-cft/main.jl | 27 +++++++++++--------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/examples/quantum1d/1.ising-cft/main.jl b/examples/quantum1d/1.ising-cft/main.jl index 547560125..bbcf6dfe2 100644 --- a/examples/quantum1d/1.ising-cft/main.jl +++ b/examples/quantum1d/1.ising-cft/main.jl @@ -51,10 +51,12 @@ either diagramatically as or in the code as: """ - -id = complex(isomorphism(ℂ^2, ℂ^2)) -@tensor O[-1 -2; -3 -4] := id[-1, -3] * id[-2, -4] -T = periodic_boundary_conditions(InfiniteMPO([O]), L) +function O_shift(L) + id = complex(isomorphism(ℂ^2, ℂ^2)) + @tensor O[-1 -2; -3 -4] := id[-1, -3] * id[-2, -4] + T = periodic_boundary_conditions(InfiniteMPO([O]), L) + return T; +end md""" We can then calculate the momentum of the groundstate as the expectation value of this @@ -62,22 +64,15 @@ operator. However, there is a subtlety because of the degeneracies in the energy eigenvalues. The eigensolver will find an orthonormal basis within each energy subspace, but this basis is not necessarily a basis of eigenstates of the translation operator. In order to fix this, we diagonalize the translation operator within each energy subspace. +The resulting energy levels have one-to-one correspondence to the operators in CFT, where the momentum is related to their conformal spin as $P_n = \frac{2\pi}{L}S_n$. """ - -momentum(ψᵢ, ψⱼ=ψᵢ) = angle(dot(ψᵢ, T * ψⱼ)) - + function fix_degeneracies(basis) - N = zeros(ComplexF64, length(basis), length(basis)) M = zeros(ComplexF64, length(basis), length(basis)) for i in eachindex(basis), j in eachindex(basis) - N[i, j] = dot(basis[i], basis[j]) - M[i, j] = momentum(basis[i], basis[j]) + M[i, j] = dot(basis[i],O_shift(L)*basis[j]) end - vals, vecs = eigen(Hermitian(N)) - M = (vecs' * M * vecs) - M /= diagm(vals) - vals, vecs = eigen(M) return angle.(vals) end @@ -99,7 +94,7 @@ plot(momenta, xlabel="momentum", ylabel="energy", legend=false) - +vline!([2π/L*i for i=-3:3],color="gray",linestyle=:dash) md""" ## Finite bond dimension @@ -122,7 +117,6 @@ E_ex, qps = excitations(H_mps, QuasiparticleAnsatz(), ψ, envs; num=16) states_mps = vcat(ψ, map(qp -> convert(FiniteMPS, qp), qps)) E_mps = map(x -> expectation_value(x, H_mps), states_mps) -T_mps = periodic_boundary_conditions(InfiniteMPO([O]), L_mps) momenta_mps = Float64[] append!(momenta_mps, fix_degeneracies(states[1:1])) append!(momenta_mps, fix_degeneracies(states[2:2])) @@ -139,3 +133,4 @@ plot(momenta_mps, xlabel="momentum", ylabel="energy", legend=false) +vline!([2π/L*i for i=-3:3],color="gray",linestyle=:dash) From a5bb099c486a6f3259d5dfb3529495b4d56a0c60 Mon Sep 17 00:00:00 2001 From: darts <101638759+dartsushi@users.noreply.github.com> Date: Mon, 12 May 2025 13:09:37 +0200 Subject: [PATCH 2/4] Update main.jl --- examples/quantum1d/1.ising-cft/main.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/quantum1d/1.ising-cft/main.jl b/examples/quantum1d/1.ising-cft/main.jl index bbcf6dfe2..c66d6fbac 100644 --- a/examples/quantum1d/1.ising-cft/main.jl +++ b/examples/quantum1d/1.ising-cft/main.jl @@ -68,6 +68,7 @@ The resulting energy levels have one-to-one correspondence to the operators in C """ function fix_degeneracies(basis) + L = length(basis[1]) M = zeros(ComplexF64, length(basis), length(basis)) for i in eachindex(basis), j in eachindex(basis) M[i, j] = dot(basis[i],O_shift(L)*basis[j]) From bcca7d2f2eb982ab9e7baadaa67d7ea93b3cef11 Mon Sep 17 00:00:00 2001 From: Lukas Devos Date: Tue, 13 May 2025 10:02:07 -0400 Subject: [PATCH 3/4] Update example --- .../examples/quantum1d/1.ising-cft/index.md | 482 +++++++++--------- .../examples/quantum1d/1.ising-cft/main.ipynb | 56 +- examples/Cache.toml | 2 +- examples/quantum1d/1.ising-cft/main.jl | 38 +- 4 files changed, 297 insertions(+), 281 deletions(-) diff --git a/docs/src/examples/quantum1d/1.ising-cft/index.md b/docs/src/examples/quantum1d/1.ising-cft/index.md index 81143e46a..7c9813b01 100644 --- a/docs/src/examples/quantum1d/1.ising-cft/index.md +++ b/docs/src/examples/quantum1d/1.ising-cft/index.md @@ -14,7 +14,7 @@ analysis to larger system sizes through the use of MPS techniques. ````julia using MPSKit, MPSKitModels, TensorKit, Plots, KrylovKit -using LinearAlgebra: eigen, diagm, Hermitian +using LinearAlgebra: eigvals, diagm, Hermitian ```` The hamiltonian is defined on a finite lattice with periodic boundary conditions, @@ -63,68 +63,69 @@ plot(real.(energies); - + - + - + - + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ``` @@ -144,26 +145,15 @@ either diagramatically as or in the code as: ````julia -id = complex(isomorphism(ℂ^2, ℂ^2)) -@tensor O[-1 -2; -3 -4] := id[-1, -3] * id[-2, -4] -T = periodic_boundary_conditions(InfiniteMPO([O]), L) +function O_shift(L) + id = complex(isomorphism(ℂ^2, ℂ^2)) + @tensor O[-1 -2; -3 -4] := id[-1, -3] * id[-2, -4] + return periodic_boundary_conditions(InfiniteMPO([O]), L) +end ```` ```` -12-site FiniteMPO{TensorKit.TensorMap{ComplexF64, TensorKit.ComplexSpace, 2, 2, Vector{ComplexF64}}}: -┬ O[12]: TensorMap((ℂ^4 ⊗ ℂ^2) ← (ℂ^2 ⊗ ℂ^1)) -┼ O[11]: TensorMap((ℂ^4 ⊗ ℂ^2) ← (ℂ^2 ⊗ ℂ^4)) -┼ O[10]: TensorMap((ℂ^4 ⊗ ℂ^2) ← (ℂ^2 ⊗ ℂ^4)) -┼ O[9]: TensorMap((ℂ^4 ⊗ ℂ^2) ← (ℂ^2 ⊗ ℂ^4)) -┼ O[8]: TensorMap((ℂ^4 ⊗ ℂ^2) ← (ℂ^2 ⊗ ℂ^4)) -┼ O[7]: TensorMap((ℂ^4 ⊗ ℂ^2) ← (ℂ^2 ⊗ ℂ^4)) -┼ O[6]: TensorMap((ℂ^4 ⊗ ℂ^2) ← (ℂ^2 ⊗ ℂ^4)) -┼ O[5]: TensorMap((ℂ^4 ⊗ ℂ^2) ← (ℂ^2 ⊗ ℂ^4)) -┼ O[4]: TensorMap((ℂ^4 ⊗ ℂ^2) ← (ℂ^2 ⊗ ℂ^4)) -┼ O[3]: TensorMap((ℂ^4 ⊗ ℂ^2) ← (ℂ^2 ⊗ ℂ^4)) -┼ O[2]: TensorMap((ℂ^4 ⊗ ℂ^2) ← (ℂ^2 ⊗ ℂ^4)) -┴ O[1]: TensorMap((ℂ^1 ⊗ ℂ^2) ← (ℂ^2 ⊗ ℂ^4)) - +O_shift (generic function with 1 method) ```` We can then calculate the momentum of the groundstate as the expectation value of this @@ -171,23 +161,18 @@ operator. However, there is a subtlety because of the degeneracies in the energy eigenvalues. The eigensolver will find an orthonormal basis within each energy subspace, but this basis is not necessarily a basis of eigenstates of the translation operator. In order to fix this, we diagonalize the translation operator within each energy subspace. +The resulting energy levels have one-to-one correspondence to the operators in CFT, where the momentum is related to their conformal spin as $P_n = \frac{2\pi}{L}S_n$. ````julia -momentum(ψᵢ, ψⱼ=ψᵢ) = angle(dot(ψᵢ, T * ψⱼ)) - function fix_degeneracies(basis) - N = zeros(ComplexF64, length(basis), length(basis)) + L = length(basis[1]) M = zeros(ComplexF64, length(basis), length(basis)) - for i in eachindex(basis), j in eachindex(basis) - N[i, j] = dot(basis[i], basis[j]) - M[i, j] = momentum(basis[i], basis[j]) + T = O_shift(L) + for j in eachindex(basis), i in eachindex(basis) + M[i, j] = dot(basis[i], T, basis[j]) end - vals, vecs = eigen(Hermitian(N)) - M = (vecs' * M * vecs) - M /= diagm(vals) - - vals, vecs = eigen(M) + vals = eigvals(M) return angle.(vals) end @@ -202,80 +187,88 @@ append!(momenta, fix_degeneracies(states[12:12])) append!(momenta, fix_degeneracies(states[13:16])) append!(momenta, fix_degeneracies(states[17:18])) -plot(momenta, - real.(energies[1:18]); - seriestype=:scatter, - xlabel="momentum", - ylabel="energy", - legend=false) +p = plot(momenta, real.(energies[1:18]); + seriestype=:scatter, xlabel="momentum", ylabel="energy", legend=false) +vline!(p, [2π / L * i for i in -3:3]; color="gray", linestyle=:dash) +hline!(p, [0, 1 / 8, 1, 9 / 8, 2, 17 / 8]; color="gray", linestyle=:dash) +p ```` ```@raw html - + - + - + - + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ``` @@ -293,39 +286,48 @@ D = 64 ```` ```` -[ Info: DMRG init: obj = -1.985048003930e+01 err = 7.2317e-02 -[ Info: DMRG 1: obj = -2.549098966283e+01 err = 7.8053488477e-03 time = 2.60 sec -[ Info: DMRG 2: obj = -2.549098968635e+01 err = 8.7334840815e-07 time = 0.67 sec -[ Info: DMRG 3: obj = -2.549098968636e+01 err = 1.2954774429e-07 time = 0.65 sec -[ Info: DMRG 4: obj = -2.549098968636e+01 err = 8.8619635923e-09 time = 0.38 sec -[ Info: DMRG 5: obj = -2.549098968636e+01 err = 4.0315399959e-09 time = 0.80 sec -[ Info: DMRG 6: obj = -2.549098968636e+01 err = 3.2944729108e-09 time = 0.37 sec -[ Info: DMRG 7: obj = -2.549098968636e+01 err = 2.9865723847e-09 time = 0.41 sec -[ Info: DMRG 8: obj = -2.549098968636e+01 err = 2.6357410693e-09 time = 0.42 sec -[ Info: DMRG 9: obj = -2.549098968636e+01 err = 2.2240717932e-09 time = 0.42 sec -[ Info: DMRG 10: obj = -2.549098968636e+01 err = 1.8085277012e-09 time = 0.42 sec -[ Info: DMRG 11: obj = -2.549098968636e+01 err = 1.6691363159e-09 time = 0.40 sec -[ Info: DMRG 12: obj = -2.549098968636e+01 err = 1.5815738385e-09 time = 0.40 sec -[ Info: DMRG 13: obj = -2.549098968636e+01 err = 1.4646953060e-09 time = 0.41 sec -[ Info: DMRG 14: obj = -2.549098968636e+01 err = 1.3303795749e-09 time = 0.40 sec -[ Info: DMRG 15: obj = -2.549098968636e+01 err = 1.1895189194e-09 time = 0.39 sec -[ Info: DMRG 16: obj = -2.549098968636e+01 err = 1.0506295654e-09 time = 0.39 sec -[ Info: DMRG 17: obj = -2.549098968636e+01 err = 9.1947251000e-10 time = 0.39 sec -[ Info: DMRG 18: obj = -2.549098968636e+01 err = 7.9934905173e-10 time = 0.78 sec -[ Info: DMRG 19: obj = -2.549098968636e+01 err = 6.9168756403e-10 time = 0.34 sec -[ Info: DMRG 20: obj = -2.549098968636e+01 err = 5.9665203224e-10 time = 0.42 sec -[ Info: DMRG 21: obj = -2.549098968636e+01 err = 5.1364326892e-10 time = 0.43 sec -[ Info: DMRG 22: obj = -2.549098968636e+01 err = 4.4166061761e-10 time = 0.45 sec -[ Info: DMRG 23: obj = -2.549098968636e+01 err = 3.7953956622e-10 time = 0.44 sec -[ Info: DMRG 24: obj = -2.549098968636e+01 err = 3.2609572758e-10 time = 0.44 sec -[ Info: DMRG 25: obj = -2.549098968636e+01 err = 2.8020469415e-10 time = 0.44 sec -[ Info: DMRG 26: obj = -2.549098968636e+01 err = 2.4084097310e-10 time = 0.44 sec -[ Info: DMRG 27: obj = -2.549098968636e+01 err = 2.0709226936e-10 time = 0.44 sec -[ Info: DMRG 28: obj = -2.549098968636e+01 err = 1.7815981840e-10 time = 0.43 sec -[ Info: DMRG 29: obj = -2.549098968636e+01 err = 1.5335144532e-10 time = 0.44 sec -[ Info: DMRG 30: obj = -2.549098968636e+01 err = 1.3207131024e-10 time = 0.44 sec -[ Info: DMRG 31: obj = -2.549098968636e+01 err = 1.1380867710e-10 time = 0.45 sec -[ Info: DMRG conv 32: obj = -2.549098968636e+01 err = 9.8126879511e-11 time = 17.14 sec +[ Info: DMRG init: obj = -1.924595691431e+01 err = 7.4971e-02 +[ Info: DMRG 1: obj = -2.549098966524e+01 err = 6.1535608960e-03 time = 1.32 sec +[ Info: DMRG 2: obj = -2.549098968636e+01 err = 8.6139661593e-07 time = 0.31 sec +[ Info: DMRG 3: obj = -2.549098968636e+01 err = 1.2502325498e-07 time = 0.50 sec +[ Info: DMRG 4: obj = -2.549098968636e+01 err = 1.7370682051e-08 time = 0.22 sec +[ Info: DMRG 5: obj = -2.549098968636e+01 err = 9.4449095251e-09 time = 0.19 sec +[ Info: DMRG 6: obj = -2.549098968636e+01 err = 4.6627228058e-09 time = 0.18 sec +[ Info: DMRG 7: obj = -2.549098968636e+01 err = 2.5258558477e-09 time = 0.19 sec +[ Info: DMRG 8: obj = -2.549098968636e+01 err = 1.5875623507e-09 time = 0.19 sec +[ Info: DMRG 9: obj = -2.549098968636e+01 err = 1.3946487937e-09 time = 0.21 sec +[ Info: DMRG 10: obj = -2.549098968636e+01 err = 1.5064827337e-09 time = 0.21 sec +[ Info: DMRG 11: obj = -2.549098968636e+01 err = 1.6111902952e-09 time = 0.20 sec +[ Info: DMRG 12: obj = -2.549098968636e+01 err = 1.6973177531e-09 time = 0.20 sec +[ Info: DMRG 13: obj = -2.549098968636e+01 err = 1.7545608105e-09 time = 0.39 sec +[ Info: DMRG 14: obj = -2.549098968636e+01 err = 1.7796590699e-09 time = 0.26 sec +[ Info: DMRG 15: obj = -2.549098968636e+01 err = 1.8277493800e-09 time = 0.20 sec +[ Info: DMRG 16: obj = -2.549098968636e+01 err = 1.8325213578e-09 time = 0.19 sec +[ Info: DMRG 17: obj = -2.549098968636e+01 err = 1.7989363799e-09 time = 0.19 sec +[ Info: DMRG 18: obj = -2.549098968636e+01 err = 1.7382086681e-09 time = 0.24 sec +[ Info: DMRG 19: obj = -2.549098968636e+01 err = 1.6414992227e-09 time = 0.21 sec +[ Info: DMRG 20: obj = -2.549098968636e+01 err = 1.5191635048e-09 time = 0.21 sec +[ Info: DMRG 21: obj = -2.549098968636e+01 err = 1.3824129990e-09 time = 0.20 sec +[ Info: DMRG 22: obj = -2.549098968636e+01 err = 1.2412046595e-09 time = 0.19 sec +[ Info: DMRG 23: obj = -2.549098968636e+01 err = 1.1031103071e-09 time = 0.19 sec +[ Info: DMRG 24: obj = -2.549098968636e+01 err = 9.7311187868e-10 time = 0.42 sec +[ Info: DMRG 25: obj = -2.549098968636e+01 err = 8.5396698152e-10 time = 0.26 sec +[ Info: DMRG 26: obj = -2.549098968636e+01 err = 7.4678756885e-10 time = 0.20 sec +[ Info: DMRG 27: obj = -2.549098968636e+01 err = 6.5159959156e-10 time = 0.19 sec +[ Info: DMRG 28: obj = -2.549098968636e+01 err = 5.6778796255e-10 time = 0.20 sec +[ Info: DMRG 29: obj = -2.549098968636e+01 err = 4.9440956973e-10 time = 0.21 sec +[ Info: DMRG 30: obj = -2.549098968636e+01 err = 4.3039488133e-10 time = 0.20 sec +[ Info: DMRG 31: obj = -2.549098968636e+01 err = 3.7466784202e-10 time = 0.20 sec +[ Info: DMRG 32: obj = -2.549098968636e+01 err = 3.2621134339e-10 time = 0.20 sec +[ Info: DMRG 33: obj = -2.549098968636e+01 err = 2.8409765763e-10 time = 0.20 sec +[ Info: DMRG 34: obj = -2.549098968636e+01 err = 2.4749922520e-10 time = 0.42 sec +[ Info: DMRG 35: obj = -2.549098968636e+01 err = 2.1568776361e-10 time = 0.30 sec +[ Info: DMRG 36: obj = -2.549098968636e+01 err = 1.8802770528e-10 time = 0.22 sec +[ Info: DMRG 37: obj = -2.549098968636e+01 err = 1.6396716228e-10 time = 0.20 sec +[ Info: DMRG 38: obj = -2.549098968636e+01 err = 1.4302823771e-10 time = 0.20 sec +[ Info: DMRG 39: obj = -2.549098968636e+01 err = 1.2479765887e-10 time = 0.21 sec +[ Info: DMRG 40: obj = -2.549098968636e+01 err = 1.0891817884e-10 time = 0.21 sec +[ Info: DMRG conv 41: obj = -2.549098968636e+01 err = 9.5080925861e-11 time = 10.65 sec ```` @@ -338,7 +340,6 @@ E_ex, qps = excitations(H_mps, QuasiparticleAnsatz(), ψ, envs; num=16) states_mps = vcat(ψ, map(qp -> convert(FiniteMPS, qp), qps)) E_mps = map(x -> expectation_value(x, H_mps), states_mps) -T_mps = periodic_boundary_conditions(InfiniteMPO([O]), L_mps) momenta_mps = Float64[] append!(momenta_mps, fix_degeneracies(states[1:1])) append!(momenta_mps, fix_degeneracies(states[2:2])) @@ -349,78 +350,101 @@ append!(momenta_mps, fix_degeneracies(states[10:11])) append!(momenta_mps, fix_degeneracies(states[12:12])) append!(momenta_mps, fix_degeneracies(states[13:16])) -plot(momenta_mps, - real.(energies[1:16]); - seriestype=:scatter, - xlabel="momentum", - ylabel="energy", - legend=false) +plot(momenta_mps, real.(energies[1:16]); + seriestype=:scatter, xlabel="momentum", ylabel="energy", legend=false) +vline!(p, [2π / L * i for i in -3:3]; color="gray", linestyle=:dash) +hline!(p, [0, 1 / 8, 1, 9 / 8, 2, 17 / 8]; color="gray", linestyle=:dash) +p ```` ```@raw html - + - + - + - + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ``` diff --git a/docs/src/examples/quantum1d/1.ising-cft/main.ipynb b/docs/src/examples/quantum1d/1.ising-cft/main.ipynb index 2273b27ca..fd42e14a9 100644 --- a/docs/src/examples/quantum1d/1.ising-cft/main.ipynb +++ b/docs/src/examples/quantum1d/1.ising-cft/main.ipynb @@ -16,7 +16,7 @@ "cell_type": "code", "source": [ "using MPSKit, MPSKitModels, TensorKit, Plots, KrylovKit\n", - "using LinearAlgebra: eigen, diagm, Hermitian" + "using LinearAlgebra: eigvals, diagm, Hermitian" ], "metadata": {}, "execution_count": null @@ -95,9 +95,11 @@ "outputs": [], "cell_type": "code", "source": [ - "id = complex(isomorphism(ℂ^2, ℂ^2))\n", - "@tensor O[-1 -2; -3 -4] := id[-1, -3] * id[-2, -4]\n", - "T = periodic_boundary_conditions(InfiniteMPO([O]), L)" + "function O_shift(L)\n", + " id = complex(isomorphism(ℂ^2, ℂ^2))\n", + " @tensor O[-1 -2; -3 -4] := id[-1, -3] * id[-2, -4]\n", + " return periodic_boundary_conditions(InfiniteMPO([O]), L)\n", + "end" ], "metadata": {}, "execution_count": null @@ -109,7 +111,8 @@ "operator. However, there is a subtlety because of the degeneracies in the energy\n", "eigenvalues. The eigensolver will find an orthonormal basis within each energy subspace, but\n", "this basis is not necessarily a basis of eigenstates of the translation operator. In order\n", - "to fix this, we diagonalize the translation operator within each energy subspace." + "to fix this, we diagonalize the translation operator within each energy subspace.\n", + "The resulting energy levels have one-to-one correspondence to the operators in CFT, where the momentum is related to their conformal spin as $P_n = \\frac{2\\pi}{L}S_n$." ], "metadata": {} }, @@ -117,21 +120,15 @@ "outputs": [], "cell_type": "code", "source": [ - "momentum(ψᵢ, ψⱼ=ψᵢ) = angle(dot(ψᵢ, T * ψⱼ))\n", - "\n", "function fix_degeneracies(basis)\n", - " N = zeros(ComplexF64, length(basis), length(basis))\n", + " L = length(basis[1])\n", " M = zeros(ComplexF64, length(basis), length(basis))\n", - " for i in eachindex(basis), j in eachindex(basis)\n", - " N[i, j] = dot(basis[i], basis[j])\n", - " M[i, j] = momentum(basis[i], basis[j])\n", + " T = O_shift(L)\n", + " for j in eachindex(basis), i in eachindex(basis)\n", + " M[i, j] = dot(basis[i], T, basis[j])\n", " end\n", "\n", - " vals, vecs = eigen(Hermitian(N))\n", - " M = (vecs' * M * vecs)\n", - " M /= diagm(vals)\n", - "\n", - " vals, vecs = eigen(M)\n", + " vals = eigvals(M)\n", " return angle.(vals)\n", "end\n", "\n", @@ -146,12 +143,11 @@ "append!(momenta, fix_degeneracies(states[13:16]))\n", "append!(momenta, fix_degeneracies(states[17:18]))\n", "\n", - "plot(momenta,\n", - " real.(energies[1:18]);\n", - " seriestype=:scatter,\n", - " xlabel=\"momentum\",\n", - " ylabel=\"energy\",\n", - " legend=false)" + "p = plot(momenta, real.(energies[1:18]);\n", + " seriestype=:scatter, xlabel=\"momentum\", ylabel=\"energy\", legend=false)\n", + "vline!(p, [2π / L * i for i in -3:3]; color=\"gray\", linestyle=:dash)\n", + "hline!(p, [0, 1 / 8, 1, 9 / 8, 2, 17 / 8]; color=\"gray\", linestyle=:dash)\n", + "p" ], "metadata": {}, "execution_count": null @@ -195,7 +191,6 @@ "states_mps = vcat(ψ, map(qp -> convert(FiniteMPS, qp), qps))\n", "E_mps = map(x -> expectation_value(x, H_mps), states_mps)\n", "\n", - "T_mps = periodic_boundary_conditions(InfiniteMPO([O]), L_mps)\n", "momenta_mps = Float64[]\n", "append!(momenta_mps, fix_degeneracies(states[1:1]))\n", "append!(momenta_mps, fix_degeneracies(states[2:2]))\n", @@ -206,12 +201,11 @@ "append!(momenta_mps, fix_degeneracies(states[12:12]))\n", "append!(momenta_mps, fix_degeneracies(states[13:16]))\n", "\n", - "plot(momenta_mps,\n", - " real.(energies[1:16]);\n", - " seriestype=:scatter,\n", - " xlabel=\"momentum\",\n", - " ylabel=\"energy\",\n", - " legend=false)" + "plot(momenta_mps, real.(energies[1:16]);\n", + " seriestype=:scatter, xlabel=\"momentum\", ylabel=\"energy\", legend=false)\n", + "vline!(p, [2π / L * i for i in -3:3]; color=\"gray\", linestyle=:dash)\n", + "hline!(p, [0, 1 / 8, 1, 9 / 8, 2, 17 / 8]; color=\"gray\", linestyle=:dash)\n", + "p" ], "metadata": {}, "execution_count": null @@ -232,11 +226,11 @@ "file_extension": ".jl", "mimetype": "application/julia", "name": "julia", - "version": "1.11.4" + "version": "1.11.5" }, "kernelspec": { "name": "julia-1.11", - "display_name": "Julia 1.11.4", + "display_name": "Julia 1.11.5", "language": "julia" } }, diff --git a/examples/Cache.toml b/examples/Cache.toml index b592e022c..c26785d9c 100644 --- a/examples/Cache.toml +++ b/examples/Cache.toml @@ -7,5 +7,5 @@ "7.xy-finiteT" = "0243b44634d38d04ddd96b180fd1fc24e20485e97135cb7c805c9d60baab9ccb" "3.ising-dqpt" = "f437ac4560db51f67e3997867c02bb8844b1077731b1dd1a06c61ab7c4846e97" "5.haldane-spt" = "6443696b20d416652951c646cf78b604a7fd0d79804995588491ea53ca210d57" -"1.ising-cft" = "bd1253451973aa73c4fee6b64d81ee52cc2feba5b9632f87ce332eea3a05f460" +"1.ising-cft" = "f8e4987501c248a28dee6ada344e3638b515fdf28a451e6bb7ed22c0bec1fa8d" "4.xxz-heisenberg" = "f8359ad29a028b01d41913014c0a442b99c3bd5cd403c23bd2a59f646a7c78cf" diff --git a/examples/quantum1d/1.ising-cft/main.jl b/examples/quantum1d/1.ising-cft/main.jl index c66d6fbac..c72b27a0f 100644 --- a/examples/quantum1d/1.ising-cft/main.jl +++ b/examples/quantum1d/1.ising-cft/main.jl @@ -7,7 +7,7 @@ analysis to larger system sizes through the use of MPS techniques. """ using MPSKit, MPSKitModels, TensorKit, Plots, KrylovKit -using LinearAlgebra: eigen, diagm, Hermitian +using LinearAlgebra: eigvals, diagm, Hermitian md""" The hamiltonian is defined on a finite lattice with periodic boundary conditions, @@ -51,11 +51,11 @@ either diagramatically as or in the code as: """ + function O_shift(L) id = complex(isomorphism(ℂ^2, ℂ^2)) @tensor O[-1 -2; -3 -4] := id[-1, -3] * id[-2, -4] - T = periodic_boundary_conditions(InfiniteMPO([O]), L) - return T; + return periodic_boundary_conditions(InfiniteMPO([O]), L) end md""" @@ -70,11 +70,12 @@ The resulting energy levels have one-to-one correspondence to the operators in C function fix_degeneracies(basis) L = length(basis[1]) M = zeros(ComplexF64, length(basis), length(basis)) - for i in eachindex(basis), j in eachindex(basis) - M[i, j] = dot(basis[i],O_shift(L)*basis[j]) + T = O_shift(L) + for j in eachindex(basis), i in eachindex(basis) + M[i, j] = dot(basis[i], T, basis[j]) end - vals, vecs = eigen(M) + vals = eigvals(M) return angle.(vals) end @@ -89,13 +90,12 @@ append!(momenta, fix_degeneracies(states[12:12])) append!(momenta, fix_degeneracies(states[13:16])) append!(momenta, fix_degeneracies(states[17:18])) -plot(momenta, - real.(energies[1:18]); - seriestype=:scatter, - xlabel="momentum", - ylabel="energy", - legend=false) -vline!([2π/L*i for i=-3:3],color="gray",linestyle=:dash) +p = plot(momenta, real.(energies[1:18]); + seriestype=:scatter, xlabel="momentum", ylabel="energy", legend=false) +vline!(p, [2π / L * i for i in -3:3]; color="gray", linestyle=:dash) +hline!(p, [0, 1 / 8, 1, 9 / 8, 2, 17 / 8]; color="gray", linestyle=:dash) +p + md""" ## Finite bond dimension @@ -128,10 +128,8 @@ append!(momenta_mps, fix_degeneracies(states[10:11])) append!(momenta_mps, fix_degeneracies(states[12:12])) append!(momenta_mps, fix_degeneracies(states[13:16])) -plot(momenta_mps, - real.(energies[1:16]); - seriestype=:scatter, - xlabel="momentum", - ylabel="energy", - legend=false) -vline!([2π/L*i for i=-3:3],color="gray",linestyle=:dash) +plot(momenta_mps, real.(energies[1:16]); + seriestype=:scatter, xlabel="momentum", ylabel="energy", legend=false) +vline!(p, [2π / L * i for i in -3:3]; color="gray", linestyle=:dash) +hline!(p, [0, 1 / 8, 1, 9 / 8, 2, 17 / 8]; color="gray", linestyle=:dash) +p From eec7a879db52085c7cb33166326737a72baa54a1 Mon Sep 17 00:00:00 2001 From: Lukas Devos Date: Tue, 13 May 2025 10:12:52 -0400 Subject: [PATCH 4/4] fix formatting --- .../examples/quantum1d/1.ising-cft/index.md | 441 +++++++++--------- examples/Cache.toml | 2 +- examples/quantum1d/1.ising-cft/main.jl | 2 +- 3 files changed, 216 insertions(+), 229 deletions(-) diff --git a/docs/src/examples/quantum1d/1.ising-cft/index.md b/docs/src/examples/quantum1d/1.ising-cft/index.md index 7c9813b01..fbfc7eeed 100644 --- a/docs/src/examples/quantum1d/1.ising-cft/index.md +++ b/docs/src/examples/quantum1d/1.ising-cft/index.md @@ -63,69 +63,70 @@ plot(real.(energies); - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ``` @@ -198,77 +199,77 @@ p - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ``` @@ -286,48 +287,34 @@ D = 64 ```` ```` -[ Info: DMRG init: obj = -1.924595691431e+01 err = 7.4971e-02 -[ Info: DMRG 1: obj = -2.549098966524e+01 err = 6.1535608960e-03 time = 1.32 sec -[ Info: DMRG 2: obj = -2.549098968636e+01 err = 8.6139661593e-07 time = 0.31 sec -[ Info: DMRG 3: obj = -2.549098968636e+01 err = 1.2502325498e-07 time = 0.50 sec -[ Info: DMRG 4: obj = -2.549098968636e+01 err = 1.7370682051e-08 time = 0.22 sec -[ Info: DMRG 5: obj = -2.549098968636e+01 err = 9.4449095251e-09 time = 0.19 sec -[ Info: DMRG 6: obj = -2.549098968636e+01 err = 4.6627228058e-09 time = 0.18 sec -[ Info: DMRG 7: obj = -2.549098968636e+01 err = 2.5258558477e-09 time = 0.19 sec -[ Info: DMRG 8: obj = -2.549098968636e+01 err = 1.5875623507e-09 time = 0.19 sec -[ Info: DMRG 9: obj = -2.549098968636e+01 err = 1.3946487937e-09 time = 0.21 sec -[ Info: DMRG 10: obj = -2.549098968636e+01 err = 1.5064827337e-09 time = 0.21 sec -[ Info: DMRG 11: obj = -2.549098968636e+01 err = 1.6111902952e-09 time = 0.20 sec -[ Info: DMRG 12: obj = -2.549098968636e+01 err = 1.6973177531e-09 time = 0.20 sec -[ Info: DMRG 13: obj = -2.549098968636e+01 err = 1.7545608105e-09 time = 0.39 sec -[ Info: DMRG 14: obj = -2.549098968636e+01 err = 1.7796590699e-09 time = 0.26 sec -[ Info: DMRG 15: obj = -2.549098968636e+01 err = 1.8277493800e-09 time = 0.20 sec -[ Info: DMRG 16: obj = -2.549098968636e+01 err = 1.8325213578e-09 time = 0.19 sec -[ Info: DMRG 17: obj = -2.549098968636e+01 err = 1.7989363799e-09 time = 0.19 sec -[ Info: DMRG 18: obj = -2.549098968636e+01 err = 1.7382086681e-09 time = 0.24 sec -[ Info: DMRG 19: obj = -2.549098968636e+01 err = 1.6414992227e-09 time = 0.21 sec -[ Info: DMRG 20: obj = -2.549098968636e+01 err = 1.5191635048e-09 time = 0.21 sec -[ Info: DMRG 21: obj = -2.549098968636e+01 err = 1.3824129990e-09 time = 0.20 sec -[ Info: DMRG 22: obj = -2.549098968636e+01 err = 1.2412046595e-09 time = 0.19 sec -[ Info: DMRG 23: obj = -2.549098968636e+01 err = 1.1031103071e-09 time = 0.19 sec -[ Info: DMRG 24: obj = -2.549098968636e+01 err = 9.7311187868e-10 time = 0.42 sec -[ Info: DMRG 25: obj = -2.549098968636e+01 err = 8.5396698152e-10 time = 0.26 sec -[ Info: DMRG 26: obj = -2.549098968636e+01 err = 7.4678756885e-10 time = 0.20 sec -[ Info: DMRG 27: obj = -2.549098968636e+01 err = 6.5159959156e-10 time = 0.19 sec -[ Info: DMRG 28: obj = -2.549098968636e+01 err = 5.6778796255e-10 time = 0.20 sec -[ Info: DMRG 29: obj = -2.549098968636e+01 err = 4.9440956973e-10 time = 0.21 sec -[ Info: DMRG 30: obj = -2.549098968636e+01 err = 4.3039488133e-10 time = 0.20 sec -[ Info: DMRG 31: obj = -2.549098968636e+01 err = 3.7466784202e-10 time = 0.20 sec -[ Info: DMRG 32: obj = -2.549098968636e+01 err = 3.2621134339e-10 time = 0.20 sec -[ Info: DMRG 33: obj = -2.549098968636e+01 err = 2.8409765763e-10 time = 0.20 sec -[ Info: DMRG 34: obj = -2.549098968636e+01 err = 2.4749922520e-10 time = 0.42 sec -[ Info: DMRG 35: obj = -2.549098968636e+01 err = 2.1568776361e-10 time = 0.30 sec -[ Info: DMRG 36: obj = -2.549098968636e+01 err = 1.8802770528e-10 time = 0.22 sec -[ Info: DMRG 37: obj = -2.549098968636e+01 err = 1.6396716228e-10 time = 0.20 sec -[ Info: DMRG 38: obj = -2.549098968636e+01 err = 1.4302823771e-10 time = 0.20 sec -[ Info: DMRG 39: obj = -2.549098968636e+01 err = 1.2479765887e-10 time = 0.21 sec -[ Info: DMRG 40: obj = -2.549098968636e+01 err = 1.0891817884e-10 time = 0.21 sec -[ Info: DMRG conv 41: obj = -2.549098968636e+01 err = 9.5080925861e-11 time = 10.65 sec +[ Info: DMRG init: obj = -1.950932334537e+01 err = 7.6388e-02 +[ Info: DMRG 1: obj = -2.549098967614e+01 err = 4.9971525324e-03 time = 1.36 sec +[ Info: DMRG 2: obj = -2.549098968636e+01 err = 8.4649097719e-07 time = 0.31 sec +[ Info: DMRG 3: obj = -2.549098968636e+01 err = 1.0653583798e-07 time = 0.26 sec +[ Info: DMRG 4: obj = -2.549098968636e+01 err = 1.0285945253e-08 time = 0.38 sec +[ Info: DMRG 5: obj = -2.549098968636e+01 err = 4.9294778725e-09 time = 0.24 sec +[ Info: DMRG 6: obj = -2.549098968636e+01 err = 3.4402601557e-09 time = 0.21 sec +[ Info: DMRG 7: obj = -2.549098968636e+01 err = 2.6081578543e-09 time = 0.20 sec +[ Info: DMRG 8: obj = -2.549098968636e+01 err = 1.9647429697e-09 time = 0.22 sec +[ Info: DMRG 9: obj = -2.549098968636e+01 err = 1.4606856043e-09 time = 0.21 sec +[ Info: DMRG 10: obj = -2.549098968636e+01 err = 1.0804235983e-09 time = 0.20 sec +[ Info: DMRG 11: obj = -2.549098968636e+01 err = 8.7649268155e-10 time = 0.20 sec +[ Info: DMRG 12: obj = -2.549098968636e+01 err = 7.6509949985e-10 time = 0.21 sec +[ Info: DMRG 13: obj = -2.549098968636e+01 err = 6.6586719998e-10 time = 0.20 sec +[ Info: DMRG 14: obj = -2.549098968636e+01 err = 5.7837098453e-10 time = 0.20 sec +[ Info: DMRG 15: obj = -2.549098968636e+01 err = 5.0175362626e-10 time = 0.43 sec +[ Info: DMRG 16: obj = -2.549098968636e+01 err = 4.3497459831e-10 time = 0.26 sec +[ Info: DMRG 17: obj = -2.549098968636e+01 err = 3.7695147403e-10 time = 0.22 sec +[ Info: DMRG 18: obj = -2.549098968636e+01 err = 3.2663807492e-10 time = 0.21 sec +[ Info: DMRG 19: obj = -2.549098968636e+01 err = 2.8306434660e-10 time = 0.20 sec +[ Info: DMRG 20: obj = -2.549098968636e+01 err = 2.4535365971e-10 time = 0.20 sec +[ Info: DMRG 21: obj = -2.549098968636e+01 err = 2.1272698230e-10 time = 0.20 sec +[ Info: DMRG 22: obj = -2.549098968636e+01 err = 1.8449972817e-10 time = 0.21 sec +[ Info: DMRG 23: obj = -2.549098968636e+01 err = 1.6007478776e-10 time = 0.20 sec +[ Info: DMRG 24: obj = -2.549098968636e+01 err = 1.3893409102e-10 time = 0.22 sec +[ Info: DMRG 25: obj = -2.549098968636e+01 err = 1.2062942021e-10 time = 0.21 sec +[ Info: DMRG 26: obj = -2.549098968636e+01 err = 1.0477391341e-10 time = 0.26 sec +[ Info: DMRG conv 27: obj = -2.549098968636e+01 err = 9.1034011073e-11 time = 7.67 sec ```` @@ -361,90 +348,90 @@ p - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ``` diff --git a/examples/Cache.toml b/examples/Cache.toml index c26785d9c..9dd502d5e 100644 --- a/examples/Cache.toml +++ b/examples/Cache.toml @@ -7,5 +7,5 @@ "7.xy-finiteT" = "0243b44634d38d04ddd96b180fd1fc24e20485e97135cb7c805c9d60baab9ccb" "3.ising-dqpt" = "f437ac4560db51f67e3997867c02bb8844b1077731b1dd1a06c61ab7c4846e97" "5.haldane-spt" = "6443696b20d416652951c646cf78b604a7fd0d79804995588491ea53ca210d57" -"1.ising-cft" = "f8e4987501c248a28dee6ada344e3638b515fdf28a451e6bb7ed22c0bec1fa8d" "4.xxz-heisenberg" = "f8359ad29a028b01d41913014c0a442b99c3bd5cd403c23bd2a59f646a7c78cf" +"1.ising-cft" = "f8e4987501c248a28dee6ada344e3638b515fdf28a451e6bb7ed22c0bec1fa8d" diff --git a/examples/quantum1d/1.ising-cft/main.jl b/examples/quantum1d/1.ising-cft/main.jl index c72b27a0f..e0516e1dc 100644 --- a/examples/quantum1d/1.ising-cft/main.jl +++ b/examples/quantum1d/1.ising-cft/main.jl @@ -66,7 +66,7 @@ this basis is not necessarily a basis of eigenstates of the translation operator to fix this, we diagonalize the translation operator within each energy subspace. The resulting energy levels have one-to-one correspondence to the operators in CFT, where the momentum is related to their conformal spin as $P_n = \frac{2\pi}{L}S_n$. """ - + function fix_degeneracies(basis) L = length(basis[1]) M = zeros(ComplexF64, length(basis), length(basis))