Trotter gates for ancilla/purification method

Hello,

I am trying to construct a finite temperature 1/beta MPS state using the ancilla/purification method, namely in a chain of 2 N spin half, then build the initial state as the identity matrix

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.Aref(n) = ITensor(s1);
psi.Aref(n+1) = ITensor(s2);
svd(wf,psi.Aref(n),D,psi.Aref(n+1));
psi.Aref(n) *= D;
}

and now apply exp[- beta/2 H] X 1 on psi. I want to time evolve with Trotter gates that only apply on the physical legs of the MPS. So I have built the gates

for(int b = 1; b <= N-1; ++b)
{
auto s1 = 2b+1,
s2 = 2
b-1;

    auto hterm = sites.op("Sz",s1)*sites.op("Sz",s2);
hterm += 0.5*sites.op("S+",s1)*sites.op("S-",s2);
hterm += 0.5*sites.op("S-",s1)*sites.op("S+",s2);

auto g = Gate(sites,s1,s2,Gate::tImag,tau/2.,hterm);
gatesPhys.push_back(g);
}


and with the reverse direction, but when I run

gateTEvol(gatesPhys,ttotal,tau,psi,{"Cutoff=",cutoff,"Verbose=",true});

I obtain the error

From line 84, file itdata/combiner.cc

No contracted indices in combiner-tensor product

No contracted indices in combiner-tensor product
Abort trap: 6

What am I doing wrong?

Thanks so much!

Jacopo.

Hi Jacopo,
Thanks for the question. So the problem here is on us, namely that we had not yet documented the gateTEvol method despite publicizing it. The key thing you are missing is that gateTEvol requires each of the gates passed to it to act only on consecutive (nearest-neighbor) site pairs.

I just started documenting it so people will know this in the future:
http://itensor.org/docs.cgi?vers=cppv2&page=classes/tevol

In order to do the ancilla technique with Trotter gates (which is a very good way to do it), you will need to insert "swap gates" into your gate list. You can use the "Gate = BondGate" class to make swap gates like this:

auto swapij = Gate(sites,i,j);


In the upcoming version 3 of ITensor we're going to make a more intuitive interface for making gates. (Probably just separate functions such as swapGate, realGate, imagGate etc.)

Best regards,
Miles