Hello.
I am studying the spin-polarized system(J<0 Heisenberg Chain) by iDMRG.
When I calculate two-site correlator, I met error:

terminate called after throwing an instance of 'std::bad_alloc'


The MPS I'd like to contruct is,

psi.A(2) =
/--------------IQTensor--------------
r=3 div=QN(0) log(scale)=0

IQIndex("S=1/2 2",2,Site|143) <Out>
("Up 2",1,Site|4) QN(1)
("Dn 2",1,Site|62) QN(-1)

\------------------------------------


and my code is,

Print(psi.A(2));
Print(prime(dag(psi.A(2))));
Print(psi.A(2) * prime(dag(psi.A(2)), Link)); // <- cause error!


. m>=400 always cause this error, but I checked m=200 goes well.
My server has 512GB RAM.
I think that the large QN due to the spin-polarization and the large maxm might cause this problem.
"to_MPS" function does not resolve this issue.

Can I fix this problem? Should I do something like "reset QN"?

Hello, I solved this problem.
This problem is due to my little knowledge of the efficient MPS contraction.

The Tensor

  psi.A(2) * prime(dag(psi.A(2))


has a very big index dimension, but what I'd like to do is calculate a correlation function.
So I should do:

lcorr *= psi.A(2);


where "lcorr" follows basic notation in the ITensor code formula.

Thank you every one.

commented by (29.7k points)
Thanks very much for posting this answer. I was planning to reply but was a bit puzzled as to how this issue could be occurring without looking much more closely at your code.

We have been planning to add a feature which, when in debug mode, throws an error if any tensor has too many indices, say 10 indices. This feature would help catch bugs of the type you just encountered. So thanks for the reminder that we should definitely add this bug-catching feature!