+1 vote
asked by (390 points)


from what I understand in version 3.1 QN conservation is demanded at the level of the declaration of sites, as:

auto sites = SpinHalf(2*N,{"ConserveQNs=",true});

Is there a way to makes the indices conserve Sz (for example) quantum numbers in the ancilla purification method to construct thermal states?

Assuming obviously the Hamiltonian conserve QN as

auto ampo = AutoMPO(sites);
for(auto j : range1(N-1))
auto s1 = 2j-1,
s2 = 2
ampo += 0.5,"S+",s1,"S-",s2;
ampo += 0.5,"S-",s1,"S+",s2;
ampo += "Sz",s1,"Sz",s2;

auto H = toMPO(ampo);

what would be the choice of the initial infinite temperature state with the correct QN to be evolved in imaginary time with H?
All my attempts lead to "Mismatched QN Index arrows" error.

Thanks a lot!


commented by (14.1k points)
Hi Jacopo,

Could you please include a minimal example of what you have tried? Then we can help you figure out where it is going wrong.

commented by (390 points)
Dear Matt,

the most obvious choice is the initial state which is a product of singlets

auto psi = MPS(sites);
    for(int n = 1; n <= 2*N; n += 2)
        auto s1 = sites(n);
        auto s2 = sites(n+1);
        auto wf = ITensor(s1,s2);
        wf.set(s1(1),s2(2), ISqrt2);
        wf.set(s1(2),s2(1), -ISqrt2);
        ITensor D;
        psi.ref(n) = ITensor(s1);
        psi.ref(n+1) = ITensor(s2);
        psi.ref(n) *= D;

and then I evolve with applyMPO toExpH on psi. This gives me the error but I suspect that the initial state has indeed a problem in QN ... (I am learning to use version 3)

commented by (70.1k points)
Hi Jacopo, I agree with Matt that more info is helpful here. We may have to see the rest of your code to guess where the arrow error is arising.

Your question about QN's and which initial state is a good one, but the answer is the state you are already making, which is one where the ancilla state, thought of as a pure-state wavefunciton on 2N sites, has a total QN of zero (since it's a product state of singlets).

However, this question is a bit orthogonal to issues related to arrows. From what I can see of your code, you set up the Index arrows correctly (all site arrows going Out, and the svd should handle the bond-dimension arrows correctly) so it doesn't appear you are doing anything wrong so far. So the only issues I can see remaining are e.g. if the MPO is somehow being produced incorrectly or if additional dimension-1 bond/link indices are needed between the singlets as well as within the singlets. (Usually our MPS/MPO codes are tolerant of missing bond indices but sometimes they can be picky about this, depending on the algorithm used or version of the code.)

commented by (390 points)
Dear Miles and Matt,

I just checked that taking your code, ancilla.cc, in the subfolder tutorial/finiteT in ITensor-3.1.1 and changing sites to conserved QN sites, namely writing auto sites = SpinHalf(2*N,{"ConserveQNs=",true}), then it gives the same error during runtime, which appears at the level of psi = applyMPO(expH,psi,args).

commented by (70.1k points)
Thanks, that gives us a code to test -
commented by (70.1k points)
Hi ok, so I found the error. It's actually not related to QNs, but was just caught in the QN version of the code because it does stricter checking of Index arrows. I'll post a more detail explanation below.

1 Answer

0 votes
answered by (70.1k points)

Hi, so the issue you encountered is actually not to do with QNs per se, but rather to do with a change in behavior of MPO functions in ITensor v3 (versus version 2).

The change in behavior is that functions such as applyMPO no longer automatically "un prime" site indices. So when acting with an MPO of the kind produced by AutoMPO which has sites s1,s2,s3... and sites s1', s2', s3',...onto an MPS, the resulting MPS psi will have primed site indices. It's necessary to call psi.noPrime(); afterward to remove the primes.

The ancilla.cc tutorial code you used wasn't properly upgraded to version 3, but I'll upgrade it right now. Unfortunately it was still appearing to run correctly without QN conservation because when there are no QNs, the code doesn't check Index arrows (even though it could) so certain incorrect algorithms sometimes slip through the automatic error checking.

In your own code, please add a line:
after the call to applyMPO, and I'll do the same in that tutorial code.

Thanks for pointing this out -


commented by (390 points)
Ah, I read about this change but then I forgot.  Thanks again!
commented by (70.1k points)
No problem; it was definitely confusing that (a) we didn't update that code and (b) it appeared to run correctly  without QNs turned on!
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.