3
0
mirror of https://github.com/triqs/dft_tools synced 2024-11-18 12:03:50 +01:00

This fix ensures than in the bloch_basis=False mode the complex diagonal components of the Hamiltonian are zero. If this is not checked it can lead to instabilities in the inversion for G_latt, which is a problem for ReFreq Green's functions

This commit is contained in:
phibeck 2021-12-15 17:35:39 -05:00
parent 64bbe9925b
commit a995f114ae

View File

@ -486,6 +486,19 @@ class Wannier90Converter(ConverterTools):
else: else:
# make Fourier transform H(R) -> H(k) : it can be done one spin at a time # make Fourier transform H(R) -> H(k) : it can be done one spin at a time
hamk = self.fourier_ham(hamr_full[isp]) 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 # finally write hamk into hoppings
for ik in range(self.n_k): for ik in range(self.n_k):
hopping[ik, isp] = hamk[ik] - numpy.identity(numpy.max(n_orbitals)) * self.fermi_energy hopping[ik, isp] = hamk[ik] - numpy.identity(numpy.max(n_orbitals)) * self.fermi_energy