Dear Miles,
thank you very much for your prompt response. I chose C++ because I had some experience with this language. Apart from that I wrongly assumed that the Julia version of ITensor has the same functionality as the C++ version. Knowing now that the Julia version has the function that I need to time evolve an MPO, I will consider changing to Julia in the future.
Meanwhile I chose the last option that you mentioned above and wrote a function based on gateTEvol. Preliminary tests of this code seem to suggest that it works well. I include this code below. The main modifications concern (as suspected) the ITensor AA.
Walter
============================================================
void gateTEvolMPO(std::vector<BondGate> const& gatelist,
Real ttotal,
Real tstep,
MPO & rho,
Args args)
{
const bool verbose = args.getBool("Verbose",false);
const int nt = int(ttotal/tstep+(1e-9*(ttotal/tstep)));
if(fabs(nt*tstep-ttotal) > 1E-9)
{
Error("Timestep not commensurate with total time");
}
if(verbose)
{
printfln("Taking %d steps of timestep %.5f, total time %.5f",nt,tstep,ttotal);
}
rho.position(gatelist.front().i1());
Real tsofar = 0;
int i1, i2, ni1, ni2;
ITensor AA;
for(auto tt : range1(nt))
{
auto g = gatelist.begin();
while(g != gatelist.end())
{
i1 = g->i1();
i2 = g->i2();
AA = rho(i1)*rho(i2)*prime(g->gate());
AA *= swapTags(conj(g->gate()),"Site,1","Site,0");
AA.replaceTags("Site,1","Site,0");
AA.replaceTags("Site,2","Site,1");
++g;
if(g != gatelist.end())
{
//Look ahead to next gate position
ni1 = g->i1();
ni2 = g->i2();
//SVD AA to restore MPO form
//before applying current gate
if(ni1 >= i2)
{
rho.svdBond(i1,AA,Fromleft,args);
rho.position(ni1); //does no work if position already ni1
}
else
{
rho.svdBond(i1,AA,Fromright,args);
rho.position(ni2); //does no work if position already ni2
}
}
else
{
//No next gate to analyze, just restore MPO form
rho.svdBond(i1,AA,Fromright,args);
}
}
tsofar += tstep;
args.add("TimeStepNum",tt);
args.add("Time",tsofar);
args.add("TotalTime",ttotal);
}
if(verbose)
{
printfln("\nTotal time evolved = %.5f\n",tsofar);
}
} // gateTEvolMPO