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_cell/klist.h"
16#include "source_psi/psi.h"
17#include "source_lcao/module_dftu/dftu.h" // mohan add 2025-11-06
18
19//-------------------------------------------------------------------
20// mohan reconstruction note: 2021-02-07
21// the stress code needs reconstructions (by Daye Zheng)
22// 1) add explanations for each function, each variable, for
23// main procedures, make the code readable
24// 2) divide the stress class into several files, each file
25// deals with only one part of the stress, it is convenient for
26// the next-step reconstruction, for example, we want to make
27// pw as an external variable instead of a global variable
28// 3) for PW and LCAO, keeps only one copy of the code, for example
29// the ewald term needs only one copy, it will reduce the
30// time to maintain both copies of stress codes.
31// 4) remain openning interfaces for others to contribute stress
32// codes, for example, molecular dynamics will have an ionic stress
33// term, +U? exx? may have other stress terms.
34// 5) delete useless comments and tests, if you have a useless code,
35// please explicitly explain why you want to keep the test
36// 6) format should be beautiful! code should be readable like a
37// note (let readers be comfortable)
38//-------------------------------------------------------------------
39
40//----------------------------------------------------------------
41// compute the stress terms in terms of the plane wave basis set
42// the stress terms include:
43// 1) the stress from the electron kinetic energy
44// 2) the stress from the local pseudopotentials
45// 3) the stress from the non-local pseudopotentials
46// 4) the stress from the Hartree term
47// 5) the stress from the non-linear core correction (if any)
48// 6) the strees from the exchange-correlation functional term
49// 7) the stress from the ewald term (ion-ion intraction under
50// periodic boundary conditions).
51// 8) the stress from ionic contributions (for molecular dynamics)
52//----------------------------------------------------------------
53
54template <typename FPTYPE, typename Device = base_device::DEVICE_CPU>
56{
57 public:
60
61 // stress functions
62 // 1) the stress from the electron kinetic energy
64 const ModuleBase::matrix& wg,
66 K_Vectors* p_kv,
67 ModulePW::PW_Basis_K* wfc_basis,
68 const UnitCell& ucell_in,
69 const psi::Psi <std::complex<FPTYPE>, Device>* psi_in = nullptr); // electron kinetic part in PW basis
70
71 // 2) the stress from the Hartree term
72 void stress_har(const UnitCell& ucell,
73 ModuleBase::matrix& sigma,
74 ModulePW::PW_Basis* rho_basis,
75 const bool is_pw,
76 const Charge* const chr); // hartree part in PW or LCAO basis
77
78 // 3) the stress from the ewald term (ion-ion intraction under
79 // periodic boundary conditions).
80 void stress_ewa(const UnitCell& ucell,
81 ModuleBase::matrix& sigma,
82 ModulePW::PW_Basis* rho_basis,
83 const bool is_pw); // ewald part in PW or LCAO basis
84
85 // 4) the stress from the local pseudopotentials
86 void stress_loc(const UnitCell& ucell,
87 ModuleBase::matrix& sigma,
88 ModulePW::PW_Basis* rho_basis,
89 const ModuleBase::matrix& vloc,
90 const Structure_Factor* p_sf,
91 const bool is_pw,
92 const Charge* const chr); // local pseudopotential part in PW or LCAO
93
94 void dvloc_of_g(const int& msh,
95 const FPTYPE* rab,
96 const FPTYPE* r,
97 const FPTYPE* vloc_at,
98 const FPTYPE& zp,
99 FPTYPE* dvloc,
100 ModulePW::PW_Basis* rho_basis,
101 const UnitCell& ucell_in); // used in local pseudopotential stress
102
108 void dvloc_coulomb(const UnitCell& ucell,
109 const FPTYPE& zp,
110 FPTYPE* dvloc,
111 ModulePW::PW_Basis* rho_basis); // used in local pseudopotential stress
112
113 // 5) the stress from the non-linear core correction (if any)
114 void stress_cc(ModuleBase::matrix& sigma,
115 ModulePW::PW_Basis* rho_basis,
117 const Structure_Factor* p_sf,
118 const bool is_pw,
119 const bool *numeric,
120 const Charge* const chr); // nonlinear core correction stress in PW or LCAO basis
121
122 void deriv_drhoc(const bool& numeric,
123 const double& omega,
124 const double& tpiba2,
125 const int mesh,
126 const FPTYPE* r,
127 const FPTYPE* rab,
128 const FPTYPE* rhoc,
129 FPTYPE* drhocg,
130 ModulePW::PW_Basis* rho_basis,
131 int type); // used in nonlinear core correction stress
132
133 // 6) the stress from the exchange-correlation functional term
134 void stress_gga(const UnitCell& ucell,
135 ModuleBase::matrix& sigma,
136 ModulePW::PW_Basis* rho_basis,
137 const Charge* const chr); // gga part in both PW and LCAO basis
138 void stress_mgga(const UnitCell& ucell,
139 ModuleBase::matrix& sigma,
140 const ModuleBase::matrix& wg,
141 const ModuleBase::matrix& v_ofk,
142 const Charge* const chr,
143 K_Vectors* p_kv,
144 ModulePW::PW_Basis_K* wfc_basis,
145 const psi::Psi <std::complex<FPTYPE>, Device>* psi_in); // gga part in PW basis
146
147 // 7) the stress from the non-local pseudopotentials
157 void stress_nl(ModuleBase::matrix& sigma,
158 const ModuleBase::matrix& wg,
159 const ModuleBase::matrix& ekb,
160 Structure_Factor* p_sf,
161 K_Vectors* p_kv,
163 ModulePW::PW_Basis_K* wfc_basis,
164 const psi::Psi <std::complex<FPTYPE>, Device>* psi_in,
165 const pseudopot_cell_vnl& nlpp_in,
166 const UnitCell& ucell_in); // nonlocal part in PW basis
167 // 8) the stress from the DFT+U and DeltaSpin calculations
179 const ModuleBase::matrix& wg,
180 const ModulePW::PW_Basis_K* wfc_basis,
181 const UnitCell& ucell_in,
182 const Plus_U &dftu, // mohan add 2025-11-06
183 const void* 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:17
Definition klist.h:12
Definition complexmatrix.h:13
3 elements vector
Definition vector3.h:24
Definition matrix.h:18
double float array
Definition realarray.h:21
Special pw_basis class. It includes different k-points.
Definition pw_basis_k.h:56
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:15
Definition dftu.h:19
Definition stress_func.h:56
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_har.cpp:9
Stress_Func()
Definition stress_func.h:58
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_kin.cpp:8
void get_dvnl1(ModuleBase::ComplexMatrix &vkb, const int ik, const int ipol, Structure_Factor *p_sf, ModulePW::PW_Basis_K *wfc_basis)
Definition stress_nl.cpp:104
~Stress_Func()
Definition stress_func.h:59
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_nl.cpp:12
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_cc.cpp:16
void stress_ewa(const UnitCell &ucell, ModuleBase::matrix &sigma, ModulePW::PW_Basis *rho_basis, const bool is_pw)
Definition stress_ewa.cpp:15
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_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_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_us.cpp:193
void get_dvnl2(ModuleBase::ComplexMatrix &vkb, const int ik, Structure_Factor *p_sf, ModulePW::PW_Basis_K *wfc_basis)
Definition stress_nl.cpp:231
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_cc.cpp:217
void stress_gga(const UnitCell &ucell, ModuleBase::matrix &sigma, ModulePW::PW_Basis *rho_basis, const Charge *const chr)
Definition stress_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_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_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_nl.cpp:352
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 void *psi_in, ModuleSymmetry::Symmetry *p_symm)
This routine computes the stress contribution from the DFT+U and DeltaSpin calculations Stress^{NL}_{...
Definition stress_onsite.cpp:25
Definition structure_factor.h:10
Definition unitcell.h:15
Definition vnl_pw.h:21
Definition psi.h:37
AbacusDevice_t
Definition types.h:12
Definition math_kernel_op.h:216
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