Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bugfix] Ensure that projection environments have correct above #204

Merged
merged 2 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/environments/FinEnv.jl
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,10 @@
N = length(below)
leftstart = isomorphism(storagetype(S),
left_virtualspace(below, 0) ⊗ space(O[1], 1)' ←
left_virtualspace(below, 0))
left_virtualspace(something(above, below), 0))
rightstart = isomorphism(storagetype(S),
right_virtualspace(below, N) ⊗ space(O[N], 4)' ←
right_virtualspace(something(above, below), N) ⊗
space(O[N], 4)' ←
right_virtualspace(below, length(below)))
return environments(below, O, above, leftstart, rightstart)
end
Expand All @@ -101,7 +102,7 @@
function environments(state::Union{FiniteMPS,WindowMPS}, opp::ProjectionOperator)
@plansor leftstart[-1; -2 -3 -4] := l_LL(opp.ket)[-3; -4] * l_LL(opp.ket)[-1; -2]
@plansor rightstart[-1; -2 -3 -4] := r_RR(opp.ket)[-1; -2] * r_RR(opp.ket)[-3; -4]
return environments(state, fill(nothing, length(state)), state, leftstart, rightstart)
return environments(state, fill(nothing, length(state)), opp.ket, leftstart, rightstart)

Check warning on line 105 in src/environments/FinEnv.jl

View check run for this annotation

Codecov / codecov/patch

src/environments/FinEnv.jl#L105

Added line #L105 was not covered by tests
end

#notify the cache that we updated in-place, so it should invalidate the dependencies
Expand Down
14 changes: 7 additions & 7 deletions test/algorithms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -426,16 +426,16 @@ end
ψ = FiniteMPS(rand, ComplexF64, len, ℙ^2, ℙ^15)
(ψ, envs, _) = find_groundstate(ψ, H; verbosity)

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

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

# find energy with Chepiga ansatz
energies_ch, _ = excitations(H, ChepigaAnsatz(), ψ, envs)
Expand Down
Loading