|
ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
|
Class for k-points management. More...
#include <klist.h>
Public Member Functions | |
| K_Vectors () | |
| ~K_Vectors () | |
| K_Vectors & | operator= (const K_Vectors &)=default |
| K_Vectors & | operator= (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, std::ofstream &ofs_warning, const bool use_ibz, const std::string &global_out_dir, const bool gamma_only_local, const double kspacing[3], const std::string &kmesh_type, const double koffset[3]) |
| Set up the k-points for the system. | |
| int | get_nks () const |
| int | get_nkstot () const |
| int | get_nkstot_nospin () const |
| double | get_koffset (const int i) const |
| int | get_k_nkstot () const |
| int | get_spin_mult () const |
| Spin multiplicity of the k-point list: 1 (no doubling, also for non-collinear nspin=4) or 2 (LSDA, k points split into up/down). | |
| std::string | get_k_kword () const |
| void | set_nks (int value) |
| void | set_nkstot (int value) |
| void | set_nkstot_nospin (int value) |
| void | set_spin_mult (int value) |
| Set the spin multiplicity: 1 (no doubling, also for non-collinear nspin=4) or 2 (LSDA, k points split into up/down). | |
| bool | get_is_mp () const |
| bool | is_uniform_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, std::ofstream &ofs_running, const int my_rank) |
| Updates the k-points to use the irreducible Brillouin zone (IBZ). | |
| void | set_after_vc (const ModuleBase::Matrix3 &G, const ModuleSymmetry::Symmetry &symm, const bool update_symmetry, std::ofstream &ofs_running) |
| Updates the k-points after a volume change. | |
| bool | read_kpoints_for_testing (const UnitCell &ucell, const std::string &fn, const bool gamma_only_local, const double kspacing[3], const std::string &kmesh_type, const double koffset_in[3], std::ofstream &ofs_running, std::ofstream &ofs_warning, const int my_rank) |
| void | renew_for_testing (const int &kpoint_number) |
| void | reduce_by_symmetry_for_testing (const UnitCell &ucell, const ModuleSymmetry::Symmetry &symm, bool use_symm, std::string &skpt, bool &match, const int my_rank, std::ofstream &ofs_running) |
| void | set_kup_and_kdw_for_testing (std::ofstream &ofs_running) |
| Public Member Functions inherited from ModuleCell::ReciprocalGrid | |
| ReciprocalGrid ()=default | |
| virtual | ~ReciprocalGrid ()=default |
| ReciprocalGrid & | operator= (const ReciprocalGrid &)=default |
| ReciprocalGrid & | operator= (ReciprocalGrid &&)=default |
| double | Monkhorst_Pack_formula (const int &k_type, const double &offset, const int &n, const int &dim) |
| Coordinate of a point generated by the Monkhorst-Pack scheme. | |
| void | Monkhorst_Pack (const int *nmp_in, const double *koffset_in, const int k_type) |
| Generate a Monkhorst-Pack mesh. | |
| void | kvec_d2c (const ModuleBase::Matrix3 &reciprocal_vec) |
| Convert direct to Cartesian coordinates. | |
| void | kvec_c2d (const ModuleBase::Matrix3 &latvec) |
| Convert Cartesian to direct coordinates. | |
| void | set_both_kvec (const ModuleBase::Matrix3 &G, const ModuleBase::Matrix3 &R, std::string &skpt, std::ofstream &ofs_running, std::ofstream &ofs_warning) |
| Set both the direct and Cartesian coordinates, and print the table. | |
| void | normalize_wk (const int °spin) |
| Normalize the weights so that they sum to the spin degeneracy. | |
| void | print_klists (std::ofstream &ofs) const |
| Print the points in both Cartesian and direct coordinates. | |
| void | reduce_ibz (const ModuleBase::Matrix3 *rot_ops, int nrotkm, const ModuleBase::Matrix3 &G, const ModuleBase::Matrix3 &k_lattice, const ModuleBase::Matrix3 *kkmatrix, double epsilon, std::vector< ModuleBase::Vector3< double > > &vec_ibz, std::vector< double > &wk_ibz, std::vector< int > &ibz_index, std::vector< int > &ibz2bz) |
| Star (IBZ) reduction primitive shared by k-points and q-points. | |
Public Attributes | |
| std::vector< int > | isk |
| distinguish spin up and down k points | |
| std::vector< std::map< int, ModuleBase::Vector3< double > > > | kstars |
| equal k points to each ibz-kpont, corresponding to a certain symmetry operations. dim: [iks_ibz][(isym, kvec_d)] | |
| 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 | |
| Public Attributes inherited from ModuleCell::ReciprocalGrid | |
| std::vector< ModuleBase::Vector3< double > > | kvec_c |
| Cartesian coordinates of the points, in unit of 2*pi/lat0. | |
| std::vector< ModuleBase::Vector3< double > > | kvec_d |
| Direct coordinates of the points. | |
| std::vector< ModuleBase::Vector3< double > > | kvec_c_full |
| Cartesian coordinates of the full (unreduced) mesh, in unit of 2*pi/lat0. | |
| std::vector< double > | wk |
| Weight of each point. | |
| std::vector< int > | ngk |
| Number of plane waves for each point (filled by the PW basis). | |
| int | nmp [3] = {0, 0, 0} |
| Monkhorst-Pack grid dimensions. | |
| std::vector< int > | kl_segids |
| Index of the k-line segment each point belongs to. | |
| bool | kc_done = false |
| Whether the Cartesian coordinates have been computed. | |
| bool | kd_done = false |
| Whether the direct coordinates have been computed. | |
| int | nks = 0 |
| Number of points in the current pool (spin-free view). | |
| int | nkstot = 0 |
| int | nkstot_nospin = 0 |
| bool | is_mp = false |
| Whether this is a Monkhorst-Pack grid. | |
| int | k_nkstot = 0 |
| Total number of points read from a point-list file (0 = auto mesh). | |
| std::string | k_kword |
| Type keyword of the point-list file. | |
Private Member Functions | |
| void | renew (const int &kpoint_number) override |
| Resize the k-point related vectors according to the new k-point number. | |
| int | spin_factor () const override |
| Spin multiplicity used when generating the mesh (1/2). | |
| void | reduce_by_symmetry (const UnitCell &ucell, const ModuleSymmetry::Symmetry &symm, bool use_symm, std::string &skpt, bool &match, const int my_rank, std::ofstream &ofs_running) override |
| Reduce the k-points to the irreducible Brillouin zone (IBZ). | |
| bool | read_kpoints (const UnitCell &ucell, const std::string &fn, const bool gamma_only_local, const double kspacing[3], const std::string &kmesh_type, const double koffset[3], std::ofstream &ofs_running, std::ofstream &ofs_warning, const int my_rank) |
| step 1 : generate kpoints | |
| bool | parse_kfile (const std::string &fn, std::ofstream &ofs_running, std::ofstream &ofs_warning) |
| Read the KPT file and build the k-point list from it. | |
| bool | read_mp_mesh (std::ifstream &ifk, const std::string &kword, std::ofstream &ofs_running, std::ofstream &ofs_warning) |
| Read the Monkhorst-Pack/Gamma mesh block and generate the mesh. | |
| bool | read_listed_kpoints (std::ifstream &ifk, const std::string &kword, std::ofstream &ofs_warning) |
| Read the explicitly listed k points (nkstot > 0 form of KPT). | |
| bool | setup_line_kpoints (std::ifstream &ifk, std::vector< ModuleBase::Vector3< double > > &kvec, const bool cartesian, std::ofstream &ofs_warning) |
| Build line-mode k points by interpolating between special points. | |
| void | handle_symmetry_mismatch (const UnitCell &ucell, const ModuleSymmetry::Symmetry &symm, std::string &skpt, bool &match, const int my_rank, std::ofstream &ofs) |
| Handle a reciprocal/real lattice Bravais-type mismatch after IBZ reduction. | |
| void | interpolate_k_between (std::ifstream &ifk, std::vector< ModuleBase::Vector3< double > > &kvec) |
| Adds k-points linearly between special points. | |
| void | set_kup_and_kdw (std::ofstream &ofs_running) |
| step 4 : *2 kpoints | |
| void | mpi_k (std::ofstream &ofs_running, const int my_rank, const int my_pool) |
| Distributes k-points among MPI processes. | |
Private Attributes | |
| int | spin_mult = 0 |
| double | koffset [3] = {0.0} |
| used only in automatic k-points | |
Additional Inherited Members | |
| Protected Member Functions inherited from ModuleCell::ReciprocalGrid | |
| bool | build_star_ops (const UnitCell &ucell, const ModuleSymmetry::Symmetry &symm, bool use_symm, ModuleBase::Matrix3 &k_vec, std::vector< ModuleBase::Matrix3 > &kgmatrix, int &nrotkm) const |
| Build the reciprocal-space point-group operations for star reduction. | |
Class for k-points management.
Inherits the spin-free common reciprocal-grid functionality (mesh generation, coordinate conversion, weights, printing, star/IBZ reduction primitive) from ModuleCell::ReciprocalGrid and adds the spin expansion (isk, spin-multiplicity doubling) and the k-point IBZ logic.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Spin multiplicity of the k-point list: 1 (no doubling, also for non-collinear nspin=4) or 2 (LSDA, k points split into up/down).
|
private |
Handle a reciprocal/real lattice Bravais-type mismatch after IBZ reduction.
When symmetry_autoclose is enabled, symmetry is switched off and the IBZ reduction is retried; otherwise the run aborts with a WARNING_QUIT listing the possible remedies.
| ucell | unit cell used for the retried IBZ reduction |
| symm | symmetry operations used for the retried reduction |
| skpt | k-point option string forwarded to reduce_by_symmetry |
| match | set to true when the autoclose retry succeeds |
|
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.
| ifk | The input file stream from which the special points and the number of k-points between them are read. |
| kvec | A vector to store the generated k-points. |
| bool K_Vectors::is_uniform_mp | ( | ) | const |
|
private |
Distributes k-points among MPI processes.
Broadcasts the k-point metadata (flags, counts, mesh, segment IDs) from rank 0 and distributes the per-pool k-point slice (indices, weights, coordinates) to every process. Only compiled with MPI.
|
private |
Read the KPT file and build the k-point list from it.
Locates the "K_POINTS" header, reads the point count and type keyword, then dispatches to the Monkhorst-Pack mesh, the explicit Cartesian/ Direct list, or the Line-mode interpolation accordingly.
| fn | KPT filename to read |
|
private |
step 1 : generate kpoints
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.
| fn | The name of the file containing the k-points. |
|
inline |
|
private |
Read the explicitly listed k points (nkstot > 0 form of KPT).
Dispatches on the type keyword: Cartesian/Direct lists are sized via renew() and filled through KListIO::read_kpt_list; Line_Cartesian/ Line_Direct delegate to setup_line_kpoints.
| ifk | stream positioned after the type keyword |
| kword | type keyword: Cartesian, C, Direct, D, Line_Cartesian, Line_Direct, L or Line |
|
private |
Read the Monkhorst-Pack/Gamma mesh block and generate the mesh.
Handles the nkstot == 0 form of the KPT file: validates the type keyword, reads the mesh dimensions and optional offsets, then calls Monkhorst_Pack to fill the k-point list.
| ifk | stream positioned after the type keyword |
| kword | type keyword (Gamma / Monkhorst-Pack / MP / mp) |
| ofs_running | running log stream |
|
overrideprivatevirtual |
Reduce the k-points to the irreducible Brillouin zone (IBZ).
Orchestrates the K-specific parts of the IBZ reduction (Bravais-lattice compatibility checks, point-group construction, time-reversal / magnetic operation doubling, k-star bookkeeping and the printed reduction table) and delegates the generic folding loop to ReciprocalGrid::reduce_ibz.
| ucell | unit cell |
| symm | symmetry of the system |
| use_symm | whether symmetry reduction is enabled |
| skpt | output string holding the reduction table |
| match | set to false if the reciprocal lattice is not compatible with the real-space lattice |
Implements ModuleCell::ReciprocalGrid.
|
inline |
|
overrideprivatevirtual |
Resize the k-point related vectors according to the new k-point number.
Extends the base-class implementation so that the spin index (isk) is resized along with the coordinate/weight containers.
| kpoint_number | The new number of k-points. |
Reimplemented from ModuleCell::ReciprocalGrid.
|
inline |
| 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, | ||
| std::ofstream & | ofs_warning, | ||
| const bool | use_ibz, | ||
| const std::string & | global_out_dir, | ||
| const bool | gamma_only_local, | ||
| const double | kspacing[3], | ||
| const std::string & | kmesh_type, | ||
| const double | koffset[3] ) |
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.
| symm | The symmetry of the system. |
| k_file_name | The name of the file containing the k-points. |
| nspin_in | The number of spins. |
| reciprocal_vec | The reciprocal vector of the system. |
| latvec | The lattice vector of the system. |
| use_ibz | Whether to reduce k-points to the irreducible Brillouin zone. |
| void K_Vectors::set_after_vc | ( | const ModuleBase::Matrix3 & | G, |
| const ModuleSymmetry::Symmetry & | symm, | ||
| const bool | update_symmetry, | ||
| std::ofstream & | ofs_running ) |
Updates the k-points after a volume change.
Converts the direct coordinates (which are kept across the volume change) to the new Cartesian coordinates using the new reciprocal lattice, prints the resulting table, and marks both coordinate sets as up to date. The spin multiplicity is not touched: it was fixed by set() and never changes during a run.
Reindex existing k-stars using the newly analyzed symmetry operations, preserving IBZ representatives, weights, and pool/spin ownership.
| G | The new reciprocal lattice matrix. |
| symm | The symmetry analyzed for the new cell. |
| update_symmetry | Whether crystal symmetry is enabled. |
|
private |
step 4 : *2 kpoints
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
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Set the spin multiplicity: 1 (no doubling, also for non-collinear nspin=4) or 2 (LSDA, k points split into up/down).
|
private |
Build line-mode k points by interpolating between special points.
Refuses (warning + false) when symmetry reduction is enabled, then interpolates the special points read from ifk, resets all weights to 1, and marks the Cartesian or Direct coordinate set as done.
| ifk | stream to read the special points from |
| kvec | target coordinate container (kvec_c or kvec_d) |
| cartesian | true for Line_Cartesian, false for Line_Direct |
| ofs_warning | warning-log stream for error messages |
|
inlineoverrideprivatevirtual |
Spin multiplicity used when generating the mesh (1/2).
Reimplemented from ModuleCell::ReciprocalGrid.
| 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, | ||
| std::ofstream & | ofs_running, | ||
| const int | my_rank ) |
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.
| std::vector<int> K_Vectors::ibz_index |
map k points (before symmetry reduction) to irreducible k-points
| std::vector<int> K_Vectors::ik2iktot |
[nks] map ik to the global index of k points
| std::vector<int> K_Vectors::isk |
distinguish spin up and down k points
|
private |
used only in automatic k-points
| std::vector<std::map<int, ModuleBase::Vector3<double> > > K_Vectors::kstars |
equal k points to each ibz-kpont, corresponding to a certain symmetry operations. dim: [iks_ibz][(isym, kvec_d)]
| Parallel_Kpoints K_Vectors::para_k |
parallel for kpoints
|
private |
Spin multiplicity used to size the k-point list: 1 for input nspin 1 or 4 (non-collinear k points are not doubled) and 2 for input nspin 2 (LSDA up/down k points). This is NOT the physical nspin (1/2/4).