+2 votes
asked by (180 points)
edited by

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 (320 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 (180 points)
oh I see, thanks! :)
commented by (46.8k points)
Thank you for contributing a good answer JR
+3 votes
answered by (850 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 (180 points)
Thanks you so much!
commented by (46.8k points)
Thank you for contributing a good answer Sujay
Welcome to ITensor Support Q&A, where you can ask questions and receive answers from other members of the community.

Formatting Tips:
  • To format code, indent by four spaces
  • To format inline LaTeX, surround it by @@ on both sides
  • To format LaTeX on its own line, surround it by $$ above and below
  • For LaTeX, it may be necessary to backslash-escape underscore characters to obtain proper formatting. So for example writing \sum\_i to represent a sum over i.
If you cannot register due to firewall issues (e.g. you cannot see the capcha box) please email Miles Stoudenmire to ask for an account.

To report ITensor bugs, please use the issue tracker.

Categories

...