Dear ITensor,

I follow tutorial in order to calculate imaginary time correlation function such as <S^{z}*{1}(L/2)S^{z}*{1}>. here is my naive code. it can run but I get wrong answer (compare my QMC datas). so please help me check my naive code, Thanks!!!

int main()

{

ofstream outfile;

outfile.open("cor_t.dat",ios::app);

int length[7]={12,16,24,32,48,64,80};

for(int &N : length)

{

auto sites = SpinHalf(N);

auto state = InitState(sites);

for(int i = 1; i <= N; ++i)

{

//Neel state

state.set(i,i%2==1 ? "Up" : "Dn");

}

auto psi0 = MPS(state);

auto psi = MPS(state);

auto ampo = AutoMPO(sites);

//Make the Heisenberg Hamiltonian

for(int b = 1; b < N; ++b)

{

ampo += 0.5,"S+",b,"S-",b+1;

ampo += 0.5,"S-",b,"S+",b+1;

ampo += "Sz",b,"Sz",b+1;

}

auto H = MPO(ampo);

auto sweeps = Sweeps(30);

sweeps.maxm() = 100,200,800,800,1000;

sweeps.cutoff() = 1E-10;

sweeps.niter() = 2;

sweeps.noise() = 1E-7,1E-8,1E-9;

println(sweeps);

//

// Begin the DMRG calculation

//

auto energy = dmrg(psi,H,sweeps,"Quiet");

//

auto Sz_1=sites.op("Sz",1);

auto tau =0.1;

auto expHL0 = toExpH(ampo,tau);

auto expHR0 = toExpH(ampo,-tau);

auto args = Args("Cutoff=",1E-9,"Maxm=",3000);

auto ttotal = N/4;

auto nt = int(ttotal/tau+(1e-9*(ttotal/tau)));

// left part <tau(t)|S^{z}

for(int n = 1; n <= nt; ++n)

{

psi = exactApplyMPO(expHL0,psi,args);

normalize(psi);

}

auto newpsi= Sz_1*psi.A(1);

newpsi.noprime();

psi.setA(1,newpsi);

// Right part exp(-H\tau)*S^{z}|g.s>

auto newpsi0 = Sz_1*psi0.A(1);

newpsi0.noprime();

psi0.setA(1,newpsi0);

for(int n = 1; n <= nt; ++n)

{

psi0 = exactApplyMPO(expHR0,psi0,args);

normalize(psi0);

}

//Print(psi0);

auto result=overlapC(psi,psi0).real();

//Print(result);

outfile <<N<<" "<<abs(result)<< endl;

}

outfile.close();

return 0;

}