ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | Friends | List of all members
K_Vectors Class Reference

#include <klist.h>

Collaboration diagram for K_Vectors:

Public Member Functions

 K_Vectors ()
 
 ~K_Vectors ()
 
K_Vectorsoperator= (const K_Vectors &)=default
 
K_Vectorsoperator= (K_Vectors &&rhs)=default
 
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.
 
int get_nks () const
 
int get_nkstot () const
 
int get_nkstot_full () const
 
double get_koffset (const int i) const
 
int get_k_nkstot () const
 
int get_nspin () const
 
std::string get_k_kword () const
 
void set_nks (int value)
 
void set_nkstot (int value)
 
void set_nkstot_full (int value)
 
void set_nspin (int value)
 
bool get_is_mp () const
 
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).
 

Public Attributes

std::vector< ModuleBase::Vector3< double > > kvec_c
 
std::vector< ModuleBase::Vector3< double > > kvec_d
 Cartesian coordinates of k points.
 
std::vector< double > wk
 Direct coordinates of k points.
 
std::vector< int > ngk
 wk, weight of k points
 
std::vector< int > isk
 ngk, number of plane waves for each k point
 
int nmp [3] ={0}
 distinguish spin up and down k points
 
std::vector< int > kl_segids
 Number of Monhorst-Pack.
 
std::vector< std::map< int, ModuleBase::Vector3< double > > > kstars
 index of kline segment
 
bool kc_done = false
 
bool kd_done = false
 
Parallel_Kpoints para_k
 parallel for kpoints
 
std::vector< int > ik2iktot
 [nks] map ik to the global index of k points
 
std::vector< int > ibz_index
 map k points (before symmetry reduction) to irreducible k-points
 

Private Member Functions

void renew (const int &kpoint_number)
 Resize the k-point related vectors according to the new k-point number.
 
bool read_kpoints (const UnitCell &ucell, const std::string &fn)
 Reads the k-points from a file.
 
void interpolate_k_between (std::ifstream &ifk, std::vector< ModuleBase::Vector3< double > > &kvec)
 Adds k-points linearly between special points.
 
void Monkhorst_Pack (const int *nmp_in, const double *koffset_in, const int tipo)
 Generates k-points using the Monkhorst-Pack scheme.
 
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.
 
void normalize_wk (const int &degspin)
 Normalizes the weights of the k-points.
 
void set_kup_and_kdw ()
 Sets up the k-points for spin-up and spin-down calculations.
 
void cal_ik_global ()
 Gets the global index of a k-point.
 

Private Attributes

int nks = 0
 number of symmetry-reduced k points in this pool(processor, up+dw)
 
int nkstot = 0
 number of symmetry-reduced k points in full k mesh
 
int nkstot_full = 0
 number of k points before symmetry reduction in full k mesh
 
int nspin = 0
 
double koffset [3] = {0.0}
 
std::string k_kword
 
int k_nkstot = 0
 
bool is_mp = false
 

Friends

void KVectorUtils::kvec_mpi_k (K_Vectors &kvec)
 

Constructor & Destructor Documentation

◆ K_Vectors()

K_Vectors::K_Vectors ( )
inline

◆ ~K_Vectors()

K_Vectors::~K_Vectors ( )
inline

Member Function Documentation

◆ cal_ik_global()

void K_Vectors::cal_ik_global ( )
private

Gets the global index of a k-point.

Returns
this->ik2iktot[ik]
Here is the caller graph for this function:

◆ get_is_mp()

bool K_Vectors::get_is_mp ( ) const
inline
Here is the caller graph for this function:

◆ get_k_kword()

std::string K_Vectors::get_k_kword ( ) const
inline
Here is the caller graph for this function:

◆ get_k_nkstot()

int K_Vectors::get_k_nkstot ( ) const
inline
Here is the caller graph for this function:

◆ get_koffset()

double K_Vectors::get_koffset ( const int  i) const
inline

◆ get_nks()

int K_Vectors::get_nks ( ) const
inline

◆ get_nkstot()

int K_Vectors::get_nkstot ( ) const
inline
Here is the caller graph for this function:

◆ get_nkstot_full()

int K_Vectors::get_nkstot_full ( ) const
inline
Here is the caller graph for this function:

◆ get_nspin()

int K_Vectors::get_nspin ( ) const
inline
Here is the caller graph for this function:

◆ interpolate_k_between()

void K_Vectors::interpolate_k_between ( std::ifstream &  ifk,
std::vector< ModuleBase::Vector3< double > > &  kvec 
)
private

Adds k-points linearly between special points.

This function adds k-points linearly between special points in the Brillouin zone. The special points and the number of k-points between them are read from an input file.

