ITensors.jl
ITensors.jl copied to clipboard
`randomMPS` fails to create states with `linkdim>1` on heterogenous lattice when qns are conserved
Basically, if I have a lattice where alternating sites have different sitetypes, randomMPS(s, f; linkdims=k)
for k>1
will end up erroring. Here is a MWE:
using ITensors
function ITensors.space(::SiteType"Sf=1/2";
conserve_qns=false)
if conserve_qns
return [QN("Sz", 1)=>1, QN("Sz",-1)=>1]
end
return 2
end
function ITensors.space(::SiteType"Sb=1/2";
conserve_qns=false)
if conserve_qns
return [QN("Sz", 2)=>1, QN("Sz",-2)=>1]
end
return 2
end
ITensors.state(::StateName"Up", ::SiteType"Sf=1/2") = [1.0, 0.0]
ITensors.state(::StateName"Dn", ::SiteType"Sf=1/2") = [0.0, 1.0]
ITensors.state(::StateName"Up", ::SiteType"Sb=1/2") = [1.0, 0.0]
ITensors.state(::StateName"Dn", ::SiteType"Sb=1/2") = [0.0, 1.0]
let
N = 4
s = siteinds(n -> isodd(n) ? "Sf=1/2" : "Sb=1/2", N; conserve_qns=true)
ψ = randomMPS(s, n -> isodd(n) ? "Up" : "Dn"; linkdims=4)
end
#+RESULTS:
MPS center bond dim less than requested
Stacktrace:
[1] error(s::String)
@ Base ./error.jl:33
[2] randomizeMPS!(M::MPS, sites::Vector{Index{Vector{Pair{QN, Int64}}}}, linkdim::Int64)
@ ITensors ~/.julia/packages/ITensors/XnM47/src/mps/mps.jl:126
[3] randomMPS(ElType::Type, sites::Vector{Index{Vector{Pair{QN, Int64}}}}, state::Function; linkdims::Int64)
@ ITensors ~/.julia/packages/ITensors/XnM47/src/mps/mps.jl:213
[4] #randomMPS#829
@ ~/.julia/packages/ITensors/XnM47/src/mps/mps.jl:207 [inlined]
[5] top-level scope
@ In[7]:28
[6] eval
@ ./boot.jl:373 [inlined]
[7] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)
@ Base ./loading.jl:1196
Important to this example is that Sb=1/2
sites carry a flux of two times greater than Sf=1/2
sites. If they carry the same flux, then the problem disappears.
This isn't particular to heterogeneous lattices, it can also happen with homogeneous lattices with certain starting states and desired bond dimensions. I think we should just make this a warning instead of an error while we work out a more substantial fix.