randomMPS method can not be used with Zn symmetry (Julia)

+1 vote

I have created a new Z3 sitetype using

const Z3Site = TagType"Z3"
function siteinds(::Z3Site, Num::Int;kwargs...)
conserve_qns = get(kwargs,:conserve_qns,false)
if conserve_qns
s = [ QN(("P", n, 3)) => 1 for n = 0:2]
return [Index(s;tags="Site,Z3,n=$n") for n=1:Num] end return [Index(N,"Site,Z3,n=$n") for n=1:Num]
end
function state(::Z3Site,
st::AbstractString)
if st == "s1"
return 1
elseif st == "s2"
return 2
elseif st == "s3"
return 3
end


when I use these site type to initialize a random mps with

sites=siteinds("Z3",N,conserve_qns=true)
state = ["s1" for n in 1:N]
randomMPS(sites,state,10)


It throws the error that

"Indices must have the same spaces to be replaced"

This error can be reproduced using the following minimal code

sites = siteinds("Z3",N,conserve_qns=true);
s1 = sites[1];
s2 = sites[2];
M = randomITensor(QN(),s1',s2',dag(s1),dag(s2));
U,S,V = svd(M,(s1',s2'));
replaceind!(U,ind(S,1),ind(S,2))


because

space(ind(S,2))!=space(ind(S,1))


However, when I print the space of the two index space, it seems that they are the same when module 3

space(ind(S,2))
3-element Array{Pair{QN,Int64},1}:
QN("P",-2,3) => 3
QN("P",-1,3) => 3
QN("P",0,3) => 3

space(ind(S,1))
3-element Array{Pair{QN,Int64},1}:
QN("P",1,3) => 3
QN("P",2,3) => 3
QN("P",0,3) => 3


Is there something wrong when I define the Z3 sitetype?

Thank you very much for the answer!

commented by (44k points)
Hi Runze,
Thanks for reporting this issue and for the detailed explanation and minimal code which is very helpful. I've filed an issue on our issue tracker and can reproduce the bug. I have  a suspicion it has to do with some faulty code related to our QN objects when they are defined mod 3. I'll look into and hope to fix it really soon.

Miles

Hi Runze,
This issue should now be fixed as of version 0.1.10. So please do "update ITensors" in the package manager and try your first, randomMPS code again. Please let me know if it still doesn't work.

The issue I found was that a constructor which gets called when making QNs with modulus values other than 1 had a missing return keyword, which made it silently set the wrong QN value. So that was causing the error but now it's fixed.

Thanks again for bringing this to our attention -

Miles

commented by (150 points)
Thank you very much, this problem is fixed and give the correct result ！
However, there is another problem when I try to save the mps using the HDF5. The "write" function seems to not support MPS with QN, is there some alternative method？
commented by (44k points)
Hi Runze,