@@ -547,18 +547,22 @@ void ESolver_KS<T, Device>::runner(const int istep, UnitCell& ucell)
547547
548548 this ->conv_esolver = (drho < this ->scf_thr && not_restart_step && is_U_converged);
549549
550- // calculate energy of output charge density
551- this ->pelec ->cal_energies (2 ); // 2 means Kohn-Sham functional
552- // now, etot_old is the energy of input density, while etot is the energy of output density
553- this ->pelec ->f_en .etot_delta = this ->pelec ->f_en .etot - this ->pelec ->f_en .etot_old ;
554- // output etot_delta
555- GlobalV::ofs_running << " DeltaE_womix = " << this ->pelec ->f_en .etot_delta * ModuleBase::Ry_to_eV << " eV" << std::endl;
556550 // add energy threshold for SCF convergence
557- if (this ->scf_ene_thr > 0.0 && iter > 1 && this -> conv_esolver == 1 ) // only check when density is converged
551+ if (this ->scf_ene_thr > 0.0 )
558552 {
559- // update the convergence flag
560- this ->conv_esolver
561- = (std::abs (this ->pelec ->f_en .etot_delta * ModuleBase::Ry_to_eV) < this ->scf_ene_thr );
553+ // calculate energy of output charge density
554+ this ->update_pot (istep, iter);
555+ this ->pelec ->cal_energies (2 ); // 2 means Kohn-Sham functional
556+ // now, etot_old is the energy of input density, while etot is the energy of output density
557+ this ->pelec ->f_en .etot_delta = this ->pelec ->f_en .etot - this ->pelec ->f_en .etot_old ;
558+ // output etot_delta
559+ GlobalV::ofs_running << " DeltaE_womix = " << this ->pelec ->f_en .etot_delta * ModuleBase::Ry_to_eV << " eV" << std::endl;
560+ if (iter > 1 && this ->conv_esolver == 1 ) // only check when density is converged
561+ {
562+ // update the convergence flag
563+ this ->conv_esolver
564+ = (std::abs (this ->pelec ->f_en .etot_delta * ModuleBase::Ry_to_eV) < this ->scf_ene_thr );
565+ }
562566 }
563567
564568 // If drho < hsolver_error in the first iter or drho < scf_thr, we
0 commit comments