+1 vote
asked by (150 points)
edited by

I want to write an IQMPS to disk to a format that I can process further. Namely given usual A-representation of an MPS state which is a family of matrices indexed by site index and local hilbert space index, I want to write the A tensors to disk in the text form. I wanted to figure that out from documentation but I reached self-contradictionary information.

1) Is this simple enough that someone could provide a code snippet?

2) What actually psi.A(sitenumber) for psi being an IQMPS does? Here (http://itensor.org/docs.cgi?page=classes/mps) it is written that it provides a local IQTensor, on the other hand somewhere else I noticed that psi.A(sitenumber) changes orthogonality center of an MPS (just like psi.position). This is suggested here: http://itensor.org/docs.cgi?page=tutorials/MPS

3) is there a way to access a site tensor without modifying it? It seems that psi.A(sitenumber) is not that method.

Mateusz Łącki

1 Answer

0 votes
answered by (70.1k points)

Hi Mateusz,
First of all, to answer your questions 2 and 3, the page tutorials/MPS you reached had some incorrect information on it. I just updated that page to now have the correct information.

So the correct information about psi.A(j) is that it just provides read-only access to the MPS tensor at site j, without modifying that tensor in any way. If you do want to modify the tensor at site j you can call psi.Aref(j). Neither of these changes the MPS gauge. To move the MPS gauge center to some site i call psi.position(i);

Finally, about writing the tensor elements to a text file, there isn't a facility in ITensor right now to do this automatically. But you could write a short code yourself to do this. The main thing to know is that you will need a local copy of the MPS indices to access elements. To get these you can use the linkInd method.

So let's say you want to get the elements of the third MPS tensor psi.A(3). Here is some sample code for doing that:

auto ll = linkInd(psi,2);
auto rl = linkInd(psi,3);
auto s = findtype(psi.A(3),Site);


The code above will give you the 4,2,7 element of the tensor A(3). You can get the sizes of each of the indices ll, rl, and s by calling ll.m(), rl.m() etc. and then looping over all of the values of the tensor and printing them to a file.

Best regards,

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.