forked from abacusmodeling/abacus-develop
-
Notifications
You must be signed in to change notification settings - Fork 245
Expand file tree
/
Copy pathgint.h
More file actions
275 lines (232 loc) · 10.1 KB
/
Copy pathgint.h
File metadata and controls
275 lines (232 loc) · 10.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
#ifndef GINT_INTERFACE
#define GINT_INTERFACE
#include "gint_tools.h"
#include "source_cell/module_neighbor/sltk_grid_driver.h"
#include "source_lcao/module_gint/grid_technique.h"
#include "source_lcao/module_hcontainer/hcontainer.h"
#include <functional>
//----------------------------------------------------------
//!This class provides a unified interface to the
//!grid intergration operation used to calculate
//!electron density, and the contribution of local
//!potential to Hamiltonian and force/stress.
//!There are two derived classes of this class
//! namely Gint_Gamma and Gint_k, which contain
//! specific operations for gamma point/multi-k calculations
//----------------------------------------------------------
class Gint {
public:
~Gint();
//! move operator for the next ESolver to directly use its infomation
Gint& operator=(Gint&& rhs);
hamilt::HContainer<double>* get_hRGint() const { return hRGint; }
std::vector<hamilt::HContainer<double>*> get_DMRGint() const { return DMRGint; }
int get_ncxyz() const { return ncxyz; }
//! the unified interface to grid integration
void cal_gint(Gint_inout* inout);
//! preparing FFT grid
void prep_grid(const Grid_Technique& gt,
const int& nbx_in,
const int& nby_in,
const int& nbz_in,
const int& nbz_start_in,
const int& ncxyz_in,
const int& bx_in,
const int& by_in,
const int& bz_in,
const int& bxyz_in,
const int& nbxx_in,
const int& ny_in,
const int& nplane_in,
const int& startz_current_in,
const UnitCell* ucell_in,
const LCAO_Orbitals* orb_in);
/**
* @brief calculate the neighbor atoms of each atom in this processor
* size of BaseMatrix with be the non-parallel version
*/
void initialize_pvpR(const UnitCell& unitcell, const Grid_Driver* gd, const int& nspin);
/**
* @brief resize DMRGint to nspin and reallocate the memory
*/
void reset_DMRGint(const int& nspin);
/**
* @brief transfer DMR (2D para) to DMR (Grid para) in elecstate_lcao.cpp
*/
void transfer_DM2DtoGrid(std::vector<hamilt::HContainer<double>*> DM2D);
const Grid_Technique* gridt = nullptr;
const UnitCell* ucell;
// psir_ylm_new = psir_func(psir_ylm)
// psir_func==nullptr means psir_ylm_new=psir_ylm
using T_psir_func = std::function<
const ModuleBase::Array_Pool<double>&(
const ModuleBase::Array_Pool<double> &psir_ylm,
const Grid_Technique >,
const int grid_index,
const int is,
const std::vector<int> &block_iw,
const std::vector<int> &block_size,
const std::vector<int> &block_index,
const ModuleBase::Array_Pool<bool> &cal_flag)>;
T_psir_func psir_func_1 = nullptr;
T_psir_func psir_func_2 = nullptr;
protected:
//! variables related to FFT grid
int nbx;
int nby;
int nbz;
int ncxyz;
int nbz_start;
int bx;
int by;
int bz;
int bxyz;
int nbxx;
int ny;
int nplane;
int startz_current; // from rhopw
//! in cal_gint_gpu.cpp
void gpu_vlocal_interface(Gint_inout* inout);
void gpu_rho_interface(Gint_inout* inout);
void gpu_force_interface(Gint_inout* inout);
//! in cal_gint_cpu.cpp
void gint_kernel_vlocal(Gint_inout* inout);
//! calculate H_mu_nu(local)=<phi_0|vlocal|dphi_R>
void gint_kernel_dvlocal(Gint_inout* inout);
//! calculate vlocal in meta-GGA functionals
void gint_kernel_vlocal_meta(Gint_inout* inout);
//! calculate charge density rho(r)=\int D_munu \phi_mu \phi_nu
void gint_kernel_rho(Gint_inout* inout);
//! used in meta-GGA functional
void gint_kernel_tau(Gint_inout* inout);
//! compute forces
void gint_kernel_force(Gint_inout* inout);
//! compute forces related to meta-GGA functionals
void gint_kernel_force_meta(Gint_inout* inout);
//! calculate local potential contribution to the Hamiltonian
//! na_grid: how many atoms on this (i,j,k) grid
//! block_size: dim is [block_size], number of columns of a band
//! block_index: dim is [na_grid+1], total number of atomic orbitals
//! grid_index: index of grid group, for tracing iat
//! cal_flag: dim is [bxyz][na_grid], whether the atom-grid distance is larger than cutoff
//! psir_ylm: dim is [bxyz][LD_pool]
//! psir_vlbr3: dim is [bxyz][LD_pool]
//! hR: HContainer for storing the <phi_0|V|phi_R> matrix elements
//! cal_meshball_vlocal is thread-safe!
void cal_meshball_vlocal(
const int na_grid,
const int LD_pool,
const int* const block_size,
const int* const block_index,
const int grid_index,
const bool* const* const cal_flag,
const double* const* const psir_ylm,
const double* const* const psir_vlbr3,
hamilt::HContainer<double>* hR);
//! in gint_fvl.cpp
//! calculate vl contributuion to force & stress via grid integrals
void gint_kernel_force(const int na_grid,
const int grid_index,
const double delta_r,
double* vldr3,
const int is,
const bool isforce,
const bool isstress,
ModuleBase::matrix* fvl_dphi,
ModuleBase::matrix* svl_dphi,
const UnitCell& ucell);
//! in gint_fvl.cpp
//! calculate vl contributuion to force & stress via grid integrals
//! used in meta-GGA calculations
void gint_kernel_force_meta(const int na_grid,
const int grid_index,
const double delta_r,
double* vldr3,
double* vkdr3,
const int is,
const bool isforce,
const bool isstress,
ModuleBase::matrix* fvl_dphi,
ModuleBase::matrix* svl_dphi,
const UnitCell& ucell);
//! Use grid integrals to compute the atomic force contributions
//! na_grid: how many atoms on this (i,j,k) grid
//! block_size: dim is [na_grid], number of columns of a band
//! block_index: dim is [na_grid+1], total number of atomis orbitals
//! psir_vlbr3_DMR: dim is [bxyz][LD_pool]
//! dpsir_x: dim is [bxyz][LD_pool]
//! dpsir_y: dim is [bxyz][LD_pool]
//! dpsir_z: dim is [bxyz][LD_pool]
void cal_meshball_force(
const int grid_index,
const int na_grid,
const int* const block_size,
const int* const block_index,
const double* const* const psir_vlbr3_DMR,
const double* const* const dpsir_x, // psir_vlbr3[bxyz][LD_pool]
const double* const* const dpsir_y, // psir_vlbr3[bxyz][LD_pool]
const double* const* const dpsir_z, // psir_vlbr3[bxyz][LD_pool]
ModuleBase::matrix* force);
//! Use grid integrals to compute the stress contributions
//! na_grid: how many atoms on this (i,j,k) grid
//! block_index: dim is [na_grid+1], total number of atomis orbitals
void cal_meshball_stress(
const int na_grid,
const int*const block_index,
const double*const psir_vlbr3_DMR,
const double*const dpsirr,
ModuleBase::matrix *stress);
//! Use grid integrals to compute charge density
//! in gint_k_rho.cpp
//! calculate the charge density & kinetic energy density (tau) via grid integrals
void gint_kernel_rho(const int na_grid,
const int grid_index,
const double delta_r,
int* vindex,
const int LD_pool,
const UnitCell& ucell,
Gint_inout* inout);
//! Use grid integrals to compute charge density in a meshball
void cal_meshball_rho(const int na_grid,
const int*const block_index,
const int*const vindex,
const double*const*const psir_ylm,
const double*const*const psir_DMR,
double*const rho);
//! Use grid integrals to compute kinetic energy density tau
//!in meta-GGA functional
void gint_kernel_tau(const int na_grid,
const int grid_index,
const double delta_r,
int* vindex,
const int LD_pool,
Gint_inout* inout,
const UnitCell& ucell);
//! Use grid integrals to compute kinetic energy density tau
//!in a meshball, used in meta-GGA functional calculations
void cal_meshball_tau(const int na_grid,
int* block_index,
int* vindex,
double** dpsix,
double** dpsiy,
double** dpsiz,
double** dpsix_dm,
double** dpsiy_dm,
double** dpsiz_dm,
double* rho);
//! save the < phi_0i | V | phi_Rj > in sparse H matrix.
//! stores Hamiltonian in sparse format
hamilt::HContainer<double>* hRGint = nullptr;
//! size of vec is 4, only used when nspin = 4
std::vector<hamilt::HContainer<double>*> hRGint_tmp;
//! stores Hamiltonian in sparse format
hamilt::HContainer<std::complex<double>>* hRGintCd = nullptr;
//! stores DMR in sparse format
std::vector<hamilt::HContainer<double>*> DMRGint;
//! tmp tools used in transfer_DM2DtoGrid
hamilt::HContainer<double>* dm2d_tmp = nullptr;
std::vector<hamilt::HContainer<double>> pvdpRx_reduced;
std::vector<hamilt::HContainer<double>> pvdpRy_reduced;
std::vector<hamilt::HContainer<double>> pvdpRz_reduced;
};
#endif