ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
stress_func.h
Go to the documentation of this file.
1#ifndef STRESS_FUNC_H
2#define STRESS_FUNC_H
3
10#include "source_base/vector3.h"
12#include "source_cell/klist.h"
18#include "source_psi/psi.h"
19
20//-------------------------------------------------------------------
21// mohan reconstruction note: 2021-02-07
22// the stress code needs reconstructions (by Daye Zheng)
23// 1) add explanations for each function, each variable, for
24// main procedures, make the code readable
25// 2) divide the stress class into several files, each file
26// deals with only one part of the stress, it is convenient for
27// the next-step reconstruction, for example, we want to make
28// pw as an external variable instead of a global variable
29// 3) for PW and LCAO, keeps only one copy of the code, for example
30// the ewald term needs only one copy, it will reduce the
31// time to maintain both copies of stress codes.
32// 4) remain openning interfaces for others to contribute stress
33// codes, for example, molecular dynamics will have an ionic stress
34// term, +U? exx? may have other stress terms.
35// 5) delete useless comments and tests, if you have a useless code,
36// please explicitly explain why you want to keep the test
37// 6) format should be beautiful! code should be readable like a
38// note (let readers be comfortable)
39//-------------------------------------------------------------------
40
41//----------------------------------------------------------------
42// compute the stress terms in terms of the plane wave basis set
43// the stress terms include:
44// 1) the stress from the electron kinetic energy
45// 2) the stress from the local pseudopotentials
46// 3) the stress from the non-local pseudopotentials
47// 4) the stress from the Hartree term
48// 5) the stress from the non-linear core correction (if any)
49// 6) the strees from the exchange-correlation functional term
50// 7) the stress from the ewald term (ion-ion intraction under
51// periodic boundary conditions).
52// 8) the stress from ionic contributions (for molecular dynamics)
53//----------------------------------------------------------------
54
55template <typename FPTYPE, typename Device = base_device::DEVICE_CPU>
57{
58 public:
61
62 // stress functions
63 // 1) the stress from the electron kinetic energy
65 const ModuleBase::matrix& wg,
67 K_Vectors* p_kv,
68 ModulePW::PW_Basis_K* wfc_basis,
69 const UnitCell& ucell_in,
70 const psi::Psi <std::complex<FPTYPE>, Device>* psi_in = nullptr); // electron kinetic part in PW basis
71
72 // 2) the stress from the Hartree term
73 void stress_har(const UnitCell& ucell,
74 ModuleBase::matrix& sigma,
75 ModulePW::PW_Basis* rho_basis,
76 const bool is_pw,
77 const Charge* const chr); // hartree part in PW or LCAO basis
78
79 // 3) the stress from the ewald term (ion-ion intraction under
80 // periodic boundary conditions).
81 void stress_ewa(const UnitCell& ucell,
82 ModuleBase::matrix& sigma,
83 ModulePW::PW_Basis* rho_basis,
84 const bool is_pw); // ewald part in PW or LCAO basis
85
86 // 4) the stress from the local pseudopotentials
87 void stress_loc(const UnitCell& ucell,
88 ModuleBase::matrix& sigma,
89 ModulePW::PW_Basis* rho_basis,
90 const ModuleBase::matrix& vloc,
91 const Structure_Factor* p_sf,
92 const bool is_pw,
93 const Charge* const chr); // local pseudopotential part in PW or LCAO
94
95 void dvloc_of_g(const int& msh,
96 const FPTYPE* rab,
97 const FPTYPE* r,
98 const FPTYPE* vloc_at,
99 const FPTYPE& zp,
100 FPTYPE* dvloc,
101 ModulePW::PW_Basis* rho_basis,
102 const UnitCell& ucell_in); // used in local pseudopotential stress
103
109 void dvloc_coulomb(const UnitCell& ucell,
110 const FPTYPE& zp,
111 FPTYPE* dvloc,
112 ModulePW::PW_Basis* rho_basis); // used in local pseudopotential stress
113
114 // 5) the stress from the non-linear core correction (if any)
115 void stress_cc(ModuleBase::matrix& sigma,
116 ModulePW::PW_Basis* rho_basis,
118 const Structure_Factor* p_sf,
119 const bool is_pw,
120 const bool *numeric,
121 const Charge* const chr); // nonlinear core correction stress in PW or LCAO basis
122
123 void deriv_drhoc(const bool& numeric,
124 const double& omega,
125 const double& tpiba2,
126 const int mesh,
127 const FPTYPE* r,
128 const FPTYPE* rab,
129 const FPTYPE* rhoc,
130 FPTYPE* drhocg,
131 ModulePW::PW_Basis* rho_basis,
132 int type); // used in nonlinear core correction stress
133
134 // 6) the stress from the exchange-correlation functional term
135 void stress_gga(const UnitCell& ucell,
136 ModuleBase::matrix& sigma,
137 ModulePW::PW_Basis* rho_basis,
138 const Charge* const chr); // gga part in both PW and LCAO basis
139 void stress_mgga(const UnitCell& ucell,
140 ModuleBase::matrix& sigma,
141 const ModuleBase::matrix& wg,
142 const ModuleBase::matrix& v_ofk,
143 const Charge* const chr,
144 K_Vectors* p_kv,
145 ModulePW::PW_Basis_K* wfc_basis,
146 const psi::Psi <std::complex<FPTYPE>, Device>* psi_in); // gga part in PW basis
147
148 // 7) the stress from the non-local pseudopotentials
158 void stress_nl(ModuleBase::matrix& sigma,
159 const ModuleBase::matrix& wg,
160 const ModuleBase::matrix& ekb,
161 Structure_Factor* p_sf,
162 K_Vectors* p_kv,
164 ModulePW::PW_Basis_K* wfc_basis,
165 const psi::Psi <std::complex<FPTYPE>, Device>* psi_in,
166 const pseudopot_cell_vnl& nlpp_in,
167 const UnitCell& ucell_in); // nonlocal part in PW basis
168 // 8) the stress from the DFT+U and DeltaSpin calculations
180 const ModuleBase::matrix& wg,
181 const ModulePW::PW_Basis_K* wfc_basis,
182 const UnitCell& ucell_in,
183 const psi::Psi <std::complex<FPTYPE>, Device>* psi_in,
184 ModuleSymmetry::Symmetry* p_symm); // nonlocal part in PW basis
185
187 const int ik,
188 const int ipol,
189 Structure_Factor* p_sf,
190 ModulePW::PW_Basis_K* wfc_basis); // used in nonlocal part in PW basis
192 const int ik,
193 Structure_Factor* p_sf,
194 ModulePW::PW_Basis_K* wfc_basis); // used in nonlocal part in PW basis
195
197 const int& dim1,
198 const int& dim2,
199 const int& dim3,
200 const FPTYPE& table_interval,
201 const FPTYPE& x);
202
226 void dqvan2(const pseudopot_cell_vnl& ppcell_in,
227 const int ih,
228 const int jh,
229 const int itype,
230 const int ipol,
231 const int ng,
233 const FPTYPE* qnorm,
234 const FPTYPE& tpiba,
235 const ModuleBase::matrix& ylmk0,
236 const ModuleBase::matrix& dylmk0,
237 std::complex<FPTYPE>* dqg);
238
239 protected:
240 Device* ctx = {};
241 base_device::DEVICE_CPU* cpu_ctx = {};
243 private:
247
254 = base_device::memory::synchronize_memory_op<std::complex<FPTYPE>, Device, base_device::DEVICE_CPU>;
256 = base_device::memory::synchronize_memory_op<std::complex<FPTYPE>, base_device::DEVICE_CPU, Device>;
257
265
269
272
275
276 protected:
278 const UnitCell* ucell = nullptr;
279};
280
281#endif
Definition charge.h:20
Definition klist.h:13
Definition complexmatrix.h:14
3 elements vector
Definition vector3.h:22
Definition matrix.h:19
double float array
Definition realarray.h:21
Special pw_basis class. It includes different k-points.
Definition pw_basis_k.h:57
A class which can convert a function of "r" to the corresponding linear superposition of plane waves ...
Definition pw_basis.h:56
Definition symmetry.h:16
Definition stress_func.h:57
base_device::DEVICE_CPU * cpu_ctx
Definition stress_func.h:241
void stress_har(const UnitCell &ucell, ModuleBase::matrix &sigma, ModulePW::PW_Basis *rho_basis, const bool is_pw, const Charge *const chr)
Definition stress_func_har.cpp:9
Stress_Func()
Definition stress_func.h:59
void stress_kin(ModuleBase::matrix &sigma, const ModuleBase::matrix &wg, ModuleSymmetry::Symmetry *p_symm, K_Vectors *p_kv, ModulePW::PW_Basis_K *wfc_basis, const UnitCell &ucell_in, const psi::Psi< std::complex< FPTYPE >, Device > *psi_in=nullptr)
Definition stress_func_kin.cpp:9
void stress_onsite(ModuleBase::matrix &sigma, const ModuleBase::matrix &wg, const ModulePW::PW_Basis_K *wfc_basis, const UnitCell &ucell_in, const psi::Psi< std::complex< FPTYPE >, Device > *psi_in, ModuleSymmetry::Symmetry *p_symm)
This routine computes the stress contribution from the DFT+U and DeltaSpin calculations Stress^{NL}_{...
Definition stress_func_onsite.cpp:10
void get_dvnl1(ModuleBase::ComplexMatrix &vkb, const int ik, const int ipol, Structure_Factor *p_sf, ModulePW::PW_Basis_K *wfc_basis)
Definition stress_func_nl.cpp:105
~Stress_Func()
Definition stress_func.h:60
void stress_nl(ModuleBase::matrix &sigma, const ModuleBase::matrix &wg, const ModuleBase::matrix &ekb, Structure_Factor *p_sf, K_Vectors *p_kv, ModuleSymmetry::Symmetry *p_symm, ModulePW::PW_Basis_K *wfc_basis, const psi::Psi< std::complex< FPTYPE >, Device > *psi_in, const pseudopot_cell_vnl &nlpp_in, const UnitCell &ucell_in)
This routine computes the atomic force of non-local pseudopotential Stress^{NL}_{ij} = -1/\Omega \sum...
Definition stress_func_nl.cpp:13
void stress_cc(ModuleBase::matrix &sigma, ModulePW::PW_Basis *rho_basis, UnitCell &ucell, const Structure_Factor *p_sf, const bool is_pw, const bool *numeric, const Charge *const chr)
Definition stress_func_cc.cpp:16
void stress_ewa(const UnitCell &ucell, ModuleBase::matrix &sigma, ModulePW::PW_Basis *rho_basis, const bool is_pw)
Definition stress_func_ewa.cpp:14
void dvloc_of_g(const int &msh, const FPTYPE *rab, const FPTYPE *r, const FPTYPE *vloc_at, const FPTYPE &zp, FPTYPE *dvloc, ModulePW::PW_Basis *rho_basis, const UnitCell &ucell_in)
Definition stress_func_loc.cpp:170
void stress_loc(const UnitCell &ucell, ModuleBase::matrix &sigma, ModulePW::PW_Basis *rho_basis, const ModuleBase::matrix &vloc, const Structure_Factor *p_sf, const bool is_pw, const Charge *const chr)
Definition stress_func_loc.cpp:11
pseudopot_cell_vnl * nlpp
Definition stress_func.h:277
void dqvan2(const pseudopot_cell_vnl &ppcell_in, const int ih, const int jh, const int itype, const int ipol, const int ng, const ModuleBase::Vector3< FPTYPE > *g, const FPTYPE *qnorm, const FPTYPE &tpiba, const ModuleBase::matrix &ylmk0, const ModuleBase::matrix &dylmk0, std::complex< FPTYPE > *dqg)
Compute the derivatives of the radial Fourier transform of the Q functions.
Definition stress_func_us.cpp:192
void get_dvnl2(ModuleBase::ComplexMatrix &vkb, const int ik, Structure_Factor *p_sf, ModulePW::PW_Basis_K *wfc_basis)
Definition stress_func_nl.cpp:232
Device * ctx
Definition stress_func.h:240
void deriv_drhoc(const bool &numeric, const double &omega, const double &tpiba2, const int mesh, const FPTYPE *r, const FPTYPE *rab, const FPTYPE *rhoc, FPTYPE *drhocg, ModulePW::PW_Basis *rho_basis, int type)
Definition stress_func_cc.cpp:217
void stress_gga(const UnitCell &ucell, ModuleBase::matrix &sigma, ModulePW::PW_Basis *rho_basis, const Charge *const chr)
Definition stress_func_gga.cpp:8
base_device::AbacusDevice_t device
Definition stress_func.h:242
void stress_mgga(const UnitCell &ucell, ModuleBase::matrix &sigma, const ModuleBase::matrix &wg, const ModuleBase::matrix &v_ofk, const Charge *const chr, K_Vectors *p_kv, ModulePW::PW_Basis_K *wfc_basis, const psi::Psi< std::complex< FPTYPE >, Device > *psi_in)
Definition stress_func_mgga.cpp:12
void dvloc_coulomb(const UnitCell &ucell, const FPTYPE &zp, FPTYPE *dvloc, ModulePW::PW_Basis *rho_basis)
compute the derivative of the coulomb potential in reciprocal space D V(g^2) / D g^2 = 4pi e^2/omegai...
Definition stress_func_loc.cpp:275
const UnitCell * ucell
Definition stress_func.h:278
FPTYPE Polynomial_Interpolation_nl(const ModuleBase::realArray &table, const int &dim1, const int &dim2, const int &dim3, const FPTYPE &table_interval, const FPTYPE &x)
Definition stress_func_nl.cpp:353
Definition structure_factor.h:11
Definition unitcell.h:16
Definition VNL_in_pw.h:21
Definition psi.h:37
AbacusDevice_t
Definition types.h:12
Definition math_kernel_op.h:217
Definition memory_op.h:77
Definition memory_op.h:17
Definition memory_op.h:31
Definition stress_op.h:15
Definition stress_op.h:57
Definition stress_op.h:181
Definition stress_op.h:166
Definition stress_op.h:217
Definition stress_op.h:201