+1 vote
asked by (150 points)

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 (70.1k 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

1 Answer

0 votes
answered by (70.1k points)

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 (70.1k points)
Hi Runze,
Glad it works!

Thanks for asking but unfortunately we haven't added that feature yet. We plan to add it soon -

Miles
commented by (150 points)
Thank you again,I  will wait for it
commented by (70.1k points)
Hi Runze,
The latest version of Julia ITensor now supports writing ITensors, MPS, and MPO which have conserved QNs to HDF5 files. So please upgrade to that version and it should now work -

Miles
commented by (150 points)
That's great! I will give it a try!
Welcome to ITensor Support Q&A, where you can ask questions and receive answers from other members of the community.

Formatting Tips:
  • To format code, indent by four spaces
  • To format inline LaTeX, surround it by @@ on both sides
  • To format LaTeX on its own line, surround it by $$ above and below
  • For LaTeX, it may be necessary to backslash-escape underscore characters to obtain proper formatting. So for example writing \sum\_i to represent a sum over i.
If you cannot register due to firewall issues (e.g. you cannot see the capcha box) please email Miles Stoudenmire to ask for an account.

To report ITensor bugs, please use the issue tracker.

Categories

...