From 897ab7934a0d8621bf754b7a172ee1e00e2f6d81 Mon Sep 17 00:00:00 2001 From: ErjieWu Date: Fri, 25 Oct 2024 09:17:20 +0800 Subject: [PATCH 1/4] update the default setting for symmetry --- source/module_io/read_input_item_system.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/module_io/read_input_item_system.cpp b/source/module_io/read_input_item_system.cpp index 5145f12d91..65a4727022 100644 --- a/source/module_io/read_input_item_system.cpp +++ b/source/module_io/read_input_item_system.cpp @@ -156,6 +156,10 @@ void ReadInput::item_system() { para.input.symmetry = "-1"; // disable kpoint reduce } + if (para.input.berry_phase) + { + para.input.symmetry = "-1"; // disable kpoint reduce + } }; this->add_item(item); } From 67076fdbcb3e1aec34a5e25cc7d1fb87b73b4f56 Mon Sep 17 00:00:00 2001 From: ErjieWu Date: Fri, 25 Oct 2024 09:46:05 +0800 Subject: [PATCH 2/4] modify the unit test for read_input_item_system.cpp --- source/module_io/test_serial/read_input_item_test.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/source/module_io/test_serial/read_input_item_test.cpp b/source/module_io/test_serial/read_input_item_test.cpp index 16f84911e1..013462fe3f 100644 --- a/source/module_io/test_serial/read_input_item_test.cpp +++ b/source/module_io/test_serial/read_input_item_test.cpp @@ -151,6 +151,11 @@ TEST_F(InputTest, Item_test) param.input.qo_switch = true; it->second.reset_value(it->second, param); EXPECT_EQ(param.input.symmetry, "-1"); + + param.input.symmetry = "default"; + param.input.berry_phase = true; + it->second.reset_value(it->second, param); + EXPECT_EQ(param.input.symmetry, "-1"); } { // nelec auto it = find_label("nelec", readinput.input_lists); From bf89de31d0efe5b1a07c43d34f5c5a68250836e8 Mon Sep 17 00:00:00 2001 From: ErjieWu Date: Mon, 11 Nov 2024 16:28:11 +0800 Subject: [PATCH 3/4] Add support for reading old version HexxR* files. --- .../operator_lcao/op_exx_lcao.hpp | 64 ++++++++++++++++--- source/module_io/restart_exx_csr.h | 6 ++ source/module_io/restart_exx_csr.hpp | 13 ++++ 3 files changed, 74 insertions(+), 9 deletions(-) diff --git a/source/module_hamilt_lcao/hamilt_lcaodft/operator_lcao/op_exx_lcao.hpp b/source/module_hamilt_lcao/hamilt_lcaodft/operator_lcao/op_exx_lcao.hpp index da72d37c03..a66abea7c0 100644 --- a/source/module_hamilt_lcao/hamilt_lcaodft/operator_lcao/op_exx_lcao.hpp +++ b/source/module_hamilt_lcao/hamilt_lcaodft/operator_lcao/op_exx_lcao.hpp @@ -102,15 +102,40 @@ OperatorEXX>::OperatorEXX(HS_Matrix_K* hsk_in, if (PARAM.inp.calculation == "nscf" && GlobalC::exx_info.info_global.cal_exx) { // if nscf, read HexxR first and reallocate hR according to the read-in HexxR const std::string file_name_exx = PARAM.globalv.global_readin_dir + "HexxR" + std::to_string(GlobalV::MY_RANK); - if (GlobalC::exx_info.info_ri.real_number) + bool all_exist = true; + for (int is=0;isadd_hexx_type == Add_Hexx_Type::R) { reallocate_hcontainer(*Hexxd, this->hR); } + // Read HexxR in CSR format + if (GlobalC::exx_info.info_ri.real_number) + { + ModuleIO::read_Hexxs_csr(file_name_exx, GlobalC::ucell, PARAM.inp.nspin, PARAM.globalv.nlocal, *Hexxd); + if (this->add_hexx_type == Add_Hexx_Type::R) { reallocate_hcontainer(*Hexxd, this->hR); } + } + else + { + ModuleIO::read_Hexxs_csr(file_name_exx, GlobalC::ucell, PARAM.inp.nspin, PARAM.globalv.nlocal, *Hexxc); + if (this->add_hexx_type == Add_Hexx_Type::R) { reallocate_hcontainer(*Hexxc, this->hR); } + } } else { - ModuleIO::read_Hexxs_csr(file_name_exx, GlobalC::ucell, PARAM.inp.nspin, PARAM.globalv.nlocal, *Hexxc); - if (this->add_hexx_type == Add_Hexx_Type::R) { reallocate_hcontainer(*Hexxc, this->hR); } + // Read HexxR in binary format (old version) + const std::string file_name_exx_cereal = PARAM.globalv.global_readin_dir + "HexxR_" + std::to_string(GlobalV::MY_RANK); + if (GlobalC::exx_info.info_ri.real_number) + { + ModuleIO::read_Hexxs_cereal(file_name_exx_cereal, *Hexxd); + if (this->add_hexx_type == Add_Hexx_Type::R) { reallocate_hcontainer(*Hexxd, this->hR); } + } + else + { + ModuleIO::read_Hexxs_cereal(file_name_exx_cereal, *Hexxc); + if (this->add_hexx_type == Add_Hexx_Type::R) { reallocate_hcontainer(*Hexxc, this->hR); } + } } this->use_cell_nearest = false; } @@ -179,11 +204,32 @@ OperatorEXX>::OperatorEXX(HS_Matrix_K* hsk_in, { // read in Hexx(R) const std::string restart_HR_path = GlobalC::restart.folder + "HexxR" + std::to_string(GlobalV::MY_RANK); - if (GlobalC::exx_info.info_ri.real_number) { - ModuleIO::read_Hexxs_csr(restart_HR_path, GlobalC::ucell, PARAM.inp.nspin, PARAM.globalv.nlocal, *Hexxd); + bool all_exist = true; + for (int is = 0; is < PARAM.inp.nspin; ++is) + { + std::ifstream ifs(restart_HR_path + "_" + std::to_string(is) + ".csr"); + if (!ifs) { all_exist = false; break; } + } + if (all_exist) + { + // Read HexxR in CSR format + if (GlobalC::exx_info.info_ri.real_number) { + ModuleIO::read_Hexxs_csr(restart_HR_path, GlobalC::ucell, PARAM.inp.nspin, PARAM.globalv.nlocal, *Hexxd); + } + else { + ModuleIO::read_Hexxs_csr(restart_HR_path, GlobalC::ucell, PARAM.inp.nspin, PARAM.globalv.nlocal, *Hexxc); + } } - else { - ModuleIO::read_Hexxs_csr(restart_HR_path, GlobalC::ucell, PARAM.inp.nspin, PARAM.globalv.nlocal, *Hexxc); + else + { + // Read HexxR in binary format (old version) + const std::string restart_HR_path_cereal = GlobalC::restart.folder + "HexxR_" + std::to_string(GlobalV::MY_RANK); + if (GlobalC::exx_info.info_ri.real_number) { + ModuleIO::read_Hexxs_cereal(restart_HR_path_cereal, *Hexxd); + } + else { + ModuleIO::read_Hexxs_cereal(restart_HR_path_cereal, *Hexxc); + } } } diff --git a/source/module_io/restart_exx_csr.h b/source/module_io/restart_exx_csr.h index 7dbb778c2b..86e73234ab 100644 --- a/source/module_io/restart_exx_csr.h +++ b/source/module_io/restart_exx_csr.h @@ -2,6 +2,7 @@ #include "module_base/abfs-vector3_order.h" #include "module_cell/unitcell.h" #include +#include "module_ri/serialization_cereal.h" #include namespace ModuleIO @@ -15,6 +16,11 @@ namespace ModuleIO const int nspin, const int nbasis, std::vector>>>& Hexxs); + /// read Hexxs in cereal format + template + void read_Hexxs_cereal(const std::string& file_name, + std::vector>>>& Hexxs); + /// write Hexxs in CSR format template void write_Hexxs_csr(const std::string& file_name, const UnitCell& ucell, diff --git a/source/module_io/restart_exx_csr.hpp b/source/module_io/restart_exx_csr.hpp index e18a9d5a8d..6f6f3dd2ae 100644 --- a/source/module_io/restart_exx_csr.hpp +++ b/source/module_io/restart_exx_csr.hpp @@ -3,6 +3,7 @@ #include "module_cell/unitcell.h" #include "module_io/csr_reader.h" #include "module_io/write_HS_sparse.h" +#include "module_ri/serialization_cereal.h" #include #include @@ -49,6 +50,18 @@ namespace ModuleIO } } + template + void read_Hexxs_cereal(const std::string& file_name, + std::vector>>>& Hexxs) + { + ModuleBase::TITLE("Exx_LRI", "read_Hexxs_cereal"); + ModuleBase::timer::tick("Exx_LRI", "read_Hexxs_cereal"); + std::ifstream ifs(file_name, std::ios::binary); + cereal::BinaryInputArchive iar(ifs); + iar(Hexxs); + ModuleBase::timer::tick("Exx_LRI", "read_Hexxs_cereal"); + } + template std::map, std::map>> calculate_RI_Tensor_sparse(const double& sparse_threshold, From 3bfcea9c4fbee76e924e9b236bdab63d145da635 Mon Sep 17 00:00:00 2001 From: ErjieWu Date: Mon, 11 Nov 2024 16:37:37 +0800 Subject: [PATCH 4/4] Code standardization for #include. --- source/module_io/restart_exx_csr.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/module_io/restart_exx_csr.h b/source/module_io/restart_exx_csr.h index 86e73234ab..1eab69f4ef 100644 --- a/source/module_io/restart_exx_csr.h +++ b/source/module_io/restart_exx_csr.h @@ -1,8 +1,8 @@ #pragma once #include "module_base/abfs-vector3_order.h" #include "module_cell/unitcell.h" -#include #include "module_ri/serialization_cereal.h" +#include #include namespace ModuleIO