11#ifndef GINT_INTERFACE
22#define GINT_INTERFACE
33
4- // This class provides a unified interface to the
5- // grid intergration operation used to calculate
6- // electron density, and the contribution of local potential
7- // to Hamiltonian and force/stress
8- // There are two derived classes of this class
9- // namely Gint_k and Gint_Gamma, which contains some
10- // specific operations for gamma point/multi-k calculations
11-
124#include " gint_tools.h"
135#include " module_cell/module_neighbor/sltk_grid_driver.h"
146#include " module_hamilt_lcao/module_gint/grid_technique.h"
157#include " module_hamilt_lcao/module_hcontainer/hcontainer.h"
16-
178#include < functional>
189
10+ // ----------------------------------------------------------
11+ // !This class provides a unified interface to the
12+ // !grid intergration operation used to calculate
13+ // !electron density, and the contribution of local
14+ // !potential to Hamiltonian and force/stress.
15+ // !There are two derived classes of this class
16+ // ! namely Gint_Gamma and Gint_k, which contain
17+ // ! specific operations for gamma point/multi-k calculations
18+ // ----------------------------------------------------------
19+
1920class Gint {
2021 public:
2122 ~Gint ();
2223
23- // / move operator for the next ESolver to directly use its infomation
24+ // ! move operator for the next ESolver to directly use its infomation
2425 Gint& operator =(Gint&& rhs);
2526
2627 hamilt::HContainer<double >* get_hRGint () const { return hRGint; }
28+
2729 std::vector<hamilt::HContainer<double >*> get_DMRGint () const { return DMRGint; }
30+
2831 int get_ncxyz () const { return ncxyz; }
2932
30- // the unified interface to grid integration
33+ // ! the unified interface to grid integration
3134 void cal_gint (Gint_inout* inout);
3235
33- // preparing FFT grid
36+ // ! preparing FFT grid
3437 void prep_grid (const Grid_Technique& gt,
3538 const int & nbx_in,
3639 const int & nby_in,
@@ -79,66 +82,81 @@ class Gint {
7982 const std::vector<int > &block_size,
8083 const std::vector<int > &block_index,
8184 const ModuleBase::Array_Pool<bool > &cal_flag)>;
85+
8286 T_psir_func psir_func_1 = nullptr ;
8387 T_psir_func psir_func_2 = nullptr ;
8488
8589 protected:
86- // variables related to FFT grid
90+
91+ // ! variables related to FFT grid
8792 int nbx;
8893 int nby;
8994 int nbz;
9095 int ncxyz;
9196 int nbz_start;
92- int bx, by, bz, bxyz;
97+ int bx;
98+ int by;
99+ int bz;
100+ int bxyz;
93101 int nbxx;
94- int ny, nplane, startz_current; // from rhopw
102+ int ny;
103+ int nplane;
104+ int startz_current; // from rhopw
95105
96- // in cal_gint_gpu.cpp
106+ // ! in cal_gint_gpu.cpp
97107 void gpu_vlocal_interface (Gint_inout* inout);
98108
99109 void gpu_rho_interface (Gint_inout* inout);
100110
101111 void gpu_force_interface (Gint_inout* inout);
102112
103- // in cal_gint_cpu.cpp
104-
113+ // ! in cal_gint_cpu.cpp
105114 void gint_kernel_vlocal (Gint_inout* inout);
106115
107- // calculate < phi_0 | vlocal | dphi_R >
116+ // ! calculate H_mu_nu(local)=< phi_0| vlocal| dphi_R>
108117 void gint_kernel_dvlocal (Gint_inout* inout);
109118
119+ // ! calculate vlocal in meta-GGA functionals
110120 void gint_kernel_vlocal_meta (Gint_inout* inout);
111121
122+ // ! calculate charge density rho(r)=\int D_munu \phi_mu \phi_nu
112123 void gint_kernel_rho (Gint_inout* inout);
113124
125+ // ! used in meta-GGA functional
114126 void gint_kernel_tau (Gint_inout* inout);
115127
128+ // ! compute forces
116129 void gint_kernel_force (Gint_inout* inout);
117130
131+ // ! compute forces related to meta-GGA functionals
118132 void gint_kernel_force_meta (Gint_inout* inout);
119133
134+ // ! calculate local potential contribution to the Hamiltonian
135+ // ! na_grid: how many atoms on this (i,j,k) grid
136+ // ! block_iw: dim is [na_grid], index of wave function for each block
137+ // ! block_size: dim is [block_size], number of columns of a band
138+ // ! block_index: dim is [na_grid+1], total number of atomic orbitals
139+ // ! grid_index: index of grid group, for tracing iat
140+ // ! cal_flag: dim is [bxyz][na_grid], whether the atom-grid distance is larger than cutoff
141+ // ! psir_ylm: dim is [bxyz][LD_pool]
142+ // ! psir_vlbr3: dim is [bxyz][LD_pool]
143+ // ! hR: HContainer for storing the <phi_0|V|phi_R> matrix elements
144+
120145 void cal_meshball_vlocal (
121- const int na_grid, // how many atoms on this (i,j,k) grid
146+ const int na_grid,
122147 const int LD_pool,
123- const int * const block_iw, // block_iw[na_grid], index of wave
124- // functions for each block
125- const int * const
126- block_size, // block_size[na_grid], number of columns of a band
127- const int * const block_index, // block_index[na_grid+1], count total
128- // number of atomis orbitals
129- const int grid_index, // index of grid group, for tracing iat
130- const bool * const * const
131- cal_flag, // cal_flag[bxyz][na_grid], whether the atom-grid
132- // distance is larger than cutoff
133- const double * const * const psir_ylm, // psir_ylm[bxyz][LD_pool]
134- const double * const * const psir_vlbr3, // psir_vlbr3[bxyz][LD_pool]
135- hamilt::HContainer<double >* hR); // HContainer for storing the <phi_0 |
136- // V | phi_R> matrix element.
137-
138- // ------------------------------------------------------
139- // in gint_fvl.cpp
140- // ------------------------------------------------------
141- // calculate vl contributuion to force & stress via grid integrals
148+ const int * const block_iw,
149+ const int * const block_size,
150+ const int * const block_index,
151+ const int grid_index,
152+ const bool * const * const cal_flag,
153+ const double * const * const psir_ylm,
154+ const double * const * const psir_vlbr3,
155+ hamilt::HContainer<double >* hR);
156+
157+
158+ // ! in gint_fvl.cpp
159+ // ! calculate vl contributuion to force & stress via grid integrals
142160 void gint_kernel_force (const int na_grid,
143161 const int grid_index,
144162 const double delta_r,
@@ -150,6 +168,9 @@ class Gint {
150168 ModuleBase::matrix* svl_dphi,
151169 const UnitCell& ucell);
152170
171+ // ! in gint_fvl.cpp
172+ // ! calculate vl contributuion to force & stress via grid integrals
173+ // ! used in meta-GGA calculations
153174 void gint_kernel_force_meta (const int na_grid,
154175 const int grid_index,
155176 const double delta_r,
@@ -162,31 +183,38 @@ class Gint {
162183 ModuleBase::matrix* svl_dphi,
163184 const UnitCell& ucell);
164185
186+ // ! Use grid integrals to compute the atomic force contributions
187+ // ! na_grid: how many atoms on this (i,j,k) grid
188+ // ! block_size: dim is [na_grid], number of columns of a band
189+ // ! block_index: dim is [na_grid+1], total number of atomis orbitals
190+ // ! psir_vlbr3_DMR: dim is [bxyz][LD_pool]
191+ // ! dpsir_x: dim is [bxyz][LD_pool]
192+ // ! dpsir_y: dim is [bxyz][LD_pool]
193+ // ! dpsir_z: dim is [bxyz][LD_pool]
165194 void cal_meshball_force (
166195 const int grid_index,
167- const int na_grid, // how many atoms on this (i,j,k) grid
168- const int * const
169- block_size, // block_size[na_grid], number of columns of a band
170- const int * const block_index, // block_index[na_grid+1], count total
171- // number of atomis orbitals
172- const double * const * const psir_vlbr3_DMR, // psir_vlbr3[bxyz][LD_pool]
196+ const int na_grid,
197+ const int * const block_size,
198+ const int * const block_index,
199+ const double * const * const psir_vlbr3_DMR,
173200 const double * const * const dpsir_x, // psir_vlbr3[bxyz][LD_pool]
174201 const double * const * const dpsir_y, // psir_vlbr3[bxyz][LD_pool]
175202 const double * const * const dpsir_z, // psir_vlbr3[bxyz][LD_pool]
176203 ModuleBase::matrix* force);
177204
205+ // ! Use grid integrals to compute the stress contributions
206+ // ! na_grid: how many atoms on this (i,j,k) grid
207+ // ! block_index: dim is [na_grid+1], total number of atomis orbitals
178208 void cal_meshball_stress (
179- const int na_grid, // how many atoms on this (i,j,k) grid
180- const int *const block_index, // block_index[na_grid+1], count total number of atomis orbitals
209+ const int na_grid,
210+ const int *const block_index,
181211 const double *const psir_vlbr3_DMR,
182212 const double *const dpsirr,
183213 ModuleBase::matrix *stress);
184-
185- // ------------------------------------------------------
186- // in gint_k_rho.cpp
187- // ------------------------------------------------------
188- // calculate the charge density & kinetic energy density (tau) via grid
189- // integrals
214+
215+ // ! Use grid integrals to compute charge density
216+ // ! in gint_k_rho.cpp
217+ // ! calculate the charge density & kinetic energy density (tau) via grid integrals
190218 void gint_kernel_rho (const int na_grid,
191219 const int grid_index,
192220 const double delta_r,
@@ -195,13 +223,16 @@ class Gint {
195223 const UnitCell& ucell,
196224 Gint_inout* inout);
197225
226+ // ! Use grid integrals to compute charge density in a meshball
198227 void cal_meshball_rho (const int na_grid,
199228 const int *const block_index,
200229 const int *const vindex,
201230 const double *const *const psir_ylm,
202231 const double *const *const psir_DMR,
203232 double *const rho);
204233
234+ // ! Use grid integrals to compute kinetic energy density tau
235+ // !in meta-GGA functional
205236 void gint_kernel_tau (const int na_grid,
206237 const int grid_index,
207238 const double delta_r,
@@ -210,6 +241,8 @@ class Gint {
210241 Gint_inout* inout,
211242 const UnitCell& ucell);
212243
244+ // ! Use grid integrals to compute kinetic energy density tau
245+ // !in a meshball, used in meta-GGA functional calculations
213246 void cal_meshball_tau (const int na_grid,
214247 int * block_index,
215248 int * vindex,
@@ -221,16 +254,22 @@ class Gint {
221254 double ** dpsiz_dm,
222255 double * rho);
223256
224- // save the < phi_0i | V | phi_Rj > in sparse H matrix.
225- hamilt::HContainer<double >* hRGint
226- = nullptr ; // stores Hamiltonian in sparse format
227- std::vector<hamilt::HContainer<double >*> hRGint_tmp; // size of vec is 4, only used when nspin = 4
228- hamilt::HContainer<std::complex <double >>* hRGintCd
229- = nullptr ; // stores Hamiltonian in sparse format
230- std::vector<hamilt::HContainer<double >*>
231- DMRGint; // stores DMR in sparse format
232- hamilt::HContainer<double >* DMRGint_full
233- = nullptr ; // tmp tools used in transfer_DM2DtoGrid
257+ // ! save the < phi_0i | V | phi_Rj > in sparse H matrix.
258+ // ! stores Hamiltonian in sparse format
259+ hamilt::HContainer<double >* hRGint = nullptr ;
260+
261+ // ! size of vec is 4, only used when nspin = 4
262+ std::vector<hamilt::HContainer<double >*> hRGint_tmp;
263+
264+ // ! stores Hamiltonian in sparse format
265+ hamilt::HContainer<std::complex <double >>* hRGintCd = nullptr ;
266+
267+ // ! stores DMR in sparse format
268+ std::vector<hamilt::HContainer<double >*> DMRGint;
269+
270+ // ! tmp tools used in transfer_DM2DtoGrid
271+ hamilt::HContainer<double >* DMRGint_full = nullptr ;
272+
234273 std::vector<hamilt::HContainer<double >> pvdpRx_reduced;
235274 std::vector<hamilt::HContainer<double >> pvdpRy_reduced;
236275 std::vector<hamilt::HContainer<double >> pvdpRz_reduced;
0 commit comments