Skip to content
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
12 changes: 6 additions & 6 deletions source/module_elecstate/module_charge/charge_mixing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1708,11 +1708,6 @@ bool Charge_Mixing::if_scf_oscillate(const int iteration, const double drho, con
ModuleBase::TITLE("Charge_Mixing", "if_scf_oscillate");
ModuleBase::timer::tick("Charge_Mixing", "if_scf_oscillate");

if(threshold >= 0) // close the function
{
return false;
}

if(this->_drho_history.size() == 0)
{
this->_drho_history.resize(PARAM.inp.scf_nmax);
Expand All @@ -1721,8 +1716,13 @@ bool Charge_Mixing::if_scf_oscillate(const int iteration, const double drho, con
// add drho into history
this->_drho_history[iteration - 1] = drho;

if(threshold >= 0) // close the function
{
return false;
}

// check if the history is long enough
if(iteration < iternum_used)
if(iteration < iternum_used + this->mixing_restart_last)
{
return false;
}
Expand Down
3 changes: 2 additions & 1 deletion source/module_elecstate/module_charge/charge_mixing.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,9 @@ class Charge_Mixing
Base_Mixing::Mixing* get_mixing() const {return mixing;}

// for mixing restart
int mixing_restart_step = 0; //which step to restart mixing during SCF
int mixing_restart_step = 0; //which step to restart mixing during SCF, always equal to scf_namx except for the mixing restart
int mixing_restart_count = 0; // the number of restart mixing during SCF. Do not set mixing_restart_count as bool since I want to keep some flexibility in the future
int mixing_restart_last = 0; // the label of mixing restart step, store the step number of the last mixing restart

// to calculate the slope of drho curve during SCF, which is used to determine if SCF oscillate
bool if_scf_oscillate(const int iteration, const double drho, const int iternum_used, const double threshold);
Expand Down
1 change: 1 addition & 0 deletions source/module_esolver/esolver_ks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,7 @@ void ESolver_KS<T, Device>::iter_finish(const int istep, int& iter)
// notice for restart
if (PARAM.inp.mixing_restart > 0 && iter == this->p_chgmix->mixing_restart_step - 1 && iter != PARAM.inp.scf_nmax)
{
this->p_chgmix->mixing_restart_last = iter;
std::cout << " SCF restart after this step!" << std::endl;
}
}
Expand Down
Loading