I have been running into a few trivial issues with quantum number conservation which I am not sure how to fix by looking at the documentation. Say I have some spin-1 sites sites = siteinds("S=1",N,conserve_sz=true), and I define a wavefunction by e.g. psi = productMPS(sites,["Up" for i=1:N]). A lot of the usual MPS operations, such as expect(psi,"Sz"), orthogonalize!(psi,n), correlation_matrix(psi,"Sz","Sz"), etc, are throwing a method error:
**ERROR:** MethodError: no method matching block(::Index{Vector{Pair{QN, Int64}}}, ::UInt64)
This same error comes up when running DMRG with an initial state with definite flux like the psi defined above (of course using a Hamiltonian that preserves S^z). Does the above error mean that one needs to somehow `strip away’ the QN information when using these functions?
Thanks for the question. All of those functions you mentioned should work perfectly even for that type of MPS (with QN conserving tensors). For example, all of the code pasted below worked for me just now when I tested it.
Are you making some change to your wavefunction before you call those MPS operations on it? What version of ITensors.jl are you using and is it the latest one?
Here is the sample code that worked ok for me:
using ITensors
let
N = 10
sites = siteinds("S=1",N,conserve_sz=true)
psi = productMPS(sites,["Up" for i=1:N])
orthogonalize!(psi,N)
orthogonalize!(psi,1)
@show expect(psi,"Sz")
C = correlation_matrix(psi,"Sz","Sz")
display(C)
return
end
Ah, thank you, it was indeed a version problem. I had been using v0.3.10, back from April. Didn’t realize that things were changing that quickly — thanks!