Skip to content

Commit

Permalink
Merge branch 'master' into blocktensor2
Browse files Browse the repository at this point in the history
  • Loading branch information
lkdvos committed Dec 11, 2024
2 parents a743813 + cd81eef commit 4c66f24
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
8 changes: 5 additions & 3 deletions src/environments/finite_envs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ function environments(below::FiniteMPS{S}, O::DenseMPO, above=nothing) where {S}
N = length(below)
leftstart = isomorphism(storagetype(S),

Check warning on line 39 in src/environments/finite_envs.jl

View check run for this annotation

Codecov / codecov/patch

src/environments/finite_envs.jl#L37-L39

Added lines #L37 - L39 were not covered by tests
left_virtualspace(below, 0) space(O[1], 1)'
left_virtualspace(below, 0))
left_virtualspace(something(above, below), 0))
rightstart = isomorphism(storagetype(S),

Check warning on line 42 in src/environments/finite_envs.jl

View check run for this annotation

Codecov / codecov/patch

src/environments/finite_envs.jl#L42

Added line #L42 was not covered by tests
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)

Check warning on line 46 in src/environments/finite_envs.jl

View check run for this annotation

Codecov / codecov/patch

src/environments/finite_envs.jl#L46

Added line #L46 was not covered by tests
end
Expand Down Expand Up @@ -85,7 +86,8 @@ function environments(state::Union{FiniteMPS,WindowMPS}, operator::ProjectionOpe
l_LL(operator.ket)[-1; -2]
@plansor rightstart[-1; -2 -3 -4] := r_RR(operator.ket)[-1; -2] *

Check warning on line 87 in src/environments/finite_envs.jl

View check run for this annotation

Codecov / codecov/patch

src/environments/finite_envs.jl#L87

Added line #L87 was not covered by tests
r_RR(operator.ket)[-3; -4]
return environments(state, fill(nothing, length(state)), state, leftstart, rightstart)
return environments(state, fill(nothing, length(state)), operator.ket, leftstart,

Check warning on line 89 in src/environments/finite_envs.jl

View check run for this annotation

Codecov / codecov/patch

src/environments/finite_envs.jl#L89

Added line #L89 was not covered by tests
rightstart)
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 @@ -455,16 +455,16 @@ end
ψ = FiniteMPS(rand, ComplexF64, len, ℙ^2, ℙ^10)
ψ, 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, maxiter=30)), ψ)
@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

0 comments on commit 4c66f24

Please sign in to comment.