Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor: remove pelec frome hsolverpw solve func #4846

Merged
merged 4 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions source/module_esolver/esolver_ks_pw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,12 +353,12 @@ void ESolver_KS_PW<T, Device>::hamilt2density(const int istep, const int iter, c
hsolver::DiagoIterAssist<T, Device>::SCF_ITER = iter;
hsolver::DiagoIterAssist<T, Device>::PW_DIAG_THR = ethr;
hsolver::DiagoIterAssist<T, Device>::PW_DIAG_NMAX = GlobalV::PW_DIAG_NMAX;


hsolver::HSolverPW<T, Device> hsolver_pw_obj(this->pw_wfc, &this->wf, this->init_psi);
hsolver_pw_obj.solve(this->p_hamilt, // hamilt::Hamilt<T, Device>* pHamilt,
hsolver_pw_obj.solve(this->p_hamilt, // hamilt::Hamilt<T, Device>* pHamilt,
this->kspw_psi[0], // psi::Psi<T, Device>& psi,
this->pelec, // elecstate::ElecState<T, Device>* pelec,
this->pelec, // elecstate::ElecState<T, Device>* pelec,
this->pelec->ekb.c,
PARAM.inp.ks_solver,
PARAM.inp.calculation,
PARAM.inp.basis_type,
Expand Down
1 change: 1 addition & 0 deletions source/module_esolver/pw_fun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ void ESolver_KS_PW<T, Device>::hamilt2estates(const double ethr) {
hsolver_pw_obj.solve(this->p_hamilt,
this->kspw_psi[0],
this->pelec,
this->pelec->ekb.c,
PARAM.inp.ks_solver,
PARAM.inp.calculation,
PARAM.inp.basis_type,
Expand Down
3 changes: 3 additions & 0 deletions source/module_hsolver/hsolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ class HSolver
virtual void solve(hamilt::Hamilt<T, Device>* phm,
psi::Psi<T, Device>& ppsi,
elecstate::ElecState* pes,

double* out_eigenvalues,

const std::string method,

const std::string calculation_type_in,
Expand Down
6 changes: 5 additions & 1 deletion source/module_hsolver/hsolver_pw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,9 @@ template <typename T, typename Device>
void HSolverPW<T, Device>::solve(hamilt::Hamilt<T, Device>* pHamilt,
psi::Psi<T, Device>& psi,
elecstate::ElecState* pes,

double* out_eigenvalues,

const std::string method_in,

const std::string calculation_type_in,
Expand Down Expand Up @@ -340,11 +343,12 @@ void HSolverPW<T, Device>::solve(hamilt::Hamilt<T, Device>* pHamilt,
}
// END Loop over k points

// copy eigenvalues to pes->ekb in ElecState
// copy eigenvalues to ekb in ElecState
base_device::memory::cast_memory_op<double, Real, base_device::DEVICE_CPU, base_device::DEVICE_CPU>()(
cpu_ctx,
cpu_ctx,
pes->ekb.c,
// out_eigenvalues,
eigenvalues.data(),
pes->ekb.nr * pes->ekb.nc);

Expand Down
3 changes: 3 additions & 0 deletions source/module_hsolver/hsolver_pw.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ class HSolverPW : public HSolver<T, Device>
void solve(hamilt::Hamilt<T, Device>* pHamilt,
psi::Psi<T, Device>& psi,
elecstate::ElecState* pes,

double* out_eigenvalues,

const std::string method_in,

const std::string calculation_type_in,
Expand Down
19 changes: 2 additions & 17 deletions source/module_hsolver/test/test_hsolver_pw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ TEST_F(TestHSolverPW, solve) {
this->hs_f.solve(&hamilt_test_f,
psi_test_cf,
&elecstate_test,
elecstate_test.ekb.c,
method_test,
"scf",
"pw",
Expand All @@ -106,6 +107,7 @@ TEST_F(TestHSolverPW, solve) {
this->hs_d.solve(&hamilt_test_d,
psi_test_cd,
&elecstate_test,
elecstate_test.ekb.c,
method_test,
"scf",
"pw",
Expand Down Expand Up @@ -234,23 +236,6 @@ TEST_F(TestHSolverPW, solve) {
EXPECT_EQ(test_diagethr_d, 0.1);
}

/*#include "mpi.h"
#include "module_base/timer.h"
int main(int argc, char **argv)
{
ModuleBase::timer::disable();
MPI_Init(&argc, &argv);
testing::InitGoogleTest(&argc, argv);

MPI_Comm_size(MPI_COMM_WORLD,&GlobalV::NPROC);
MPI_Comm_rank(MPI_COMM_WORLD,&GlobalV::MY_RANK);
int result = RUN_ALL_TESTS();

MPI_Finalize();

return result;
}*/

TEST_F(TestHSolverPW, SolveLcaoInPW) {
pwbk.nks = 1;
// initial memory and data
Expand Down
Loading