Skip to content

Commit 8f69fa2

Browse files
add the energy threshold for SCF before mix_rho
1 parent 4e53045 commit 8f69fa2

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

source/module_esolver/esolver_ks.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,18 @@ 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+
// add energy threshold for SCF convergence
551+
if (this->scf_ene_thr > 0.0 && iter > 1 && this->conv_esolver == 1) // only check when density is converged
552+
{
553+
// only calculate energy when density is converged to reduce the time cost
554+
this->pelec->cal_energies(2); // 2 means Kohn-Sham functional
555+
// now, etot_old is the energy of input density, while etot is the energy of output density
556+
this->pelec->f_en.etot_delta = this->pelec->f_en.etot - this->pelec->f_en.etot_old;
557+
// update the convergence flag
558+
this->conv_esolver
559+
= (std::abs(this->pelec->f_en.etot_delta * ModuleBase::Ry_to_eV) < this->scf_ene_thr);
560+
}
561+
550562
// If drho < hsolver_error in the first iter or drho < scf_thr, we
551563
// do not change rho.
552564
if (drho < hsolver_error || this->conv_esolver)

0 commit comments

Comments
 (0)