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 effective 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 ~Potential();
66
67 // initialize potential when SCF begin
68 void init_pot(int istep, const Charge*const chg);
69 // initialize potential components before SCF
70 void pot_register(const std::vector<std::string>& components_list);
71 // update potential from current charge
72 void update_from_charge(const Charge*const chg, const UnitCell*const ucell);
73 // interface for SCF-converged, etxc vtxc for Energy, vnew for force_scc
74 void get_vnew(const Charge* chg, ModuleBase::matrix& vnew);
75
76 PotBase* get_pot_type(const std::string& pot_type);
77
78 // interfaces to get values
80 {
81 return this->v_effective;
82 }
84 {
85 return this->v_effective;
86 }
87
88 double* get_effective_v(int is)
89 {
90 if (this->v_effective.nc > 0)
91 {
92 return &(this->v_effective(is, 0));
93 }
94 else
95 {
96 return nullptr;
97 }
98 }
99 const double* get_effective_v(int is) const
100 {
101 if (this->v_effective.nc > 0)
102 {
103 return &(this->v_effective(is, 0));
104 }
105 else
106 {
107 return nullptr;
108 }
109 }
111 {
112 return this->vofk_effective;
113 }
115 {
116 return this->vofk_effective;
117 }
118 double* get_effective_vofk(int is)
119 {
120 if (this->vofk_effective.nc > 0)
121 {
122 return &(this->vofk_effective(is, 0));
123 }
124 else
125 {
126 return nullptr;
127 }
128 }
129 const double* get_effective_vofk(int is) const
130 {
131 if (this->vofk_effective.nc > 0)
132 {
133 return &(this->vofk_effective(is, 0));
134 }
135 else
136 {
137 return nullptr;
138 }
139 }
140
142 {
143 return this->veff_smooth;
144 }
146 {
147 return this->veff_smooth;
148 }
149
151 {
152 return this->vofk_smooth;
153 }
155 {
156 return this->vofk_smooth;
157 }
158
159 template <typename FPTYPE>
161
162 template <typename FPTYPE>
164
165 double* get_fixed_v()
166 {
167 return this->v_effective_fixed.data();
168 }
169 const double* get_fixed_v() const
170 {
171 return this->v_effective_fixed.data();
172 }
174 {
175 return this->rho_basis_;
176 }
177 // What about adding a function to get the wfc?
178 // This is useful for the calculation of the exx energy
179
180
183 double get_vl_of_0() const
184 {
185 return this->vl_of_0;
186 }
187
188 private:
189 void cal_v_eff(const Charge*const chg, const UnitCell*const ucell, ModuleBase::matrix& v_eff) override;
190 void cal_fixed_v(double* vl_pseudo) override;
191 // interpolate potential on the smooth mesh if necessary
192 void interpolate_vrs();
193
194 void allocate();
195
196 std::vector<double> v_effective_fixed;
198
199 ModuleBase::matrix veff_smooth; // used in uspp liuyu 2023-10-12
200 ModuleBase::matrix vofk_smooth; // used in uspp liuyu 2023-10-12
201
202 ModuleBase::matrix v_xc; // if PAW is used, vxc must be stored separately
203
204 float *s_veff_smooth = nullptr, *s_vofk_smooth = nullptr;
205 double *d_veff_smooth = nullptr, *d_vofk_smooth = nullptr;
206
208
209 bool fixed_done = false;
210
211 // gather etxc and vtxc in Potential, will be used in ESolver
212 double* etxc_ = nullptr;
213 double* vtxc_ = nullptr;
214
215 double vl_of_0 = 0.0;
216
217 std::vector<PotBase*> components;
218
219 const UnitCell* ucell_ = nullptr;
220 const ModuleBase::matrix* vloc_ = nullptr;
222 surchem* solvent_ = nullptr;
223 bool use_gpu_ = false;
224};
225
226} // namespace elecstate
227
228#endif
Definition charge.h:20
Definition matrix.h:19
int nc
Definition matrix.h:24
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:11
Definition unitcell.h:16
Definition pot_base.h:22
const ModulePW::PW_Basis * rho_basis_
Definition pot_base.h:35
Definition potential_new.h:48
ModuleBase::matrix veff_smooth
Definition potential_new.h:199
const ModuleBase::matrix & get_effective_vofk() const
Definition potential_new.h:114
double vl_of_0
Definition potential_new.h:215
~Potential()
Definition potential_new.cpp:38
bool use_gpu_
Definition potential_new.h:223
bool fixed_done
Definition potential_new.h:209
void get_vnew(const Charge *chg, ModuleBase::matrix &vnew)
Definition potential_new.cpp:259
std::vector< PotBase * > components
Definition potential_new.h:217
void allocate()
Definition potential_new.cpp:92
const ModuleBase::matrix & get_vofk_smooth() const
Definition potential_new.h:154
double * d_vofk_smooth
Definition potential_new.h:205
ModuleBase::matrix & get_effective_vofk()
Definition potential_new.h:110
surchem * solvent_
Definition potential_new.h:222
ModuleBase::matrix & get_veff_smooth()
Definition potential_new.h:141
ModuleBase::matrix & get_effective_v()
Definition potential_new.h:79
std::vector< double > v_effective_fixed
Definition potential_new.h:196
Structure_Factor * structure_factors_
Definition potential_new.h:221
const ModuleBase::matrix & get_effective_v() const
Definition potential_new.h:83
const ModuleBase::matrix * vloc_
Definition potential_new.h:220
void init_pot(int istep, const Charge *const chg)
Definition potential_new.cpp:244
Potential()
Definition potential_new.h:51
void pot_register(const std::vector< std::string > &components_list)
Definition potential_new.cpp:62
ModuleBase::matrix v_effective
Definition potential_new.h:197
ModuleBase::matrix & get_vofk_smooth()
Definition potential_new.h:150
float * s_veff_smooth
Definition potential_new.h:204
float * s_vofk_smooth
Definition potential_new.h:204
const UnitCell * ucell_
Definition potential_new.h:219
ModuleBase::matrix vofk_smooth
Definition potential_new.h:200
PotBase * get_pot_type(const std::string &pot_type)
Definition potential_types.cpp:23
double * get_effective_v(int is)
Definition potential_new.h:88
const double * get_fixed_v() const
Definition potential_new.h:169
void cal_v_eff(const Charge *const chg, const UnitCell *const ucell, ModuleBase::matrix &v_eff) override
Definition potential_new.cpp:211
FPTYPE * get_veff_smooth_data()
double * get_effective_vofk(int is)
Definition potential_new.h:118
ModuleBase::matrix v_xc
Definition potential_new.h:202
const double * get_effective_v(int is) const
Definition potential_new.h:99
const ModuleBase::matrix & get_veff_smooth() const
Definition potential_new.h:145
double * etxc_
Definition potential_new.h:212
double * d_veff_smooth
Definition potential_new.h:205
void cal_fixed_v(double *vl_pseudo) override
Definition potential_new.cpp:194
void update_from_charge(const Charge *const chg, const UnitCell *const ucell)
Definition potential_new.cpp:152
double get_vl_of_0() const
get the value of vloc at G=0;
Definition potential_new.h:183
ModuleBase::matrix vofk_effective
Definition potential_new.h:207
void interpolate_vrs()
Definition potential_new.cpp:275
const ModulePW::PW_Basis * get_rho_basis() const
Definition potential_new.h:173
double * vtxc_
Definition potential_new.h:213
const double * get_effective_vofk(int is) const
Definition potential_new.h:129
FPTYPE * get_vofk_smooth_data()
double * get_fixed_v()
Definition potential_new.h:165
Definition surchem.h:15
Definition cal_dm.h:10