77#include < chrono>
88#endif
99#include " module_base/timer.h"
10+ #include " module_cell/cal_atoms_info.h"
1011#include " module_io/json_output/init_info.h"
12+ #include " module_io/output_log.h"
1113#include " module_io/print_info.h"
1214#include " module_io/write_istate_info.h"
1315#include " module_parameter/parameter.h"
14- #include " module_cell/cal_atoms_info.h"
1516
1617#include < iostream>
1718// --------------Temporary----------------
@@ -221,7 +222,7 @@ void ESolver_KS<T, Device>::before_all_runners(const Input_para& inp, UnitCell&
221222 ModuleBase::GlobalFunc::DONE (GlobalV::ofs_running, " INIT K-POINTS" );
222223
223224 // ! 7) print information
224- Print_Info ::setup_parameters (ucell, this ->kv );
225+ ModuleIO ::setup_parameters (ucell, this ->kv );
225226
226227 // ! 8) new plane wave basis, fft grids, etc.
227228#ifdef __MPI
@@ -419,7 +420,7 @@ void ESolver_KS<T, Device>::runner(const int istep, UnitCell& ucell)
419420 ModuleBase::GlobalFunc::DONE (GlobalV::ofs_running, " INIT SCF" );
420421
421422 bool firstscf = true ;
422- this ->conv_elec = false ;
423+ this ->conv_esolver = false ;
423424 this ->niter = this ->maxniter ;
424425
425426 // 4) SCF iterations
@@ -429,7 +430,7 @@ void ESolver_KS<T, Device>::runner(const int istep, UnitCell& ucell)
429430 for (int iter = 1 ; iter <= this ->maxniter ; ++iter)
430431 {
431432 // 5) write head
432- this -> write_head (GlobalV::ofs_running, istep, iter);
433+ ModuleIO:: write_head (GlobalV::ofs_running, istep, iter, this -> basisname );
433434
434435#ifdef __MPI
435436 auto iterstart = MPI_Wtime ();
@@ -496,9 +497,9 @@ void ESolver_KS<T, Device>::runner(const int istep, UnitCell& ucell)
496497 PARAM.inp .esolver_type ,
497498 diag_ethr,
498499 PARAM.inp .nelec );
499-
500+
500501 // The error of HSolver is larger than drho,
501- // so a more precise HSolver should be excuconv_elected .
502+ // so a more precise HSolver should be executed .
502503 if (hsolver_error > drho)
503504 {
504505 diag_ethr = hsolver::reset_diag_ethr (GlobalV::ofs_running,
@@ -540,11 +541,11 @@ void ESolver_KS<T, Device>::runner(const int istep, UnitCell& ucell)
540541 }
541542#endif
542543
543- this ->conv_elec = (drho < this ->scf_thr && not_restart_step && is_U_converged);
544+ this ->conv_esolver = (drho < this ->scf_thr && not_restart_step && is_U_converged);
544545
545546 // If drho < hsolver_error in the first iter or drho < scf_thr, we
546547 // do not change rho.
547- if (drho < hsolver_error || this ->conv_elec )
548+ if (drho < hsolver_error || this ->conv_esolver )
548549 {
549550 if (drho < hsolver_error)
550551 {
@@ -577,13 +578,13 @@ void ESolver_KS<T, Device>::runner(const int istep, UnitCell& ucell)
577578 }
578579#ifdef __MPI
579580 MPI_Bcast (&drho, 1 , MPI_DOUBLE, 0 , PARAPW_WORLD);
580- MPI_Bcast (&this ->conv_elec , 1 , MPI_DOUBLE, 0 , PARAPW_WORLD);
581+ MPI_Bcast (&this ->conv_esolver , 1 , MPI_DOUBLE, 0 , PARAPW_WORLD);
581582 MPI_Bcast (pelec->charge ->rho [0 ], this ->pw_rhod ->nrxx , MPI_DOUBLE, 0 , PARAPW_WORLD);
582583#endif
583584
584585 // 9) update potential
585586 // Hamilt should be used after it is constructed.
586- // this->phamilt->update(conv_elec );
587+ // this->phamilt->update(conv_esolver );
587588 this ->update_pot (istep, iter);
588589
589590 // 10) finish scf iterations
@@ -617,7 +618,7 @@ void ESolver_KS<T, Device>::runner(const int istep, UnitCell& ucell)
617618#endif // __RAPIDJSON
618619
619620 // 13) check convergence
620- if (this ->conv_elec )
621+ if (this ->conv_esolver )
621622 {
622623 this ->niter = iter;
623624 break ;
@@ -632,7 +633,7 @@ void ESolver_KS<T, Device>::runner(const int istep, UnitCell& ucell)
632633 std::cout << " >> Leave SCF iteration.\n * * * * * *" << std::endl;
633634#ifdef __RAPIDJSON
634635 // 14) add Json of efermi energy converge
635- Json::add_output_efermi_converge (this ->pelec ->eferm .ef * ModuleBase::Ry_to_eV, this ->conv_elec );
636+ Json::add_output_efermi_converge (this ->pelec ->eferm .ef * ModuleBase::Ry_to_eV, this ->conv_esolver );
636637#endif // __RAPIDJSON
637638
638639 // 15) after scf
@@ -666,9 +667,9 @@ void ESolver_KS<T, Device>::iter_finish(int& iter)
666667 this ->pelec ->f_en .etot_old = this ->pelec ->f_en .etot ;
667668
668669 // add a energy threshold for SCF convergence
669- if (this ->conv_elec == 0 ) // only check when density is not converged
670+ if (this ->conv_esolver == 0 ) // only check when density is not converged
670671 {
671- this ->conv_elec
672+ this ->conv_esolver
672673 = (iter != 1 && std::abs (this ->pelec ->f_en .etot_delta * ModuleBase::Ry_to_eV) < this ->scf_ene_thr );
673674 }
674675}
@@ -687,33 +688,6 @@ void ESolver_KS<T, Device>::after_scf(const int istep)
687688 }
688689}
689690
690- // ------------------------------------------------------------------------------
691- // ! the 8th function of ESolver_KS: print_head
692- // ! mohan add 2024-05-12
693- // ------------------------------------------------------------------------------
694- template <typename T, typename Device>
695- void ESolver_KS<T, Device>::print_head()
696- {
697- std::cout << " " << std::setw (7 ) << " ITER" ;
698-
699- if (PARAM.inp .nspin == 2 )
700- {
701- std::cout << std::setw (10 ) << " TMAG" ;
702- std::cout << std::setw (10 ) << " AMAG" ;
703- }
704-
705- std::cout << std::setw (15 ) << " ETOT(eV)" ;
706- std::cout << std::setw (15 ) << " EDIFF(eV)" ;
707- std::cout << std::setw (11 ) << " DRHO" ;
708-
709- if (XC_Functional::get_func_type () == 3 || XC_Functional::get_func_type () == 5 )
710- {
711- std::cout << std::setw (11 ) << " DKIN" ;
712- }
713-
714- std::cout << std::setw (11 ) << " TIME(s)" << std::endl;
715- }
716-
717691// ------------------------------------------------------------------------------
718692// ! the 8th function of ESolver_KS: print_iter
719693// ! mohan add 2024-05-12
@@ -725,18 +699,7 @@ void ESolver_KS<T, Device>::print_iter(const int iter,
725699 const double duration,
726700 const double ethr)
727701{
728- this ->pelec ->print_etot (this ->conv_elec , iter, drho, dkin, duration, PARAM.inp .printe , ethr);
729- }
730-
731- // ------------------------------------------------------------------------------
732- // ! the 9th function of ESolver_KS: write_head
733- // ! mohan add 2024-05-12
734- // ------------------------------------------------------------------------------
735- template <typename T, typename Device>
736- void ESolver_KS<T, Device>::write_head(std::ofstream& ofs_running, const int istep, const int iter)
737- {
738- ofs_running << " \n " << this ->basisname << " ALGORITHM --------------- ION=" << std::setw (4 ) << istep + 1
739- << " ELEC=" << std::setw (4 ) << iter << " --------------------------------\n " ;
702+ this ->pelec ->print_etot (this ->conv_esolver , iter, drho, dkin, duration, PARAM.inp .printe , ethr);
740703}
741704
742705// ------------------------------------------------------------------------------
0 commit comments