Skip to content

Commit

Permalink
Refactor diagonalization to accept operators instead of explicit matr…
Browse files Browse the repository at this point in the history
…ices

Previously, our module could only accept explicit matrices for diagonalization. I have now modified the code to accept operators as parameters for diagonalization, eliminating the need to store the entire matrix explicitly. This allows us to compute eigenvalues for larger Hamiltonians using the sparse matrix storage provided by `SciPy`.

The operator is a function pointer that accepts a vector and returns a vector. To diagonalize an operator A, we define a function or lambda function `mv_op` such that `mv_op(x) = Ax`, which can then be used in the diagonalization process.

Additionally, I have added a new test case for the Hamiltonian matrix corresponding to H2O. The matrix size is `67024x67024`, which previously could not be stored explicitly due to memory constraints. The updated operator method now supports the computation of eigenvalues for such large matrices.

Test cases have been updated to reflect these changes.
  • Loading branch information
a1henu committed Aug 14, 2024
1 parent 82de65a commit d7f64ee
Showing 1 changed file with 0 additions and 2 deletions.
2 changes: 0 additions & 2 deletions python/pyabacus/src/py_diago_dav_subspace.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,6 @@ class PyDiagoDavSubspace
bool scf_type,
hsolver::diag_comm_info comm_info
) {
// TODO: Wrap std::function<void(T*, T*, const int, const int, const int, const int)>
// to a python callable type
auto hpsi_func = [mv_op] (std::complex<double> *hpsi_out,
std::complex<double> *psi_in, const int nband_in,
const int nbasis_in, const int band_index1,
Expand Down

0 comments on commit d7f64ee

Please sign in to comment.