Skip to content

Commit a17874a

Browse files
committed
add variance tests for FiniteMPS + allow it to be negative (?) + add FiniteExcited test
1 parent 03dbee3 commit a17874a

File tree

1 file changed

+23
-14
lines changed

1 file changed

+23
-14
lines changed

test/multifusion.jl

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -76,27 +76,37 @@ module TestMultifusion
7676

7777
@testset "Finite systems" begin
7878
L = 6
79-
g = 1.5
79+
g = 4
8080
H = TFIM_multifusion(; g = g, L = L)
8181
V = Vect[I](M => 8)
8282
init = FiniteMPS(L, PD, V; left = Vect[I](M => 1), right = Vect[I](M => 1))
83-
ψ, envs = find_groundstate(init, H, DMRG())
83+
v₀ = variance(init, H)
84+
ψ, envs, δ = find_groundstate(init, H, DMRG())
85+
v = variance(ψ, H)
8486
E = expectation_value(ψ, H, envs)
8587

86-
ψ2, envs2 = find_groundstate(init, H, DMRG2(; trscheme = truncbelow(1.0e-6)))
88+
ψ2, envs2, δ2 = find_groundstate(init, H, DMRG2(; trscheme = truncbelow(1.0e-6)))
89+
v2 = variance(ψ2, H)
8790
E2 = expectation_value(ψ2, H, envs2)
8891

92+
@test δ 0 atol=1e-3
93+
@test δ2 0 atol=1e-3
94+
@test v < v₀ && v2 < v₀
95+
8996
@test isapprox(E, E2; atol = 1.0e-6)
9097

9198
ED, _ = exact_diagonalization(H; sector = D0)
9299
@test isapprox(E, first(ED); atol = 1.0e-6)
93100

94101
@test_throws ArgumentError("one of Type IsingBimodule doesn't exist") excitations(H, QuasiparticleAnsatz(), ψ)
95-
excE, qp = excitations(H, QuasiparticleAnsatz(), ψ2; sector=C0, num=10) # testing sector kwarg
102+
excE, qp = excitations(H, QuasiparticleAnsatz(), ψ2; sector=C1, num=1) # testing sector kwarg
96103
@test 0 < variance(qp[1], H) < 1e-8
104+
105+
excE_DM, qp_DM = excitations(H, FiniteExcited(;gsalg=DMRG2(; trscheme=truncbelow(1e-6))), ψ2;num=1)
106+
@test isapprox(first(excE_DM), first(excE) + E2; atol = 1.0e-6)
97107
end
98108

99-
# @testset "Infinite systems" begin
109+
@testset "Infinite systems" begin
100110
# Multifusion: effectively studying the KW dual in SSB phase
101111
g = 1 / 4
102112
H = TFIM_multifusion(; g = g, L = Inf, twosite = true)
@@ -123,7 +133,7 @@ module TestMultifusion
123133
end
124134
for var in [v, v2, v3]
125135
@test var < v₀
126-
@test 0 < var < 1e-8
136+
@test var < 1e-8
127137
end
128138

129139
@test_throws ArgumentError("sectors of $V are non-diagonal") transfer_spectrum(ψ)
@@ -134,21 +144,20 @@ module TestMultifusion
134144

135145
momentum = 0
136146
@test_throws ArgumentError("one of Type IsingBimodule doesn't exist") excitations(H, QuasiparticleAnsatz(), momentum, ψ)
137-
excC0, qpC0 = excitations(H, QuasiparticleAnsatz(), momentum, ψ3; sector = C0) # testing sector kwarg
138147
excC1, qpC1 = excitations(H, QuasiparticleAnsatz(), momentum, ψ3; sector = C1)
139148
@test isapprox(first(excC1), abs(2 * (g - 1)); atol = 1.0e-6) # charged excitation lower in energy
140-
@test variance(qpC1[1], H) < 1e-8 #TODO: figure out why this is negative
149+
@test variance(qpC1[1], H) < 1e-8
141150

142151
# diagonal test (M = D): injective GS in symmetric phase
143152
Hdual = TFIM_multifusion(; g = 1 / g, L = Inf, twosite = true)
144153
Vdiag = Vect[I](D0 => 24, D1 => 24)
145154
initdiag = InfiniteMPS([PD, PD], [Vdiag, Vdiag])
146155
gsdiag, envsdiag = find_groundstate(initdiag, Hdual, VUMPS(;tol=tol, maxiter=400))
147156
Ediag = expectation_value(gsdiag, Hdual, envsdiag)
148-
excD0, qpD0 = excitations(Hdual, QuasiparticleAnsatz(), momentum, gsdiag; sector = D0)
157+
149158
excD1, qpD1 = excitations(Hdual, QuasiparticleAnsatz(), momentum, gsdiag; sector = D1)
150159
@test isapprox(first(excD1), abs(2 * (1 / g - 1)); atol = 1.0e-6) # charged excitation lower in energy
151-
@test variance(qpD1[1], Hdual) < 1e-8 # TODO: is this ever negative?
160+
@test variance(qpD1[1], Hdual) < 1e-8
152161

153162
# comparison to Z2 Ising: injective in symmetric phase
154163
HZ2 = transverse_field_ising(Z2Irrep; g = 1 / g, L = Inf, twosite = true)
@@ -158,10 +167,10 @@ module TestMultifusion
158167
gsZ2, envsZ2 = find_groundstate(initZ2, HZ2, VUMPS(;tol=tol, maxiter=400))
159168
EZ2 = expectation_value(gsZ2, HZ2, envsZ2)
160169
@test isapprox(EZ2, Ediag; atol = 1.0e-6)
161-
excZ2_0, qpZ2_0 = excitations(HZ2, QuasiparticleAnsatz(), momentum, gsZ2; sector = Z2Irrep(0))
170+
162171
excZ2_1, qpZ2_1 = excitations(HZ2, QuasiparticleAnsatz(), momentum, gsZ2; sector = Z2Irrep(1))
163-
@test isapprox(first(excZ2_1), first(excD1); atol = 1.0e-5)
164-
@test variance(qpZ2_1[1], HZ2) < 1e-6 #TODO: and this?
165-
# end
172+
@test isapprox(first(excZ2_1), first(excD1); atol = 1.0e-6)
173+
@test variance(qpZ2_1[1], HZ2) < 1e-8
174+
end
166175

167176
end # module TestMultifusion

0 commit comments

Comments
 (0)