3
0
mirror of https://github.com/triqs/dft_tools synced 2025-01-10 21:18:22 +01:00

Beautify check density imag part

This commit is contained in:
Manuel 2019-08-12 16:28:49 -04:00
parent ac1f55f3de
commit 46d9229722

View File

@ -1345,7 +1345,7 @@ class SumkDFT(object):
calc_in_solver_blocks : bool, optional calc_in_solver_blocks : bool, optional
Whether the property shall be diagonalized in the Whether the property shall be diagonalized in the
full sumk structure, or just in the solver structure. full sumk structure, or just in the solver structure.
write_to_blockstructure : bool, optional write_to_blockstructure : bool, optional
Whether the diagonalization matrix shall be written to Whether the diagonalization matrix shall be written to
the BlockStructure directly. the BlockStructure directly.
@ -1359,8 +1359,8 @@ class SumkDFT(object):
""" """
trafo = {} trafo = {}
if prop_to_be_diagonal == 'eal': if prop_to_be_diagonal == 'eal':
prop = self.eff_atomic_levels()[ish] prop = self.eff_atomic_levels()[ish]
elif prop_to_be_diagonal == 'dm': elif prop_to_be_diagonal == 'dm':
@ -1393,7 +1393,7 @@ class SumkDFT(object):
# measure for the 'unity' of the transformation: # measure for the 'unity' of the transformation:
#wsqr = sum(abs(self.w.diagonal())**2) / self.w.diagonal().size #wsqr = sum(abs(self.w.diagonal())**2) / self.w.diagonal().size
#return wsqr #return wsqr
if write_to_blockstructure: if write_to_blockstructure:
if self.block_structure.transformation == None: if self.block_structure.transformation == None:
self.block_structure.transformation = [{} for icrsh in range(self.n_corr_shells)] self.block_structure.transformation = [{} for icrsh in range(self.n_corr_shells)]
@ -1401,11 +1401,11 @@ class SumkDFT(object):
for sp in self.spin_block_names[self.corr_shells[icrsh]['SO']]: for sp in self.spin_block_names[self.corr_shells[icrsh]['SO']]:
self.block_structure.transformation[icrsh][sp] = numpy.eye(self.corr_shells[icrsh]['dim'], dtype=numpy.complex_) self.block_structure.transformation[icrsh][sp] = numpy.eye(self.corr_shells[icrsh]['dim'], dtype=numpy.complex_)
self.block_structure.transformation[ish] = trafo self.block_structure.transformation[ish] = trafo
return trafo return trafo
def density_matrix(self, method='using_gf', beta=40.0): def density_matrix(self, method='using_gf', beta=40.0):
"""Calculate density matrices in one of two ways. """Calculate density matrices in one of two ways.
@ -1884,10 +1884,10 @@ class SumkDFT(object):
# collect data from mpi: # collect data from mpi:
dens = mpi.all_reduce(mpi.world, dens, lambda x, y: x + y) dens = mpi.all_reduce(mpi.world, dens, lambda x, y: x + y)
mpi.barrier() mpi.barrier()
import numpy as np
if np.abs(np.imag(dens)) > 1e-20: if abs(dens.imag) > 1e-20:
mpi.report("Warning: Imaginary part in density will be ignored ({})".format(str(np.abs(np.imag(dens))))) mpi.report("Warning: Imaginary part in density will be ignored ({})".format(str(abs(dens.imag))))
return np.real(dens) return dens.real
def set_mu(self, mu): def set_mu(self, mu):
r""" r"""