ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
vnl_pw.h
Go to the documentation of this file.
1#ifndef VNL_IN_PW_H
2#define VNL_IN_PW_H
3
11#include "source_psi/psi.h"
12#ifdef __LCAO
14#endif
15
16//==========================================================
17// Calculate the non-local pseudopotential in reciprocal
18// space using plane wave as basis set.
19//==========================================================
21{
22
23 public:
26 void init(const UnitCell& cell,
27 Structure_Factor* psf_in,
28 const ModulePW::PW_Basis_K* wfc_basis = nullptr,
29 const bool allocate_vkb = true);
30
31 double cell_factor = 0.0; // LiuXh add 20180619
32
33 int nkb = 0; // total number of beta functions considering all atoms
34
35 int lmaxkb = 0; // max angular momentum for non-local projectors
36
37 void init_vnl(UnitCell& cell, const ModulePW::PW_Basis* rho_basis);
38
39 void rescale_vnl(const double& omega_in);
40
41 template <typename FPTYPE, typename Device>
42 void getvnl(Device* ctx, const UnitCell& ucell, const int& ik, std::complex<FPTYPE>* vkb_in) const;
43
44 // void getvnl_alpha(const int &ik);
45
46 void init_vnl_alpha(const UnitCell& cell);
47
48 void initgradq_vnl(const UnitCell& cell);
49
50 void getgradq_vnl(const UnitCell& ucell, const int ik);
51
52 //===============================================================
53 // MEMBER VARIABLES :
54 // NAME : nqx(number of interpolation points)
55 // NAME : nqxq(size of interpolation table)
56 // NAME : nhm(max number of different beta functions per atom)
57 // NAME : lmaxq
58 // NAME : dq(space between points in the pseudopotential tab)
59 //===============================================================
60 // private:
61
62 int nhm = 0;
63 int nbetam = 0; // max number of beta functions
64
65 int lmaxq = 0;
66
67 ModuleBase::matrix indv; // indes linking atomic beta's to beta's in the solid
68 ModuleBase::matrix nhtol; // correspondence n <-> angular momentum l
69 ModuleBase::matrix nhtolm; // correspondence n <-> combined lm index for (l,m)
71
72 ModuleBase::realArray dvan; //(:,:,:), the D functions of the solid
73 ModuleBase::ComplexArray dvan_so; //(:,:,:), spin-orbit case, added by zhengdy-soc
74
75 ModuleBase::realArray tab; //(:,:,:), interpolation table for PPs: 4pi/sqrt(V) * \int betar(r)jl(qr)rdr
77 ModuleBase::realArray tab_at; //(:,:,:), interpolation table for atomic wfc
78 ModuleBase::realArray tab_dq; // 4pi/sqrt(V) * \int betar(r)*djl(qr)/d(qr)*r^2 dr
79
80 ModuleBase::realArray deeq; //(:,:,:,:), the integral of V_eff and Q_{nm}
81 bool multi_proj = false;
82 float* s_deeq = nullptr;
83 double* d_deeq = nullptr;
84 ModuleBase::ComplexArray deeq_nc; //(:,:,:,:), the spin-orbit case
85 std::complex<float>* c_deeq_nc = nullptr; // GPU array of deeq_nc
86 std::complex<double>* z_deeq_nc = nullptr; // GPU array of deeq_nc
87
88 // liuyu add 2023-10-03
89 // uspp
90 int* indv_ijkb0 = nullptr; // first beta (index in the solid) for each atom
91 ModuleBase::IntArray ijtoh; // correspondence beta indexes ih,jh -> composite index ijh
92 ModuleBase::realArray qq_at; // the integral of q functions in the solid (ONE PER ATOM)
93 ModuleBase::realArray qq_nt; // the integral of q functions in the solid (ONE PER NTYP) used to be the qq array
94 ModuleBase::ComplexArray qq_so; // Q_{nm} for spin-orbit case
95 ModuleBase::realArray ap; // the expansion coefficients
96 ModuleBase::IntArray lpx; // for each input limi,ljmj is the number of LM in the sum
97 ModuleBase::IntArray lpl; // for each input limi,ljmj points to the allowed LM
98 ModuleBase::realArray qrad; // radial FT of Q functions
99
100 float* s_qq_nt = nullptr;
101 double* d_qq_nt = nullptr;
102 std::complex<float>* c_qq_so = nullptr; // GPU array of qq_so
103 std::complex<double>* z_qq_so = nullptr; // GPU array of qq_so
104
105 mutable ModuleBase::ComplexMatrix vkb; // all beta functions in reciprocal space
106 mutable ModuleBase::ComplexArray gradvkb; // gradient of beta functions
107 std::complex<double>*** vkb1_alpha;
108 std::complex<double>*** vkb_alpha;
110
111 // Column dimension of vkb matrix (= npwx), used as leading dimension in gemm/gemv.
112 // On GPU path vkb ComplexMatrix is not allocated to save CPU memory; this stores the dimension.
113 int vkbnc = 0;
114
115 // other variables
116 std::complex<double> Cal_C(int alpha, int lu, int mu, int L, int M);
117
118 double CG(int l1, int m1, int l2, int m2, int L, int M);
119
120 void print_vnl(std::ofstream& ofs);
121
139 void radial_fft_q(const int ng,
140 const int ih,
141 const int jh,
142 const int itype,
143 const double* qnorm,
144 const ModuleBase::matrix ylm,
145 std::complex<double>* qg) const;
146 template <typename FPTYPE, typename Device>
147 void radial_fft_q(Device* ctx,
148 const int ng,
149 const int ih,
150 const int jh,
151 const int itype,
152 const FPTYPE* qnorm,
153 const FPTYPE* ylm,
154 std::complex<FPTYPE>* qg) const;
155
163 void cal_effective_D(const ModuleBase::matrix& veff, const ModulePW::PW_Basis* rho_basis, UnitCell& cell);
164#ifdef __LCAO
165 ORB_gaunt_table MGT;
166#endif
167
168 template <typename FPTYPE>
169 FPTYPE* get_nhtol_data() const;
170 template <typename FPTYPE>
171 FPTYPE* get_nhtolm_data() const;
172 template <typename FPTYPE>
173 FPTYPE* get_indv_data() const;
174 template <typename FPTYPE>
175 FPTYPE* get_tab_data() const;
176 template <typename FPTYPE>
177 FPTYPE* get_deeq_data() const;
178 template <typename FPTYPE>
179 FPTYPE* get_qq_nt_data() const;
180 template <typename FPTYPE>
181 std::complex<FPTYPE>* get_qq_so_data() const;
182 template <typename FPTYPE>
183 std::complex<FPTYPE>* get_vkb_data() const;
184 template <typename FPTYPE>
185 std::complex<FPTYPE>* get_deeq_nc_data() const;
186
187 void release_memory();
188
189 private:
190 bool memory_released = false;
191 float* s_nhtol = nullptr;
192 float* s_nhtolm = nullptr;
193 float* s_indv = nullptr;
194 float* s_tab = nullptr;
195 std::complex<float>* c_vkb = nullptr;
196
197 double* d_nhtol = nullptr;
198 double* d_nhtolm = nullptr;
199 double* d_indv = nullptr;
200 double* d_tab = nullptr;
201 std::complex<double>* z_vkb = nullptr;
202
203 const ModulePW::PW_Basis_K* wfcpw = nullptr;
204
206
207 double omega_old = 0;
208 bool use_gpu_ = false;
209
219 void compute_qrad(UnitCell& cell);
220
228 void newq(const ModuleBase::matrix& veff, const ModulePW::PW_Basis* rho_basis, UnitCell& cell);
229
236 void newd_so(const int& iat, UnitCell& cell);
237
244 void newd_nc(const int& iat, UnitCell& cell);
245};
246
247#endif // VNL_IN_PW
A basic type of data for complex array.
Definition complexarray.h:15
Definition complexmatrix.h:13
Integer array.
Definition intarray.h:17
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 ORB_gaunt_table.h:9
Definition soc.h:49
Definition structure_factor.h:10
Definition unitcell.h:15
Definition vnl_pw.h:21
ModuleBase::matrix indv
Definition vnl_pw.h:67
double omega_old
Definition vnl_pw.h:207
double CG(int l1, int m1, int l2, int m2, int L, int M)
ModuleBase::ComplexArray gradvkb
Definition vnl_pw.h:106
int nhm
Definition vnl_pw.h:62
int * indv_ijkb0
Definition vnl_pw.h:90
float * s_qq_nt
Definition vnl_pw.h:100
ModuleBase::matrix nhtoj
Definition vnl_pw.h:70
Structure_Factor * psf
Definition vnl_pw.h:109
std::complex< double > * z_vkb
Definition vnl_pw.h:201
std::complex< float > * c_qq_so
Definition vnl_pw.h:102
int lmaxkb
Definition vnl_pw.h:35
const ModulePW::PW_Basis_K * wfcpw
Definition vnl_pw.h:203
float * s_deeq
Definition vnl_pw.h:82
ModuleBase::realArray ap
Definition vnl_pw.h:95
FPTYPE * get_nhtol_data() const
std::complex< FPTYPE > * get_deeq_nc_data() const
std::complex< float > * c_vkb
Definition vnl_pw.h:195
std::complex< FPTYPE > * get_qq_so_data() const
std::complex< double > *** vkb_alpha
Definition vnl_pw.h:108
ModuleBase::realArray deeq
Definition vnl_pw.h:80
ModuleBase::ComplexArray deeq_nc
Definition vnl_pw.h:84
ModuleBase::ComplexArray qq_so
Definition vnl_pw.h:94
std::complex< double > Cal_C(int alpha, int lu, int mu, int L, int M)
ModuleBase::realArray dvan
Definition vnl_pw.h:72
FPTYPE * get_indv_data() const
double * d_qq_nt
Definition vnl_pw.h:101
ModuleBase::realArray tab_dq
Definition vnl_pw.h:78
float * s_nhtolm
Definition vnl_pw.h:192
pseudopot_cell_vnl()
Definition klist_test.cpp:74
float * s_nhtol
Definition vnl_pw.h:191
void newd_so(const int &iat, UnitCell &cell)
calculate D functions in the soc case when tvanp is true
Definition vnl_pw.cpp:1536
int nbetam
Definition vnl_pw.h:63
void compute_qrad(UnitCell &cell)
Compute interpolation table qrad.
Definition vnl_pw.cpp:805
std::complex< float > * c_deeq_nc
Definition vnl_pw.h:85
double * d_indv
Definition vnl_pw.h:199
std::complex< double > *** vkb1_alpha
Definition vnl_pw.h:107
void print_vnl(std::ofstream &ofs)
Definition vnl_pw.cpp:1267
bool memory_released
Definition vnl_pw.h:190
double cell_factor
Definition vnl_pw.h:31
std::complex< double > * z_qq_so
Definition vnl_pw.h:103
FPTYPE * get_qq_nt_data() const
ModuleBase::ComplexMatrix vkb
Definition vnl_pw.h:105
void rescale_vnl(const double &omega_in)
Definition vnl_pw.cpp:1617
ModuleBase::IntArray lpl
Definition vnl_pw.h:97
void init_vnl_alpha(const UnitCell &cell)
Definition vnl_pw.cpp:1193
double * d_nhtolm
Definition vnl_pw.h:198
ModuleBase::IntArray ijtoh
Definition vnl_pw.h:91
int nkb
Definition vnl_pw.h:33
ModuleBase::realArray qq_at
Definition vnl_pw.h:92
void init(const UnitCell &cell, Structure_Factor *psf_in, const ModulePW::PW_Basis_K *wfc_basis=nullptr, const bool allocate_vkb=true)
Definition vnl_pw.cpp:84
std::complex< FPTYPE > * get_vkb_data() const
FPTYPE * get_nhtolm_data() const
void getvnl(Device *ctx, const UnitCell &ucell, const int &ik, std::complex< FPTYPE > *vkb_in) const
Definition vnl_pw.cpp:311
bool use_gpu_
Definition vnl_pw.h:208
int lmaxq
Definition vnl_pw.h:65
ModuleBase::realArray tab
Definition vnl_pw.h:75
bool multi_proj
Definition vnl_pw.h:81
ModuleBase::realArray qq_nt
Definition vnl_pw.h:93
ModuleBase::realArray tab_alpha
Definition vnl_pw.h:76
void init_vnl(UnitCell &cell, const ModulePW::PW_Basis *rho_basis)
Definition vnl_pw.cpp:443
FPTYPE * get_deeq_data() const
void radial_fft_q(const int ng, const int ih, const int jh, const int itype, const double *qnorm, const ModuleBase::matrix ylm, std::complex< double > *qg) const
Compute the radial Fourier transform of the Q functions.
Definition vnl_pw.cpp:858
ModuleBase::realArray tab_at
Definition vnl_pw.h:77
FPTYPE * get_tab_data() const
ModuleBase::ComplexArray dvan_so
Definition vnl_pw.h:73
ModuleBase::matrix nhtolm
Definition vnl_pw.h:69
ModuleBase::realArray qrad
Definition vnl_pw.h:98
~pseudopot_cell_vnl()
Definition klist_test.cpp:77
std::complex< double > * z_deeq_nc
Definition vnl_pw.h:86
void release_memory()
Definition vnl_pw.cpp:31
void getgradq_vnl(const UnitCell &ucell, const int ik)
Definition vnl_pw_grad.cpp:61
float * s_indv
Definition vnl_pw.h:193
void cal_effective_D(const ModuleBase::matrix &veff, const ModulePW::PW_Basis *rho_basis, UnitCell &cell)
calculate the effective coefficient matrix for non-local pseudopotential projectors
Definition vnl_pw.cpp:1273
double * d_nhtol
Definition vnl_pw.h:197
ModuleBase::IntArray lpx
Definition vnl_pw.h:96
void initgradq_vnl(const UnitCell &cell)
Definition vnl_pw_grad.cpp:9
void newq(const ModuleBase::matrix &veff, const ModulePW::PW_Basis *rho_basis, UnitCell &cell)
computes the integral of the effective potential with the Q function
Definition vnl_pw.cpp:1414
void newd_nc(const int &iat, UnitCell &cell)
calculate D functions in the noncolin case when tvanp is true
Definition vnl_pw.cpp:1589
double * d_tab
Definition vnl_pw.h:200
float * s_tab
Definition vnl_pw.h:194
int vkbnc
Definition vnl_pw.h:113
Soc soc
Definition vnl_pw.h:205
double * d_deeq
Definition vnl_pw.h:83
ModuleBase::matrix nhtol
Definition vnl_pw.h:68