0 votes
asked by (320 points)


I got a ground state of a nearest-neighbour hubbard model by DMRG and called the state psi.I saved the psi by using ITensors.HDF5. I want to get the time evolution of psi and use the modified code from enter link description here

However,when the program is running the
psi = apply(gates, psi; cutoff=cutoff)
It can't work and get the output:

ERROR: BoundsError: attempt to access 0-element Vector{Int64} at index 
[1] getindex
   @ ./array.jl:861 [inlined]
[2] product(o::ITensor, ψ::MPS, ns::Vector{Int64}; move_sites_back::Bool, apply_dag::Bool, kwargs::Base.Pairs{Symbol, Float64, Tuple{Symbol}, NamedTuple{(:cutoff,), Tuple{Float64}}})
@ ITensors ~/.julia/packages/ITensors/cu9Bo/src/mps/abstractmps.jl:1751
[3] product(As::Vector{ITensor}, ψ::MPS; move_sites_back::Bool, kwargs::Base.Pairs{Symbol, Float64, Tuple{Symbol}, NamedTuple{(:cutoff,), Tuple{Float64}}})
@ ITensors ~/.julia/packages/ITensors/cu9Bo/src/mps/abstractmps.jl:1859
[4] top-level scope
@ REPL[1]:1

I can make sure the Hamiltonian in TEBD is right.When I used

psi = productMPS(s, n -> isodd(n) ? "Up" : "Dn");

to set a random MPS to replace psi. The TEBD works well.
Having tried the hubbard model and the Heisenberg model,I think the question results from the relation between "h5"file and the function"apply".If I can't run time evolution for a ground state from h5 file by this way,Is there another way?


1 Answer

0 votes
answered by (70.1k points)
selected by
Best answer

Thanks for the question. We may need to discuss more to figure out what is going on, but I bet it is not specific to the function apply. I think what has happened is probably that the "site" indices you used to make your MPS when you wrote it to disk originally are different from the ones that you used to make the gates that you are inputting into apply.

It would explain why when you re-make psi using productMPS that the error goes away.

Did you also write the "s" object to disk and re-read it back in? An alternative to that is that you can "grab" the sites of an MPS like this:

s = siteinds(psi)

so you can use that to make sure that s is compatible with psi before using either of them.

Please try updating your code to make sure "s" is compatible with psi and if you are running into more issues happy to discuss it more below.

Best regards,

commented by (320 points)
Thanks a lot Miles! I don't save the "s" in disk as a file. I only use
 "s= siteinds(psi)"
to replace
 "s = siteinds("Electron", N; conserve_qns=true)"
in time evolution. The program works very well and outcome is just as I expect. You've helped me a lot.
I have a idea that the example can be added in the part MPS Time Evolution of " Documentation for the Julia version of ITensor". Probably many users like me want to use ITensor to run time evolution.

Best wishes,
commented by (70.1k points)
Really glad you were able to fix it and that siteinds helped. Good idea to add examples to the documentation showing saving of wave functions to disk.
Welcome to ITensor Support Q&A, where you can ask questions and receive answers from other members of the community.

Formatting Tips:
  • To format code, indent by four spaces
  • To format inline LaTeX, surround it by @@ on both sides
  • To format LaTeX on its own line, surround it by $$ above and below
  • For LaTeX, it may be necessary to backslash-escape underscore characters to obtain proper formatting. So for example writing \sum\_i to represent a sum over i.
If you cannot register due to firewall issues (e.g. you cannot see the capcha box) please email Miles Stoudenmire to ask for an account.

To report ITensor bugs, please use the issue tracker.