Skip to content

[BUG] write_when_maxdim_exceeds not working for excited state dmrg calculation #145

@Connor-Aronoff

Description

@Connor-Aronoff

Description of bug

I seem to be running into a bug regarding "write_when_maxdim_exceeds" when calculating excited states using dmrg. This seems to be a similar bug other people have posted about for other solvers, but I was hoping since "write_when_maxdim_exceeds" works for the ground state dmrg calculation, it may be easily fixed for the subsequent excited state calculations.

Let me know if there is a known work around.

Minimal code demonstrating the bug or unexpected behavior

Minimal runnable code

using ITensors, ITensorMPS

let
  N = 100
  sites = siteinds("S=1",N)

  os = OpSum()
  for j=1:N-1
    os += 0.5,"S+",j,"S-",j+1
    os += 0.5,"S-",j,"S+",j+1
    os += "Sz",j,"Sz",j+1
  end
  H = MPO(os,sites)

  nsweeps = 5 # number of sweeps is 5
  maxdim = [10,20,100,100,200] # gradually increase states kept
  cutoff = [1E-10] # desired truncation error

  psi0 = random_mps(sites;linkdims=2)

  energy,psi = dmrg(H,psi0;nsweeps,maxdim,cutoff, write_when_maxdim_exceeds=1)

  energy2, psi2 = dmrg(H,[psi], psi0;nsweeps,maxdim,cutoff, write_when_maxdim_exceeds=1)

  return
end

Expected output or behavior

I guess I expect the 2nd dmrg calculation done for the first excited state to be able to save to disk.

Actual output or behavior

I get the following error once the 2nd dmrg sweeps start

Output of minimal runnable code

ERROR: LoadError: MethodError: no method matching disk(::ProjMPO_MPS; path::String)
The function `disk` exists, but no method is defined for this combination of argument types.

Closest candidates are:
  disk(::ProjMPO; kwargs...)
   @ ITensorMPS C:\Users\395642\.julia\packages\ITensorMPS\50GxK\src\abstractprojmpo\diskprojmpo.jl:69
  disk(::ITensorMPS.DiskProjMPO; kwargs...)
   @ ITensorMPS C:\Users\395642\.julia\packages\ITensorMPS\50GxK\src\abstractprojmpo\diskprojmpo.jl:82
  disk(::ITensorMPS.AbstractSum; disk_kwargs...)
   @ ITensorMPS C:\Users\395642\.julia\packages\ITensorMPS\50GxK\src\abstractprojmpo\projmposum.jl:118
  ...

Stacktrace:
 [1] dmrg(PH::ProjMPO_MPS, psi0::MPS, sweeps::Sweeps; which_decomp::Nothing, svd_alg::Nothing, observer::NoObserver, outputlevel::Int64, write_when_maxdim_exceeds::Int64, write_path::String, eigsolve_tol::Float64, eigsolve_krylovdim::Int64, eigsolve_maxiter::Int64, eigsolve_verbosity::Int64, eigsolve_which_eigenvalue::Symbol, ishermitian::Bool)
   @ ITensorMPS C:\Users\395642\.julia\packages\ITensorMPS\50GxK\src\dmrg.jl:199
 [2] dmrg
   @ C:\Users\395642\.julia\packages\ITensorMPS\50GxK\src\dmrg.jl:158 [inlined]
 [3] dmrg(H::MPO, Ms::Vector{MPS}, psi0::MPS, sweeps::Sweeps; weight::Bool, kwargs::@Kwargs{outputlevel::Int64, write_when_maxdim_exceeds::Int64})
   @ ITensorMPS C:\Users\395642\.julia\packages\ITensorMPS\50GxK\src\dmrg.jl:55
 [4] dmrg
   @ C:\Users\395642\.julia\packages\ITensorMPS\50GxK\src\dmrg.jl:41 [inlined]
 [5] #dmrg#518
   @ C:\Users\395642\.julia\packages\ITensorMPS\50GxK\src\dmrg.jl:374 [inlined]
 [6] top-level scope
   @ C:\Users\395642\Documents\julia\save_to_disk_test.jl:23
in expression starting at C:\Users\395642\Documents\julia\save_to_disk_test.jl:3

Version information

  • Output from versioninfo():
julia> versioninfo()
Julia Version 1.11.5
Commit 760b2e5b73 (2025-04-14 06:53 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: 32 × 13th Gen Intel(R) Core(TM) i9-13950HX
  WORD_SIZE: 64
  LLVM: libLLVM-16.0.6 (ORCJIT, alderlake)
Threads: 1 default, 0 interactive, 1 GC (on 32 virtual cores)
  • Output from using Pkg; Pkg.status("ITensorMPS"):
julia> using Pkg; Pkg.status("ITensorMPS")
Status `C:\Users\395642\.julia\environments\v1.11\Project.toml`
  [0d1a4710] ITensorMPS v0.3.18

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions