ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
chg_mix.h
Go to the documentation of this file.
1#ifndef CHG_MIX_H
2#define CHG_MIX_H
3#include "charge.h"
4#include "chg_mix_cfg.h"
7#include <functional>
8#include <memory>
9
11{
23
24 public:
27
36 void set_mixing(const MixingConfig& cfg,
37 ModulePW::PW_Basis* rhopw_in,
38 ModulePW::PW_Basis* rhodpw_in,
39 double& omega_in,
40 double& tpiba_in);
41
52 void init_mixing();
53
58 void mix_rho(Charge* chr);
59
64 void allocate_mixing_uom(int size_uom);
65
71 void mix_uom(std::vector<double>& uom_in, std::vector<double>& uom_save_in);
72
76 void mix_reset();
77
79 void reset_scf_history(int iter_limit);
80
87 void restart_for_new_model(const int iter);
88
89 // extracting parameters normally these parameters will not be used outside charge mixing
90 // while Exx is using them as well as some other places
91 const std::string& get_mixing_mode() const {return cfg_.mixing_mode;}
92 double get_mixing_beta() const {return cfg_.mixing_beta;}
93 int get_mixing_ndim() const {return cfg_.mixing_ndim;}
94 Base_Mixing::Mixing* get_mixing() const {return mixing.get();}
95
103
112
117
121 const MixingConfig& get_mixing_config() const {return cfg_;}
122
132 void set_mixing_config(const MixingConfig& cfg) {cfg_ = cfg;}
133
134 // for mixing restart
141
142 // to calculate the slope of drho curve during SCF, which is used to determine if SCF oscillate
143 bool if_scf_oscillate(const int iteration, const double drho,
144 const int iternum_used, const double threshold);
145
146 private:
147
148 // mixing_data
150 std::unique_ptr<Base_Mixing::Mixing> mixing;
155 std::unique_ptr<Base_Mixing::Plain_Mixing> mixing_highf;
156
157 //======================================
158 // private mixing parameters
159 //======================================
161 double* omega = nullptr;
162 double* tpiba = nullptr;
163 std::vector<double> _drho_history;
164
167
173 bool kerker_disabled_ = false;
174
179 void mix_rho_recip(Charge* chr);
180
185 void mix_rho_real(Charge* chr);
186};
187
188#endif
data for Mixing class
Definition mixing_data.h:14
Mixing class can mixing different steps of data to solver the iteration problem. For equation x = f(x...
Definition mixing.h:19
Base_Mixing::Mixing_Data rho_mdata
Mixing data for charge density.
Definition chg_mix.h:151
int mixing_restart_step
which step to restart mixing during SCF
Definition chg_mix.h:136
Base_Mixing::Mixing_Data uom_mdata
Mixing data for DFT+U occupation matrix.
Definition chg_mix.h:154
void set_mixing(const MixingConfig &cfg, ModulePW::PW_Basis *rhopw_in, ModulePW::PW_Basis *rhodpw_in, double &omega_in, double &tpiba_in)
Set all private mixing parameters from an aggregated config.
Definition chg_mix.cpp:28
std::unique_ptr< Base_Mixing::Mixing > mixing
Mixing object for charge and kinetic energy.
Definition chg_mix.h:150
void mix_reset()
reset mixing, actually we only call init_mixing() to reset mixing instead of this function
Definition chg_mix.cpp:193
double * tpiba
2*pi/beta for non-linear core correction
Definition chg_mix.h:162
void mix_rho_real(Charge *chr)
charge mixing for real space
Definition chg_mix_rho.cpp:253
~Charge_Mixing()
Definition chg_mix.cpp:23
int mixing_restart_last
the label of mixing restart step
Definition chg_mix.h:140
const MixingConfig & get_mixing_config() const
read-only access to the aggregated mixing config set by set_mixing()
Definition chg_mix.h:121
int get_mixing_ndim() const
Definition chg_mix.h:93
void mix_rho(Charge *chr)
charge mixing
Definition chg_mix_rho.cpp:378
double * omega
omega for non-linear core correction
Definition chg_mix.h:161
int mixing_restart_count
the number of restart mixing during SCF
Definition chg_mix.h:138
void restart_for_new_model(const int iter)
restart mixing after the potential model changed during the SCF (SCCS delayed start)
Definition chg_mix.cpp:216
Charge_Mixing()
Definition chg_mix.cpp:18
ModulePW::PW_Basis * rhodpw
dense grid, same as rhopw for ncpp.
Definition chg_mix.h:166
void set_mixing_config(const MixingConfig &cfg)
replace the aggregated mixing config without re-running set_mixing()
Definition chg_mix.h:132
Base_Mixing::Mixing_Data & get_dmr_mdata()
mutable access to the real-space density-matrix mixing history
Definition chg_mix.h:102
MixingConfig cfg_
aggregated mixing config, also holds nspin/scf_thr_type/double_grid
Definition chg_mix.h:160
Base_Mixing::Mixing_Data & get_tau_mdata()
mutable access to the kinetic-energy-density mixing history
Definition chg_mix.h:116
bool if_scf_oscillate(const int iteration, const double drho, const int iternum_used, const double threshold)
Definition chg_mix.cpp:222
std::vector< double > _drho_history
Residual history for oscillation detection, sized to the active SCF limit.
Definition chg_mix.h:163
void allocate_mixing_uom(int size_uom)
allocate memory of uom_mdata
Definition chg_mix.cpp:294
Base_Mixing::Mixing * get_mixing() const
Definition chg_mix.h:94
Base_Mixing::Mixing_Data dmr_mdata
Mixing data for real space density matrix.
Definition chg_mix.h:153
std::unique_ptr< Base_Mixing::Plain_Mixing > mixing_highf
The high_frequency part is mixed by plain mixing method.
Definition chg_mix.h:155
double get_mixing_beta() const
Definition chg_mix.h:92
ModulePW::PW_Basis * rhopw
smooth grid
Definition chg_mix.h:165
void init_mixing()
initialize mixing, including constructing mixing and allocating memory for mixing data
Definition chg_mix.cpp:100
void reset_scf_history(int iter_limit)
Reset restart counters and residual history for an independently limited SCF trial.
Definition chg_mix.cpp:208
bool kerker_disabled_
Definition chg_mix.h:173
const std::string & get_mixing_mode() const
Definition chg_mix.h:91
void close_kerker_gg0()
Definition chg_mix.h:47
Base_Mixing::Mixing_Data tau_mdata
Mixing data for kinetic energy density.
Definition chg_mix.h:152
Base_Mixing::Mixing_Data & get_rho_mdata()
mutable access to the charge-density mixing history
Definition chg_mix.h:111
void mix_uom(std::vector< double > &uom_in, std::vector< double > &uom_save_in)
DFT+U occupation matrix mixing.
Definition chg_mix.cpp:307
void mix_rho_recip(Charge *chr)
charge mixing for reciprocal space
Definition chg_mix_rho.cpp:14
Definition charge.h:24
A class which can convert a function of "r" to the corresponding linear superposition of plane waves ...
Definition pw_basis.h:60
#define threshold
Definition sph_bessel_rec_test.cpp:4
Definition chg_mix_cfg.h:12