# Rotation beween two sites of the lattice, C++

+1 vote

Dear ITensor community,

I would like to ask for help with the following problem:

For a 1D boson-chain psi I would like to consider situation:

1. Let's us define operator
"auto Sy = 0.5/Cplx_i*( sites.op("Adag",i)*sites.op("A",j) - sites.op("Adag",j)*sites.op("A",i))"

2. Let's us define its exponential
"auto expSy = expHermitian(Sy, -Cplx_i*Y);"

I would like to define such an operation:

"psi_i_j:= expSy*psi_i_j",


i.e. rotation between sites {i,j} by angle Y. I know that to extract a single physical index I should use, psi.Aref(i), however, I stuck in the construction of a rotation itself.

Many thanks in advance,
Marcin

answered by (70.1k points)

Hi Marcin,
Thanks for the question.

First of all, when you say you are stuck in the construction of the rotation itself, which part are you stuck on? It seems like you have figured it out perfectly, namely that you can define a Hermitian ITensor (in this case Sy) and then use expHermitian to exponentiate it to construct your rotation operator. So is your question whether the procedure you are doing to make expSy the right one? Or is your question about applying expSy to an MPS?

If your question is about applying expSy to an MPS, then there are two distinct cases:

1. if i and j are nearest-neighbors, such that j = i+1 say, then there is a tutorial about how to apply gates to MPS on neighboring sites here: http://itensor.org/docs.cgi?vers=cppv3&page=formulas/gate
Note that this necessarily involves two MPS tensors so it is not sufficient to just get the i'th MPS tensor (I say this since you mentioned psi.Aref(i)).

2. if i and j are not neighbors, then to apply a gate onto them you just first move one of the sites (say j) through the MPS using a series of "swap" moves in order to apply a gate, then move j back to its original position. There are various ways to do this, but it's much more technical so please let me know first if this is your situation. (Note that in the Julia version of ITensor this is done automatically for you but we don't have that in the C++ version.)

Finally, please note that you don't need to call psi.ref unless it is to modify an MPS tensor. If you are just obtaining the MPS tensor to, say, contract it with some other tensor it's better to write psi(i) and this comes with some extra efficiencies.

Best regards,
Miles

commented by (190 points)
Dear Miles,

Sorry for not being specific. Indeed, I'm considering nearest-neighbours so {j,j+1}. Thanks for the reference - it works!
Best regards,

Marcin
commented by (70.1k points)
Glad to hear it is working!