Skip to content

Commit e291ed0

Browse files
calculate the energy of output density every iteration and output it
1 parent d4540f0 commit e291ed0

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

source/module_esolver/esolver_ks.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -547,13 +547,15 @@ 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;
550556
// add energy threshold for SCF convergence
551557
if (this->scf_ene_thr > 0.0 && iter > 1 && this->conv_esolver == 1) // only check when density is converged
552558
{
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;
557559
// update the convergence flag
558560
this->conv_esolver
559561
= (std::abs(this->pelec->f_en.etot_delta * ModuleBase::Ry_to_eV) < this->scf_ene_thr);

0 commit comments

Comments
 (0)