ERROR: LoadError: UndefVarError: `checkdone!` not defined in `ITensors`

Hi, dear developers

Recently, I installed ITensor in a new cluster, as following

module load anaconda3/5.2.0; pip install jill; jill install
add ITensors; add ITensorMPS; add PackageCompiler
using ITensors; using PackageCompiler; ITensors.compile
using Pkg; Pkg.update()

Fortunatly, I could evaluate some baisc dmrg calculations. However, the checkdone! method seems broken.

ERROR: LoadError: UndefVarError: `checkdone!` not defined in `ITensors`
Stacktrace:
 [1] getproperty(x::Module, f::Symbol)
   @ Base ./Base.jl:42
 [2] top-level scope
   @ ~/laughlin/untitled.jl:10
in expression starting at /public/home/acamtw70yu/laughlin/untitled.jl:10

My Itensors version is v0.7.7, and ITensorMPS version is v0.3.2. My program is the sample code in the tutorial.

using ITensors, ITensorMPS

mutable struct DemoObserver <: AbstractObserver
   energy_tol::Float64
   last_energy::Float64

   DemoObserver(energy_tol=0.0) = new(energy_tol,1000.0)
end

function ITensors.checkdone!(o::DemoObserver;kwargs...)
  sw = kwargs[:sweep]
  energy = kwargs[:energy]
  if abs(energy-o.last_energy)/abs(energy) < o.energy_tol
    println("Stopping DMRG after sweep $sw")
    return true
  end
  # Otherwise, update last_energy and keep going
  o.last_energy = energy
  return false
end

function ITensors.measure!(o::DemoObserver; kwargs...)
  energy = kwargs[:energy]
  sweep = kwargs[:sweep]
  bond = kwargs[:bond]
  outputlevel = kwargs[:outputlevel]

  if outputlevel > 0
    println("Sweep $sweep at bond $bond, the energy is $energy")
  end
end

let
  N = 10
  etol = 1E-4

  s = siteinds("S=1/2",N)

  a = OpSum()
  for n=1:N-1
    a += "Sz",n,"Sz",n+1
    a += 0.5,"S+",n,"S-",n+1
    a += 0.5,"S-",n,"S+",n+1
  end
  H = MPO(a,s)
  psi0 = random_mps(s;linkdims=4)

  nsweeps = 5
  cutoff = 1E-8
  maxdim = [10,20,100]

  obs = DemoObserver(etol)

  println("Starting DMRG")
  energy, psi = dmrg(H,psi0; nsweeps, cutoff, maxdim, observer=obs, outputlevel=1)

  return
end

How can I fix the problem?

Thank you for your patience, I would be very grateful for any suggestions. I am looking to to hearing from you.
Regards,
Y.D.Shen.

Those functions have moved to ITensorMPS
So please change ITensors.checkdone!ITensorMPS.checkdone! etc

(I’ve also opened a pull request to fix the docs for this: [Docs] Update docs for ITensorMPS by ryanlevy · Pull Request #1603 · ITensor/ITensors.jl · GitHub )

Thanks a lot!!

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.