Skip to content

Commit

Permalink
fix: make get_h_qp helper only return the matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
thenoursehorse committed May 9, 2024
1 parent a0c0d81 commit 1eaad4c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
19 changes: 9 additions & 10 deletions src/risb/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,26 +248,24 @@ def get_h_qp(R : np.ndarray,
h0_kin_k : np.ndarray,
mu : float = 0) -> tuple[ np.ndarray, np.ndarray ]:
"""
Construct eigenvalues and eigenvectors of the quasiparticle Hamiltonian.
Construct the quasiparticle Hamiltonian.
Parameters
----------
R : numpy.ndarray
Renormalization matrix) from electrons to quasiparticles.
Renormalization matrix) from electrons to quasiparticles
Lambda : numpy.ndarray
Correlation potential of quasiparticles.
h0_kin_k : numpy.ndarray
Single-particle dispersion between local clusters. Indexed as
k, orb_i, orb_j.
k, orb_i, orb_j
mu : float, optional
Chemical potential.
Chemical potential
Return
------
eigenvalues : numpy.ndarray
Indexed as k, band.
eigenvectors : numpy.ndarray
Indexed as k, each column an eigenvector.
h_qp : numpy.ndarray
Indexed as k, orb_i, orb_j
Notes
-----
Expand All @@ -280,8 +278,9 @@ def get_h_qp(R : np.ndarray,
(Lambda - mu*np.eye(Lambda.shape[0]))
if not np.allclose(h_qp, np.swapaxes(h_qp, 1, 2).conj()):
warnings.warn("H_qp is not Hermitian !", RuntimeWarning)
eig, vec = np.linalg.eigh(h_qp)
return (eig, vec)
#eig, vec = np.linalg.eigh(h_qp)
#return (eig, vec)
return h_qp

def get_h0_kin_k_R(R : np.ndarray,
h0_kin_k : np.ndarray,
Expand Down
3 changes: 2 additions & 1 deletion src/risb/solve_lattice.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,8 @@ def one_cycle(self,
h0_k_R = dict()
#R_h0_k_R = dict()
for bl in self.h0_kin_k.keys():
self.energies_qp[bl], self.bloch_vector_qp[bl] = helpers.get_h_qp(self.R_full[bl], self.Lambda_full[bl], self.h0_kin_k[bl])
h_qp = helpers.get_h_qp(self.R_full[bl], self.Lambda_full[bl], self.h0_kin_k[bl])
self.energies_qp[bl], self.bloch_vector_qp[bl] = np.linalg.eigh(h_qp)
h0_k_R[bl] = helpers.get_h0_kin_k_R(self.R_full[bl], self.h0_kin_k[bl], self.bloch_vector_qp[bl])
#R_h0_k_R[bl] = helpers.get_R_h0_kin_kR(R_full[bl], self.h0_kin_k[bl], self.bloch_vector_qp[bl])

Expand Down
3 changes: 2 additions & 1 deletion tests/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ def test_get_h_qp(subtests):
np.fill_diagonal(R, 1)
Lambda = np.zeros(shape=(2,2))
np.fill_diagonal(Lambda, 0.5)
eig, vec = helpers.get_h_qp(R, Lambda, h0_k)
h_qp = helpers.get_h_qp(R, Lambda, h0_k)
eig, vec = np.linalg.eigh(h_qp)
with subtests.test(msg="eigenvalues"):
assert eig == approx(eig_expected, abs=abs)
with subtests.test(msg="eigenvectors"):
Expand Down

0 comments on commit 1eaad4c

Please sign in to comment.