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