Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion source/module_cell/cell_index.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* the maximum L of a given atom, the number of chi of a given atom and a given L, the atom label of a given atom,
* etc. The class provides the interface to get the information of the atoms and orbitals indices in the unit cell. It
* also provides the interface to write the orbital information into a file. It is now used only in the Output_Mulliken
* class. However, it is supposed to be able to replace GlobalC::ucell in LCAO codes where only cell indices are needed.
* class. However, it is supposed to be able to replace ucell in LCAO codes where only cell indices are needed.
* Take care that the three key vectors atomCounts, lnchiCounts, and atomLabels should be set from the UnitCell class.
* It depends on nspin because the functions get_nw() and get_iwt() are related to nspin, and can
* be used in the LCAO Hamiltonian construction.
Expand Down
20 changes: 11 additions & 9 deletions source/module_cell/klist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ int K_Vectors::get_ik_global(const int& ik, const int& nkstot)
}
}

void K_Vectors::set(const ModuleSymmetry::Symmetry& symm,
void K_Vectors::set(const UnitCell& ucell,
const ModuleSymmetry::Symmetry& symm,
const std::string& k_file_name,
const int& nspin_in,
const ModuleBase::Matrix3& reciprocal_vec,
Expand Down Expand Up @@ -93,7 +94,7 @@ void K_Vectors::set(const ModuleSymmetry::Symmetry& symm,
this->nspin = (this->nspin == 4) ? 1 : this->nspin;

// read KPT file and generate K-point grid
bool read_succesfully = this->read_kpoints(k_file_name);
bool read_succesfully = this->read_kpoints(ucell,k_file_name);
#ifdef __MPI
Parallel_Common::bcast_bool(read_succesfully);
#endif
Expand All @@ -113,7 +114,7 @@ void K_Vectors::set(const ModuleSymmetry::Symmetry& symm,
{
bool match = true;
// calculate kpoints in IBZ and reduce kpoints according to symmetry
this->ibz_kpoint(symm, ModuleSymmetry::Symmetry::symm_flag, skpt1, GlobalC::ucell, match);
this->ibz_kpoint(symm, ModuleSymmetry::Symmetry::symm_flag, skpt1, ucell, match);
#ifdef __MPI
Parallel_Common::bcast_bool(match);
#endif
Expand All @@ -128,7 +129,7 @@ void K_Vectors::set(const ModuleSymmetry::Symmetry& symm,
std::cout << "Automatically set symmetry to 0 and continue ..." << std::endl;
ModuleSymmetry::Symmetry::symm_flag = 0;
match = true;
this->ibz_kpoint(symm, ModuleSymmetry::Symmetry::symm_flag, skpt1, GlobalC::ucell, match);
this->ibz_kpoint(symm, ModuleSymmetry::Symmetry::symm_flag, skpt1, ucell, match);
} else {
ModuleBase::WARNING_QUIT("K_Vectors::ibz_kpoint",
"Possible solutions: \n \
Expand Down Expand Up @@ -209,7 +210,8 @@ void K_Vectors::renew(const int& kpoint_number)

// Read the KPT file, which contains K-point coordinates, weights, and grid size information
// Generate K-point grid according to different parameters of the KPT file
bool K_Vectors::read_kpoints(const std::string& fn)
bool K_Vectors::read_kpoints(const UnitCell& ucell,
const std::string& fn)
{
ModuleBase::TITLE("K_Vectors", "read_kpoints");
if (GlobalV::MY_RANK != 0)
Expand All @@ -236,16 +238,16 @@ bool K_Vectors::read_kpoints(const std::string& fn)
ModuleBase::WARNING_QUIT("K_Vectors", "kspacing should > 0");
};
// number of K points = max(1,int(|bi|/KSPACING+1))
ModuleBase::Matrix3 btmp = GlobalC::ucell.G;
ModuleBase::Matrix3 btmp = ucell.G;
double b1 = sqrt(btmp.e11 * btmp.e11 + btmp.e12 * btmp.e12 + btmp.e13 * btmp.e13);
double b2 = sqrt(btmp.e21 * btmp.e21 + btmp.e22 * btmp.e22 + btmp.e23 * btmp.e23);
double b3 = sqrt(btmp.e31 * btmp.e31 + btmp.e32 * btmp.e32 + btmp.e33 * btmp.e33);
int nk1
= std::max(1, static_cast<int>(b1 * ModuleBase::TWO_PI / PARAM.inp.kspacing[0] / GlobalC::ucell.lat0 + 1));
= std::max(1, static_cast<int>(b1 * ModuleBase::TWO_PI / PARAM.inp.kspacing[0] / ucell.lat0 + 1));
int nk2
= std::max(1, static_cast<int>(b2 * ModuleBase::TWO_PI / PARAM.inp.kspacing[1] / GlobalC::ucell.lat0 + 1));
= std::max(1, static_cast<int>(b2 * ModuleBase::TWO_PI / PARAM.inp.kspacing[1] / ucell.lat0 + 1));
int nk3
= std::max(1, static_cast<int>(b3 * ModuleBase::TWO_PI / PARAM.inp.kspacing[2] / GlobalC::ucell.lat0 + 1));
= std::max(1, static_cast<int>(b3 * ModuleBase::TWO_PI / PARAM.inp.kspacing[2] / ucell.lat0 + 1));

GlobalV::ofs_warning << " Generate k-points file according to KSPACING: " << fn << std::endl;
std::ofstream ofs(fn.c_str());
Expand Down
6 changes: 4 additions & 2 deletions source/module_cell/klist.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ class K_Vectors
* it will output a warning and suggest possible solutions.
* @note Only available for nspin = 1 or 2 or 4.
*/
void set(const ModuleSymmetry::Symmetry& symm,
void set(const UnitCell& ucell,
const ModuleSymmetry::Symmetry& symm,
const std::string& k_file_name,
const int& nspin,
const ModuleBase::Matrix3& reciprocal_vec,
Expand Down Expand Up @@ -204,7 +205,8 @@ class K_Vectors
* @note If the k-points type is Line mode and the symmetry flag is 1, it will quit with a warning.
* @note If the number of k-points is greater than 100000, it will quit with a warning.
*/
bool read_kpoints(const std::string& fn); // return 0: something wrong.
bool read_kpoints(const UnitCell& ucell,
const std::string& fn); // return 0: something wrong.

/**
* @brief Adds k-points linearly between special points.
Expand Down
Loading
Loading