ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
gint_info.h
Go to the documentation of this file.
1#ifndef ABACUS_SOURCE_HAMILT_MODULE_GINT_GINT_INFO_H
2#define ABACUS_SOURCE_HAMILT_MODULE_GINT_GINT_INFO_H
3
4#include "big_grid.h"
5#include "divide_info.h"
6#include "gint_atom.h"
7#include "gint_helper.h"
8#include "localcell_info.h"
13#include "unitcell_info.h"
14#include <memory>
15#include <vector>
16
17#ifdef __CUDA
18#include "batch_biggrid.h"
20#endif
21
22namespace ModuleGint
23{
24
26{
27 public:
28 // constructor
30 int nbx,
31 int nby,
32 int nbz,
33 int nmx,
34 int nmy,
35 int nmz,
36 int startidx_bx,
37 int startidx_by,
38 int startidx_bz,
39 int nbx_local,
40 int nby_local,
41 int nbz_local,
42 const Numerical_Orbital *Phi,
43 const UnitCell &ucell,
44 Grid_Driver &gd,
45 int nspin,
46 bool gamma_only,
47 bool domag,
48 bool use_gpu,
49 int nstream);
50
51 ~GintInfo();
52
53 static GintInfo make_test_instance(const UnitCell &ucell, std::vector<int> ijr_info)
54 {
55 GintInfo info;
56 info.ucell_ = &ucell;
57 info.ijr_info_ = std::move(ijr_info);
58 return info;
59 }
60
61 static GintInfo *make_test_instance_ptr(const UnitCell &ucell, std::vector<int> ijr_info)
62 {
63 GintInfo *info = new GintInfo();
64 info->ucell_ = &ucell;
65 info->ijr_info_ = std::move(ijr_info);
66 return info;
67 }
68
69 // getter functions
70 const std::vector<std::shared_ptr<BigGrid>> &get_biggrids() { return biggrids_; }
71 int get_bgrids_num() const { return static_cast<int>(biggrids_.size()); }
72 const std::vector<int> &get_trace_lo() const { return trace_lo_; }
73 int get_lgd() const { return lgd_; }
74 int get_nat() const { return ucell_->nat; } // return the number of atoms in the unitcell
75 const UnitCell *get_ucell() const { return ucell_; }
76 const std::vector<int> &get_ijr_info() const { return ijr_info_; }
77 int get_local_mgrid_num() const { return localcell_info_->get_mgrids_num(); }
78 double get_mgrid_volume() const { return meshgrid_info_->get_volume(); }
80 int get_nspin() const { return nspin_; }
81 bool get_domag() const { return domag_; }
82 bool use_gpu() const { return use_gpu_; }
83 void set_exec_precision(const GintPrecision precision) { exec_precision_ = precision; }
84
85 //=========================================
86 // functions about hcontainer
87 //=========================================
88 template <typename T>
89 HContainer<T> get_hr(int npol = 1) const
90 {
91 auto hr = HContainer<T>(ucell_->nat);
92 if (gamma_only_)
93 {
94 hr.fix_gamma();
95 }
96 hr.insert_ijrs(&ijr_info_, *ucell_, npol);
97 hr.allocate(nullptr, true);
98 return hr;
99 }
100
101 private:
102 GintInfo() = default;
103
104 // initialize the atoms
105 void init_atoms_(int ntype, const Atom *atoms, const Numerical_Orbital *Phi);
106
107 // initialize trace_lo_ and lgd_
108 void init_trace_lo_(const UnitCell &ucell, const int nspin);
109
110 // initialize the ijr_info
111 void init_ijr_info_(const UnitCell &ucell, Grid_Driver &gd);
112
113 const UnitCell *ucell_ = nullptr;
114
115 // the unitcell information
116 std::shared_ptr<const UnitCellInfo> unitcell_info_;
117
118 // the biggrid information
119 std::shared_ptr<const BigGridInfo> biggrid_info_;
120
121 // the meshgrid information
122 std::shared_ptr<const MeshGridInfo> meshgrid_info_;
123
124 // the divide information
125 std::shared_ptr<const DivideInfo> divide_info_;
126
127 // the localcell information
128 std::shared_ptr<const LocalCellInfo> localcell_info_;
129
130 // the big grids on this processor
131 std::vector<std::shared_ptr<BigGrid>> biggrids_;
132
133 // the total atoms in the unitcell(include extended unitcell) on this processor
134 // atoms[iat][Vec3i] is the atom with index iat in the unitcell with index Vec3i
135 // Note: Since GintAtom does not implement a default constructor,
136 // the map should not be accessed using [], but rather using the at function
137 std::vector<std::map<Vec3i, GintAtom>> atoms_;
138
139 // if the iat-th(global index) atom is in this processor, return true
140 std::vector<bool> is_atom_in_proc_;
141
142 // format for storing atomic pair information in hcontainer, used for initializing hcontainer
143 std::vector<int> ijr_info_;
144
145 // map the global index of atomic orbitals to local index
146 std::vector<int> trace_lo_;
147
148 // store the information about Numerical orbitals
149 std::vector<Numerical_Orbital> orbs_;
150
151 // total num of atomic orbitals on this proc
152 int lgd_ = 0;
153
155 int nspin_ = 1;
156 bool gamma_only_ = false;
157 bool domag_ = false;
158 bool use_gpu_ = false;
159
160#ifdef __CUDA
161 public:
162 std::vector<std::shared_ptr<BatchBigGrid>> &get_bgrid_batches() { return bgrid_batches_; };
163 int get_bgrid_batches_num() const { return static_cast<int>(bgrid_batches_.size()); };
164 std::shared_ptr<const GintGpuVars> get_gpu_vars() const { return gpu_vars_; };
165 int get_dev_id() const { return gpu_vars_->dev_id_; };
166 int get_streams_num() const { return streams_num_; };
167
168 private:
169 void init_bgrid_batches_(int batch_size);
170 std::vector<std::shared_ptr<BatchBigGrid>> bgrid_batches_;
171 std::shared_ptr<const GintGpuVars> gpu_vars_;
172 // More streams can improve parallelism and may speed up grid integration, at the cost of higher GPU memory usage.
173 int streams_num_;
174#endif
175};
176
177} // namespace ModuleGint
178
179#endif // ABACUS_SOURCE_HAMILT_MODULE_GINT_GINT_INFO_H
Atom class for storing atom information.
Atom class for storing atom information.
Definition atom_spec.h:14
Grid_Driver class for neighbor search interface.
Definition sltk_grid_driver.h:63
void init_ijr_info_(const UnitCell &ucell, Grid_Driver &gd)
Definition gint_info.cpp:219
bool use_gpu() const
Definition gint_info.h:82
~GintInfo()
Definition gint_info.cpp:80
const std::vector< int > & get_trace_lo() const
Definition gint_info.h:72
std::shared_ptr< const MeshGridInfo > meshgrid_info_
Definition gint_info.h:122
GintPrecision get_exec_precision() const
Definition gint_info.h:79
const UnitCell * get_ucell() const
Definition gint_info.h:75
void set_exec_precision(const GintPrecision precision)
Definition gint_info.h:83
bool use_gpu_
Definition gint_info.h:158
int get_local_mgrid_num() const
Definition gint_info.h:77
GintPrecision exec_precision_
Definition gint_info.h:154
bool domag_
Definition gint_info.h:157
const UnitCell * ucell_
Definition gint_info.h:113
std::vector< Numerical_Orbital > orbs_
Definition gint_info.h:149
HContainer< T > get_hr(int npol=1) const
Definition gint_info.h:89
void init_atoms_(int ntype, const Atom *atoms, const Numerical_Orbital *Phi)
Definition gint_info.cpp:86
int get_bgrids_num() const
Definition gint_info.h:71
bool get_domag() const
Definition gint_info.h:81
int lgd_
Definition gint_info.h:152
void init_trace_lo_(const UnitCell &ucell, const int nspin)
Definition gint_info.cpp:170
int get_nspin() const
Definition gint_info.h:80
GintInfo(int nbx, int nby, int nbz, int nmx, int nmy, int nmz, int startidx_bx, int startidx_by, int startidx_bz, int nbx_local, int nby_local, int nbz_local, const Numerical_Orbital *Phi, const UnitCell &ucell, Grid_Driver &gd, int nspin, bool gamma_only, bool domag, bool use_gpu, int nstream)
Definition gint_info.cpp:12
std::vector< bool > is_atom_in_proc_
Definition gint_info.h:140
int get_lgd() const
Definition gint_info.h:73
std::shared_ptr< const LocalCellInfo > localcell_info_
Definition gint_info.h:128
std::vector< std::map< Vec3i, GintAtom > > atoms_
Definition gint_info.h:137
std::vector< int > ijr_info_
Definition gint_info.h:143
std::vector< std::shared_ptr< BigGrid > > biggrids_
Definition gint_info.h:131
int nspin_
Definition gint_info.h:155
double get_mgrid_volume() const
Definition gint_info.h:78
std::shared_ptr< const BigGridInfo > biggrid_info_
Definition gint_info.h:119
std::shared_ptr< const UnitCellInfo > unitcell_info_
Definition gint_info.h:116
bool gamma_only_
Definition gint_info.h:156
const std::vector< std::shared_ptr< BigGrid > > & get_biggrids()
Definition gint_info.h:70
const std::vector< int > & get_ijr_info() const
Definition gint_info.h:76
std::vector< int > trace_lo_
Definition gint_info.h:146
static GintInfo * make_test_instance_ptr(const UnitCell &ucell, std::vector< int > ijr_info)
Definition gint_info.h:61
std::shared_ptr< const DivideInfo > divide_info_
Definition gint_info.h:125
int get_nat() const
Definition gint_info.h:74
static GintInfo make_test_instance(const UnitCell &ucell, std::vector< int > ijr_info)
Definition gint_info.h:53
Definition orb_atomic.h:52
Provide the basic information about unitcell.
Definition unitcell.h:16
Definition batch_biggrid.cpp:4
GintPrecision
Definition gint_helper.h:11
@ fp64
Definition gint_helper.h:12
hamilt::HContainer< T > HContainer
Definition gint_type.h:15
Grid_Driver class for neighbor search interface.