Dear itensor,
Thank you and your team for developing itensor.
Recently, I have encountered some issues while using itensor. I would like to measure the following operator,
It is a product operator acting on all lattice sites, where the matrix form of the local operator is as follows (the lattice sites I am using are electronic lattice sites):
This operator as a whole does not violate particle number conservation, but each local operator, when acting on a matrix product state, converts empty states and doubly occupied states into each other.
Therefore, if we measure it directly, the following error will be reported:
Trying to set element:
Index: (dim=4|id=689|“n=1,Elec,Site”)
1: 1 QN({“Nf”,0,-1},{“Lz”,0})
2: 1 QN({“Nf”,1,-1},{“Lz”,1})
3: 1 QN({“Nf”,1,-1},{“Lz”,1})
4: 1 QN({“Nf”,2,-1},{“Lz”,2}), Val: 2
Index: (dim=4|id=689|“n=1,Elec,Site”)’
1: 1 QN({“Nf”,0,-1},{“Lz”,0})
2: 1 QN({“Nf”,1,-1},{“Lz”,1})
3: 1 QN({“Nf”,1,-1},{“Lz”,1})
4: 1 QN({“Nf”,2,-1},{“Lz”,2}), Val: 2
Element flux is: QN({“Nf”,0,-1},{“Lz”,0})
ITensor flux is: QN({“Nf”,-2,-1},{“Lz”,-2})
From line 327, file /home/customer/ys/itensor/itensor/itensor_impl.h
In .set, cannot set element with flux different from ITensor flux
In .set, cannot set element with flux different from ITensor flux
The measurement code I am using is as follows:
auto psi2=psi;
for (int j1 = 1; j1 <= N; j1++)
{
auto PHop = op(sites_new, "O", j1);
auto psitem = (PHop * psi2(j1));
psitem.noPrime();
psi2.set(j1, psitem);
}
auto PH = inner(psi2, psi);
the ‘O’ operator in the above code is defined as:
if(opname == "O")
{
Op.set(Em,UDP,-1);
Op.set(Up,UpP,+1);
Op.set(Dn,DnP,+1);
Op.set(UD,EmP,+1);
}
The electronic lattice code I am using is as follows:
auto conserveQNs = args.getBool("ConserveQNs");
auto conserveNf = args.getBool("ConserveNf");
auto conserveLz = args.getBool("ConserveLz");
if(conserveQNs || conserveNf || conserveLz)
{
if(conserveNf && conserveLz)
{
s = Index(QN({"Nf",0,-1}, {"Lz",0}),1,
QN({"Nf",1,-1}, {"Lz",n}),1,
QN({"Nf",1,-1}, {"Lz",n}),1,
QN({"Nf",2,-1}, {"Lz",2*n}),1,Out,ts);
cout<<"s="<<endl;
print(s);
}
else if(conserveNf) // don't conserve Sz
{
s = Index(QN({"Nf",0,-1}),1,
QN({"Nf",1,-1}),1,
QN({"Nf",1,-1}),1,
QN({"Nf",2,-1}),1,Out,ts);
}
}
else
{
s = Index(4,ts);
}
}
Is there any other way for me to measure this physical quantity?
Thank you for your help.