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
8#include "pot_base.h"
9
10#include <vector>
11
12namespace elecstate
13{
47class Potential : public PotBase
48{
49 public:
50 // default constructor for UT
52 // In constructor, size of every potential components should be allocated
53 // rho_basis_in is the dense grids, rho_basis_smooth_in is the smooth grids in USPP
54 // charge density and potential are defined on dense grids,
55 // but eff potential needs to be interpolated on smooth grids in order to compute Veff|psi>
56 // Note: rho_basis_in and rho_basis_smooth_in are the same in NCPP
57 Potential(const ModulePW::PW_Basis* rho_basis_in,
58 const ModulePW::PW_Basis* rho_basis_smooth_in,
59 const UnitCell* ucell_in,
60 const ModuleBase::matrix* vloc_in,
61 Structure_Factor* structure_factors_in,
62 surchem* solvent_in,
63 double* etxc_in,
64 double* vtxc_in,
65 VSep* vsep_cell_in = nullptr);
66 ~Potential();
67
68 // initialize potential when SCF begin
69 void init_pot(const Charge*const chg);
70 // initialize potential components before SCF
71 void pot_register(const std::vector<std::string>& components_list);
72 // update potential from current charge
73 void update_from_charge(const Charge*const chg, const UnitCell*const ucell);
74 // interface for SCF-converged, etxc vtxc for Energy, vnew for force_scc
75 void get_vnew(const Charge* chg, ModuleBase::matrix& vnew);
76
77 PotBase* get_pot_type(const std::string& pot_type);
78
79 // interfaces to get values
81 {
82 return this->v_eff;
83 }
85 {
86 return this->v_eff;
87 }
88
89 double* get_eff_v(int is)
90 {
91 if (this->v_eff.nc > 0)
92 {
93 return &(this->v_eff(is, 0));
94 }
95 else
96 {
97 return nullptr;
98 }
99 }
100 const double* get_eff_v(int is) const
101 {
102 if (this->v_eff.nc > 0)
103 {
104 return &(this->v_eff(is, 0));
105 }
106 else
107 {
108 return nullptr;
109 }
110 }
112 {
113 return this->vofk_eff;
114 }
116 {
117 return this->vofk_eff;
118 }
119 double* get_eff_vofk(int is)
120 {
121 if (this->vofk_eff.nc > 0)
122 {
123 return &(this->vofk_eff(is, 0));
124 }
125 else
126 {
127 return nullptr;
128 }
129 }
130 const double* get_eff_vofk(int is) const
131 {
132 if (this->vofk_eff.nc > 0)
133 {
134 return &(this->vofk_eff(is, 0));
135 }
136 else
137 {
138 return nullptr;
139 }
140 }
141
143 {
144 return this->veff_smooth;
145 }
147 {
148 return this->veff_smooth;
149 }
150
152 {
153 return this->vofk_smooth;
154 }
156 {
157 return this->vofk_smooth;
158 }
159
160 template <typename FPTYPE>
162
163 template <typename FPTYPE>
165
166 double* get_fixed_v()
167 {
168 return this->v_eff_fixed.data();
169 }
170 const double* get_fixed_v() const
171 {
172 return this->v_eff_fixed.data();
173 }
175 {
176 return this->rho_basis_;
177 }
178 // What about adding a function to get the wfc?
179 // This is useful for the calculation of the exx energy
180
181
184 double get_vl_of_0() const
185 {
186 return this->vl_of_0;
187 }
188
191 double get_ml_exx_energy() const;
192
193 private:
194 void cal_v_eff(const Charge*const chg, const UnitCell*const ucell, ModuleBase::matrix& v_eff) override;
195 void cal_fixed_v(double* vl_pseudo) override;
196 // interpolate potential on the smooth mesh if necessary
197 void interpolate_vrs();
198
199 void allocate();
200
201 std::vector<double> v_eff_fixed;
203
204 ModuleBase::matrix veff_smooth; // used in uspp liuyu 2023-10-12
205 ModuleBase::matrix vofk_smooth; // used in uspp liuyu 2023-10-12
206
207 ModuleBase::matrix v_xc; // if PAW is used, vxc must be stored separately
208
209 float *s_veff_smooth = nullptr;
210 float *s_vofk_smooth = nullptr;
211 double *d_veff_smooth = nullptr;
212 double *d_vofk_smooth = nullptr;
213
215
216 bool fixed_done = false;
217
218 // gather etxc and vtxc in Potential, will be used in ESolver
219 double* etxc_ = nullptr;
220 double* vtxc_ = nullptr;
221
222 double vl_of_0 = 0.0;
223
224 std::vector<PotBase*> components;
225
226 const UnitCell* ucell_ = nullptr;
227 const ModuleBase::matrix* vloc_ = nullptr;
229 surchem* solvent_ = nullptr;
230 VSep* vsep_cell = nullptr;
231 bool use_gpu_ = false;
232};
233
234} // namespace elecstate
235
236#endif
Definition charge.h:17
Definition matrix.h:18
int nc
Definition matrix.h:23
A class which can convert a function of "r" to the corresponding linear superposition of plane waves ...
Definition pw_basis.h:56
Definition structure_factor.h:10
Definition unitcell.h:15
Definition vsep_pw.h:12
Definition pot_base.h:22
const ModulePW::PW_Basis * rho_basis_
Definition pot_base.h:37
Definition potential_new.h:48
ModuleBase::matrix veff_smooth
Definition potential_new.h:204
double vl_of_0
Definition potential_new.h:222
~Potential()
Definition potential_new.cpp:41
bool use_gpu_
Definition potential_new.h:231
bool fixed_done
Definition potential_new.h:216
void get_vnew(const Charge *chg, ModuleBase::matrix &vnew)
Definition potential_new.cpp:265
std::vector< PotBase * > components
Definition potential_new.h:224
const double * get_eff_vofk(int is) const
Definition potential_new.h:130
const double * get_eff_v(int is) const
Definition potential_new.h:100
const ModuleBase::matrix & get_eff_vofk() const
Definition potential_new.h:115
void allocate()
Definition potential_new.cpp:94
const ModuleBase::matrix & get_vofk_smooth() const
Definition potential_new.h:155
void init_pot(const Charge *const chg)
Definition potential_new.cpp:251
surchem * solvent_
Definition potential_new.h:229
ModuleBase::matrix & get_veff_smooth()
Definition potential_new.h:142
Structure_Factor * structure_factors_
Definition potential_new.h:228
ModuleBase::matrix & get_eff_vofk()
Definition potential_new.h:111
const ModuleBase::matrix * vloc_
Definition potential_new.h:227
Potential()
Definition potential_new.h:51
void pot_register(const std::vector< std::string > &components_list)
Definition potential_new.cpp:65
ModuleBase::matrix v_eff
Definition potential_new.h:202
ModuleBase::matrix vofk_eff
Definition potential_new.h:214
float * s_vofk_smooth
Definition potential_new.h:210
ModuleBase::matrix & get_vofk_smooth()
Definition potential_new.h:151
float * s_veff_smooth
Definition potential_new.h:209
const UnitCell * ucell_
Definition potential_new.h:226
ModuleBase::matrix vofk_smooth
Definition potential_new.h:205
PotBase * get_pot_type(const std::string &pot_type)
Definition potential_types.cpp:25
const double * get_fixed_v() const
Definition potential_new.h:170
void cal_v_eff(const Charge *const chg, const UnitCell *const ucell, ModuleBase::matrix &v_eff) override
Definition potential_new.cpp:218
FPTYPE * get_veff_smooth_data()
const ModuleBase::matrix & get_eff_v() const
Definition potential_new.h:84
ModuleBase::matrix v_xc
Definition potential_new.h:207
double get_ml_exx_energy() const
get the ML-EXX energy, avoiding static variable
Definition potential_new.cpp:346
double * get_eff_v(int is)
Definition potential_new.h:89
const ModuleBase::matrix & get_veff_smooth() const
Definition potential_new.h:146
double * etxc_
Definition potential_new.h:219
double * d_veff_smooth
Definition potential_new.h:211
void cal_fixed_v(double *vl_pseudo) override
Definition potential_new.cpp:201
double * get_eff_vofk(int is)
Definition potential_new.h:119
void update_from_charge(const Charge *const chg, const UnitCell *const ucell)
Definition potential_new.cpp:159
double * d_vofk_smooth
Definition potential_new.h:212
double get_vl_of_0() const
get the value of vloc at G=0;
Definition potential_new.h:184
void interpolate_vrs()
Definition potential_new.cpp:281
const ModulePW::PW_Basis * get_rho_basis() const
Definition potential_new.h:174
double * vtxc_
Definition potential_new.h:220
ModuleBase::matrix & get_eff_v()
Definition potential_new.h:80
FPTYPE * get_vofk_smooth_data()
std::vector< double > v_eff_fixed
Definition potential_new.h:201
double * get_fixed_v()
Definition potential_new.h:166
VSep * vsep_cell
Definition potential_new.h:230
Definition surchem.h:13
Definition read_atoms_helper_test.cpp:11