mirror of
https://github.com/triqs/dft_tools
synced 2024-12-22 04:13:47 +01:00
Optimized slightly orthogonalization routine
At one step of the orthogonaliztion procedure two matrix multiplications have been replaced with one matrix multiplication and a element-wise multiplication of a vector and a matrix.
This commit is contained in:
parent
b2b25a9fd0
commit
7db721c8d1
@ -240,14 +240,16 @@ class ProjectorGroup:
|
|||||||
|
|
||||||
Orthogonalized projector matrix, initial overlap matrix and its eigenvalues.
|
Orthogonalized projector matrix, initial overlap matrix and its eigenvalues.
|
||||||
"""
|
"""
|
||||||
|
# TODO: check the precision of the calculations below,
|
||||||
|
# it seems to be inferior to that of Fortran implementation
|
||||||
# Overlap matrix O_{m m'} = \sum_{v} P_{m v} P^{*}_{v m'}
|
# Overlap matrix O_{m m'} = \sum_{v} P_{m v} P^{*}_{v m'}
|
||||||
overlap = np.dot(p_matrix, p_matrix.conj().T)
|
overlap = np.dot(p_matrix, p_matrix.conj().T)
|
||||||
# Calculate [O^{-1/2}]_{m m'}
|
# Calculate [O^{-1/2}]_{m m'}
|
||||||
eig, eigv = np.linalg.eigh(overlap)
|
eig, eigv = np.linalg.eigh(overlap)
|
||||||
assert np.all(eig > 0.0), ("Negative eigenvalues of the overlap matrix:"
|
assert np.all(eig > 0.0), ("Negative eigenvalues of the overlap matrix:"
|
||||||
"projectors are ill-defined")
|
"projectors are ill-defined")
|
||||||
sqrt_eig = np.diag(1.0 / np.sqrt(eig))
|
sqrt_eig = 1.0 / np.sqrt(eig)
|
||||||
shalf = np.dot(eigv, np.dot(sqrt_eig, eigv.conj().T))
|
shalf = np.dot(eigv * sqrt_eig, eigv.conj().T)
|
||||||
# Apply \tilde{P}_{m v} = \sum_{m'} [O^{-1/2}]_{m m'} P_{m' v}
|
# Apply \tilde{P}_{m v} = \sum_{m'} [O^{-1/2}]_{m m'} P_{m' v}
|
||||||
p_ortho = np.dot(shalf, p_matrix)
|
p_ortho = np.dot(shalf, p_matrix)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user