@@ -985,18 +985,18 @@ void ESolver_KS_LCAO<TK, TR>::after_scf(UnitCell& ucell, const int istep)
985985 this ->pelec ->cal_tau (*(this ->psi ));
986986 }
987987
988- // 2 ) call after_scf() of ESolver_KS
988+ // ! 5 ) call after_scf() of ESolver_KS
989989 ESolver_KS<TK>::after_scf (ucell, istep);
990990
991- // 3 ) write density matrix for sparse matrix
991+ // ! 6 ) write density matrix for sparse matrix
992992 ModuleIO::write_dmr (dynamic_cast <const elecstate::ElecStateLCAO<TK>*>(this ->pelec )->get_DM ()->get_DMR_vector (),
993993 this ->pv ,
994994 PARAM.inp .out_dm1 ,
995995 false ,
996996 PARAM.inp .out_app_flag ,
997997 istep);
998998
999- // 4 ) write density matrix
999+ // ! 7 ) write density matrix
10001000 if (PARAM.inp .out_dm )
10011001 {
10021002 std::vector<double > efermis (PARAM.inp .nspin == 2 ? 2 : 1 );
@@ -1013,7 +1013,7 @@ void ESolver_KS_LCAO<TK, TR>::after_scf(UnitCell& ucell, const int istep)
10131013 }
10141014
10151015#ifdef __EXX
1016- // 5 ) write Hexx matrix for NSCF (see `out_chg` in docs/advanced/input_files/input-main.md)
1016+ // ! 8 ) write Hexx matrix for NSCF (see `out_chg` in docs/advanced/input_files/input-main.md)
10171017 if (PARAM.inp .calculation != " nscf" )
10181018 {
10191019 if (GlobalC::exx_info.info_global .cal_exx && PARAM.inp .out_chg [0 ]
@@ -1032,7 +1032,7 @@ void ESolver_KS_LCAO<TK, TR>::after_scf(UnitCell& ucell, const int istep)
10321032 }
10331033#endif
10341034
1035- // 10) write deepks information
1035+ // ! 9) Write DeePKS information
10361036#ifdef __DEEPKS
10371037 std::shared_ptr<LCAO_Deepks> ld_shared_ptr (&GlobalC::ld, [](LCAO_Deepks*) {});
10381038 LCAO_Deepks_Interface LDI = LCAO_Deepks_Interface (ld_shared_ptr);
@@ -1054,14 +1054,22 @@ void ESolver_KS_LCAO<TK, TR>::after_scf(UnitCell& ucell, const int istep)
10541054 ModuleBase::timer::tick (" ESolver_KS_LCAO" , " out_deepks_labels" );
10551055#endif
10561056
1057+ // ! 10) Perform RDMFT calculations
10571058 /* ******* test RDMFT *********/
10581059 if ( PARAM.inp .rdmft == true ) // rdmft, added by jghan, 2024-10-17
10591060 {
10601061 ModuleBase::matrix occ_number_ks (this ->pelec ->wg );
1061- for (int ik=0 ; ik < occ_number_ks.nr ; ++ik) { for (int inb=0 ; inb < occ_number_ks.nc ; ++inb) occ_number_ks (ik, inb) /= this ->kv .wk [ik]; }
1062+ for (int ik=0 ; ik < occ_number_ks.nr ; ++ik)
1063+ {
1064+ for (int inb=0 ; inb < occ_number_ks.nc ; ++inb)
1065+ {
1066+ occ_number_ks (ik, inb) /= this ->kv .wk [ik];
1067+ }
1068+ }
10621069 this ->rdmft_solver .update_elec (occ_number_ks, *(this ->psi ));
10631070
1064- // initialize the gradients of Etotal on occupation numbers and wfc, and set all elements to 0.
1071+ // ! initialize the gradients of Etotal with respect to occupation numbers and wfc,
1072+ // ! and set all elements to 0.
10651073 ModuleBase::matrix dE_dOccNum (this ->pelec ->wg .nr , this ->pelec ->wg .nc , true );
10661074 psi::Psi<TK> dE_dWfc (this ->psi ->get_nk (), this ->psi ->get_nbands (), this ->psi ->get_nbasis ());
10671075 dE_dWfc.zero_out ();
@@ -1072,7 +1080,7 @@ void ESolver_KS_LCAO<TK, TR>::after_scf(UnitCell& ucell, const int istep)
10721080
10731081
10741082#ifdef __EXX
1075- // 11) write rpa information
1083+ // 11) Write RPA information.
10761084 if (PARAM.inp .rpa )
10771085 {
10781086 // ModuleRPA::DFT_RPA_interface
@@ -1087,7 +1095,7 @@ void ESolver_KS_LCAO<TK, TR>::after_scf(UnitCell& ucell, const int istep)
10871095 }
10881096#endif
10891097
1090- // 12) write HR in npz format
1098+ // 12) write HR in npz format.
10911099 if (PARAM.inp .out_hr_npz )
10921100 {
10931101 this ->p_hamilt ->updateHk (0 ); // first k point, up spin
@@ -1106,7 +1114,7 @@ void ESolver_KS_LCAO<TK, TR>::after_scf(UnitCell& ucell, const int istep)
11061114 }
11071115 }
11081116
1109- // 13) write dm in npz format
1117+ // 13) write density matrix in the ' npz' format.
11101118 if (PARAM.inp .out_dm_npz )
11111119 {
11121120 const elecstate::DensityMatrix<TK, double >* dm
@@ -1121,32 +1129,33 @@ void ESolver_KS_LCAO<TK, TR>::after_scf(UnitCell& ucell, const int istep)
11211129 }
11221130 }
11231131
1124- // 14) output sparse matrix
1132+ // ! 14) Print out information every 'out_interval' steps.
11251133 if (PARAM.inp .calculation != " md" || istep % PARAM.inp .out_interval == 0 )
11261134 {
1135+ // ! Print out sparse matrix
11271136 ModuleIO::output_mat_sparse (PARAM.inp .out_mat_hs2 ,
11281137 PARAM.inp .out_mat_dh ,
11291138 PARAM.inp .out_mat_t ,
11301139 PARAM.inp .out_mat_r ,
11311140 istep,
11321141 this ->pelec ->pot ->get_effective_v (),
11331142 this ->pv ,
1134- this ->GK , // mohan add 2024-04-01
1143+ this ->GK ,
11351144 two_center_bundle_,
11361145 orb_,
11371146 ucell,
1138- GlobalC::GridD, // mohan add 2024-04-06
1147+ GlobalC::GridD,
11391148 this ->kv ,
11401149 this ->p_hamilt );
1141- // mulliken charge analysis
1150+
1151+ // ! Perform Mulliken charge analysis
11421152 if (PARAM.inp .out_mul )
11431153 {
11441154 ModuleIO::cal_mag (&(this ->pv ), this ->p_hamilt , this ->kv , this ->pelec , ucell, istep, true );
11451155 }
11461156 }
11471157
1148- // 15) write atomic magnetization only when spin_constraint is on
1149- // spin constrain calculations.
1158+ // ! 15) Print out atomic magnetization only when 'spin_constraint' is on.
11501159 if (PARAM.inp .sc_mag_switch )
11511160 {
11521161 spinconstrain::SpinConstrain<TK>& sc = spinconstrain::SpinConstrain<TK>::getScInstance ();
@@ -1155,13 +1164,14 @@ void ESolver_KS_LCAO<TK, TR>::after_scf(UnitCell& ucell, const int istep)
11551164 sc.print_Mag_Force (GlobalV::ofs_running);
11561165 }
11571166
1158- // 16) delete grid
1167+ // ! 16) Clean up RA.
1168+ // ! this should be last function and put it in the end, mohan request 2024-11-28
11591169 if (!PARAM.inp .cal_force && !PARAM.inp .cal_stress )
11601170 {
11611171 RA.delete_grid ();
11621172 }
11631173
1164- // 17) write quasi-orbitals, added by Yike Huang .
1174+ // ! 17) Print out quasi-orbitals.
11651175 if (PARAM.inp .qo_switch )
11661176 {
11671177 toQO tqo (PARAM.inp .qo_basis , PARAM.inp .qo_strategy , PARAM.inp .qo_thr , PARAM.inp .qo_screening_coeff );
@@ -1176,6 +1186,7 @@ void ESolver_KS_LCAO<TK, TR>::after_scf(UnitCell& ucell, const int istep)
11761186 tqo.calculate ();
11771187 }
11781188
1189+ // ! 18) Print out kinetic matrix.
11791190 if (PARAM.inp .out_mat_tk [0 ])
11801191 {
11811192 hamilt::HS_Matrix_K<TK> hsk (&pv, true );
@@ -1206,10 +1217,11 @@ void ESolver_KS_LCAO<TK, TR>::after_scf(UnitCell& ucell, const int istep)
12061217 GlobalV::DRANK);
12071218 }
12081219
1220+ // where is new? mohan ask 2024-11-28
12091221 delete ekinetic;
12101222 }
12111223
1212- // add by jingan in 2018.11.7
1224+ // ! 19) Wannier 90 function, added by jingan in 2018.11.7
12131225 if (PARAM.inp .calculation == " nscf" && PARAM.inp .towannier90 )
12141226 {
12151227 std::cout << FmtCore::format (" \n * * * * * *\n << Start %s.\n " , " Wave function to Wannier90" );
@@ -1223,8 +1235,13 @@ void ESolver_KS_LCAO<TK, TR>::after_scf(UnitCell& ucell, const int istep)
12231235 PARAM.inp .nnkpfile ,
12241236 PARAM.inp .wannier_spin );
12251237
1226- myWannier
1227- .calculate (this ->pelec ->ekb , this ->pw_wfc , this ->pw_big , this ->sf , this ->kv , this ->psi , &(this ->pv ));
1238+ myWannier.calculate (this ->pelec ->ekb ,
1239+ this ->pw_wfc ,
1240+ this ->pw_big ,
1241+ this ->sf ,
1242+ this ->kv ,
1243+ this ->psi ,
1244+ &(this ->pv ));
12281245 }
12291246 else if (PARAM.inp .wannier_method == 2 )
12301247 {
@@ -1242,8 +1259,10 @@ void ESolver_KS_LCAO<TK, TR>::after_scf(UnitCell& ucell, const int istep)
12421259 std::cout << FmtCore::format (" >> Finish %s.\n * * * * * *\n " , " Wave function to Wannier90" );
12431260 }
12441261
1245- // add by jingan
1246- if (PARAM.inp .calculation == " nscf" && berryphase::berry_phase_flag && ModuleSymmetry::Symmetry::symm_flag != 1 )
1262+ // ! 20) berry phase calculations, added by jingan
1263+ if (PARAM.inp .calculation == " nscf" &&
1264+ berryphase::berry_phase_flag &&
1265+ ModuleSymmetry::Symmetry::symm_flag != 1 )
12471266 {
12481267 std::cout << FmtCore::format (" \n * * * * * *\n << Start %s.\n " , " Berry phase calculation" );
12491268 berryphase bp (&(this ->pv ));
@@ -1257,11 +1276,6 @@ void ESolver_KS_LCAO<TK, TR>::after_scf(UnitCell& ucell, const int istep)
12571276 }
12581277}
12591278
1260-
1261- // ------------------------------------------------------------------------------
1262- // ! the 20th,21th,22th functions of ESolver_KS_LCAO
1263- // ! mohan add 2024-05-11
1264- // ------------------------------------------------------------------------------
12651279template class ESolver_KS_LCAO <double , double >;
12661280template class ESolver_KS_LCAO <std::complex <double >, double >;
12671281template class ESolver_KS_LCAO <std::complex <double >, std::complex <double >>;
0 commit comments