Skip to content

Commit

Permalink
Merge pull request TRIQS#199 from phibeck/w90
Browse files Browse the repository at this point in the history
Make sure Wannier90 Hamiltonian is Hermitian (remove diagonal complex entries)
  • Loading branch information
the-hampel authored Dec 16, 2021
2 parents 64bbe99 + a995f11 commit cd1672c
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions python/triqs_dft_tools/converters/wannier90.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,19 @@ def convert_dft_input(self):
else:
# make Fourier transform H(R) -> H(k) : it can be done one spin at a time
hamk = self.fourier_ham(hamr_full[isp])

# Sanity check if imaginary diagonal elements are zero, otherwise instabilties in lattice Gf!
diag_iterator = range(0,dim_corr_shells)
for ik in range(self.n_k):
if not numpy.allclose(hamk[ik][diag_iterator, diag_iterator].imag, 0, atol=1e-10):
mpi.report('ERROR: Wannier Hamiltonian has complex diagonal entries. '
+ f'First occurred at kpt {ik}:')
with numpy.printoptions(formatter={'float': '{:+.10f}'.format}):
mpi.report('\nWannier Hamiltonian diagonal, Fourier(H(r)), imaginary')
mpi.report(hamk[ik][diag_iterator, diag_iterator].imag)
mpi.MPI.COMM_WORLD.Abort(1)
# set imaginary part to zero
hamk[ik][diag_iterator, diag_iterator] = hamk[ik][diag_iterator, diag_iterator].real + 0*1j
# finally write hamk into hoppings
for ik in range(self.n_k):
hopping[ik, isp] = hamk[ik] - numpy.identity(numpy.max(n_orbitals)) * self.fermi_energy
Expand Down

0 comments on commit cd1672c

Please sign in to comment.