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#include "source_lcao/module_dftu/dftu.h" // mohan add 2025-11-06
20
21//-------------------------------------------------------------------
22// mohan reconstruction note: 2021-02-07
23// the stress code needs reconstructions (by Daye Zheng)
24// 1) add explanations for each function, each variable, for
25// main procedures, make the code readable
26// 2) divide the stress class into several files, each file
27// deals with only one part of the stress, it is convenient for
28// the next-step reconstruction, for example, we want to make
29// pw as an external variable instead of a global variable
30// 3) for PW and LCAO, keeps only one copy of the code, for example
31// the ewald term needs only one copy, it will reduce the
32// time to maintain both copies of stress codes.
33// 4) remain openning interfaces for others to contribute stress
34// codes, for example, molecular dynamics will have an ionic stress
35// term, +U? exx? may have other stress terms.
36// 5) delete useless comments and tests, if you have a useless code,
37// please explicitly explain why you want to keep the test
38// 6) format should be beautiful! code should be readable like a
39// note (let readers be comfortable)
40//-------------------------------------------------------------------
41
42//----------------------------------------------------------------
43// compute the stress terms in terms of the plane wave basis set
44// the stress terms include:
45// 1) the stress from the electron kinetic energy
46// 2) the stress from the local pseudopotentials
47// 3) the stress from the non-local pseudopotentials
48// 4) the stress from the Hartree term
49// 5) the stress from the non-linear core correction (if any)
50// 6) the strees from the exchange-correlation functional term
51// 7) the stress from the ewald term (ion-ion intraction under
52// periodic boundary conditions).
53// 8) the stress from ionic contributions (for molecular dynamics)
54//----------------------------------------------------------------
55
56template <typename FPTYPE, typename Device = base_device::DEVICE_CPU>
58{
59 public:
62
63 // stress functions
64 // 1) the stress from the electron kinetic energy
66 const ModuleBase::matrix& wg,
68 K_Vectors* p_kv,
69 ModulePW::PW_Basis_K* wfc_basis,
70 const UnitCell& ucell_in,
71 const psi::Psi <std::complex<FPTYPE>, Device>* psi_in = nullptr); // electron kinetic part in PW basis
72
73 // 2) the stress from the Hartree term
74 void stress_har(const UnitCell& ucell,
75 ModuleBase::matrix& sigma,
76 ModulePW::PW_Basis* rho_basis,
77 const bool is_pw,
78 const Charge* const chr); // hartree part in PW or LCAO basis
79
80 // 3) the stress from the ewald term (ion-ion intraction under
81 // periodic boundary conditions).
82 void stress_ewa(const UnitCell& ucell,
83 ModuleBase::matrix& sigma,
84 ModulePW::PW_Basis* rho_basis,
85 const bool is_pw); // ewald part in PW or LCAO basis
86
87 // 4) the stress from the local pseudopotentials
88 void stress_loc(const UnitCell& ucell,
89 ModuleBase::matrix& sigma,
90 ModulePW::PW_Basis* rho_basis,
91 const ModuleBase::matrix& vloc,
92 const Structure_Factor* p_sf,
93 const bool is_pw,
94 const Charge* const chr); // local pseudopotential part in PW or LCAO
95
96 void dvloc_of_g(const int& msh,
97 const FPTYPE* rab,
98 const FPTYPE* r,
99 const FPTYPE* vloc_at,
100 const FPTYPE& zp,
101 FPTYPE* dvloc,
102 ModulePW::PW_Basis* rho_basis,
103 const UnitCell& ucell_in); // used in local pseudopotential stress
104
110 void dvloc_coulomb(const UnitCell& ucell,
111 const FPTYPE& zp,
112 FPTYPE* dvloc,
113 ModulePW::PW_Basis* rho_basis); // used in local pseudopotential stress
114
115 // 5) the stress from the non-linear core correction (if any)
116 void stress_cc(ModuleBase::matrix& sigma,
117 ModulePW::PW_Basis* rho_basis,
119 const Structure_Factor* p_sf,
120 const bool is_pw,
121 const bool *numeric,
122 const Charge* const chr); // nonlinear core correction stress in PW or LCAO basis
123
124 void deriv_drhoc(const bool& numeric,
125 const double& omega,
126 const double& tpiba2,
127 const int mesh,
128 const FPTYPE* r,
129 const FPTYPE* rab,
130 const FPTYPE* rhoc,
131 FPTYPE* drhocg,
132 ModulePW::PW_Basis* rho_basis,
133 int type); // used in nonlinear core correction stress
134
135 // 6) the stress from the exchange-correlation functional term
136 void stress_gga(const UnitCell& ucell,
137 ModuleBase::matrix& sigma,
138 ModulePW::PW_Basis* rho_basis,
139 const Charge* const chr); // gga part in both PW and LCAO basis
140 void stress_mgga(const UnitCell& ucell,
141 ModuleBase::matrix& sigma,
142 const ModuleBase::matrix& wg,
143 const ModuleBase::matrix& v_ofk,
144 const Charge* const chr,
145 K_Vectors* p_kv,
146 ModulePW::PW_Basis_K* wfc_basis,
147 const psi::Psi <std::complex<FPTYPE>, Device>* psi_in); // gga part in PW basis
148
149 // 7) the stress from the non-local pseudopotentials
159 void stress_nl(ModuleBase::matrix& sigma,
160 const ModuleBase::matrix& wg,
161 const ModuleBase::matrix& ekb,
162 Structure_Factor* p_sf,
163 K_Vectors* p_kv,
165 ModulePW::PW_Basis_K* wfc_basis,
166 const psi::Psi <std::complex<FPTYPE>, Device>* psi_in,
167 const pseudopot_cell_vnl& nlpp_in,
168 const UnitCell& ucell_in); // nonlocal part in PW basis
169 // 8) the stress from the DFT+U and DeltaSpin calculations
181 const ModuleBase::matrix& wg,
182 const ModulePW::PW_Basis_K* wfc_basis,
183 const UnitCell& ucell_in,
184 const Plus_U &dftu, // mohan add 2025-11-06
185 const psi::Psi <std::complex<FPTYPE>, Device>* psi_in,
186 ModuleSymmetry::Symmetry* p_symm); // nonlocal part in PW basis
187
189 const int ik,
190 const int ipol,
191 Structure_Factor* p_sf,
192 ModulePW::PW_Basis_K* wfc_basis); // used in nonlocal part in PW basis
194 const int ik,
195 Structure_Factor* p_sf,
196 ModulePW::PW_Basis_K* wfc_basis); // used in nonlocal part in PW basis
197
199 const int& dim1,
200 const int& dim2,
201 const int& dim3,
202 const FPTYPE& table_interval,
203 const FPTYPE& x);
204
228 void dqvan2(const pseudopot_cell_vnl& ppcell_in,
229 const int ih,
230 const int jh,
231 const int itype,
232 const int ipol,
233 const int ng,
235 const FPTYPE* qnorm,
236 const FPTYPE& tpiba,
237 const ModuleBase::matrix& ylmk0,
238 const ModuleBase::matrix& dylmk0,
239 std::complex<FPTYPE>* dqg);
240
241 protected:
242 Device* ctx = {};
243 base_device::DEVICE_CPU* cpu_ctx = {};
245 private:
249
256 = base_device::memory::synchronize_memory_op<std::complex<FPTYPE>, Device, base_device::DEVICE_CPU>;
258 = base_device::memory::synchronize_memory_op<std::complex<FPTYPE>, base_device::DEVICE_CPU, Device>;
259
267
271
274
277
278 protected:
280 const UnitCell* ucell = nullptr;
281};
282
283#endif
Definition charge.h:18
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 dftu.h:20
Definition stress_func.h:58
base_device::DEVICE_CPU * cpu_ctx
Definition stress_func.h:243
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:60
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 Plus_U &dftu, 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:61
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:279
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:242
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:244
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:280
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:17
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:115
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
Plus_U dftu
Definition test_dftu.cpp:14