+1 vote
asked by (280 points)

Hi all,
I have a quick question. How do I store a local operator acting on MPS in Julia version?
In C++, I used the following form :
auto psiy=noPrime(psi(m)*op(sites,"Sy",m));
psi.set(m,psiy) : stores value of local Sy operator in original MPS psi. How do I store it in Julia?

Also, is there any way that I can orthogonalize two or more in MPS and apply two or more local operators simultaneously. I tried "orthogonalize!(psi,j,k)" in Julia but I failed. Is there any way to access this property or modify as it may speed up to find correlation function?

commented by (14.1k points)
edited by
The code would be very similar in the Julia version as what you showed, mostly you would just replace `.position` with `orthogonalize!`. You can see the docs for it here: https://itensor.github.io/ITensors.jl/stable/MPSandMPO.html#ITensors.orthogonalize!

If you have trouble, please reply with a minimal example of what you have tried and we can help with any details.

There is no version of `orthogonalize!` that accepts two site locations in the MPS, it only moves the orthogonality center to a specified site. When you are calculating a correlation function, it is only necessary to move the orthogonality center somewhere between the two sites where the operators are located (i.e. for the correlation function <O_4 O_8>, you can put the orthogonality center on any site 4,5,6,7 or 8). Again, if you are having trouble, please post a minimal example of what you have tried and we can give more guidance.
commented by (280 points)
Hi Matt,
Thank you for you answer. I understand that `orthogonalize!`will give orthogonality center In Julia version.
I don't know how do I use something similar to  "psi.set(m,psiy) ( C++ version)" in Julia version to modify MPS after applying a local operator.
commented by (14.1k points)
Ah, I see. You can just use the notation `psi[m] = psiy`.

1 Answer

0 votes
answered by (70.1k points)

Hi Ajit,
Thanks for the timely question, as this is an important operation to do when working with MPS. As Matt said above, the short answer to your question is that you just do psi[n] = T to set the nth tensor of an MPS to be T.

But for a longer example, I just adapted the code formula for doing this from the C++ version to the new Julia version of ITensor.

Please see the code formula for this here:

And let us know if you have any more questions.

Best regards,

commented by (280 points)
Hi Miles,
Thank you so much, I am new on Julia platform so my questions might be too trivial. Also, I found a way to calculate correlation (e.g. S_{r).S_{r+n}) for arbitrary n  by applying local operator at two different location on psi> and later taking a dot product with original psi>. I guess its not computationally efficient like the one explained in "http://itensor.org/docs.cgi?vers=cppv3&page=formulas/correlator_mps" . I do not know how do I access left or right linking index feature leftLinkIndex(psi,i) in Julia as explained in C++ version.
commented by (70.1k points)
Hi Ajit,
Yes, the function for accessing the link or bond index `i` connecting sites j and j+1 is:

    i = linkind(psi,j)

Right now in the Julia version we don't have a function like `leftLinkIndex` - to get that index you can just do `linkind(psi,j-1)`
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.