+1 vote
asked by (170 points)

I'm running tDMRG for a small Heisenberg spin-1/2 chain, using exactApplyMPO and normalizing the wave-function after each time step. When I run for 10 or 15 steps it works perfectly, but when I try to run more steps, I get a weird error:

element = (3.12191E-05,-7.29522E-19)
terminate called after throwing an instance of 'itensor::ITError'
what(): tensor is complex valued, use .cplx(...) method

1 Answer

0 votes
answered by (25k points)

Hi, so the reason for this error is that somehow an element of a tensor turned out to be complex even though a subroutine expected a real result. This isn't too surprising since you were doing real-time evolution, so complex numbers were involved. Then some subroutine multiplied (essentially) a complex number by its conjugate giving a real number ideally, but due to some floating point roundoff error gave a tiny imaginary part.

The code that triggered this error checks if the imaginary part is more than 1E-14 times smaller than the real part. Because the real part here was so small that check failed. So I'll put in a separate check that only runs this one if the imaginary part is larger than some reasonable value.

It's hard to get these things to be perfect in every case - thanks for reporting this.

commented by (25k points)
I just pushed a patch to ITensor that ought to prevent this particular error from happening the same way.
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.