# To measure total spin angular momentum S^2 on MPS

+1 vote

Hi,

Is there any possibility to measure total S^2 for a large system ?
Since the site operators can only be added with the same indexes, we would do expectations separately and sum over it. However, there are some cross terms which can be long range correlation measurement. Any suggestion for it?
Thank you so much!

Best,
Victor.

+1 vote
answered Sep 9, 2017 by (20,240 points)

Hi Victor,
Interesting question. So yes, you can efficiently measure S^2 for a large system by representing the total S^2 operator as an MPO. (You can use the overlap(psi,S2,psi) function to efficiently compute the expectation value of an MPO S2 with respect to an MPS psi.)

Since this is something I've needed for projects in the past, I am pasting below a function which will generate an MPO for the total S^2 operator using a Hubbard site set to define the Hilbert space of the lattice. If you're doing a different kind of system, like a spin system, you should be able to adapt this code pretty straightforwardly for your case, but let me know if you encounter any problems. The main change you'd need to make is to define the QN objects going into the link/virtual indices to not have the "Nf" quantum number anymore.

The code below makes S2 as an IQMPO, but if you are not using quantum numbers you should be able just to convert the return value to an MPO like this:

MPO S2 = makeS2(sites);

Oh, and if this solves your problem, could I recruit you for a task? This would be a nice function to turn into a "code formula" to go on the ITensor website (http://itensor.org/docs.cgi?page=formulas). Could you do a brief writeup of it (see the source for the other code formulas here:
https://github.com/ITensor/website/tree/master/docs/formulas
Of course you don't have to if you're too busy. Just an idea & I'll put your name on the contributors page with a badge.

Ok here is the function:

IQMPO
makeS2(Hubbard const& sites)
{
auto N = sites.N();

auto S2 = IQMPO(sites);

for(auto n : range(N+1))
{
Index("0",3),QN("Nf=",0,"Sz=",0),
Index("+",1),QN("Nf=",0,"Sz=",-2),
Index("-",1),QN("Nf=",0,"Sz=",+2));
}

for(auto n : range1(N))
{
auto& W = S2.Aref(n);
W = IQTensor(row,col,dag(sites(n)),prime(sites(n)));

W += sites.op("Id",n) * row(1) * col(1);
W += sites.op("Id",n) * row(2) * col(2);

W += sites.op("S2",n) * row(2) * col(1);

W += 2*sites.op("Sz",n) * row(2) * col(3);
W += sites.op("Id",n) * row(3) * col(3);
W += sites.op("Sz",n) * row(3) * col(1);

W += sites.op("S+",n) * row(2) * col(4);
W += sites.op("Id",n) * row(4) * col(4);
W += sites.op("S-",n) * row(4) * col(1);

W += sites.op("S-",n) * row(2) * col(5);
W += sites.op("Id",n) * row(5) * col(5);
W += sites.op("S+",n) * row(5) * col(1);

W.scaleTo(1.);
}

return S2;
}

commented Sep 10, 2017 by (400 points)
Hi , Miles.
Thanks for your quick reply. I will try to figure it out. Yeah, I am willing to contribute.
Thank you so much!
commented Sep 13, 2017 by (400 points)
Hi, Miles.
Since I'm doing spin half and spin one systems. Is it too naive to get what I need by deleting all "Nf=",0 and changing Hubbard const& sites to SiteSet const& sites ?
commented Sep 15, 2017 by (400 points)
Hi, Miles.
I checked with my spin one and spin half small systems. It's correct.
commented Sep 17, 2017 by (20,240 points)
Hi Victor, I meant to write back to say yes just removing "Nf=",0 and changing the argument to a general SiteSet ought to do the trick. So I'm glad to hear it worked.

I may try to upgrade the QN system a bit (backwards compatible) to make it work more broadly across different system types. Currently if you had left in the "Nf=",0 it would have caused a runtime bug. Right now the QN class design is a trade off between convenience/robustness and speed.