Skip to content

Commit 1e01ed8

Browse files
committed
Handle real/complex environments
1 parent 77bba70 commit 1e01ed8

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/algorithms/timestep/tdvp.jl

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,18 @@ end
178178

179179
#copying version
180180
function timestep::AbstractFiniteMPS, H, time::Number, timestep::Number,
181-
alg::Union{TDVP,TDVP2}, envs::AbstractMPSEnvironments=environments(ψ, H);
181+
alg::Union{TDVP,TDVP2}, envs::AbstractMPSEnvironments...;
182182
kwargs...)
183-
return timestep!(copy(complex(ψ)), H, time, timestep, alg, envs; kwargs...)
183+
isreal = scalartype(ψ) <: Real
184+
ψ′ = isreal ? complex(ψ) : copy(ψ)
185+
if length(envs) != 0 && isreal
186+
@warn "Currently cannot reuse real environments for complex evolution"
187+
envs′ = environments(ψ′, H)
188+
elseif length(envs) == 1
189+
envs′ = only(envs)
190+
else
191+
@assert length(envs) == 0 "Invalid signature"
192+
envs′ = environments(ψ′, H)
193+
end
194+
return timestep!(ψ′, H, time, timestep, alg, envs′; kwargs...)
184195
end

0 commit comments

Comments
 (0)