Parameters
ifkThe input file stream from which the special points and the number of k-points between them are read.
kvecA vector to store the generated k-points.
Returns
void
Note
The function first reads the number of special points (nks_special) and the number of k-points between them (nkl) from the input file.
The function then recalculates the total number of k-points (nkstot) based on the number of k-points between the special points.
The function generates the k-points by linearly interpolating between the special points.
The function also assigns a segment ID to each k-point to distinguish different k-line segments.
The function checks that the total number of generated k-points matches the calculated total number of k-points.
The function checks that the size of the segment ID vector matches the total number of k-points.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Monkhorst_Pack()

void K_Vectors::Monkhorst_Pack ( const int *  nmp_in,
const double *  koffset_in,
const int  tipo 
)
private

Generates k-points using the Monkhorst-Pack scheme.

This function generates k-points in the reciprocal space using the Monkhorst-Pack scheme.

Parameters
nmp_inthe number of k-points in each dimension.
koffset_inthe offset for the k-points in each dimension.
k_typeThe type of k-point. 1 means without Gamma point, 0 means with Gamma.
Returns
void
Note
The function assumes that the k-points are evenly distributed in the reciprocal space.
The function sets the weight of each k-point to be equal, so that the total weight of all k-points is 1.
The function sets the flag kd_done to true to indicate that the k-points have been generated.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Monkhorst_Pack_formula()

double K_Vectors::Monkhorst_Pack_formula ( const int &  k_type,
const double &  offset,
const int &  n,
const int &  dim 
)
private

Calculates the coordinate of a k-point using the Monkhorst-Pack scheme.

This function calculates the coordinate of a k-point in the reciprocal space using the Monkhorst-Pack scheme. The Monkhorst-Pack scheme is a method for generating k-points in the Brillouin zone.

Parameters
k_typeThe type of k-point. 1 means without Gamma point, 0 means with Gamma.
offsetThe offset for the k-point.
nThe index of the k-point in the current dimension.
dimThe total number of k-points in the current dimension.
Returns
double Returns the coordinate of the k-point.
Note
The function assumes that the k-points are evenly distributed in the reciprocal space.
Here is the caller graph for this function:

◆ normalize_wk()

void K_Vectors::normalize_wk ( const int &  degspin)
private

Normalizes the weights of the k-points.

This function normalizes the weights of the k-points so that their sum is equal to the degeneracy of spin (degspin).

Parameters
degspinThe degeneracy of spin. This is 1 for non-spin-polarized calculations and 2 for spin-polarized calculations.
Returns
void
Note
This function should only be called by the master process (MY_RANK == 0).
The function assumes that the sum of the weights of the k-points is greater than 0.
The function first normalizes the weights so that their sum is 1, and then scales them by the degeneracy of spin.
Here is the caller graph for this function:

◆ operator=() [1/2]

K_Vectors & K_Vectors::operator= ( const K_Vectors )
default

◆ operator=() [2/2]

K_Vectors & K_Vectors::operator= ( K_Vectors &&  rhs)
default

◆ read_kpoints()

bool K_Vectors::read_kpoints ( const UnitCell ucell,
const std::string &  fn 
)
private

Reads the k-points from a file.

This function reads the k-points from a file specified by the filename. It supports both Cartesian and Direct coordinates, and can handle different types of k-points, including Gamma, Monkhorst-Pack, and Line mode. It also supports automatic generation of k-points file if the file does not exist.

Parameters
fnThe name of the file containing the k-points.
Returns
bool Returns true if the k-points are successfully read from the file, false otherwise.
Note
It will generate a k-points file automatically according to the global variables GAMMA_ONLY_LOCAL and KSPACING.
If the k-points type is neither Gamma nor Monkhorst-Pack, it will quit with a warning.
If the k-points type is Line mode and the symmetry flag is 1, it will quit with a warning.
If the number of k-points is greater than 100000, it will quit with a warning.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ renew()

void K_Vectors::renew ( const int &  kpoint_number)
private

Resize the k-point related vectors according to the new k-point number.

This function resizes the vectors that store the k-point information, including the Cartesian and Direct coordinates of k-points, the weights of k-points, the index of k-points, and the number of plane waves for each k-point.

Parameters
kpoint_numberThe new number of k-points.
Returns
void
Note
The memory recording lines are commented out. If you want to track the memory usage, you can uncomment these lines.
Here is the caller graph for this function:

◆ set()

void K_Vectors::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.

This function sets up the k-points according to the input parameters and symmetry operations. It also treats the spin as another set of k-points.

Parameters
symmThe symmetry of the system.
k_file_nameThe name of the file containing the k-points.
nspin_inThe number of spins.
reciprocal_vecThe reciprocal vector of the system.
latvecThe lattice vector of the system.
Returns
void
Note
This function will quit with a warning if something goes wrong while reading the KPOINTS file.
If the optimized lattice type of the reciprocal lattice cannot match the optimized real lattice, it will output a warning and suggest possible solutions.
Only available for nspin = 1 or 2 or 4.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_kup_and_kdw()

