Skip to content

Commit b612611

Browse files
committed
fix bug of mixing_dmr
1 parent 27229c0 commit b612611

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

source/module_esolver/esolver_ks_lcao.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -826,13 +826,16 @@ void ESolver_KS_LCAO<TK, TR>::iter_finish(UnitCell& ucell, const int istep, int&
826826
ESolver_KS<TK>::iter_finish(ucell, istep, iter, conv_esolver);
827827

828828
// 5) mix density matrix if mixing_restart + mixing_dmr + not first
829+
// don't mix density matrix after the last step of iteration
829830
// mixing_restart at every iter
830-
if (!conv_esolver && PARAM.inp.mixing_restart > 0 && this->p_chgmix->mixing_restart_count > 0 && PARAM.inp.mixing_dmr)
831+
if(iter != PARAM.inp.scf_nmax && !conv_esolver)
831832
{
832-
elecstate::DensityMatrix<TK, double>* dm = dynamic_cast<elecstate::ElecStateLCAO<TK>*>(this->pelec)->get_DM();
833-
this->p_chgmix->mix_dmr(dm);
833+
if (PARAM.inp.mixing_restart > 0 && this->p_chgmix->mixing_restart_count > 0 && PARAM.inp.mixing_dmr)
834+
{
835+
elecstate::DensityMatrix<TK, double>* dm = dynamic_cast<elecstate::ElecStateLCAO<TK>*>(this->pelec)->get_DM();
836+
this->p_chgmix->mix_dmr(dm);
837+
}
834838
}
835-
836839
// 6) save charge density
837840
// Peize Lin add 2020.04.04
838841
if (GlobalC::restart.info_save.save_charge)

0 commit comments

Comments
 (0)