# Specific Questions about Constructing MPOs by hand in iDMRG

Hi Miles,

I have been recently trying doing some iDMRG simulations (C++v3). It is super nice of you to give sample codes in https://github.com/ITensor/iDMRG. And for others who might be interested, here is a great brief introduction to the algorithm - http://itensor.org/docs.cgi?page=tutorials/iDMRG&vers=cppv2.

But since I don't find any documentations about the implementation of the codes, it is a bit hard for me to modify based on that. And I think you might be I have some naive technical questions regarding how to construct a general Hamiltonian (to be specific, biquadratic Heisenberg model for my purpose).

$$H=\sum_{}\alpha s_i\cdot s_j+\beta(s_i\cdot s_j)^2$$

In the Heisenberg.h,

Question 1
How is the size for each QN block being decided? (3, 1, 1) in the following code.

        auto ts = format("Link,l=%d",l);
links.at(l) = Index(QN({"Sz", 0}),3,
QN({"Sz",-2}),1,
QN({"Sz",+2}),1,
Out,
ts);


Question 2

I guess the following codes are the ones that deal with the construction of Heisenberg MPO. But could you explain how these columns and rows correspond to the MPO of the Heisenberg MPO? And in general, how do you specify the row and column indices?

        W = ITensor(dag(sites_(n)),prime(sites_(n)),row,col);

W += sites_.op("Id",n) * setElt(row(1)) * setElt(col(1)); //ending state
W += sites_.op("Id",n) * setElt(row(2)) * setElt(col(2)); //starting state

W += sites_.op("Sz",n) * setElt(row(3)) * setElt(col(1));
W += sites_.op("Sz",n) * setElt(row(2)) * setElt(col(3)) * Jz_;

W += sites_.op("Sm",n) * setElt(row(4)) * setElt(col(1));
W += sites_.op("Sp",n) * setElt(row(2)) * setElt(col(4)) * J_/2;

W += sites_.op("Sp",n) * setElt(row(5)) * setElt(col(1));
W += sites_.op("Sm",n) * setElt(row(2)) * setElt(col(5)) * J_/2;


Thank you very much!

Best,
Yi

commented by (400 points)
Hi,

Thats very helpful. Actually, I have figured out the problem after checking some previous answers and McCulloch's paper https://arxiv.org/pdf/0804.2509.pdf. Although I still need to figure out the details of the iDMRG algorithms, I am now able to construct the mpo and do some calculation for now. Sorry for asking such a naive question.

Thanks a lot.

Best,
Yi

answered by (70.1k points)