# Using Sx, Sy in SpinOne

+2 votes
asked
edited

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!

## 2 Answers

+2 votes
answered by (360 points)

pay attention to the codes:
auto sites = SpinOne(N);
if you use the above codes, it means {"ConserveQNs=",true}.
when you use Sx Sy in the Hamiltonian, Itensor can not work. Because Sx-Sx interaction does not have ConserveQNs algorithm.
You can change the codes like as
auto sites = SpinOne(N,{"ConserveQNs=",false});
but the speed of the program will be much lower.

commented by (220 points)
oh I see, thanks! :)
commented by (55.1k points)
Thank you for contributing a good answer JR
+3 votes
answered by (1.1k points)

Adding on a bit to what JR said, basically, if you want to conserve total Sz, then you need to avoid the use of Sx and Sy operators directly in your code and express everything that requires Sx and Sy in terms of S+ and S-.

I agree that there are situations in which this can feel awkward; I remember asking this same question a while back on the GitHub page for the Julia version of this code.

The reasoning behind this design choice is that S+ and S- have a definite QN flux: an S+/S- operator on a site always increases/decreases the total Sz by 1. In contrast, Sx and Sy don't have this property: an Sx/Sy operator on a site has a component that increase total Sz by 1 and a component that decreases total Sz by 1.

commented by (220 points)
Thanks you so much!
commented by (55.1k points)
Thank you for contributing a good answer Sujay