ITensors.jl
ITensors.jl copied to clipboard
[ITensors] [BUG] Sum of MPOs in DMRG for excited states doesn't work
In the example page in the documentation it is reported that passing an MPO which is a sum of some MPOs as a vector to the dmrg function results in faster computation. For bigger system I found the speedup is non-negligible and I would like to use the same trick for excited states, but the implementation of dmrg for this particular case is missing.
Minimal runnable code
using ITensors
N = 4
sites = siteinds("S=1/2", N)
os_HA = OpSum()
os_HA += 1, "Z", 1, "Z", 2
os_HA += 1, "Z", 3, "Z", 4
os_HA += -1, "Z", 1, "Z", 3
os_HA += -1, "Z", 2, "Z", 4
W = rand(N)
os_HB = OpSum()
for j in 1:N
os_HB += W[j], "Z", j
end
HA = MPO(os_HA, sites)
HB = MPO(os_HB, sites)
psi0 = randomMPS(sites, 5)
psi1 = randomMPS(sites, 5)
E0, psi0 = dmrg([HA, HB], psi0, nsweeps=10, outputlevel=0)
E1, psi1 = dmrg([HA, HB], [psi0], psi1, nsweeps=10)
The first dmrg call works as expected, while the second one gives the error reported below.
Output of minimal runnable code
MethodError: no method matching dmrg(::Vector{MPO}, ::Vector{MPS}, ::MPS, ::Sweeps)
Closest candidates are:
dmrg(::MPO, ::Vector{MPS}, ::MPS, ::Sweeps; weight, kwargs...)
@ ITensors ~/.julia/packages/ITensors/MnaxI/src/mps/dmrg.jl:40
dmrg(::Any, ::Any, ::MPS; nsweeps, maxdim, mindim, cutoff, noise, kwargs...)
@ ITensors ~/.julia/packages/ITensors/MnaxI/src/mps/dmrg.jl:365
dmrg(::Vector{MPO}, ::MPS, ::Sweeps; kwargs...)
@ ITensors ~/.julia/packages/ITensors/MnaxI/src/mps/dmrg.jl:30
...
Stacktrace:
[1] dmrg(x1::Vector{MPO}, x2::Vector{MPS}, psi0::MPS; nsweeps::Int64, maxdim::Int64, mindim::Int64, cutoff::Float64, noise::Bool, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ ITensors ~/.julia/packages/ITensors/MnaxI/src/mps/dmrg.jl:376
[2] top-level scope
@ In[20]:26
Version information
- Output from
versioninfo():
julia> versioninfo()
Julia Version 1.9.4
Commit 8e5136fa297 (2023-11-14 08:46 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: macOS (arm64-apple-darwin22.4.0)
CPU: 10 × Apple M1 Pro
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-14.0.6 (ORCJIT, apple-m1)
Threads: 8 on 8 virtual cores
Environment:
JULIA_NUM_THREADS = 8
- Output from
using Pkg; Pkg.status("ITensors"):
julia> using Pkg; Pkg.status("ITensors")
Status `~/.julia/environments/v1.9/Project.toml`
[9136182c] ITensors v0.3.52
Thanks for the report. We are currently working on a rewrite of the projected MPO code, it should be easy to add support for this once that is done (we have a plan for a more general and flexible design than the current one).
@emstoudenmire this is a good use case to keep in mind for the new projected MPO code.
@mtfishman thanks, definitely helpful. I'm keeping a list of cases to cover and I'll add this one.