TRIQS / triqs

a Toolbox for Research on Interacting Quantum Systems
https://triqs.github.io
GNU General Public License v3.0
135 stars 71 forks source link

AtomDiag passes complex operator to AtomDiagReal if numerically real #918

Closed thenoursehorse closed 10 months ago

thenoursehorse commented 11 months ago

Expected behavior: If the Hamiltonian passes the check that it is real, it should pass a real operator to AtomDiagReal.

Actual behavior: The Hamiltonian passes the check that it is real, and passes a complex operator to AtomDiagReal.

Sometimes I construct operators from a complex Hamiltonian that has zero imaginary values at the start of a self-consistent loop, but will become nonzero later in the cycle. It is not hard to check myself and pass the correct object, but fixing it may be beneficial others.

Below is code that reproduces the error

from triqs.atom_diag import AtomDiag
from triqs.operators import n

h = (1 + 0*1j) * n('up', 0) * n('dn', 0)
fops = [('up', 0), ('dn', 0)]
AtomDiag(h, fops)

Version

TRIQS library version 3.2.0 git hash 90c8f8c257be434bc4560f4bbc518905c4d226ea

Wentzell commented 10 months ago

Fixed by https://github.com/TRIQS/triqs/pull/919