@@ -623,13 +623,15 @@ void ESolver_KS_LCAO<TK, TR>::iter_init(const int istep, const int iter)
623623 // calculate exact-exchange
624624 if (GlobalC::exx_info.info_ri .real_number )
625625 {
626- this ->exd ->exx_eachiterinit (*dynamic_cast <const elecstate::ElecStateLCAO<TK>*>(this ->pelec )->get_DM (),
626+ this ->exd ->exx_eachiterinit (istep,
627+ *dynamic_cast <const elecstate::ElecStateLCAO<TK>*>(this ->pelec )->get_DM (),
627628 this ->kv ,
628629 iter);
629630 }
630631 else
631632 {
632- this ->exc ->exx_eachiterinit (*dynamic_cast <const elecstate::ElecStateLCAO<TK>*>(this ->pelec )->get_DM (),
633+ this ->exc ->exx_eachiterinit (istep,
634+ *dynamic_cast <const elecstate::ElecStateLCAO<TK>*>(this ->pelec )->get_DM (),
633635 this ->kv ,
634636 iter);
635637 }
@@ -912,12 +914,12 @@ void ESolver_KS_LCAO<TK, TR>::update_pot(const int istep, const int iter)
912914// ! 5) cal_MW? (why put it here?)
913915// ------------------------------------------------------------------------------
914916template <typename TK, typename TR>
915- void ESolver_KS_LCAO<TK, TR>::iter_finish(int & iter)
917+ void ESolver_KS_LCAO<TK, TR>::iter_finish(const int istep, int & iter)
916918{
917919 ModuleBase::TITLE (" ESolver_KS_LCAO" , " iter_finish" );
918920
919921 // call iter_finish() of ESolver_KS
920- ESolver_KS<TK>::iter_finish (iter);
922+ ESolver_KS<TK>::iter_finish (istep, iter);
921923
922924 // 1) mix density matrix if mixing_restart + mixing_dmr + not first
923925 // mixing_restart at every iter
@@ -941,7 +943,7 @@ void ESolver_KS_LCAO<TK, TR>::iter_finish(int& iter)
941943 // 3) save exx matrix
942944 int two_level_step = GlobalC::exx_info.info_ri .real_number ? this ->exd ->two_level_step : this ->exc ->two_level_step ;
943945
944- if (GlobalC::restart.info_save .save_H && two_level_step > 0
946+ if (GlobalC::restart.info_save .save_H && ( two_level_step > 0 || istep > 0 )
945947 && (!GlobalC::exx_info.info_global .separate_loop || iter == 1 )) // to avoid saving the same value repeatedly
946948 {
947949 // //////// for Add_Hexx_Type::k
@@ -989,23 +991,27 @@ void ESolver_KS_LCAO<TK, TR>::iter_finish(int& iter)
989991 }
990992 if (GlobalC::exx_info.info_ri .real_number )
991993 {
994+ this ->exd ->dm_last_step = dynamic_cast <const elecstate::ElecStateLCAO<TK>*>(this ->pelec )->get_DM ();
992995 this ->conv_esolver = this ->exd ->exx_after_converge (
993996 *this ->p_hamilt ,
994997 *dynamic_cast <const elecstate::ElecStateLCAO<TK>*>(this ->pelec )->get_DM (),
995998 this ->kv ,
996999 PARAM.inp .nspin ,
9971000 iter,
1001+ istep,
9981002 this ->pelec ->f_en .etot ,
9991003 this ->scf_ene_thr );
10001004 }
10011005 else
10021006 {
1007+ this ->exc ->dm_last_step = dynamic_cast <const elecstate::ElecStateLCAO<TK>*>(this ->pelec )->get_DM ();
10031008 this ->conv_esolver = this ->exc ->exx_after_converge (
10041009 *this ->p_hamilt ,
10051010 *dynamic_cast <const elecstate::ElecStateLCAO<TK>*>(this ->pelec )->get_DM (),
10061011 this ->kv ,
10071012 PARAM.inp .nspin ,
10081013 iter,
1014+ istep,
10091015 this ->pelec ->f_en .etot ,
10101016 this ->scf_ene_thr );
10111017 }
0 commit comments