Skip to content
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
9 changes: 5 additions & 4 deletions src/algorithms/timestep/tdvp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
ψ.AC[i] = integrate(h_ac, ψ.AC[i], t, dt / 2, alg.integrator)

h_c = ∂∂C(i, ψ, H, envs)
ψ.C[i] = integrate(h_c, ψ.C[i], t, -dt / 2, alg.integrator)
ψ.C[i] = integrate(h_c, ψ.C[i], t + dt / 2, -dt / 2, alg.integrator)

Check warning on line 81 in src/algorithms/timestep/tdvp.jl

View check run for this annotation

Codecov / codecov/patch

src/algorithms/timestep/tdvp.jl#L81

Added line #L81 was not covered by tests
end

# edge case
Expand All @@ -91,7 +91,7 @@
ψ.AC[i] = integrate(h_ac, ψ.AC[i], t + dt / 2, dt / 2, alg.integrator)

h_c = ∂∂C(i - 1, ψ, H, envs)
ψ.C[i - 1] = integrate(h_c, ψ.C[i - 1], t + dt / 2, -dt / 2, alg.integrator)
ψ.C[i - 1] = integrate(h_c, ψ.C[i - 1], t + dt, -dt / 2, alg.integrator)

Check warning on line 94 in src/algorithms/timestep/tdvp.jl

View check run for this annotation

Codecov / codecov/patch

src/algorithms/timestep/tdvp.jl#L94

Added line #L94 was not covered by tests
end

# edge case
Expand Down Expand Up @@ -148,7 +148,8 @@
ψ.AC[i + 1] = (complex(nc), _transpose_front(nar))

if i != (length(ψ) - 1)
ψ.AC[i + 1] = integrate(∂∂AC(i + 1, ψ, H, envs), ψ.AC[i + 1], t, -dt / 2,
ψ.AC[i + 1] = integrate(∂∂AC(i + 1, ψ, H, envs), ψ.AC[i + 1], t + dt / 2,

Check warning on line 151 in src/algorithms/timestep/tdvp.jl

View check run for this annotation

Codecov / codecov/patch

src/algorithms/timestep/tdvp.jl#L151

Added line #L151 was not covered by tests
-dt / 2,
alg.integrator)
end
end
Expand All @@ -164,7 +165,7 @@
ψ.AC[i] = (complex(nc), _transpose_front(nar))

if i != 2
ψ.AC[i - 1] = integrate(∂∂AC(i - 1, ψ, H, envs), ψ.AC[i - 1], t + dt / 2,
ψ.AC[i - 1] = integrate(∂∂AC(i - 1, ψ, H, envs), ψ.AC[i - 1], t + dt,

Check warning on line 168 in src/algorithms/timestep/tdvp.jl

View check run for this annotation

Codecov / codecov/patch

src/algorithms/timestep/tdvp.jl#L168

Added line #L168 was not covered by tests
-dt / 2, alg.integrator)
end
end
Expand Down
12 changes: 12 additions & 0 deletions test/algorithms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,18 @@ end
@test E ≈ Et atol = 1e-8
end

Ht2 = MultipliedOperator(H, t -> t < 0 ? error("t < 0!") : 4) +
MultipliedOperator(H, 1.45)
@testset "Finite TimeDependent LazySum (fix negative t issue) $(alg isa TDVP ? "TDVP" : "TDVP2")" for alg in
algs
ψ, envs = timestep(ψ₀, Ht2, 0.0, dt, alg)
E = expectation_value(ψ, Ht2(0.0), envs)

ψt, envst = timestep(ψ₀, Ht2, 0.0, dt, alg)
Et = expectation_value(ψt, Ht2(0.0), envst)
@test E ≈ Et atol = 1e-8
end

H = repeat(force_planar(heisenberg_XXX(; spin=1)), 2)
ψ₀ = InfiniteMPS([ℙ^3, ℙ^3], [ℙ^50, ℙ^50])
E₀ = expectation_value(ψ₀, H)
Expand Down
Loading