ITensors.jl
ITensors.jl copied to clipboard
[ITensors] [BUG] Autofermion system incompatible with simple (no QN) Indices (when factorizing)
Description of bug
Enabling the Autofermion system (ITensors.enable_auto_fermion) leads to errors when performing DMRG on a system without quantum number conservation enforced.
Minimal code demonstrating the bug or unexpected behavior
This is a copy of examples/dmrg/1d_heisenberg.jl up to ITensors.enable_auto_fermion() at the top of the code block.
Minimal runnable code
using ITensors
using Printf
using Random
Random.seed!(1234)
let
N = 100
ITensors.enable_auto_fermion()
# Create N spin-one degrees of freedom
sites = siteinds("S=1", N)
# Alternatively can make spin-half sites instead
#sites = siteinds("S=1/2", N)
# Input operator terms which define a Hamiltonian
os = OpSum()
for j in 1:(N - 1)
os += "Sz", j, "Sz", j + 1
os += 0.5, "S+", j, "S-", j + 1
os += 0.5, "S-", j, "S+", j + 1
end
# Convert these terms to an MPO tensor network
H = MPO(os, sites)
# Create an initial random matrix product state
psi0 = randomMPS(sites; linkdims=10)
# Plan to do 5 DMRG sweeps:
nsweeps = 5
# Set maximum MPS bond dimensions for each sweep
maxdim = [10, 20, 100, 100, 200]
# Set maximum truncation error allowed when adapting bond dimensions
cutoff = [1E-11]
# Run the DMRG algorithm, returning energy and optimized MPS
energy, psi = dmrg(H, psi0; nsweeps, maxdim, cutoff)
@printf("Final energy = %.12f\n", energy)
end
Expected output or behavior
DMRG should run successfully.
Actual output or behavior An error is raised in the factorization, regarding the expected arrow-directions when the autofermion system is enabled. I expect the solution to be change the default arrow-direction when either interpreting a non-QN Index as a QNIndex with trivial QN or converting one to the other.
Output of minimal runnable code
ERROR: LoadError: With auto_fermion enabled, left inds in eigen must have Out arrows
Stacktrace:
[1] error(s::String)
@ Base ./error.jl:35
[2] eigen(A::ITensor, Linds::Vector{Index{Int64}}, Rinds::Vector{Index{Int64}}; mindim::Int64, maxdim::Int64, cutoff::Float64, use_absolute_cutoff::Nothing, use_relative_cutoff::Nothing, ishermitian::Bool, tags::TagSet, lefttags::Nothing, righttags::Nothing, plev::Nothing, leftplev::Nothing, rightplev::Nothing)
@ ITensors ~/.julia/v1.9/packages/ITensors/Gf9aD/src/tensor_operations/matrix_decomposition.jl:358
[3] factorize_eigen(A::ITensor, Linds::Tuple{Index{Int64}, Index{Int64}}; ortho::String, eigen_perturbation::Nothing, mindim::Int64, maxdim::Int64, cutoff::Float64, tags::TagSet, use_absolute_cutoff::Nothing, use_relative_cutoff::Nothing)
@ ITensors ~/.julia/v1.9/packages/ITensors/Gf9aD/src/tensor_operations/matrix_decomposition.jl:680
[4] factorize(A::ITensor, Linds::Tuple{Index{Int64}, Index{Int64}}; mindim::Int64, maxdim::Int64, cutoff::Float64, ortho::String, tags::TagSet, plev::Nothing, which_decomp::Nothing, eigen_perturbation::Nothing, svd_alg::Nothing, use_absolute_cutoff::Nothing, use_relative_cutoff::Nothing, min_blockdim::Nothing, singular_values!::Nothing, dir::Nothing)
@ ITensors ~/.julia/v1.9/packages/ITensors/Gf9aD/src/tensor_operations/matrix_decomposition.jl:827
[5] replacebond!(M::MPS, b::Int64, phi::ITensor; normalize::Bool, swapsites::Nothing, ortho::String, which_decomp::Nothing, mindim::Int64, maxdim::Int64, cutoff::Float64, eigen_perturbation::Nothing, svd_alg::Nothing, use_absolute_cutoff::Nothing, use_relative_cutoff::Nothing, min_blockdim::Nothing)
@ ITensors ~/.julia/v1.9/packages/ITensors/Gf9aD/src/mps/mps.jl:559
[6] replacebond!
@ ~/.julia/v1.9/packages/ITensors/Gf9aD/src/mps/mps.jl:530 [inlined]
[7] #replacebond!#956
@ ~/.julia/v1.9/packages/ITensors/Gf9aD/src/mps/mps.jl:606 [inlined]
[8] macro expansion
@ ~/.julia/v1.9/packages/ITensors/Gf9aD/src/mps/dmrg.jl:277 [inlined]
[9] macro expansion
@ ~/.julia/v1.9/packages/TimerOutputs/RsWnF/src/TimerOutput.jl:253 [inlined]
[10] macro expansion
@ ~/.julia/v1.9/packages/ITensors/Gf9aD/src/mps/dmrg.jl:276 [inlined]
[11] macro expansion
@ ./timing.jl:393 [inlined]
[12] dmrg(PH::ProjMPO, psi0::MPS, sweeps::Sweeps; which_decomp::Nothing, svd_alg::Nothing, observer::NoObserver, outputlevel::Int64, write_when_maxdim_exceeds::Nothing, write_path::String, eigsolve_tol::Float64, eigsolve_krylovdim::Int64, eigsolve_maxiter::Int64, eigsolve_verbosity::Int64, eigsolve_which_eigenvalue::Symbol, ishermitian::Bool)
@ ITensors ~/.julia/v1.9/packages/ITensors/Gf9aD/src/mps/dmrg.jl:204
[13] dmrg
@ ~/.julia/v1.9/packages/ITensors/Gf9aD/src/mps/dmrg.jl:156 [inlined]
[14] #dmrg#1053
@ ~/.julia/v1.9/packages/ITensors/Gf9aD/src/mps/dmrg.jl:27 [inlined]
[15] dmrg
@ ~/.julia/v1.9/packages/ITensors/Gf9aD/src/mps/dmrg.jl:20 [inlined]
[16] #dmrg#1059
@ ~/.julia/v1.9/packages/ITensors/Gf9aD/src/mps/dmrg.jl:391 [inlined]
[17] top-level scope
@ ~/.julia/v1.9/dev/ITensors/examples/dmrg/1d_heisenberg_af.jl:36
[18] include(fname::String)
@ Base.MainInclude ./client.jl:478
[19] top-level scope
@ REPL[3]:1
in expression starting at /mnt/home/bkloss/.julia/v1.9/dev/ITensors/examples/dmrg/1d_heisenberg_af.jl:7
Version information
- Output from
versioninfo():
julia> versioninfo()
Commit 8e63055292* (2023-05-07 11:25 UTC)
Platform Info:
OS: Linux (x86_64-pc-linux-gnu)
CPU: 32 × Intel(R) Xeon(R) Gold 6234 CPU @ 3.30GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-14.0.6 (ORCJIT, cascadelake)
Threads: 1 on 32 virtual cores
- Output from
using Pkg; Pkg.status("ITensors"):
julia> using Pkg; Pkg.status("ITensors")
Status `~/projects/ITensors_issues/af_vs_noqn/Project.toml`
[9136182c] ITensors v0.3.54
@emstoudenmire could you take a look?
Closed by #1380.