ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
klist.h
Go to the documentation of this file.
1#ifndef K_VECTORS_H
2#define K_VECTORS_H
3
8#include "parallel_kpoints.h"
9#include "k_vector_utils.h"
10#include <vector>
11
13{
14public:
15 std::vector<ModuleBase::Vector3<double>> kvec_c;
16 std::vector<ModuleBase::Vector3<double>> kvec_d;
17
18 std::vector<double> wk;
19
20 std::vector<int> ngk;
21 std::vector<int> isk;
22
23 int nmp[3]={0};
24 std::vector<int> kl_segids;
25
28 std::vector<std::map<int, ModuleBase::Vector3<double>>> kstars;
29
30 bool kc_done = false;
31 bool kd_done = false;
32
35 K_Vectors& operator=(const K_Vectors&) = default;
36 K_Vectors& operator=(K_Vectors&& rhs) = default;
37
39
40
60 void set(const UnitCell& ucell,
61 const ModuleSymmetry::Symmetry& symm,
62 const std::string& k_file_name,
63 const int& nspin,
64 const ModuleBase::Matrix3& reciprocal_vec,
65 const ModuleBase::Matrix3& latvec,
66 std::ofstream& ofs);
67
68 int get_nks() const
69 {
70 return this->nks;
71 }
72
73 int get_nkstot() const
74 {
75 return this->nkstot;
76 }
77
78 int get_nkstot_full() const
79 {
80 return this->nkstot_full;
81 }
82
83 double get_koffset(const int i) const
84 {
85 return this->koffset[i];
86 }
87
88 int get_k_nkstot() const
89 {
90 return this->k_nkstot;
91 }
92
93 int get_nspin() const
94 {
95 return this->nspin;
96 }
97
98 std::string get_k_kword() const
99 {
100 return this->k_kword;
101 }
102
103 void set_nks(int value)
104 {
105 this->nks = value;
106 }
107
108 void set_nkstot(int value)
109 {
110 this->nkstot = value;
111 }
112
113 void set_nkstot_full(int value)
114 {
115 this->nkstot_full = value;
116 }
117
118 void set_nspin(int value)
119 {
120 this->nspin = value;
121 }
122
123 bool get_is_mp() const
124 {
125 return is_mp;
126 }
127
128 std::vector<int> ik2iktot;
129 std::vector<int> ibz_index;
130
148 void update_use_ibz(const int& nkstot_ibz,
149 const std::vector<ModuleBase::Vector3<double>>& kvec_d_ibz,
150 const std::vector<double>& wk_ibz);
151
152 private:
153 int nks = 0;
154 int nkstot = 0;
155 int nkstot_full = 0;
156
157 int nspin = 0;
158 double koffset[3] = {0.0}; // used only in automatic k-points.
159 std::string k_kword; // LiuXh add 20180619
160 int k_nkstot = 0; // LiuXh add 20180619 // WHAT IS THIS?????
161 bool is_mp = false; // Monkhorst-Pack
162
177 void renew(const int& kpoint_number);
178
179 // step 1 : generate kpoints
180
200 bool read_kpoints(const UnitCell& ucell,
201 const std::string& fn); // return 0: something wrong.
202
224 void interpolate_k_between(std::ifstream& ifk, std::vector<ModuleBase::Vector3<double>>& kvec);
225
241 void Monkhorst_Pack(const int* nmp_in, const double* koffset_in, const int tipo);
242
258 double Monkhorst_Pack_formula(const int& k_type, const double& offset, const int& n, const int& dim);
259
260 // step 2 : set both kvec and kved; normalize weight
261
262 // void set_both_kvec(const ModuleBase::Matrix3& G, const ModuleBase::Matrix3& R, std::string& skpt);
263
280 void normalize_wk(const int& degspin);
281
282
283
284 // step 4 : *2 kpoints.
285
305 void set_kup_and_kdw();
306
311 void cal_ik_global();
312#ifdef __MPI
314#endif
315};
316#endif // KVECT_H
Definition klist.h:13
bool is_mp
Definition klist.h:161
void interpolate_k_between(std::ifstream &ifk, std::vector< ModuleBase::Vector3< double > > &kvec)
Adds k-points linearly between special points.
Definition klist.cpp:403
int nspin
Definition klist.h:157
double koffset[3]
Definition klist.h:158
int get_nkstot_full() const
Definition klist.h:78
void set_nkstot_full(int value)
Definition klist.h:113
int get_nks() const
Definition klist.h:68
void set_nks(int value)
Definition klist.h:103
std::vector< int > kl_segids
Number of Monhorst-Pack.
Definition klist.h:24
int nmp[3]
distinguish spin up and down k points
Definition klist.h:23
K_Vectors()
Definition klist.h:33
void Monkhorst_Pack(const int *nmp_in, const double *koffset_in, const int tipo)
Generates k-points using the Monkhorst-Pack scheme.
Definition klist.cpp:483
std::string k_kword
Definition klist.h:159
void normalize_wk(const int &degspin)
Normalizes the weights of the k-points.
Definition klist.cpp:558
double get_koffset(const int i) const
Definition klist.h:83
double Monkhorst_Pack_formula(const int &k_type, const double &offset, const int &n, const int &dim)
Calculates the coordinate of a k-point using the Monkhorst-Pack scheme.
Definition klist.cpp:468
std::vector< ModuleBase::Vector3< double > > kvec_d
Cartesian coordinates of k points.
Definition klist.h:16
void renew(const int &kpoint_number)
Resize the k-point related vectors according to the new k-point number.
Definition klist.cpp:182
void set_kup_and_kdw()
Sets up the k-points for spin-up and spin-down calculations.
Definition klist.cpp:588
~K_Vectors()
Definition klist.h:34
K_Vectors & operator=(K_Vectors &&rhs)=default
bool kc_done
Definition klist.h:30
std::vector< int > ik2iktot
[nks] map ik to the global index of k points
Definition klist.h:128
K_Vectors & operator=(const K_Vectors &)=default
bool read_kpoints(const UnitCell &ucell, const std::string &fn)
Reads the k-points from a file.
Definition klist.cpp:195
void update_use_ibz(const int &nkstot_ibz, const std::vector< ModuleBase::Vector3< double > > &kvec_d_ibz, const std::vector< double > &wk_ibz)
Updates the k-points to use the irreducible Brillouin zone (IBZ).
Definition klist.cpp:528
int get_nspin() const
Definition klist.h:93
std::vector< int > isk
ngk, number of plane waves for each k point
Definition klist.h:21
int get_k_nkstot() const
Definition klist.h:88
void set_nkstot(int value)
Definition klist.h:108
int nks
number of symmetry-reduced k points in this pool(processor, up+dw)
Definition klist.h:153
int nkstot_full
number of k points before symmetry reduction in full k mesh
Definition klist.h:155
void cal_ik_global()
Gets the global index of a k-point.
Definition klist.cpp:14
int k_nkstot
Definition klist.h:160
void set(const UnitCell &ucell, const ModuleSymmetry::Symmetry &symm, const std::string &k_file_name, const int &nspin, const ModuleBase::Matrix3 &reciprocal_vec, const ModuleBase::Matrix3 &latvec, std::ofstream &ofs)
Set up the k-points for the system.
Definition klist.cpp:43
Parallel_Kpoints para_k
parallel for kpoints
Definition klist.h:38
std::vector< int > ngk
wk, weight of k points
Definition klist.h:20
std::string get_k_kword() const
Definition klist.h:98
std::vector< std::map< int, ModuleBase::Vector3< double > > > kstars
index of kline segment
Definition klist.h:28
int nkstot
number of symmetry-reduced k points in full k mesh
Definition klist.h:154
std::vector< ModuleBase::Vector3< double > > kvec_c
Definition klist.h:15
int get_nkstot() const
Definition klist.h:73
std::vector< double > wk
Direct coordinates of k points.
Definition klist.h:18
std::vector< int > ibz_index
map k points (before symmetry reduction) to irreducible k-points
Definition klist.h:129
bool kd_done
Definition klist.h:31
bool get_is_mp() const
Definition klist.h:123
void set_nspin(int value)
Definition klist.h:118
3x3 matrix and related mathamatical operations
Definition matrix3.h:19
3 elements vector
Definition vector3.h:22
Definition symmetry.h:16
Definition parallel_kpoints.h:10
Definition unitcell.h:16
void kvec_mpi_k(K_Vectors &kv)
Distributes k-points among MPI processes.
Definition k_vector_utils.cpp:221