Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ITensors] [BUG] Itensors refuses "weight" argument to DMRG #89

Open
marcio053 opened this issue Aug 6, 2024 · 3 comments
Open

[ITensors] [BUG] Itensors refuses "weight" argument to DMRG #89

marcio053 opened this issue Aug 6, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@marcio053
Copy link

marcio053 commented Aug 6, 2024

Below I'm leaving a snippet of my code that gives an error when placing the "weight" argument in the DMRG. This code works in previous versions of Itensors, but in recent versions it does not work

H=Set_Hamiltonian(sites,N,t,t1,U,e,J,K,Gamma,t0,J1,mu,dashedon)
    ############  preparing DMRM ###########
    state=InitialState(M,"Neel")
    #psi0 = productMPS(sites,state)
    psi0 = randomMPS(sites,state,linkdims = 20)

    sweeps = Sweeps(Nsweeps)

    #maxdim!(sweeps,10,20,100,200,200,200,300)
    maxdim!(sweeps,50,100,100,300)
    mindim!(sweeps,50)
    noise!(sweeps,1E-4,1E-6,1E-8,1E-8,1E-9)
    cutoff!(sweeps,1E-8)
    println("Starting DMRG")

    weight=20.0
    etol=1E-8
    obs = DemoObserver(etol)

    ############ TDVP ############    
    H1=Set_Hamiltonian(sites,N,1,1,1,1,1,1,1,1,1,0.1,true)
    maxdim=20
    println("Starting TDVP")
    tdvp!(psi0,H,0.01,0.02,maxdim=maxdim)
    println("End.")
    #########################
    #energy,psi = dmrg(H,psi0,sweeps,outputlevel=1; observer=obs, weight)
    
    energy,psi = dmrg(H,psi0,sweeps,eigsolve_krylovdim=Sweep_Niter,ishermitian=true;outputlevel
                      =output_level, weight)
                      
  ERROR: LoadError: MethodError: no method matching dmrg(::ProjMPO, ::MPS, ::Sweeps; eigsolve_krylovdim::Int64, ishermitian::Bool, outputlevel::Int64, weight::Float64)

Closest candidates are:
dmrg(::Any, ::MPS, ::Sweeps; which_decomp, svd_alg, observer, outputlevel, write_when_maxdim_exceeds, write_path, eigsolve_tol, eigsolve_krylovdim, eigsolve_maxiter, eigsolve_verbosity, eigsolve_which_eigenvalue, ishermitian) got unsupported keyword argument "weight"
@ ITensors ~/.julia/packages/ITensors/oOwvi/src/lib/ITensorMPS/src/dmrg.jl:158
dmrg(!Matched::MPO, ::MPS, ::Sweeps; kwargs...)
@ ITensors ~/.julia/packages/ITensors/oOwvi/src/lib/ITensorMPS/src/dmrg.jl:21
dmrg(!Matched::Vector{MPO}, ::MPS, ::Sweeps; kwargs...)
@ ITensors ~/.julia/packages/ITensors/oOwvi/src/lib/ITensorMPS/src/dmrg.jl:31

@marcio053 marcio053 added the bug Something isn't working label Aug 6, 2024
@emstoudenmire
Copy link
Contributor

emstoudenmire commented Aug 6, 2024

Thanks. Could you please post a minimal example that reproduces the bug? The example above includes some functions like Set_Hamiltonian and things which I don't have so I'm not able to run it.

Also, it may or may not be unrelated to the bug, but it could help to make your code in a more up-to-date style, following the code example here:
https://itensor.github.io/ITensors.jl/dev/examples/DMRG.html#Compute-excited-states-with-DMRG
Specifically note how it's preferred to no longer use the Sweeps type and instead just pass parameters like nsweeps, maxdim, etc as keyword arguments.

@mtfishman
Copy link
Member

Also, the preferred style is using MPS instead of productMPS and random_mps instead of randomMPS, though that's unrelated to your issue.

@mtfishman mtfishman transferred this issue from ITensor/ITensors.jl Oct 28, 2024
@emstoudenmire
Copy link
Contributor

I see the problem causing this error. @marcio053: the interface to dmrg that accepts the weight keyword has a different signature from the one you used above. The correct interface has the following signature:

dmrg(H::MPO, Ms::Vector{MPS}, psi0::MPS, sweeps::Sweeps; weight=true, kwargs...)

So you must pass:

  • a vector of the previous MPS to orthogonalize against
  • a guess or initial state for the next run of dmrg

In your case, you could call it as

energy1, psi1 dmrg(H,[psi0], psi0,sweeps,eigsolve_krylovdim=Sweep_Niter,ishermitian=true;outputlevel
                      =output_level, weight)

and that ought to work. Please let us know –

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants