Skip to content

Fix: skip mix_dmr after the last iteration #6331

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions source/source_esolver/esolver_ks_lcao.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -821,11 +821,14 @@ void ESolver_KS_LCAO<TK, TR>::iter_finish(UnitCell& ucell, const int istep, int&
ESolver_KS<TK>::iter_finish(ucell, istep, iter, conv_esolver);

// 5) mix density matrix if mixing_restart + mixing_dmr + not first
// mixing_restart at every iter
if (PARAM.inp.mixing_restart > 0 && this->p_chgmix->mixing_restart_count > 0 && PARAM.inp.mixing_dmr)
// mixing_restart at every iter except the last iter
if(iter != PARAM.inp.scf_nmax && !conv_esolver)
{
elecstate::DensityMatrix<TK, double>* dm = dynamic_cast<elecstate::ElecStateLCAO<TK>*>(this->pelec)->get_DM();
this->p_chgmix->mix_dmr(dm);
if (PARAM.inp.mixing_restart > 0 && this->p_chgmix->mixing_restart_count > 0 && PARAM.inp.mixing_dmr)
{
elecstate::DensityMatrix<TK, double>* dm = dynamic_cast<elecstate::ElecStateLCAO<TK>*>(this->pelec)->get_DM();
this->p_chgmix->mix_dmr(dm);
}
}

// 6) save charge density
Expand Down
2 changes: 1 addition & 1 deletion tests/03_NAO_multik/53_NO_PK_URAMP/result.ref
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
etotref -3376.2723454300949015
etotperatomref -1688.1361727150
totalforceref 36.032716
totalstressref 12211.003288
totalstressref 12211.003182
totaltimeref 2.21
4 changes: 2 additions & 2 deletions tests/03_NAO_multik/54_NO_PK_PU/result.ref
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
etotref -7661.7030524582096405
etotperatomref -1915.4257631146
totalforceref 24.669066
totalstressref 7358.093426
totalforceref 24.663512
totalstressref 7359.638478
totaltimeref 27.05
4 changes: 2 additions & 2 deletions tests/03_NAO_multik/55_NO_PK_PU_S1/result.ref
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
etotref -5909.5419790928954171
etotperatomref -1969.8473263643
totalforceref 955.111693
totalstressref 46844.269362
totalforceref 955.111630
totalstressref 46844.260877
totaltimeref 1.25
4 changes: 2 additions & 2 deletions tests/03_NAO_multik/56_NO_PK_PU_SO/result.ref
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
etotref -6789.2817503491569369
etotperatomref -3394.6408751746
totalforceref 11.329526
totalstressref 4894.902744
totalforceref 11.335196
totalstressref 4892.274915
totaltimeref 4.70
Loading