Skip to content

Commit

Permalink
Merge branch 'Daan-vumps&tdvp' of https://github.com/maartenvd/MPSKit.jl
Browse files Browse the repository at this point in the history
 into Daan-vumps&tdvp
  • Loading branch information
DaanMaertens committed Sep 8, 2023
2 parents 1bdfa7c + 5d5d7bd commit 29b3ae2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions src/algorithms/expval.jl
Original file line number Diff line number Diff line change
Expand Up @@ -162,19 +162,19 @@ expectation_value(Ψ::WindowMPS,windowH::Window, at::Int64) = expectation_value(
expectation_value::WindowMPS,windowH::Window, windowEnvs=environments(Ψ,windowH)) = expectation_value(Ψ,windowH, 0., windowEnvs)

# with time argument
function expectation_value::WindowMPS,windowH::Window,t::Number,at::Int64)
function expectation_value::WindowMPS,windowOp::Window,t::Number,at::Int64)
if at < 1
return expectation_value.left_gs,windowH.left,t,at)
return expectation_value.left_gs,windowOp.left,t,at)
elseif 1 <= at <= length.window)
return expectation_value(Ψ,windowH.middle,t,at)
return expectation_value(Ψ,windowOp.middle,t,at)
else
return expectation_value.right_gs,windowH.right,t,at)
return expectation_value.right_gs,windowOp.right,t,at)
end
end

function expectation_value::WindowMPS,windowH::Window,t::Number,windowEnvs::Window{C,D,C}=environments(Ψ,windowH)) where {C <: Union{MultipleEnvironments,Cache}, D <: Union{MultipleEnvironments,Cache}}
left = expectation_value.left_gs,windowH.left,t,windowEnvs.left)
middle = expectation_value(Ψ,windowH.middle,t,windowEnvs.middle)
middle = expectation_value.window,windowH.middle,t,windowEnvs.middle)
right = expectation_value.right_gs,windowH.right,t,windowEnvs.right)
return [left.data...,middle...,right.data...]
end
12 changes: 6 additions & 6 deletions src/algorithms/timestep/windowtdvp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ function timestep!(Ψ::WindowMPS, H::Window, t::Number, dt::Number,alg::TDVP,env
end

# some Notes
# - at what time do we evaluate h_ac and c? at t, t+dt/4 ? do we take both at the same time?
# - at what time do we evaluate h_ac and c? at t, t+dt/4 ? do we take both at the same time? integrate itself already evaluates at t+dt/2 I think

#left to right sweep on window
for i in 1:(length(Ψ)-1)
Expand Down Expand Up @@ -123,18 +123,18 @@ function timestep!(Ψ::WindowMPS, H::Window, t::Number, dt::Number,alg::TDVP,env
#right to left sweep on window
for i in length(Ψ):-1:2
h_ac = ∂∂AC(i,Ψ,H.middle,env.middle);
Ψ.AC[i], converged, convhist = integrate(h_ac,Ψ.AC[i],t+dt/2,-1im,dt/2,alg.integrator)
Ψ.AC[i], converged, convhist = integrate(h_ac,Ψ.AC[i],t,-1im,dt/2,alg.integrator)
converged == 0 &&
@info "time evolving ac($i) failed $(convhist.normres)"

h_c = ∂∂C(i-1,Ψ,H.middle,env.middle);
Ψ.CR[i-1], converged, convhist = integrate(h_c,Ψ.CR[i-1],t+dt/2,-1im,-dt/2,alg.integrator)
Ψ.CR[i-1], converged, convhist = integrate(h_c,Ψ.CR[i-1],t,-1im,-dt/2,alg.integrator)
converged == 0 &&
@info "time evolving c($(i-1)) failed $(convhist.normres)"
end

h_ac = ∂∂AC(1,Ψ,H.middle,env.middle);
Ψ.AC[1], converged, convhist = integrate(h_ac,Ψ.AC[1],t+dt/2,-1im,dt/2,alg.integrator)
Ψ.AC[1], converged, convhist = integrate(h_ac,Ψ.AC[1],t,-1im,dt/2,alg.integrator)
converged == 0 &&
@info "time evolving ac(1) failed $(convhist.normres)"

Expand Down Expand Up @@ -189,7 +189,7 @@ function timestep!(Ψ::WindowMPS, H::Window, t::Number, dt::Number,alg::TDVP2,en
for i in length(Ψ):-1:2
h_ac2 = ∂∂AC2(i-1,Ψ,H.middle,env.middle);
ac2 = Ψ.AL[i-1]*_transpose_tail.AC[i]);
ac2, converged, convhist = integrate(h_ac2,ac2, t+dt/2,-1im,dt/2,alg.integrator)
ac2, converged, convhist = integrate(h_ac2,ac2, t,-1im,dt/2,alg.integrator)
converged == 0 &&
@info "time evolving ac2($i) failed $(convhist.normres)"
(U,S,V) = tsvd(ac2, alg = TensorKit.SVD(), trunc = alg.trscheme);
Expand All @@ -199,7 +199,7 @@ function timestep!(Ψ::WindowMPS, H::Window, t::Number, dt::Number,alg::TDVP2,en

if i > 2
h_ac = ∂∂AC(i-1,Ψ,H.middle,env.middle);
Ψ.AC[i-1], converged, convhist = integrate(h_ac,Ψ.AC[i-1],t+dt/2,-1im,-dt/2,alg.integrator)
Ψ.AC[i-1], converged, convhist = integrate(h_ac,Ψ.AC[i-1],t,-1im,-dt/2,alg.integrator)
converged == 0 &&
@info "time evolving ac($i) failed $(convhist.normres)"
end
Expand Down

0 comments on commit 29b3ae2

Please sign in to comment.