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