mirror of
https://github.com/triqs/dft_tools
synced 2024-10-04 23:36:05 +02:00
Restructured 'orthogonalization()'
The part responsible for generating a mapping between the shell/ions and block projector matrices has now been relocated to a separate method 'get_block_matrix_map()'. This simplifies the source code and makes testing easier.
This commit is contained in:
parent
c426946803
commit
72d030c5c5
@ -92,6 +92,52 @@ class ProjectorGroup:
|
|||||||
projector arrays. Note that the blocks can comprise several projector arrays
|
projector arrays. Note that the blocks can comprise several projector arrays
|
||||||
contained in different projector shells.
|
contained in different projector shells.
|
||||||
|
|
||||||
|
The construction of block maps is performed in 'self.get_block_matrix_map()'.
|
||||||
|
"""
|
||||||
|
# Quick exit if no normalization is requested
|
||||||
|
if not self.ortho:
|
||||||
|
return
|
||||||
|
|
||||||
|
block_maps, ndim = self.get_block_matrix_map()
|
||||||
|
|
||||||
|
p_mat = np.zeros((ndim, nb_max), dtype=np.complex128)
|
||||||
|
# Note that 'ns' and 'nk' are the same for all shells
|
||||||
|
for isp in xrange(ns):
|
||||||
|
for ik in xrange(nk):
|
||||||
|
nb = self.ib_win[ik, isp, 1] - self.ib_win[ik, isp, 0] + 1
|
||||||
|
# Combine all projectors of the group to one block projector
|
||||||
|
for bl_map in block_maps:
|
||||||
|
p_mat[:, :] = 0.0j # !!! Clean-up from the last k-point and block!
|
||||||
|
for ibl, block in enumerate(bl_map):
|
||||||
|
i1, i2 = block['bmat_range']
|
||||||
|
ish, ion = block['shell_ion']
|
||||||
|
shell = self.shells[ish]
|
||||||
|
p_mat[i1:i2, :nb] = shell.proj_win[ion, isp, ik, :nlm, :nb]
|
||||||
|
# Now orthogonalize the obtained block projector
|
||||||
|
ibl_max = i2
|
||||||
|
p_orth, overl, eig = self.orthogonalize_projector_matrix(p_mat[:ibl_max, :nb])
|
||||||
|
# Distribute projectors back using the same mapping
|
||||||
|
for ibl, block in enumerate(bl_map):
|
||||||
|
i1, i2 = block['bmat_range']
|
||||||
|
ish, ion = block['shell_ion']
|
||||||
|
shell = self.shells[ish]
|
||||||
|
shell.proj_win[ion, isp, ik, :nlm, :nb] = p_orth[i1:i2, :nb]
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
#
|
||||||
|
# gen_block_matrix_map
|
||||||
|
#
|
||||||
|
################################################################################
|
||||||
|
def get_block_matrix_map(self):
|
||||||
|
"""
|
||||||
|
Generates a map from a set of projectors belonging to different shells
|
||||||
|
and ions onto a set of block projector matrices, each of which is
|
||||||
|
orthonormalized.
|
||||||
|
|
||||||
|
Returns the map and the maximum orbital dimension of the block projector
|
||||||
|
matrix.
|
||||||
|
|
||||||
|
|
||||||
Mapping is defined as a list of 'block_maps' corresponding to subsets
|
Mapping is defined as a list of 'block_maps' corresponding to subsets
|
||||||
of projectors to be orthogonalized. Each subset corresponds to a subset of sites
|
of projectors to be orthogonalized. Each subset corresponds to a subset of sites
|
||||||
and spans all orbital indices. defined by 'bl_map' as
|
and spans all orbital indices. defined by 'bl_map' as
|
||||||
@ -129,15 +175,9 @@ class ProjectorGroup:
|
|||||||
((i2_start, i2_end), (i2_shell, i2_shell.ion1)),
|
((i2_start, i2_end), (i2_shell, i2_shell.ion1)),
|
||||||
((i2_start, i2_end), (i2_shell, i2_shell.ion2)),
|
((i2_start, i2_end), (i2_shell, i2_shell.ion2)),
|
||||||
...],
|
...],
|
||||||
|
|
||||||
"""
|
"""
|
||||||
# Quick exit if no normalization is requested
|
|
||||||
if not self.ortho:
|
|
||||||
return
|
|
||||||
|
|
||||||
# Determine the dimension of the projector matrix
|
|
||||||
# and map the blocks to the big matrix
|
|
||||||
if self.normion:
|
if self.normion:
|
||||||
|
# Projectors for each site are mapped onto a separate block matrix
|
||||||
block_maps = []
|
block_maps = []
|
||||||
ndim = 0
|
ndim = 0
|
||||||
for ish in self.ishells:
|
for ish in self.ishells:
|
||||||
@ -153,6 +193,7 @@ class ProjectorGroup:
|
|||||||
block_maps.append(bl_map)
|
block_maps.append(bl_map)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
# All projectors within a group are combined into one big block matrix
|
||||||
block_maps = []
|
block_maps = []
|
||||||
bl_map = []
|
bl_map = []
|
||||||
i1_bl = 0
|
i1_bl = 0
|
||||||
@ -169,29 +210,7 @@ class ProjectorGroup:
|
|||||||
ndim = i2_bl
|
ndim = i2_bl
|
||||||
block_maps.append(bl_map)
|
block_maps.append(bl_map)
|
||||||
|
|
||||||
print block_maps
|
return block_maps, ndim
|
||||||
p_mat = np.zeros((ndim, nb_max), dtype=np.complex128)
|
|
||||||
# Note that 'ns' and 'nk' are the same for all shells
|
|
||||||
for isp in xrange(ns):
|
|
||||||
for ik in xrange(nk):
|
|
||||||
nb = self.ib_win[ik, isp, 1] - self.ib_win[ik, isp, 0] + 1
|
|
||||||
# Combine all projectors of the group to one block projector
|
|
||||||
for bl_map in block_maps:
|
|
||||||
p_mat[:, :] = 0.0j # !!! Clean-up from the last k-point and block!
|
|
||||||
for ibl, block in enumerate(bl_map):
|
|
||||||
i1, i2 = block['bmat_range']
|
|
||||||
ish, ion = block['shell_ion']
|
|
||||||
shell = self.shells[ish]
|
|
||||||
p_mat[i1:i2, :nb] = shell.proj_win[ion, isp, ik, :nlm, :nb]
|
|
||||||
# Now orthogonalize the obtained block projector
|
|
||||||
ibl_max = i2
|
|
||||||
p_orth, overl, eig = self.orthogonalize_projector_matrix(p_mat[:ibl_max, :nb])
|
|
||||||
# Distribute projectors back using the same mapping
|
|
||||||
for ibl, block in enumerate(bl_map):
|
|
||||||
i1, i2 = block['bmat_range']
|
|
||||||
ish, ion = block['shell_ion']
|
|
||||||
shell = self.shells[ish]
|
|
||||||
shell.proj_win[ion, isp, ik, :nlm, :nb] = p_orth[i1:i2, :nb]
|
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
#
|
#
|
||||||
|
Loading…
Reference in New Issue
Block a user