Skip to content

Commit c20d382

Browse files
authored
[Bugfix] Ensure that projection environments have correct above (#204)
* Fix an issue with unequal above and below states * Add twosite DMRG excitations to tests
1 parent 35472e2 commit c20d382

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

src/environments/FinEnv.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,10 @@ function MPSKit.environments(below::FiniteMPS{S}, O::DenseMPO, above=nothing) wh
7373
N = length(below)
7474
leftstart = isomorphism(storagetype(S),
7575
left_virtualspace(below, 0) space(O[1], 1)'
76-
left_virtualspace(below, 0))
76+
left_virtualspace(something(above, below), 0))
7777
rightstart = isomorphism(storagetype(S),
78-
right_virtualspace(below, N) space(O[N], 4)'
78+
right_virtualspace(something(above, below), N)
79+
space(O[N], 4)'
7980
right_virtualspace(below, length(below)))
8081
return environments(below, O, above, leftstart, rightstart)
8182
end
@@ -101,7 +102,7 @@ end
101102
function environments(state::Union{FiniteMPS,WindowMPS}, opp::ProjectionOperator)
102103
@plansor leftstart[-1; -2 -3 -4] := l_LL(opp.ket)[-3; -4] * l_LL(opp.ket)[-1; -2]
103104
@plansor rightstart[-1; -2 -3 -4] := r_RR(opp.ket)[-1; -2] * r_RR(opp.ket)[-3; -4]
104-
return environments(state, fill(nothing, length(state)), state, leftstart, rightstart)
105+
return environments(state, fill(nothing, length(state)), opp.ket, leftstart, rightstart)
105106
end
106107

107108
#notify the cache that we updated in-place, so it should invalidate the dependencies

test/algorithms.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -426,16 +426,16 @@ end
426426
ψ = FiniteMPS(rand, ComplexF64, len, ℙ^2, ℙ^15)
427427
(ψ, envs, _) = find_groundstate(ψ, H; verbosity)
428428

429-
#find energy with quasiparticle ansatz
429+
# find energy with quasiparticle ansatz
430430
energies_QP, ϕs = excitations(H, QuasiparticleAnsatz(), ψ, envs)
431431
@test variance(ϕs[1], H) < 1e-6
432432

433-
#find energy with normal dmrg
434-
energies_dm, _ = excitations(H,
435-
FiniteExcited(;
436-
gsalg=DMRG(; verbosity,
437-
tol=1e-6)), ψ)
438-
@test energies_dm[1] energies_QP[1] + expectation_value(ψ, H, envs) atol = 1e-4
433+
# find energy with normal dmrg
434+
for gsalg in (DMRG(; verbosity, tol=1e-6),
435+
DMRG2(; verbosity, tol=1e-6, trscheme=truncbelow(1e-4)))
436+
energies_dm, _ = excitations(H, FiniteExcited(; gsalg), ψ)
437+
@test energies_dm[1] energies_QP[1] + expectation_value(ψ, H, envs) atol = 1e-4
438+
end
439439

440440
# find energy with Chepiga ansatz
441441
energies_ch, _ = excitations(H, ChepigaAnsatz(), ψ, envs)

0 commit comments

Comments
 (0)