ITensor / ITensor/ITensorMPS.jl

[ITensors] [BUG] Sum of MPOs in DMRG for excited states doesn't work

Open
#83 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Julia
Stars
85
Forks
27
Avg merge
22m
Merged PRs (30d)
1

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the minimal runnable Julia example and inspect the dmrg methods in src/mps/dmrg.jl, especially the signatures shown in the error. Reproduce the failing excited-state call using a vector of MPOs and a vector of MPSs. Done means the second call accepts the same MPO-sum input as the first and runs without the reported MethodError.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.