@@ -59,7 +59,8 @@ int K_Vectors::get_ik_global(const int& ik, const int& nkstot)
5959 }
6060}
6161
62- void K_Vectors::set (const ModuleSymmetry::Symmetry& symm,
62+ void K_Vectors::set (const UnitCell& ucell,
63+ const ModuleSymmetry::Symmetry& symm,
6364 const std::string& k_file_name,
6465 const int & nspin_in,
6566 const ModuleBase::Matrix3& reciprocal_vec,
@@ -93,7 +94,7 @@ void K_Vectors::set(const ModuleSymmetry::Symmetry& symm,
9394 this ->nspin = (this ->nspin == 4 ) ? 1 : this ->nspin ;
9495
9596 // read KPT file and generate K-point grid
96- bool read_succesfully = this ->read_kpoints (k_file_name);
97+ bool read_succesfully = this ->read_kpoints (ucell, k_file_name);
9798#ifdef __MPI
9899 Parallel_Common::bcast_bool (read_succesfully);
99100#endif
@@ -113,7 +114,7 @@ void K_Vectors::set(const ModuleSymmetry::Symmetry& symm,
113114 {
114115 bool match = true ;
115116 // calculate kpoints in IBZ and reduce kpoints according to symmetry
116- this ->ibz_kpoint (symm, ModuleSymmetry::Symmetry::symm_flag, skpt1, GlobalC:: ucell, match);
117+ this ->ibz_kpoint (symm, ModuleSymmetry::Symmetry::symm_flag, skpt1, ucell, match);
117118#ifdef __MPI
118119 Parallel_Common::bcast_bool (match);
119120#endif
@@ -128,7 +129,7 @@ void K_Vectors::set(const ModuleSymmetry::Symmetry& symm,
128129 std::cout << " Automatically set symmetry to 0 and continue ..." << std::endl;
129130 ModuleSymmetry::Symmetry::symm_flag = 0 ;
130131 match = true ;
131- this ->ibz_kpoint (symm, ModuleSymmetry::Symmetry::symm_flag, skpt1, GlobalC:: ucell, match);
132+ this ->ibz_kpoint (symm, ModuleSymmetry::Symmetry::symm_flag, skpt1, ucell, match);
132133 } else {
133134 ModuleBase::WARNING_QUIT (" K_Vectors::ibz_kpoint" ,
134135 " Possible solutions: \n \
@@ -209,7 +210,8 @@ void K_Vectors::renew(const int& kpoint_number)
209210
210211// Read the KPT file, which contains K-point coordinates, weights, and grid size information
211212// Generate K-point grid according to different parameters of the KPT file
212- bool K_Vectors::read_kpoints (const std::string& fn)
213+ bool K_Vectors::read_kpoints (const UnitCell& ucell,
214+ const std::string& fn)
213215{
214216 ModuleBase::TITLE (" K_Vectors" , " read_kpoints" );
215217 if (GlobalV::MY_RANK != 0 )
@@ -236,16 +238,16 @@ bool K_Vectors::read_kpoints(const std::string& fn)
236238 ModuleBase::WARNING_QUIT (" K_Vectors" , " kspacing should > 0" );
237239 };
238240 // number of K points = max(1,int(|bi|/KSPACING+1))
239- ModuleBase::Matrix3 btmp = GlobalC:: ucell.G ;
241+ ModuleBase::Matrix3 btmp = ucell.G ;
240242 double b1 = sqrt (btmp.e11 * btmp.e11 + btmp.e12 * btmp.e12 + btmp.e13 * btmp.e13 );
241243 double b2 = sqrt (btmp.e21 * btmp.e21 + btmp.e22 * btmp.e22 + btmp.e23 * btmp.e23 );
242244 double b3 = sqrt (btmp.e31 * btmp.e31 + btmp.e32 * btmp.e32 + btmp.e33 * btmp.e33 );
243245 int nk1
244- = std::max (1 , static_cast <int >(b1 * ModuleBase::TWO_PI / PARAM.inp .kspacing [0 ] / GlobalC:: ucell.lat0 + 1 ));
246+ = std::max (1 , static_cast <int >(b1 * ModuleBase::TWO_PI / PARAM.inp .kspacing [0 ] / ucell.lat0 + 1 ));
245247 int nk2
246- = std::max (1 , static_cast <int >(b2 * ModuleBase::TWO_PI / PARAM.inp .kspacing [1 ] / GlobalC:: ucell.lat0 + 1 ));
248+ = std::max (1 , static_cast <int >(b2 * ModuleBase::TWO_PI / PARAM.inp .kspacing [1 ] / ucell.lat0 + 1 ));
247249 int nk3
248- = std::max (1 , static_cast <int >(b3 * ModuleBase::TWO_PI / PARAM.inp .kspacing [2 ] / GlobalC:: ucell.lat0 + 1 ));
250+ = std::max (1 , static_cast <int >(b3 * ModuleBase::TWO_PI / PARAM.inp .kspacing [2 ] / ucell.lat0 + 1 ));
249251
250252 GlobalV::ofs_warning << " Generate k-points file according to KSPACING: " << fn << std::endl;
251253 std::ofstream ofs (fn.c_str ());
0 commit comments