ITensor / ITensor/ITensorMPS.jl

[BUG] Vector of MPOs in DMRG works for the ground state, but it does not work for the excited states.

Open
#207 0 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

Description of bug
Vector of MPOs in DMRG works for the ground state, but it does not work for the excited states.
It would be beneficial if this works, as I need it to handle MPOs with large bond dimensions.

Minimal code demonstrating the bug

Minimal runnable code


using ITensors
using ITensorMPS

# 1. Setup sites and Hamiltonian components (OpSum)
N = 10
sites = siteinds("S=1/2", N)
os_A = OpSum()
for j in 1:N-1
    os_A += 0.5, "S+", j, "S-", j+1
    os_A += 0.5, "S-", j, "S+", j+1
    os_A += "Sz", j, "Sz", j+1
end
os_B = OpSum()
for j in 1:N
    os_B += 0.1, "Sz", j # Additional potential field
end

# 2. Convert OpSum to MPOs
HA = MPO(os_A, sites)
HB = MPO(os_B, sites)
H_list = [HA, HB] # Sum of MPOs

# 3. Initial states
psi0 = randomMPS(sites, 5) # For ground state
psi1 = randomMPS(sites, 5) # For first excited state
psi2 = randomMPS(sites, 5) # For second excited state

# 4. DMRG for Ground State
E0, psi0 = dmrg(H_list, psi0; nsweeps=10)

# 5. DMRG for Excited State (ortho to psi0)
# The "Weight" keyword penalizes non-zero overlap with [psi0]
E1, psi1 = dmrg(H_list, [psi0], psi1; nsweeps=10, weight=10.0)

E2, psi2 = dmrg(H_list, [psi0, psi1], psi2; nsweeps=10, weight=10.0) # penalty for both psi0 and psi1
println("Ground Energy: ", E0)
println("First Excited Energy: ", E1)
println("Second Excited Energy: ", E2)

Error output

ERROR: MethodError: no method matching dmrg(::Vector{MPO}, ::Vector{MPS}, ::MPS, ::Sweeps; weight::Float64)
The function `dmrg` exists, but no method is defined for this combination of argument types.

Closest candidates are:
  dmrg(::MPO, ::Vector{MPS}, ::MPS, ::Sweeps; weight, kwargs...)
   @ ITensorMPS ~/.julia/packages/ITensorMPS/3SBBV/src/dmrg.jl:41
  dmrg(::Any, ::Any, ::MPS; nsweeps, maxdim, mindim, cutoff, noise, kwargs...)
   @ ITensorMPS ~/.julia/packages/ITensorMPS/3SBBV/src/dmrg.jl:363
  dmrg(::Vector{MPO}, ::MPS, ::Sweeps; kwargs...)
   @ ITensorMPS ~/.julia/packages/ITensorMPS/3SBBV/src/dmrg.jl:31
  ...

Stacktrace:
 [1] dmrg(x1::Vector{…}, x2::Vector{…}, psi0::MPS; nsweeps::Int64, maxdim::Int64, mindim::Int64, cutoff::Float64, noise::Bool, kwargs::@Kwargs{…})
   @ ITensorMPS ~/.julia/packages/ITensorMPS/3SBBV/src/dmrg.jl:374
 [2] top-level scope
   @ ~/Projects/ITensorAGP/github_7/example_scipts/MFIsing/test.jl:33
Some type information was truncated. Use `show(err)` to see complete types.

Version information

  • Output from versioninfo():
julia> versioninfo()
Julia Version 1.11.1
Commit 8f5b7ca12ad (2024-10-16 10:53 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: macOS (arm64-apple-darwin22.4.0)
  CPU: 11 × Apple M3 Pro
  WORD_SIZE: 64
  LLVM: libLLVM-16.0.6 (ORCJIT, apple-m3)
Threads: 1 default, 0 interactive, 1 GC (on 5 virtual cores)
Environment:
  JULIA_EDITOR = code
  JULIA_VSCODE_REPL = 1
  • Output from using Pkg; Pkg.status("ITensorMPS"):
julia> using Pkg; Pkg.status("ITensorMPS")
Status `~/.julia/environments/v1.11/Project.toml`
⌃ [0d1a4710] ITensorMPS v0.3.16
Info Packages marked with ⌃ have new versions available and may be upgradable.

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 dmrg methods in src/dmrg.jl, especially the entries around lines 31, 363, and 374 named in the stack trace, and rerun the minimal Julia example. Confirm that the vector-of-MPO form accepts the excited-state arguments and the example prints ground, first-excited, and second-excited energies without a MethodError.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.