@@ -15,30 +15,31 @@ namespace ModuleESolver
1515
1616ESolver_KS::ESolver_KS ()
1717{
18+ classname = " ESolver_KS" ;
1819 basisname = " PLEASE ADD BASISNAME FOR CURRENT ESOLVER." ;
1920 diag_ethr = GlobalV::PW_DIAG_THR;
2021 scf_thr = GlobalV::SCF_THR;
2122 drho = 0.0 ;
2223 maxniter = GlobalV::SCF_NMAX;
2324 niter = maxniter;
24-
25-
25+ out_freq_elec = GlobalV::OUT_FREQ_ELEC;
2626}
2727
2828void ESolver_KS:: hamilt2density(int istep, int iter, double ethr)
2929{
30+ ModuleBase::timer:: tick (this ->classname ," hamilt2density" );
3031 // Temporarily, before HSolver is constructed, it should be overrided by
3132 // LCAO, PW, SDFT and TDDFT.
3233 // After HSolver is constructed, LCAO, PW, SDFT should delete their own
3334 // hamilt2density() and use:
3435 // this->phsol->solve(this->phamilt, this->pes, this->wf, ETHR);
35-
36+ ModuleBase::timer:: tick ( this -> classname , " hamilt2density " );
3637}
3738
3839
3940void ESolver_KS:: Run(int istep, UnitCell_pseudo& cell)
4041{
41- ModuleBase::timer:: tick (" ESolver_KS " , " run " );
42+ ModuleBase::timer:: tick (this -> classname , " Run " );
4243
4344 this ->printhead (); // print the headline on the screen.
4445 this ->beforeiter (); // Something else to do before the iter loop
@@ -67,14 +68,7 @@ void ESolver_KS:: Run(int istep, UnitCell_pseudo& cell)
6768 // The error of HSolver is larger than drho, so a more precise HSolver should be excuted.
6869 if (hsover_error > drho)
6970 {
70- GlobalV::ofs_running << " Notice: Threshold on eigenvalues was too large.\n " ;
71- ModuleBase::WARNING (" scf" ," Threshold on eigenvalues was too large." );
72- GlobalV::ofs_running << " hsover_error=" << hsover_error << " > drho=" << drho << std::endl;
73-
74- GlobalV::ofs_running << " Origin diag_ethr = " << this ->diag_ethr << std::endl;
75- this ->diag_ethr =0.1 * drho / GlobalC::CHR.nelec ;
76- GlobalV::ofs_running << " New diag_ethr = " << this ->diag_ethr << std::endl;
77-
71+ reset_diagethr (GlobalV::ofs_running, hsover_error);
7872 this ->hamilt2density (istep, iter, this ->diag_ethr );
7973 drho = GlobalC::CHR.get_drho ();
8074 }
@@ -92,7 +86,7 @@ void ESolver_KS:: Run(int istep, UnitCell_pseudo& cell)
9286 // Hamilt should be used after it is constructed.
9387 // this->phamilt->update(conv_elec);
9488 updatepot (conv_elec);
95- eachiterfinish (iter);
89+ eachiterfinish (iter,conv_elec );
9690 iterend = std::clock ();
9791 double duration = double (iterend-iterstart) / CLOCKS_PER_SEC;
9892 printiter (conv_elec, iter, drho, duration, diag_ethr);
@@ -104,11 +98,11 @@ void ESolver_KS:: Run(int istep, UnitCell_pseudo& cell)
10498 }
10599 afteriter (conv_elec);
106100
107- ModuleBase::timer:: tick (" ESolver_KS " , " run " );
101+ ModuleBase::timer:: tick (this -> classname , " Run " );
108102 return ;
109103};
110104
111-
105+ // <Temporary> It should be a function of Diag_H class in the future.
112106void ESolver_KS:: set_ethr(int istep, int iter)
113107{
114108// It is too complex now and should be modified.
@@ -191,6 +185,16 @@ void ESolver_KS:: writehead(std::ofstream &ofs_running, int istep, int iter)
191185 << " --------------------------------\n " ;
192186}
193187
188+ void ESolver_KS:: reset_diagethr(std::ofstream &ofs_running, double hsover_error)
189+ {
190+ ofs_running << " Notice: Threshold on eigenvalues was too large.\n " ;
191+ ModuleBase::WARNING (" scf" ," Threshold on eigenvalues was too large." );
192+ ofs_running << " hsover_error=" << hsover_error << " > DRHO=" << drho << std::endl;
193+ ofs_running << " Origin diag_ethr = " << this ->diag_ethr << std::endl;
194+ this ->diag_ethr =0.1 * drho / GlobalC::CHR.nelec ;
195+ ofs_running << " New diag_ethr = " << this ->diag_ethr << std::endl;
196+ }
197+
194198int ESolver_KS:: getniter()
195199{
196200 return this ->niter ;
0 commit comments