3
0
mirror of https://github.com/triqs/dft_tools synced 2024-06-25 22:52:20 +02:00

add function to find min and max of band energy, and add warning to set_Sigma if its mesh is smaller than the energy bounds

This commit is contained in:
Jonathan Karp 2020-06-11 18:13:16 -04:00
parent e10ed91e3d
commit 2f0f458eb6

View File

@ -166,6 +166,9 @@ class SumkDFT(object):
if use_dft_blocks:
self.analyse_block_structure()
self.min_band_energy = None
self.max_band_energy = None
################
# hdf5 FUNCTIONS
################
@ -640,6 +643,13 @@ class SumkDFT(object):
else:
gf << Sigma_imp[icrsh][bname]
#warning if real frequency self energy is within the bounds of the band energies
if isinstance(Sigma_imp[0].mesh, MeshReFreq):
if self.min_band_energy is None or self.max_band_energy is None:
self.calculate_min_max_band_energies()
Sigma_mesh = numpy.array([i for i in Sigma_imp[0].mesh.values()])
if Sigma_mesh[0] > (self.min_band_energy - self.chemical_potential) or Sigma_mesh[-1] < (self.max_band_energy - self.chemical_potential):
warn('The given Sigma is on a mesh which does not cover the band energy range. The Sigma MeshReFreq runs from %f to %f, while the band energy (minus the chemical potential) runs from %f to %f'%(Sigma_mesh[0], Sigma_mesh[-1], self.min_band_energy, self.max_band_energy))
def transform_to_sumk_blocks(self, Sigma_imp, Sigma_out=None):
r""" transform Sigma from solver to sumk space
@ -2145,6 +2155,18 @@ class SumkDFT(object):
return res
def calculate_min_max_band_energies(self):
hop = self.hopping
diag_hop = numpy.zeros(hop.shape[:-1])
hop_slice = mpi.slice_array(hop)
diag_hop_slice = mpi.slice_array(diag_hop)
diag_hop_slice[:] = numpy.linalg.eigvalsh(hop_slice)
diag_hop = mpi.all_reduce(mpi.world, diag_hop, lambda x, y: x + y)
min_band_energy = diag_hop.min().real
max_band_energy = diag_hop.max().real
self.min_band_energy = min_band_energy
self.max_band_energy = max_band_energy
return min_band_energy, max_band_energy
################
# FIXME LEAVE UNDOCUMENTED