Skip to content

Commit 3206623

Browse files
author
root
committed
fix pyabacus
1 parent ed488e7 commit 3206623

File tree

4 files changed

+27
-7
lines changed

4 files changed

+27
-7
lines changed

python/pyabacus/src/hsolver/py_diago_dav_subspace.hpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,9 @@ class PyDiagoDavSubspace
108108
bool need_subspace,
109109
std::vector<double>& diag_ethr,
110110
bool scf_type,
111-
hsolver::diag_comm_info comm_info
111+
hsolver::diag_comm_info comm_info,
112+
int diag_subspace,
113+
int nb2d
112114
) {
113115
auto hpsi_func = [mm_op] (
114116
std::complex<double> *psi_in,
@@ -139,8 +141,8 @@ class PyDiagoDavSubspace
139141
max_iter,
140142
need_subspace,
141143
comm_info,
142-
PARAM.inp.diag_subspace,
143-
PARAM.inp.nb2d
144+
diag_subspace,
145+
nb2d
144146
);
145147

146148
return obj->diag(hpsi_func, psi, nbasis, eigenvalue, diag_ethr, scf_type);

python/pyabacus/src/hsolver/py_hsolver.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,13 @@ void bind_hsolver(py::module& m)
6767
where the initial precision of eigenvalue calculation can be coarse.
6868
If false, it indicates a non-self-consistent field (non-SCF) calculation,
6969
where high precision in eigenvalue calculation is required from the start.
70+
comm_info : diag_comm_info
71+
The communicator information.
72+
diago_subspace : int
73+
The method to solve the generalized eigenvalue problem.
74+
0: LAPACK, 1: Gen-ELPA, 2: ScaLAPACK
75+
nb2d : int
76+
The block size in 2d block cyclic distribution if use elpa or scalapack.
7077
)pbdoc",
7178
"mm_op"_a,
7279
"precond_vec"_a,
@@ -76,7 +83,9 @@ void bind_hsolver(py::module& m)
7683
"need_subspace"_a,
7784
"diag_ethr"_a,
7885
"scf_type"_a,
79-
"comm_info"_a)
86+
"comm_info"_a,
87+
"diago_subspace"_a,
88+
"nb2d"_a)
8089
.def("set_psi", &py_hsolver::PyDiagoDavSubspace::set_psi, R"pbdoc(
8190
Set the initial guess of the eigenvectors, i.e. the wave functions.
8291
)pbdoc", "psi_in"_a)

python/pyabacus/src/pyabacus/hsolver/_hsolver.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ def dav_subspace(
3434
max_iter: int = 1000,
3535
need_subspace: bool = False,
3636
diag_ethr: Union[List[float], None] = None,
37-
scf_type: bool = False
37+
scf_type: bool = False,
38+
diag_subspace: int = 0,
39+
nb2d: int = 0
3840
) -> Tuple[NDArray[np.float64], NDArray[np.complex128]]:
3941
""" A function to diagonalize a matrix using the Davidson-Subspace method.
4042
@@ -67,6 +69,11 @@ def dav_subspace(
6769
If True, the initial precision of eigenvalue calculation can be coarse.
6870
If False, it indicates a non-self-consistent field (non-SCF) calculation,
6971
where high precision in eigenvalue calculation is required from the start.
72+
diag_subspace : int, optional
73+
The method to do the diagonalization, by default 0.
74+
0: LAPACK, 1: Gen-elpa, 2: Scalapack
75+
nb2d : int, optional
76+
The block size for 2D decomposition, by default 0, which will be automatically set.
7077
7178
Returns
7279
-------
@@ -101,7 +108,9 @@ def dav_subspace(
101108
need_subspace,
102109
diag_ethr,
103110
scf_type,
104-
comm_info
111+
comm_info,
112+
diag_subspace,
113+
nb2d
105114
)
106115

107116
e = _diago_obj_dav_subspace.get_eigenvalue()

source/module_hsolver/test/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ install(FILES parallel_k2d_test.sh DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
157157
AddTest(
158158
TARGET hsolver_diago_hs_parallel
159159
LIBS parameter ${math_libs} ELPA::ELPA base device MPI::MPI_CXX genelpa psi
160-
SOURCES test_diago_hs_para.cpp ../diag_hs_para.cpp ../diago_pxxxgvx.cpp ../../module_basis/module_ao/parallel_2d.cpp ../diago_elpa.cpp ../diago_scalapack.cpp
160+
SOURCES test_diago_hs_para.cpp ../diag_hs_para.cpp ../diago_pxxxgvx.cpp ../diago_elpa.cpp ../diago_scalapack.cpp
161161
)
162162

163163
find_program(BASH bash)

0 commit comments

Comments
 (0)