Hello Everyone!
I am working on a next-neighbor tJ model system and was trying to calculate the total density of the system. I was now trying to vary the hole doping or assign number electrons but I am not entirely sure how that can be done. I am pretty new to itensor. What I am trying to do here might be very simple, but due to my very minimal knowledge of itensor, I am not able to figure it out.
Here is my code:
#include “itensor/all.h”
using namespace itensor;
int main()
{
int Lx = 12;
int Ly = 4;
auto L = Lx*Ly;
double t = 1.0;
double Jz = 1.0;
auto yperiodic = false;
auto sites = tJ(L);
auto ampo = AutoMPO(sites);
auto lattice = squareLattice(Lx,Ly,{"YPeriodic=",yperiodic});
for(auto bnd : lattice)
{
ampo += -t,"Cdagup",bnd.s1,"Cup",bnd.s2;
ampo += -t,"Cdagup",bnd.s2,"Cup",bnd.s1;
ampo += -t,"Cdagdn",bnd.s1,"Cdn",bnd.s2;
ampo += -t,"Cdagdn",bnd.s2,"Cdn",bnd.s1;
ampo += Jz,"Sz",bnd.s1,"Sz",bnd.s2;
ampo += 0.5*Jz,"S+",bnd.s1,"S-",bnd.s2;
ampo += 0.5*Jz,"S-",bnd.s1,"S+",bnd.s2;
ampo +=-0.25*Jz,"Ntot",bnd.s1,"Ntot",bnd.s2;
}
auto H = toMPO(ampo);
auto state = InitState(sites);
for(int j = 1; j <= L; ++j)
{
if(j%4==1) state.set(j,"Up");
else if(j%4==2) state.set(j,"Dn");
else state.set(j,"Emp");
}
auto psi0 = MPS(state);
auto sweeps = Sweeps(20);
sweeps.noise() = 1E-6,1E-6,1E-8,1E-10,1E-12;
sweeps.maxdim() = 20,50,100,200;
sweeps.cutoff() = 1E-14;
auto [energy,psi] = dmrg(H,psi0,sweeps,"Quiet");
Vector upd(L),dnd(L);
for(int j = 1; j <= L; ++j)
{
psi.position(j);
upd(j-1) = elt(dag(prime(psi(j),"Site"))*op(sites,"Nup",j)*psi(j));
dnd(j-1) = elt(dag(prime(psi(j),"Site"))*op(sites,"Ndn",j)*psi(j));
}
println("Up Density:");
for(int j = 0; j < L; ++j)
printfln("%d %.10f",1+j,upd(j));
println();
println("Down Density:");
for(int j = 0; j < L; ++j)
printfln("%d %.10f",1+j,dnd(j));
println();
println("Total Density:");
for(int j = 0; j < L; ++j)
printfln("%d %.10f",1+j,(upd(j)+dnd(j)));
println();
printfln("Ground State Energy = %.10f",energy);
return 0;
}