mirror of
https://github.com/triqs/dft_tools
synced 2025-04-26 02:04:59 +02:00
Rewrite calculate_diagonalization_matrix
This commit is contained in:
parent
46d9229722
commit
796e05ea64
@ -90,7 +90,7 @@ class BlockStructure(object):
|
|||||||
inequivalent correlated shell is given
|
inequivalent correlated shell is given
|
||||||
transformation : list of numpy.array or list of dict
|
transformation : list of numpy.array or list of dict
|
||||||
a list with entries for each ``ish`` giving transformation matrices
|
a list with entries for each ``ish`` giving transformation matrices
|
||||||
that are used on the Green's function in ``sumk`` space when before
|
that are used on the Green's function in ``sumk`` space before
|
||||||
converting to the ``solver`` space
|
converting to the ``solver`` space
|
||||||
Up to the change in block structure,
|
Up to the change in block structure,
|
||||||
|
|
||||||
|
@ -1330,7 +1330,7 @@ class SumkDFT(object):
|
|||||||
# a block was found, break out of the loop
|
# a block was found, break out of the loop
|
||||||
break
|
break
|
||||||
|
|
||||||
def calculate_diagonalization_matrix(self, prop_to_be_diagonal='eal', calc_in_solver_blocks=False, write_to_blockstructure = True, ish=0):
|
def calculate_diagonalization_matrix(self, prop_to_be_diagonal='eal', calc_in_solver_blocks=False, write_to_blockstructure = True, shells=None):
|
||||||
"""
|
"""
|
||||||
Calculates the diagonalisation matrix, and (optionally) stores it in the BlockStructure.
|
Calculates the diagonalisation matrix, and (optionally) stores it in the BlockStructure.
|
||||||
|
|
||||||
@ -1349,62 +1349,57 @@ class SumkDFT(object):
|
|||||||
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.
|
||||||
ish : int, optional
|
shells : list of int, optional
|
||||||
Number of the correlated shell to be diagonalized.
|
Indices of correlated shells to be diagonalized.
|
||||||
|
None: all shells
|
||||||
|
|
||||||
Returns
|
Returns
|
||||||
-------
|
-------
|
||||||
trafo : dict
|
trafo : dict
|
||||||
The transformation matrix for each spin-block in the correlated shell
|
The transformation matrix for each spin-block in the correlated shell
|
||||||
|
|
||||||
"""
|
"""
|
||||||
trafo = {}
|
|
||||||
|
|
||||||
|
# Use all shells
|
||||||
if prop_to_be_diagonal == 'eal':
|
if shells is None:
|
||||||
prop = self.eff_atomic_levels()[ish]
|
shells = range(self.n_corr_shells)
|
||||||
elif prop_to_be_diagonal == 'dm':
|
elif max(shells) >= self.n_corr_shells: # Check if the shell indices are present
|
||||||
prop = self.density_matrix(method='using_point_integration')[ish]
|
mpi.report("calculate_diagonalization_matrix: shells not correct.")
|
||||||
else:
|
|
||||||
mpi.report(
|
|
||||||
"calculate_diagonalization_matrix: not a valid quantitiy to be diagonal. Choices are 'eal' or 'dm'.")
|
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
if calc_in_solver_blocks:
|
if prop_to_be_diagonal == 'eal':
|
||||||
trafo_tmp = self.block_structure.transformation
|
prop = [self.eff_atomic_levels()[self.corr_to_inequiv[ish]]
|
||||||
self.block_structure.transformation = None
|
for ish in range(self.n_corr_shells)]
|
||||||
|
elif prop_to_be_diagonal == 'dm':
|
||||||
prop_solver = self.block_structure.convert_matrix(prop, space_from='sumk', space_to='solver')
|
prop = self.density_matrix(method='using_point_integration')
|
||||||
t= {}
|
|
||||||
for name in prop_solver:
|
|
||||||
t[name] = numpy.linalg.eigh(prop_solver[name])[1].conjugate().transpose()
|
|
||||||
trafo = self.block_structure.convert_matrix(t, space_from='solver', space_to='sumk')
|
|
||||||
#self.T = numpy.dot(self.T.transpose().conjugate(),
|
|
||||||
# self.w).conjugate().transpose()
|
|
||||||
self.block_structure.transformation = trafo_tmp
|
|
||||||
else:
|
else:
|
||||||
for name in prop:
|
mpi.report(
|
||||||
t = numpy.linalg.eigh(prop[name])[1].conjugate().transpose()
|
"calculate_diagonalization_matrix: Choices for prop_to_be_diagonal are 'eal' or 'dm'.")
|
||||||
trafo[name] = t
|
return 0
|
||||||
# calculate new Transformation matrix
|
|
||||||
#self.T = numpy.dot(self.T.transpose().conjugate(),
|
|
||||||
# self.w).conjugate().transpose()
|
|
||||||
|
|
||||||
# measure for the 'unity' of the transformation:
|
trans = [{block: numpy.eye(len(indices)) for block, indices in gfs} for gfs in self.gf_struct_sumk]
|
||||||
#wsqr = sum(abs(self.w.diagonal())**2) / self.w.diagonal().size
|
|
||||||
#return wsqr
|
for ish in shells:
|
||||||
|
trafo = {}
|
||||||
|
# Transform to solver basis if desired, blocks of prop change in this step!
|
||||||
|
if calc_in_solver_blocks:
|
||||||
|
prop[ish] = self.block_structure.convert_matrix(prop[ish], space_from='sumk', space_to='solver')
|
||||||
|
# Get diagonalisation matrix, if not already diagonal
|
||||||
|
for name in prop[ish]:
|
||||||
|
if abs(numpy.sum(prop[ish][name]-numpy.diag(numpy.diagonal(prop[ish][name])))) > 1e-13:
|
||||||
|
trafo[name] = numpy.linalg.eigh(prop[ish][name])[1].conj().T
|
||||||
|
else:
|
||||||
|
trafo[name] = numpy.identity(numpy.shape(prop[ish][name])[0])
|
||||||
|
# Transform back to sumk if necessay, blocks change in this step!
|
||||||
|
if calc_in_solver_blocks:
|
||||||
|
trafo = self.block_structure.convert_matrix(trafo, space_from='solver', space_to='sumk')
|
||||||
|
trans[ish] = trafo
|
||||||
|
|
||||||
|
# Write to block_structure object
|
||||||
|
|
||||||
if write_to_blockstructure:
|
if write_to_blockstructure:
|
||||||
if self.block_structure.transformation == None:
|
self.block_structure.transformation = trans
|
||||||
self.block_structure.transformation = [{} for icrsh in range(self.n_corr_shells)]
|
|
||||||
for icrsh in range(self. n_corr_shells):
|
|
||||||
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_)
|
|
||||||
|
|
||||||
|
return trans
|
||||||
self.block_structure.transformation[ish] = trafo
|
|
||||||
|
|
||||||
return trafo
|
|
||||||
|
|
||||||
|
|
||||||
def density_matrix(self, method='using_gf', beta=40.0):
|
def density_matrix(self, method='using_gf', beta=40.0):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user