# Products of 2-site and 4-site wavefunctions

Follow up on this question: https://itensor.org/support/1920/valence-bond-states-fast-implementation

Now my purpose instead of having 2-site products of singlets is to create 2-site products of states that are of the form (|uiuj>)x(|ukul>), etc.

For singlets, I did this:

for(int n = 1; n <= N; n += 2)
{

auto s1 = sites(n);
auto s2 = sites(n+1);
auto wf = ITensor(s1,s2);
wf.set(s1(1),s2(2), ISqrt2);
wf.set(s1(2),s2(1), -ISqrt2);

ITensor D;
psi.ref(n) = ITensor(s1);
psi.ref(n+1) = ITensor(s2);
svd(wf,psi.ref(n),D,psi.ref(n+1));
psi.ref(n) *= D;
}


So I thought that this should be easy and it should be:

wf.set(s1(1),s2(1), 1);


Unfortunately, when I compute its expectation value with the H that I have (it doesn't really matter which one it is), I do not get the same result as when I construct an all up state explicitly.

Any idea about what I might be doing wrong?

In addition to that, I would also like to construct products of tetramers. The example of a tetramer on sites 1,2,3,4 is here:$\frac{1}{\sqrt{12}}(|{\uparrow_1\uparrow_2\downarrow_3\downarrow_4}>-|{\uparrow_1\downarrow_2\uparrow_3\downarrow_4}>-2|{\uparrow_1\downarrow_2\downarrow_3\uparrow_4}>-2|{\downarrow_1\uparrow_2\uparrow_3\downarrow_4}>-|{\downarrow_1\uparrow_2\downarrow_3\uparrow_4}>+|{\downarrow_1\downarrow_2\uparrow_3\uparrow_4}>)$

I tried:

for(int n = 1; n <= N; n += 4)
{

auto s1 = sites(n);
auto s2 = sites(n+1);
auto s3 = sites(n+2);
auto s4 = sites(n+3);

auto wf = ITensor(s1,s2,s3,s4);
wf.set(s1(1),s2(1),s3(2),s4(2), sqrt(12));
wf.set(s1(1),s2(2),s3(1),s4(2), -sqrt(12));
wf.set(s1(1),s2(2),s3(2),s4(1), 2*-sqrt(12));
wf.set(s1(2),s2(1),s3(1),s4(2), 2*-sqrt(12));
wf.set(s1(2),s2(1),s3(2),s4(1), -sqrt(12));
wf.set(s1(2),s2(2),s3(1),s4(1), sqrt(12));

ITensor D;
psi.ref(n) = ITensor(s1);
psi.ref(n+1) = ITensor(s2);
svd(wf,psi.ref(n),D,psi.ref(n+1));
psi.ref(n) *= D;

ITensor D2;
psi.ref(n+2) = ITensor(s3);
psi.ref(n+3) = ITensor(s4);
svd(wf,psi.ref(n+2),D2,psi.ref(n+3));
psi.ref(n) *= D2;

}


but I am getting a findInds error (and I am not really sure that I am doing the SVD right anyway...)

Any thoughts on that?

Thank you very much,
Thanos

+1 vote
selected by

Hi, regarding the two parts of your question, let me answer them in reverse order:

(2) for the second part of your question, regarding tetramers, the main issue with the code you tried is that you are making tensors with 4 indices (which is fine) but then just splitting them into two pieces using the SVD (two, not counting the singular values, which you could multiply into either U or V). To end up with a proper MPS that you can use, each MPS tensor has to carry only one site index. But the code you wrote would result in some tensors of psi carrying three site indices, while others carry just one.

What I'd recommend is that you draw out, using tensor diagrams, what each part of the tetramer code above is doing and I think you'll see what I mean.

The solution to making tetramers is to keep going past the code you wrote by iterating the SVD step. Take the singular values "D" and multiply them into "V" (which you have stored into psi.ref(n+1). Next call the svd function on D*V, splitting off the second site index of that tetramer. Then finally split the third and fourth site indices apart with one more SVD. Throughout this process, you can use the ITensor function "commonindex" to get the newly created "Link" indices made by previous calls to svd, which you will need to pass as the "row" indices to the SVD function (using our new SVD interface, which would be better for this purpose).

(1) regarding setting a wavefunction all up, the answer is sort of similar to making dimers. The code you showed does, I think, make tensors which carry two site indices, whereas an MPS has to have tensors carrying only one site index each. Again, please diagram out what your code is doing and you should see where it's going wrong, in terms of resulting in a set of tensors you are putting into "psi" which do not have a proper MPS structure.

Hope that helps -

Miles

commented by (390 points)
Regarding the first part, I had a bug somewhere else in the code (very unfortunate) and regarding the second part I understood what you meant and I finally coded it.