void K_Vectors::set_kup_and_kdw ( )
private

Sets up the k-points for spin-up and spin-down calculations.

This function sets up the k-points for spin-up and spin-down calculations. If the calculation is spin-polarized (nspin = 2), the number of k-points is doubled. The first half of the k-points correspond to spin-up, and the second half correspond to spin-down. 2 for LSDA 4 for non-collinear

Returns
void
Note
For non-spin-polarized calculations (nspin = 1 or 4), the function simply sets the spin index of all k-points to 0.
For spin-polarized calculations (nspin = 2), the function duplicates the k-points and their weights, sets the spin index of the first half of the k-points to 0 (spin-up), and the spin index of the second half to 1 (spin-down).
The function also doubles the total number of k-points (nks and nkstot) for spin-polarized calculations.
The function prints the total number of k-points for spin-polarized calculations.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_nks()

void K_Vectors::set_nks ( int  value)
inline
Here is the caller graph for this function:

◆ set_nkstot()

void K_Vectors::set_nkstot ( int  value)
inline
Here is the caller graph for this function:

◆ set_nkstot_full()

void K_Vectors::set_nkstot_full ( int  value)
inline

◆ set_nspin()

void K_Vectors::set_nspin ( int  value)
inline
Here is the caller graph for this function:

◆ update_use_ibz()

void K_Vectors::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).

This function updates the k-points to use the irreducible Brillouin zone (IBZ) instead of the full Brillouin zone.

Returns
void
Note
This function should only be called by the master process (MY_RANK == 0).
This function assumes that the number of k-points in the IBZ (nkstot_ibz) is greater than 0.
This function updates the total number of k-points (nkstot) to be the number of k-points in the IBZ.
This function resizes the vector of k-points (kvec_d) and updates its values to be the k-points in the IBZ.
This function also updates the weights of the k-points (wk) to be the weights in the IBZ.
After this function is called, the flag kd_done is set to true to indicate that the k-points have been updated, and the flag kc_done is set to false to indicate that the Cartesian coordinates of the k-points need to be recalculated.
Here is the call graph for this function:
Here is the caller graph for this function:

Friends And Related Symbol Documentation

◆ KVectorUtils::kvec_mpi_k

void KVectorUtils::kvec_mpi_k ( K_Vectors kvec)
friend

Member Data Documentation

◆ ibz_index

std::vector<int> K_Vectors::ibz_index

map k points (before symmetry reduction) to irreducible k-points

◆ ik2iktot

std::vector<int> K_Vectors::ik2iktot

[nks] map ik to the global index of k points

◆ is_mp

bool K_Vectors::is_mp = false
private

◆ isk

std::vector<int> K_Vectors::isk

ngk, number of plane waves for each k point

◆ k_kword

std::string K_Vectors::k_kword
private

◆ k_nkstot

int K_Vectors::k_nkstot = 0
private

◆ kc_done

bool K_Vectors::kc_done = false

◆ kd_done

bool K_Vectors::kd_done = false

◆ kl_segids

std::vector<int> K_Vectors::kl_segids

Number of Monhorst-Pack.

◆ koffset

double K_Vectors::koffset[3] = {0.0}
private

◆ kstars

std::vector<std::map<int, ModuleBase::Vector3<double> > > K_Vectors::kstars

index of kline segment

equal k points to each ibz-kpont, corresponding to a certain symmetry operations. dim: [iks_ibz][(isym, kvec_d)]

◆ kvec_c

std::vector<ModuleBase::Vector3<double> > K_Vectors::kvec_c

◆ kvec_d

std::vector<ModuleBase::Vector3<double> > K_Vectors::kvec_d

Cartesian coordinates of k points.

◆ ngk

std::vector<int> K_Vectors::ngk

wk, weight of k points

◆ nks

int K_Vectors::nks = 0
private

number of symmetry-reduced k points in this pool(processor, up+dw)

◆ nkstot

int K_Vectors::nkstot = 0
private

number of symmetry-reduced k points in full k mesh

◆ nkstot_full

int K_Vectors::nkstot_full = 0
private

number of k points before symmetry reduction in full k mesh

◆ nmp

int K_Vectors::nmp[3] ={0}

distinguish spin up and down k points

◆ nspin

int K_Vectors::nspin = 0
private

◆ para_k

Parallel_Kpoints K_Vectors::para_k

parallel for kpoints

◆ wk

std::vector<double> K_Vectors::wk

Direct coordinates of k points.


The documentation for this class was generated from the following files: