@@ -46,6 +46,21 @@ namespace ModuleESolver
4646 classname = " ESolver_KS_PW" ;
4747 basisname = " PW" ;
4848 }
49+ ESolver_KS_PW::~ESolver_KS_PW ()
50+ {
51+ if (this ->pelec !=nullptr )
52+ {
53+ delete this ->pelec ;
54+ }
55+ if (this ->phami !=nullptr )
56+ {
57+ delete this ->phami ;
58+ }
59+ if (this ->phsol !=nullptr )
60+ {
61+ delete this ->phsol ;
62+ }
63+ }
4964
5065 void ESolver_KS_PW::Init (Input& inp, UnitCell_pseudo& ucell)
5166 {
@@ -188,23 +203,7 @@ namespace ModuleESolver
188203
189204 ModuleBase::GlobalFunc::DONE (GlobalV::ofs_running, " INIT BASIS" );
190205
191-
192-
193- }
194-
195- void ESolver_KS_PW::beforescf (int istep)
196- {
197- // calculate ewald energy
198- H_Ewald_pw::compute_ewald (GlobalC::ucell, GlobalC::pw);
199- // Symmetry_rho should be moved to Init()
200- Symmetry_rho srho;
201- for (int is = 0 ; is < GlobalV::NSPIN; is++)
202- {
203- srho.begin (is, GlobalC::CHR, GlobalC::pw, GlobalC::Pgrid, GlobalC::symm);
204- }
205206 // init Psi, HSolver, ElecState, Hamilt
206- hsolver::DiagoIterAssist::PW_DIAG_NMAX = GlobalV::PW_DIAG_NMAX;
207- hsolver::DiagoIterAssist::PW_DIAG_THR = GlobalV::PW_DIAG_THR;
208207 const PW_Basis* pbas = &(GlobalC::pw);
209208 if (this ->phsol != nullptr )
210209 {
@@ -217,7 +216,6 @@ namespace ModuleESolver
217216 else
218217 {
219218 this ->phsol = new hsolver::HSolverPW (pbas);
220- this ->phsol ->method = GlobalV::KS_SOLVER;
221219 }
222220 if (this ->pelec != nullptr )
223221 {
@@ -243,6 +241,19 @@ namespace ModuleESolver
243241 {
244242 this ->phami = new hamilt::HamiltPW (&(GlobalC::hm.hpw ));
245243 }
244+
245+ }
246+
247+ void ESolver_KS_PW::beforescf (int istep)
248+ {
249+ // calculate ewald energy
250+ H_Ewald_pw::compute_ewald (GlobalC::ucell, GlobalC::pw);
251+ // Symmetry_rho should be moved to Init()
252+ Symmetry_rho srho;
253+ for (int is = 0 ; is < GlobalV::NSPIN; is++)
254+ {
255+ srho.begin (is, GlobalC::CHR, GlobalC::pw, GlobalC::Pgrid, GlobalC::symm);
256+ }
246257 }
247258
248259 void ESolver_KS_PW::eachiterinit (const int istep, const int iter)
@@ -293,7 +304,8 @@ namespace ModuleESolver
293304 }
294305
295306 hsolver::DiagoIterAssist::PW_DIAG_THR = ethr;
296- this ->phsol ->solve (this ->phami , this ->psi [0 ], this ->pelec );
307+ hsolver::DiagoIterAssist::PW_DIAG_NMAX = GlobalV::PW_DIAG_NMAX;
308+ this ->phsol ->solve (this ->phami , this ->psi [0 ], this ->pelec , GlobalV::KS_SOLVER);
297309
298310 // transform energy for print
299311 GlobalC::en.eband = this ->pelec ->eband ;
@@ -670,7 +682,7 @@ namespace ModuleESolver
670682 {
671683 hsolver::DiagoIterAssist::need_subspace = false ;
672684 hsolver::DiagoIterAssist::PW_DIAG_THR = ethr;
673- this ->phsol ->solve (this ->phami , this ->psi [0 ], this ->pelec , true );
685+ this ->phsol ->solve (this ->phami , this ->psi [0 ], this ->pelec , GlobalV::KS_SOLVER, true );
674686 }
675687 else
676688 {
0 commit comments