diff --git a/source/source_cell/klist.cpp b/source/source_cell/klist.cpp index 1fd028ccc6..4cc4cae657 100644 --- a/source/source_cell/klist.cpp +++ b/source/source_cell/klist.cpp @@ -6,7 +6,6 @@ #include "source_base/parallel_global.h" #include "source_base/parallel_reduce.h" #include "source_cell/module_symmetry/symmetry.h" -#include "source_io/module_unk/berryphase.h" #include "source_io/module_parameter/parameter.h" void K_Vectors::cal_ik_global() @@ -44,7 +43,8 @@ void K_Vectors::set(const UnitCell& ucell, const int& nspin_in, const ModuleBase::Matrix3& reciprocal_vec, const ModuleBase::Matrix3& latvec, - std::ofstream& ofs) + std::ofstream& ofs, + const bool use_ibz) { ModuleBase::TITLE("K_Vectors", "set"); @@ -99,9 +99,8 @@ void K_Vectors::set(const UnitCell& ucell, // (2) - // only berry phase need all kpoints including time-reversal symmetry! - // if symm_flag is not set, only time-reversal symmetry would be considered. - if (!berryphase::berry_phase_flag && ModuleSymmetry::Symmetry::symm_flag != -1) + // reduce kpoints to IBZ according to symmetry operations + if (use_ibz) { bool match = true; // calculate kpoints in IBZ and reduce kpoints according to symmetry diff --git a/source/source_cell/klist.h b/source/source_cell/klist.h index 4960ac6846..cb8177c2a4 100644 --- a/source/source_cell/klist.h +++ b/source/source_cell/klist.h @@ -49,6 +49,7 @@ class K_Vectors * @param nspin_in The number of spins. * @param reciprocal_vec The reciprocal vector of the system. * @param latvec The lattice vector of the system. + * @param use_ibz Whether to reduce k-points to the irreducible Brillouin zone. * * @return void * @@ -63,7 +64,8 @@ class K_Vectors const int& nspin, const ModuleBase::Matrix3& reciprocal_vec, const ModuleBase::Matrix3& latvec, - std::ofstream& ofs); + std::ofstream& ofs, + const bool use_ibz); int get_nks() const { diff --git a/source/source_cell/test/klist_test.cpp b/source/source_cell/test/klist_test.cpp index 2644eb9140..e63b4e5f47 100644 --- a/source/source_cell/test/klist_test.cpp +++ b/source/source_cell/test/klist_test.cpp @@ -15,13 +15,11 @@ #include "source_pw/module_pwdft/vl_pw.h" #include "source_pw/module_pwdft/vnl_pw.h" #include "source_pw/module_pwdft/parallel_grid.h" -#include "source_io/module_unk/berryphase.h" #include "source_io/module_parameter/parameter.h" #undef private #include "source_base/mathzone.h" #include "source_base/parallel_global.h" #include "source_cell/parallel_kpoints.h" -bool berryphase::berry_phase_flag = false; pseudo::pseudo() { diff --git a/source/source_cell/test/klist_test_para.cpp b/source/source_cell/test/klist_test_para.cpp index 1dd36bdfbf..bcc8ea0516 100644 --- a/source/source_cell/test/klist_test_para.cpp +++ b/source/source_cell/test/klist_test_para.cpp @@ -23,9 +23,7 @@ #include "source_pw/module_pwdft/vl_pw.h" #include "source_pw/module_pwdft/vnl_pw.h" #include "source_pw/module_pwdft/parallel_grid.h" -#include "source_io/module_unk/berryphase.h" #undef private -bool berryphase::berry_phase_flag = false; pseudo::pseudo() { @@ -236,7 +234,8 @@ TEST_F(KlistParaTest, Set) GlobalV::RANK_IN_POOL, GlobalV::MY_POOL); ModuleSymmetry::Symmetry::symm_flag = 1; - kv->set(ucell,symm, k_file, kv->nspin, ucell.G, ucell.latvec, GlobalV::ofs_running); + const bool use_ibz = true; + kv->set(ucell, symm, k_file, kv->nspin, ucell.G, ucell.latvec, GlobalV::ofs_running, use_ibz); EXPECT_EQ(kv->get_nkstot(), 35); EXPECT_EQ(kv->get_nkstot_full(), 512); EXPECT_GT(kv->get_nkstot_full(), kv->get_nkstot()); @@ -353,7 +352,8 @@ TEST_F(KlistParaTest, SetAfterVC) GlobalV::RANK_IN_POOL, GlobalV::MY_POOL); ModuleSymmetry::Symmetry::symm_flag = 1; - kv->set(ucell,symm, k_file, kv->nspin, ucell.G, ucell.latvec, GlobalV::ofs_running); + const bool use_ibz = true; + kv->set(ucell, symm, k_file, kv->nspin, ucell.G, ucell.latvec, GlobalV::ofs_running, use_ibz); EXPECT_EQ(kv->get_nkstot(), 35); EXPECT_TRUE(kv->kc_done); EXPECT_TRUE(kv->kd_done); diff --git a/source/source_esolver/esolver_fp.cpp b/source/source_esolver/esolver_fp.cpp index 42719a4886..8306e2b6ff 100644 --- a/source/source_esolver/esolver_fp.cpp +++ b/source/source_esolver/esolver_fp.cpp @@ -65,7 +65,8 @@ void ESolver_FP::before_all_runners(UnitCell& ucell, const Input_para& inp) ModuleBase::GlobalFunc::DONE(GlobalV::ofs_running, "SETUP UNITCELL"); //! 7) setup k points in the Brillouin zone according to symmetry. - this->kv.set(ucell,ucell.symm, inp.kpoint_file, inp.nspin, ucell.G, ucell.latvec, GlobalV::ofs_running); + const bool use_ibz = !inp.berry_phase && ModuleSymmetry::Symmetry::symm_flag != -1; + this->kv.set(ucell, ucell.symm, inp.kpoint_file, inp.nspin, ucell.G, ucell.latvec, GlobalV::ofs_running, use_ibz); ModuleBase::GlobalFunc::DONE(GlobalV::ofs_running, "INIT K-POINTS"); //! 8) print information diff --git a/source/source_esolver/esolver_gets.cpp b/source/source_esolver/esolver_gets.cpp index 6a4e4f9c23..883f9ab475 100644 --- a/source/source_esolver/esolver_gets.cpp +++ b/source/source_esolver/esolver_gets.cpp @@ -40,7 +40,8 @@ void ESolver_GetS::before_all_runners(UnitCell& ucell, const Input_para& inp) } // 1.3) Setup k-points according to symmetry. - this->kv.set(ucell, ucell.symm, inp.kpoint_file, inp.nspin, ucell.G, ucell.latvec, GlobalV::ofs_running); + const bool use_ibz = !inp.berry_phase && ModuleSymmetry::Symmetry::symm_flag != -1; + this->kv.set(ucell, ucell.symm, inp.kpoint_file, inp.nspin, ucell.G, ucell.latvec, GlobalV::ofs_running, use_ibz); ModuleBase::GlobalFunc::DONE(GlobalV::ofs_running, "INIT K-POINTS"); ModuleIO::print_parameters(ucell, this->kv, inp); diff --git a/source/source_io/test/for_testing_klist.h b/source/source_io/test/for_testing_klist.h index 18c42a2753..b74335759d 100644 --- a/source/source_io/test/for_testing_klist.h +++ b/source/source_io/test/for_testing_klist.h @@ -14,9 +14,6 @@ #include "source_pw/module_pwdft/vl_pw.h" #include "source_pw/module_pwdft/vnl_pw.h" #include "source_pw/module_pwdft/parallel_grid.h" -#include "source_io/module_unk/berryphase.h" - -bool berryphase::berry_phase_flag=0; pseudo::pseudo(){} pseudo::~pseudo(){} diff --git a/source/source_lcao/module_deepks/test/deepks_test_prep.cpp b/source/source_lcao/module_deepks/test/deepks_test_prep.cpp index 6b115fa155..e606475c85 100644 --- a/source/source_lcao/module_deepks/test/deepks_test_prep.cpp +++ b/source/source_lcao/module_deepks/test/deepks_test_prep.cpp @@ -258,13 +258,15 @@ template void test_deepks::setup_kpt() { ModuleSymmetry::Symmetry::symm_flag = -1; + const bool use_ibz = false; this->kv.set(ucell, ucell.symm, PARAM.inp.kpoint_file, this->nspin, ucell.G, ucell.latvec, - GlobalV::ofs_running); + GlobalV::ofs_running, + use_ibz); } template class test_deepks; diff --git a/source/source_lcao/module_lr/esolver_lrtd_lcao.cpp b/source/source_lcao/module_lr/esolver_lrtd_lcao.cpp index 64b7f19a4f..72247d0003 100644 --- a/source/source_lcao/module_lr/esolver_lrtd_lcao.cpp +++ b/source/source_lcao/module_lr/esolver_lrtd_lcao.cpp @@ -303,7 +303,8 @@ LR::ESolver_LR::ESolver_LR(const Input_para& inp, UnitCell& ucell) : inpu ucell.symm.analy_sys(ucell.lat, ucell.st, ucell.atoms, GlobalV::ofs_running); ModuleBase::GlobalFunc::DONE(GlobalV::ofs_running, "SYMMETRY"); } - this->kv.set(ucell,ucell.symm, PARAM.inp.kpoint_file, PARAM.inp.nspin, ucell.G, ucell.latvec, GlobalV::ofs_running); + const bool use_ibz = false; + this->kv.set(ucell, ucell.symm, PARAM.inp.kpoint_file, PARAM.inp.nspin, ucell.G, ucell.latvec, GlobalV::ofs_running, use_ibz); ModuleBase::GlobalFunc::DONE(GlobalV::ofs_running, "INIT K-POINTS"); ModuleIO::print_parameters(ucell, this->kv, inp);