Hi all,
I'm new to Itensor so forgive me for asking this trivial question.. I'm currently working on a Heisenberg type Hamiltonian and I wish to calculate its ground state and local expectation value thereafter. (in Itensor V3)
FIrst, I'm having trouble with Sx Sx and Sy Sy terms in autoMPO.
auto sites = SpinOne(N)
auto ampo = AutoMPO(sites);
for (int i=1; i<N; ++i){
ampo += exc,"Sx",i,"Sx",i+1;
ampo += exc,"Sy",i,"Sy",i+1;
ampo += exc,"Sz",i,"Sz",i+1;
}
auto H = toMPO(ampo);
This lead to the runtime error: "In .set, cannot set element with flux different from ITensor flux".
Later I found this can be fixed by changing Sx, Sy to S+, S-:
ampo += 0.5*exc,"S+",i,"S-",i+1;
ampo += 0.5*exc,"S-",i,"S+",i+1;
ampo += exc,"Sz",i,"Sz",i+1;
which runs without error. I'm confused why this is happening, since I tried the former expression in Itensor v2 which worked out fine.
My second question is in the calculation of observables by the following code:
psi.position(j);
ITensor ket = psi.A(j);
ITensor bra = dag(prime(ket,"Site"));
// Sx must be converted to an ITensor prior to usage
ITensor Lxjop = sites.op("Sx",j);
ITensor Lyjop = sites.op("Sy",j);
ITensor Lzjop = sites.op("Sz",j);
// take an inner product
auto Lxj = (bra*Lxjop*ket).cplx();
auto Lyj = (bra*Lyjop*ket).cplx();
auto Lzj = (bra*Lzjop*ket).cplx();
This again gives the error: "In .set, cannot set element with flux different from ITensor flux". As I expected the problem is in the using of Sx and Sy, which, if commented out, will let the code run without error.
Can you plz help me understand what is the crux here, what is the "ITensor flux", or should I instead calculate expectation of Sx+iSy, which, however, looks pretty unatural.. Thank you!