@@ -589,10 +589,20 @@ void ESolver_KS_PW<T, Device>::iter_finish(UnitCell& ucell, const int istep, int
589589 auto start = std::chrono::high_resolution_clock::now ();
590590 exx_helper.set_firstiter (false );
591591 exx_helper.op_exx ->first_iter = false ;
592+ double dexx = 0.0 ;
593+ if (PARAM.inp .exx_thr_type == " energy" )
594+ {
595+ dexx = exx_helper.cal_exx_energy (this ->kspw_psi );
596+ }
592597 exx_helper.set_psi (this ->kspw_psi );
598+ if (PARAM.inp .exx_thr_type == " energy" )
599+ {
600+ dexx -= exx_helper.cal_exx_energy (this ->kspw_psi );
601+ // std::cout << "dexx = " << dexx << std::endl;
602+ }
603+ bool conv_ene = std::abs (dexx) < PARAM.inp .exx_ene_thr ;
593604
594- conv_esolver = exx_helper.exx_after_converge (iter);
595-
605+ conv_esolver = exx_helper.exx_after_converge (iter, conv_ene);
596606 if (!conv_esolver)
597607 {
598608 auto duration = std::chrono::high_resolution_clock::now () - start;
@@ -602,6 +612,7 @@ void ESolver_KS_PW<T, Device>::iter_finish(UnitCell& ucell, const int istep, int
602612 exx_helper.op_exx ->first_iter = false ;
603613 XC_Functional::set_xc_type (ucell.atoms [0 ].ncpp .xc_func );
604614 update_pot (ucell, istep, iter, conv_esolver);
615+ exx_helper.iter_inc ();
605616 }
606617 }
607618 }
@@ -614,8 +625,9 @@ void ESolver_KS_PW<T, Device>::iter_finish(UnitCell& ucell, const int istep, int
614625 // ----------------------------------------------------------
615626 // 3) Print out electronic wavefunctions in pw basis
616627 // ----------------------------------------------------------
617- if (iter % PARAM.inp .out_freq_elec == 0 || iter == PARAM.inp .scf_nmax || conv_esolver )
628+ if (iter % PARAM.inp .out_freq_elec == 0 || iter == PARAM.inp .scf_nmax )
618629 {
630+ // conv_esolver == true has already been dealt with in after_scf
619631 ModuleIO::write_wfc_pw (GlobalV::KPAR,
620632 GlobalV::MY_POOL,
621633 GlobalV::MY_RANK,
0 commit comments