ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
chg_extra.h
Go to the documentation of this file.
1#ifndef CHG_EXTRA_H
2#define CHG_EXTRA_H
3
4#include <vector>
5
6#include "charge.h"
10#ifdef __MPI
12#endif
13
14namespace module_charge
15{
16
18struct AtomicRhoCfg;
19
40
42{
43 public:
44
46
47 // The displacement and delta-rho arrays record the history of one
48 // molecular-dynamics trajectory; a copy would silently fork that
49 // history. Forbid copies until a deep copy is needed.
50 Charge_Extra(const Charge_Extra&) = delete;
52
67 void Init_CE(const int& nspin, const int& natom, const int& nrxx, const std::string chg_extrap);
68
84 Parallel_Grid* Pgrid,
85 UnitCell& ucell,
86 Charge* chr,
87 const ModulePW::PW_Basis& rhopw,
89 std::ofstream& ofs_running,
90 std::ofstream& ofs_warning,
91 const AtomicRhoCfg& atomic_rho_cfg,
92 const bool has_float_data);
93
102 void update_all_dis(const UnitCell& ucell);
103
113 void update_delta_rho(const UnitCell& ucell,
114 const Charge* chr,
115 const ModulePW::PW_Basis& rhopw,
116 const Structure_Factor* sf,
117 const AtomicRhoCfg& atomic_rho_cfg);
118
119 //==========================================================
120 // Accessors over the extrapolation state. The history buffers and the
121 // step bookkeeping are driven by Init_CE()/extrapolate_charge(); these
122 // expose them for inspection and for seeding a known state, which is
123 // what lets callers exercise one extrapolation order at a time.
124 //==========================================================
125
127 int get_istep() const { return istep; }
128 void set_istep(const int istep_in) { istep = istep_in; }
129
131 int get_pot_order() const { return pot_order; }
132 void set_pot_order(const int pot_order_in) { pot_order = pot_order_in; }
133
136 int get_rho_extr() const { return rho_extr; }
137
139 int get_nspin() const { return nspin; }
140
143 std::vector<ModuleBase::Vector3<double>>& get_dis_old1() { return dis_old1; }
144 std::vector<ModuleBase::Vector3<double>>& get_dis_old2() { return dis_old2; }
145 std::vector<ModuleBase::Vector3<double>>& get_dis_now() { return dis_now; }
146
148 std::vector<std::vector<double>>& get_delta_rho1() { return delta_rho1; }
149 std::vector<std::vector<double>>& get_delta_rho2() { return delta_rho2; }
150 std::vector<std::vector<double>>& get_delta_rho3() { return delta_rho3; }
151
153 double get_alpha() const { return alpha; }
154
156 double get_beta() const { return beta; }
157
161 void find_alpha_and_beta_for_testing(const int& natom,
162 std::ofstream& ofs_running,
163 std::ofstream& ofs_warning)
164 {
165 find_alpha_and_beta(natom, ofs_running, ofs_warning);
166 }
167
168 private:
169 int istep = 0;
172 int nspin;
173
174 std::vector<ModuleBase::Vector3<double>> dis_old1;
175 std::vector<ModuleBase::Vector3<double>> dis_old2;
176 std::vector<ModuleBase::Vector3<double>> dis_now;
177
178 std::vector<std::vector<double>> delta_rho1;
179 std::vector<std::vector<double>> delta_rho2;
180 std::vector<std::vector<double>> delta_rho3;
181
182 double alpha;
183 double beta;
184
192 void find_alpha_and_beta(const int& natom, std::ofstream& ofs_running, std::ofstream& ofs_warning);
193};
194
195} // namespace module_charge
196
197#endif
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
Definition parallel_grid.h:8
Definition stru_fac.h:10
Provide the basic information about unitcell.
Definition unitcell.h:16
Charge_Extra()
Definition chg_extra.cpp:14
int get_rho_extr() const
the extrapolation order actually used this step, which extrapolate_charge() derives from pot_order an...
Definition chg_extra.h:136
int get_nspin() const
the number of spins
Definition chg_extra.h:139
void set_istep(const int istep_in)
Definition chg_extra.h:128
std::vector< ModuleBase::Vector3< double > > dis_now
dis_now = pos_next - pos_now
Definition chg_extra.h:176
void find_alpha_and_beta(const int &natom, std::ofstream &ofs_running, std::ofstream &ofs_warning)
determine alpha and beta
Definition chg_extra.cpp:197
void Init_CE(const int &nspin, const int &natom, const int &nrxx, const std::string chg_extrap)
Initialization of viriables used in charge extrapolation methods.
Definition chg_extra.cpp:18
int nspin
the number of spins
Definition chg_extra.h:172
std::vector< std::vector< double > > & get_delta_rho1()
the last three steps' difference of rho and atomic_rho
Definition chg_extra.h:148
int get_istep() const
the current step
Definition chg_extra.h:127
int get_pot_order() const
the specified charge extrapolation method
Definition chg_extra.h:131
std::vector< ModuleBase::Vector3< double > > dis_old2
dis_old1 = pos_now - pos_old1
Definition chg_extra.h:175
int istep
the current step
Definition chg_extra.h:169
double alpha
parameter used in the second order extrapolation
Definition chg_extra.h:182
std::vector< ModuleBase::Vector3< double > > & get_dis_old2()
Definition chg_extra.h:144
std::vector< ModuleBase::Vector3< double > > & get_dis_now()
Definition chg_extra.h:145
void extrapolate_charge(Parallel_Grid *Pgrid, UnitCell &ucell, Charge *chr, const ModulePW::PW_Basis &rhopw, Structure_Factor *sf, std::ofstream &ofs_running, std::ofstream &ofs_warning, const AtomicRhoCfg &atomic_rho_cfg, const bool has_float_data)
charge extrapolation method
Definition chg_extra.cpp:72
std::vector< std::vector< double > > & get_delta_rho2()
Definition chg_extra.h:149
std::vector< std::vector< double > > delta_rho3
the third last step difference of rho and atomic_rho
Definition chg_extra.h:180
int pot_order
the specified charge extrapolation method
Definition chg_extra.h:170
void update_all_dis(const UnitCell &ucell)
update displacements
Definition chg_extra.cpp:260
double get_alpha() const
parameter used in the second order extrapolation
Definition chg_extra.h:153
Charge_Extra(const Charge_Extra &)=delete
std::vector< std::vector< double > > & get_delta_rho3()
Definition chg_extra.h:150
std::vector< std::vector< double > > delta_rho1
the last step difference of rho and atomic_rho
Definition chg_extra.h:178
Charge_Extra & operator=(const Charge_Extra &)=delete
std::vector< ModuleBase::Vector3< double > > dis_old1
dis_old2 = pos_old1 - pos_old2
Definition chg_extra.h:174
int rho_extr
the actually used method
Definition chg_extra.h:171
void update_delta_rho(const UnitCell &ucell, const Charge *chr, const ModulePW::PW_Basis &rhopw, const Structure_Factor *sf, const AtomicRhoCfg &atomic_rho_cfg)
update the difference of charge density
Definition chg_extra.cpp:282
std::vector< std::vector< double > > delta_rho2
the second last step difference of rho and atomic_rho
Definition chg_extra.h:179
double beta
coefficient for the third delta_rho contribution
Definition chg_extra.h:183
double get_beta() const
coefficient for the third delta_rho contribution
Definition chg_extra.h:156
std::vector< ModuleBase::Vector3< double > > & get_dis_old1()
displacement histories: dis_old2 = pos_old1 - pos_old2, dis_old1 = pos_now - pos_old1,...
Definition chg_extra.h:143
void set_pot_order(const int pot_order_in)
Definition chg_extra.h:132
void find_alpha_and_beta_for_testing(const int &natom, std::ofstream &ofs_running, std::ofstream &ofs_warning)
run find_alpha_and_beta() against the displacement histories currently held, so its solution can be c...
Definition chg_extra.h:161
Charge-density symmetrization free functions.
Definition charge.h:18
Configuration for atomic_rho, replacing GlobalV/PARAM reads.
Definition chg_atomic.h:16