ITensorInfiniteMPS.jl icon indicating copy to clipboard operation
ITensorInfiniteMPS.jl copied to clipboard

Subtle error message for symmetry broken unitcell

Open ryanlevy opened this issue 1 year ago • 2 comments

[From the forum here ] The following OpSum appears to break the code due to a single Op not being wrapped into a sum

function ITensorInfiniteMPS.unit_cell_terms(::Model"bad")
    opsum = OpSum()
    opsum += 0.5, "Z",1
    opsum += 0.4, "Z",2 # the problem
    opsum += -1, "X",1,"X",2
    return opsum
end

initstate(n) = isodd(n) ? "Up" : "Dn"
s = infsiteinds("S=1/2", N;  conserve_qns = false, initstate)
model = Model("bad")
# Form the Hamiltonian
H = InfiniteSum{MPO}(model, s;)

with the error MethodError: no method matching translatecell(::ITensorInfiniteMPS.var”#_shift_cell#176"{Int64}, ::Scaled{ComplexF64, Prod{Op}}, ::Int64) "

What's happening is that there's only one term in the second "translate" term

 julia> _infinite_terms = ITensorInfiniteMPS.infinite_terms(model)
 sum(
  0.5 Z(1,)
  -1.0 X(1,) X(2,)
)
 0.4 Z(2,)

For this to be a legal unit cell, I'd expect the user to include"X",2,"X",3 (otherwise its a trivial uniform product state I suppose). Not sure if its possible to catch this and write a more helpful message, etc

ryanlevy avatar Apr 26 '24 20:04 ryanlevy

Sorry for the absurdly long delay of response. This package is in a bit of hiatus as I am (and others also) waiting for the rewriting of the core of ITensors before putting back more work into it.

You are correct, of course, the error message should be improved.

LHerviou avatar Sep 24 '24 13:09 LHerviou

@LHerviou regarding how any rewrites going on in core ITensor packages may affect this package, see my comment: https://github.com/ITensor/ITensorInfiniteMPS.jl/issues/87#issuecomment-2371431068.

mtfishman avatar Sep 24 '24 14:09 mtfishman