ITensor / ITensorMPS.jl

MPS and MPO methods based on ITensor (ITensors.jl)
Apache License 2.0
23 stars 4 forks source link

tdvp_order throws an error for order 4 #36

Open sridevi-k-20 opened 2 years ago

sridevi-k-20 commented 2 years ago
TDVP_Order_error

TDVP_order which determines the number of forward and backward sweeps does not work for order=4. This is because the function in tdvporder.jl

function orderings(::TDVPOrder{4,direction}) where {direction}
  return [direction, Base.ReverseOrdering(direction)]
end

returns an array of length 2. However, the for loop in the file tdvp_step.jl runs over the length of sub_time_steps, which is an array of length 6 according to the definition given in tdvporder.jl.

  for substep in 1:length(sub_time_steps)
    psi, PH, info = tdvp_sweep(
      orderings[substep], solver, PH, sub_time_steps[substep], psi; current_time, kwargs...
    )

This causes an error as attached in the image. One can overcome this error by changing the function as

function orderings(::TDVPOrder{4,direction}) where {direction}
  return [direction, Base.ReverseOrdering(direction),direction, Base.ReverseOrdering(direction),direction, Base.ReverseOrdering(direction)]
end

But not sure if this a correct approach. Please check this. Thank you

mtfishman commented 2 years ago

That sounds reasonable, @b-kloss does that make sense to you?

A slightly simpler way to write it would be:

function orderings(::TDVPOrder{4,direction}) where {direction}
  return repeat(orderings(TDVPOrder{2,direction}(), 3)
end
b-kloss commented 1 year ago

Yes, either of these should be correct. I'll try to test it soon.

jkombe commented 12 months ago

Hi, I have also come across this issue, and wanted to push the fix for it. Do I need some access rights @mtfishman? Thanks!

mtfishman commented 12 months ago

You can make a fork and then a PR, no need for access rights.