ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
potential_new.h
Go to the documentation of this file.
1#ifndef POTENTIALNEW_H
2#define POTENTIALNEW_H
3
4#include "pot_base.h"
9
10#include <iosfwd>
11#include <memory>
12#include <vector>
13
14struct Input_para;
15
16namespace elecstate
17{
18class PotPcc;
19class PotSccs;
20struct SolventGridField;
21struct SccsResume;
22class TDFieldManager;
23
57class Potential : public PotBase
58{
59 public:
60 // default constructor for UT
62 // In constructor, size of every potential components should be allocated
63 // rho_basis_in is the dense grids, rho_basis_smooth_in is the smooth grids in USPP
64 // charge density and potential are defined on dense grids,
65 // but eff potential needs to be interpolated on smooth grids in order to compute Veff|psi>
66 // Note: rho_basis_in and rho_basis_smooth_in are the same in NCPP
67 Potential(const ModulePW::PW_Basis* rho_basis_in,
68 const ModulePW::PW_Basis* rho_basis_smooth_in,
69 const UnitCell* ucell_in,
70 const ModuleBase::matrix* vloc_in,
71 Structure_Factor* structure_factors_in,
72 surchem* solvent_in,
73 double* etxc_in,
74 double* vtxc_in,
75 VSep* vsep_cell_in = nullptr);
76 ~Potential();
77
78 // initialize potential when SCF begin
79 void init_pot(const Charge* const chg);
80 // initialize potential components before SCF
81 void pot_register(const std::vector<std::string>& components_list);
82 void pot_register(const std::vector<std::string>& components_list, const Input_para& input);
83 // update potential from current charge
84 void update_from_charge(const Charge* const chg, const UnitCell* const ucell);
85 // interface for SCF-converged, etxc vtxc for Energy, vnew for force_scc
86 void get_vnew(const Charge* chg, ModuleBase::matrix& vnew);
87
88 // resume is the SCCS state of the previous ionic step, used by "sccs" only.
89 PotBase* get_pot_type(const std::string& pot_type, const Input_para& input, const SccsResume& resume);
90
93 bool model_pending() const;
97 bool update_model(int electronic_iteration, double density_residual, std::ostream* log);
99 void write_corr_iter(std::ostream& output, int level, double residual) const;
100 // Solvation terms of the registered components; not PotBase overrides, so
101 // modules that stub Potential need not know about solvation.
102 void sum_sol_energy(double& electrostatic, double& non_electrostatic) const;
103 void sum_sol_force(const UnitCell& cell, ModuleBase::matrix& force) const;
104 const std::vector<double>* find_sol_pot() const;
106 std::vector<SolventGridField> sol_out_fields() const;
107
109 const TDFieldManager* td_field_manager() const { return td_field_manager_.get(); }
110
116 void set_td_field_manager(const std::shared_ptr<TDFieldManager>& field_manager)
117 {
118 this->td_field_manager_ = field_manager;
119 }
120
121 // interfaces to get values
123 {
124 return this->v_eff;
125 }
127 {
128 return this->v_eff;
129 }
130
131 double* get_eff_v(int is)
132 {
133 if (this->v_eff.nc > 0)
134 {
135 return &(this->v_eff(is, 0));
136 }
137 else
138 {
139 return nullptr;
140 }
141 }
142 const double* get_eff_v(int is) const
143 {
144 if (this->v_eff.nc > 0)
145 {
146 return &(this->v_eff(is, 0));
147 }
148 else
149 {
150 return nullptr;
151 }
152 }
154 {
155 return this->vofk_eff;
156 }
158 {
159 return this->vofk_eff;
160 }
161 double* get_eff_vofk(int is)
162 {
163 if (this->vofk_eff.nc > 0)
164 {
165 return &(this->vofk_eff(is, 0));
166 }
167 else
168 {
169 return nullptr;
170 }
171 }
172 const double* get_eff_vofk(int is) const
173 {
174 if (this->vofk_eff.nc > 0)
175 {
176 return &(this->vofk_eff(is, 0));
177 }
178 else
179 {
180 return nullptr;
181 }
182 }
183
185 {
186 return this->veff_smooth;
187 }
189 {
190 return this->veff_smooth;
191 }
192
194 {
195 return this->vofk_smooth;
196 }
198 {
199 return this->vofk_smooth;
200 }
201
202 template <typename FPTYPE>
204
205 template <typename FPTYPE>
207
208 double* get_fixed_v()
209 {
210 return this->v_eff_fixed.data();
211 }
212 const double* get_fixed_v() const
213 {
214 return this->v_eff_fixed.data();
215 }
217 {
218 return this->rho_basis_;
219 }
220 const UnitCell* get_ucell() const
221 {
222 return this->ucell_;
223 }
224 // get the local pseudopotential vloc(it, G) table; used by the dH module (out_mat_dh_vl)
226 {
227 return this->vloc_;
228 }
229 // What about adding a function to get the wfc?
230 // This is useful for the calculation of the exx energy
231
234 double get_vl_of_0() const
235 {
236 return this->vl_of_0;
237 }
238
241 double get_ml_exx_energy() const;
242
245 double pcc_energy_rydberg() const;
246 const std::vector<double>* pcc_electron_potential() const;
247 void add_pcc_force(const UnitCell& cell, ModuleBase::matrix& force) const;
248
249 private:
250 void cal_v_eff(const Charge* const chg, const UnitCell* const ucell, ModuleBase::matrix& v_eff) override;
251 void cal_fixed_v(double* vl_pseudo) override;
252 // interpolate potential on the smooth mesh if necessary
253 void interpolate_vrs();
254
255 void allocate();
256
257 // the registered PCC component, or nullptr when PCC is off
258 const PotPcc* pcc_component() const;
259 const PotSccs* sccs_component() const;
261 // The SCCS activation and warm start of an earlier ionic step are passed
262 // to the rebuilt component.
263 PotBase* make_sccs_pot(const Input_para& input, const SccsResume& resume);
264 SccsResume get_resume() const;
265
266 std::vector<double> v_eff_fixed;
268
269 ModuleBase::matrix veff_smooth; // used in uspp liuyu 2023-10-12
270 ModuleBase::matrix vofk_smooth; // used in uspp liuyu 2023-10-12
271
272 ModuleBase::matrix v_xc; // if PAW is used, vxc must be stored separately
273
274 float* s_veff_smooth = nullptr;
275 float* s_vofk_smooth = nullptr;
276 double* d_veff_smooth = nullptr;
277 double* d_vofk_smooth = nullptr;
278
280
281 bool fixed_done = false;
282
283 // gather etxc and vtxc in Potential, will be used in ESolver
284 double* etxc_ = nullptr;
285 double* vtxc_ = nullptr;
286
287 double vl_of_0 = 0.0;
288
289 std::vector<PotBase*> components;
290
291 const UnitCell* ucell_ = nullptr;
292 const ModuleBase::matrix* vloc_ = nullptr;
294 surchem* solvent_ = nullptr;
295 VSep* vsep_cell = nullptr;
296 bool use_gpu_ = false;
297 std::shared_ptr<TDFieldManager> td_field_manager_;
298};
299
300} // namespace elecstate
301
302#endif
Definition charge.h:24
Definition matrix.h:15
A class which can convert a function of "r" to the corresponding linear superposition of plane waves ...
Definition pw_basis.h:60
Definition stru_fac.h:10
Provide the basic information about unitcell.
Definition unitcell.h:16
Definition vsep_pw.h:12
Definition pot_base.h:24
const ModulePW::PW_Basis * rho_basis_
Definition pot_base.h:52
PotBase()
Definition pot_base.h:26
Self-consistent vacuum point-counter-charge (PCC) correction.
Definition pot_pcc.h:48
Definition pot_sccs.h:46
ModuleBase::matrix veff_smooth
Definition potential_new.h:269
SccsResume get_resume() const
Definition potential_sccs.cpp:61
double vl_of_0
Definition potential_new.h:287
~Potential()
Definition potential_new.cpp:42
PotBase * get_pot_type(const std::string &pot_type, const Input_para &input, const SccsResume &resume)
Definition potential_types.cpp:46
bool use_gpu_
Definition potential_new.h:296
bool fixed_done
Definition potential_new.h:281
double pcc_energy_rydberg() const
Definition potential_new.cpp:382
void get_vnew(const Charge *chg, ModuleBase::matrix &vnew)
Definition potential_new.cpp:271
std::vector< PotBase * > components
Definition potential_new.h:289
const double * get_eff_vofk(int is) const
Definition potential_new.h:172
std::vector< SolventGridField > sol_out_fields() const
Implicit-solvent fields of the registered components, for out_sol.
Definition potential_new.cpp:443
const double * get_eff_v(int is) const
Definition potential_new.h:142
const ModuleBase::matrix & get_eff_vofk() const
Definition potential_new.h:157
void allocate()
Definition potential_new.cpp:103
const ModuleBase::matrix & get_vofk_smooth() const
Definition potential_new.h:197
std::shared_ptr< TDFieldManager > td_field_manager_
Definition potential_new.h:297
void init_pot(const Charge *const chg)
Definition potential_new.cpp:257
surchem * solvent_
Definition potential_new.h:294
void sum_sol_force(const UnitCell &cell, ModuleBase::matrix &force) const
Definition potential_new.cpp:411
void add_pcc_force(const UnitCell &cell, ModuleBase::matrix &force) const
Definition potential_new.cpp:402
ModuleBase::matrix & get_veff_smooth()
Definition potential_new.h:184
Structure_Factor * structure_factors_
Definition potential_new.h:293
ModuleBase::matrix & get_eff_vofk()
Definition potential_new.h:153
const ModuleBase::matrix * vloc_
Definition potential_new.h:292
bool update_model(int electronic_iteration, double density_residual, std::ostream *log)
Definition potential_sccs.cpp:8
Potential()
Definition potential_new.h:61
void pot_register(const std::vector< std::string > &components_list)
Definition potential_new.cpp:66
ModuleBase::matrix v_eff
Definition potential_new.h:267
const UnitCell * get_ucell() const
Definition potential_new.h:220
bool model_pending() const
Definition potential_sccs.cpp:24
ModuleBase::matrix vofk_eff
Definition potential_new.h:279
float * s_vofk_smooth
Definition potential_new.h:275
const PotSccs * sccs_component() const
Definition potential_sccs.cpp:42
ModuleBase::matrix & get_vofk_smooth()
Definition potential_new.h:193
float * s_veff_smooth
Definition potential_new.h:274
void set_td_field_manager(const std::shared_ptr< TDFieldManager > &field_manager)
Inject the shared RT-TDDFT field state before potential setup.
Definition potential_new.h:116
const std::vector< double > * find_sol_pot() const
Definition potential_new.cpp:433
const UnitCell * ucell_
Definition potential_new.h:291
ModuleBase::matrix vofk_smooth
Definition potential_new.h:270
const double * get_fixed_v() const
Definition potential_new.h:212
void cal_v_eff(const Charge *const chg, const UnitCell *const ucell, ModuleBase::matrix &v_eff) override
Definition potential_new.cpp:224
FPTYPE * get_veff_smooth_data()
const std::vector< double > * pcc_electron_potential() const
Definition potential_new.cpp:392
const PotPcc * pcc_component() const
Definition potential_new.cpp:369
const ModuleBase::matrix & get_eff_v() const
Definition potential_new.h:126
ModuleBase::matrix v_xc
Definition potential_new.h:272
const TDFieldManager * td_field_manager() const
Read the shared RT-TDDFT field state.
Definition potential_new.h:109
double get_ml_exx_energy() const
get the ML-EXX energy, avoiding static variable
Definition potential_new.cpp:352
double * get_eff_v(int is)
Definition potential_new.h:131
void sum_sol_energy(double &electrostatic, double &non_electrostatic) const
Definition potential_new.cpp:419
const ModuleBase::matrix * get_vloc() const
Definition potential_new.h:225
const ModuleBase::matrix & get_veff_smooth() const
Definition potential_new.h:188
double * etxc_
Definition potential_new.h:284
double * d_veff_smooth
Definition potential_new.h:276
void cal_fixed_v(double *vl_pseudo) override
Definition potential_new.cpp:207
double * get_eff_vofk(int is)
Definition potential_new.h:161
void update_from_charge(const Charge *const chg, const UnitCell *const ucell)
Definition potential_new.cpp:168
double * d_vofk_smooth
Definition potential_new.h:277
double get_vl_of_0() const
get the value of vloc at G=0;
Definition potential_new.h:234
PotBase * make_sccs_pot(const Input_para &input, const SccsResume &resume)
Definition potential_types.cpp:25
void interpolate_vrs()
Definition potential_new.cpp:287
const ModulePW::PW_Basis * get_rho_basis() const
Definition potential_new.h:216
double * vtxc_
Definition potential_new.h:285
void write_corr_iter(std::ostream &output, int level, double residual) const
sccs_debug output of the SCCS correction.
Definition potential_sccs.cpp:30
ModuleBase::matrix & get_eff_v()
Definition potential_new.h:122
FPTYPE * get_vofk_smooth_data()
std::vector< double > v_eff_fixed
Definition potential_new.h:266
double * get_fixed_v()
Definition potential_new.h:208
VSep * vsep_cell
Definition potential_new.h:295
Own and advance all time-dependent electric fields in RT-TDDFT.
Definition td_field_manager.h:36
Definition output.h:13
Definition surchem.h:34
Definition read_atoms_hlp_test.cpp:13
Definition input_parameter.h:13
Definition pot_sccs.h:38
Definition sol_grid_field.h:12
Input_para input
Definition test_io_sys_var.cpp:58