From addfd6888a03f6e83badf0156f4de1a70571143e Mon Sep 17 00:00:00 2001 From: Fisherd99 Date: Wed, 24 Dec 2025 02:24:54 +0800 Subject: [PATCH] out_unshrinked_Vs --- source/module_io/read_input_item_exx_dftu.cpp | 6 ++ source/module_parameter/input_parameter.h | 1 + source/module_ri/RPA_LRI.hpp | 63 +++++++++++++++---- 3 files changed, 59 insertions(+), 11 deletions(-) diff --git a/source/module_io/read_input_item_exx_dftu.cpp b/source/module_io/read_input_item_exx_dftu.cpp index 930f24576f..9be9ad11b8 100644 --- a/source/module_io/read_input_item_exx_dftu.cpp +++ b/source/module_io/read_input_item_exx_dftu.cpp @@ -306,6 +306,12 @@ void ReadInput::item_exx() read_sync_double(input.shrink_LU_inv_thr); this->add_item(item); } + { + Input_Item item("out_unshrinked_v"); + item.annotation = "whether to output the large Vq matrix in unshrinked auxiliary basis"; + read_sync_bool(input.out_unshrinked_v); + this->add_item(item); + } { Input_Item item("exx_rotate_abfs"); item.annotation = "whether to rotate auxiliary basis for Coulomb calculation"; diff --git a/source/module_parameter/input_parameter.h b/source/module_parameter/input_parameter.h index 2304b35b86..60efa75bb9 100644 --- a/source/module_parameter/input_parameter.h +++ b/source/module_parameter/input_parameter.h @@ -563,6 +563,7 @@ struct Input_para double shrink_abfs_pca_thr = -1; ///< threshold to shrink auxiliary basis for GW/RPA double shrink_LU_inv_thr = 1e-6; ///< threshold to get inverse of overlap matrix by LU decomposition in auxiliary basis representation + bool out_unshrinked_v = false; ///< whether to output the large Vq matrix in unshrinked auxiliary basis double Cs_inv_thr = -1; ///< threshold to inverse Vq in abfs for generating Cs bool exx_rotate_abfs = false; ///< whether to rotate auxiliary basis for Coulomb calculation double exx_multip_moments_threshold = 1e-10; ///< threshold to screen multipole moments in Coulomb calculation diff --git a/source/module_ri/RPA_LRI.hpp b/source/module_ri/RPA_LRI.hpp index 6745482e00..54bdba852c 100644 --- a/source/module_ri/RPA_LRI.hpp +++ b/source/module_ri/RPA_LRI.hpp @@ -57,6 +57,7 @@ void RPA_LRI::cal_large_Cs(const UnitCell& ucell, const LCAO_Orbitals& if (!exx_lri_rpa) exx_lri_rpa = new Exx_LRI(GlobalC::exx_info.info_ri); exx_lri_rpa->init(mpi_comm, ucell, kv, orb); + ModuleBase::GlobalFunc::DONE(GlobalV::ofs_running, "exx_lri_rpa->init"); this->abfs = exx_lri_rpa->abfs; this->abfs_ccp = exx_lri_rpa->abfs_ccp; std::vector atoms(ucell.nat); @@ -64,18 +65,13 @@ void RPA_LRI::cal_large_Cs(const UnitCell& ucell, const LCAO_Orbitals& { atoms[iat] = iat; } - const std::array period = {p_kv->nmp[0], p_kv->nmp[1], p_kv->nmp[2]}; - - const std::array period_Cs = LRI_CV_Tools::cal_latvec_range(2, ucell, orb_cutoff_); - - const std::pair, std::vector>>>> list_As_Cs - = RI::Distribute_Equally::distribute_atoms_periods(this->mpi_comm, atoms, period_Cs, 2, false); std::map atoms_pos; for (int iat = 0; iat < ucell.nat; ++iat) atoms_pos[iat] = RI_Util::Vector3_to_array3(ucell.atoms[ucell.iat2it[iat]].tau[ucell.iat2ia[iat]]); const std::array latvec = {RI_Util::Vector3_to_array3(ucell.a1), RI_Util::Vector3_to_array3(ucell.a2), RI_Util::Vector3_to_array3(ucell.a3)}; + const std::array period = {p_kv->nmp[0], p_kv->nmp[1], p_kv->nmp[2]}; this->exx_lri_rpa->exx_lri.set_parallel(this->mpi_comm, atoms_pos, latvec, period); this->exx_lri_rpa->cv.set_orbitals(ucell, orb, @@ -83,10 +79,22 @@ void RPA_LRI::cal_large_Cs(const UnitCell& ucell, const LCAO_Orbitals& exx_lri_rpa->abfs, exx_lri_rpa->abfs_ccp, this->info.kmesh_times, - this->MGT, + this->MGT, // get MGT from exx_lri_rpa and used in `cal_abfs_overlap` true, true); + const std::array period_Vs + = LRI_CV_Tools::cal_latvec_range(1 + this->info.ccp_rmesh_times, ucell, orb_cutoff_); + std::pair, std::vector>>>> list_As_Vs + = RI::Distribute_Equally::distribute_atoms_periods(this->mpi_comm, atoms, period_Vs, 2, false); + ModuleBase::GlobalFunc::DONE(GlobalV::ofs_running, "before cal_large_Vs"); + std::map>> Vs_cut_IJR + = exx_lri_rpa->cv.cal_Vs(ucell, list_As_Vs.first, list_As_Vs.second[0], {{"writable_Vws", true}}); + ModuleBase::GlobalFunc::DONE(GlobalV::ofs_running, "cal_large_Vs"); + + const std::array period_Cs = LRI_CV_Tools::cal_latvec_range(2, ucell, orb_cutoff_); + const std::pair, std::vector>>>> list_As_Cs + = RI::Distribute_Equally::distribute_atoms_periods(this->mpi_comm, atoms, period_Cs, 2, false); std::pair>>, std::map, 3>>>> Cs_dCs = exx_lri_rpa->cv.cal_Cs_dCs(ucell, @@ -97,13 +105,46 @@ void RPA_LRI::cal_large_Cs(const UnitCell& ucell, const LCAO_Orbitals& {"writable_dCws", true}, {"writable_Vws", false}, {"writable_dVws", false}}); - std::map>>& Cs = std::get<0>(Cs_dCs); + ModuleBase::GlobalFunc::DONE(GlobalV::ofs_running, "cal_large_Cs"); + std::map>> tmp; + if (PARAM.inp.out_unshrinked_v) + { + this->Vs_period = RI::RI_Tools::cal_period(Vs_cut_IJR, period); + Vs_cut_IJR.clear(); + ModuleBase::GlobalFunc::DONE(GlobalV::ofs_running, "Vs_period"); + // MPI: {ia0, {ia1, R}} to {ia0, ia1} + const std::pair, std::vector>>> list_As_Vs_atoms + = RI::Distribute_Equally::distribute_atoms(this->mpi_comm, atoms, period_Vs, 2, false); + const auto list_A0_pair_R = list_As_Vs_atoms.first; + const auto list_A1_pair_R = list_As_Vs_atoms.second[0]; + std::set atoms00; + std::set atoms01; + for (const auto& I: list_A0_pair_R) + { + atoms00.insert(I); + } + for (const auto& JR: list_A1_pair_R) + { + atoms01.insert(JR.first); + } + + this->Vs_period = RI_2D_Comm::comm_map2_first(this->mpi_comm, this->Vs_period, atoms00, atoms01); + ModuleBase::GlobalFunc::DONE(GlobalV::ofs_running, "Vs_period_comm"); + + this->out_coulomb_k(ucell, this->Vs_period, "coulomb_unshrinked_cut_", exx_lri_rpa); + ModuleBase::GlobalFunc::DONE(GlobalV::ofs_running, "out_large_Vs"); + this->Vs_period.clear(); + this->Vs_period.swap(tmp); + } + + std::map>>& Cs = std::get<0>(Cs_dCs); this->Cs_period = RI::RI_Tools::cal_period(Cs, period); this->Cs_period = exx_lri_rpa->exx_lri.post_2D.set_tensors_map2(this->Cs_period); this->out_Cs(ucell, this->Cs_period, "Cs_data_"); - Cs_period.clear(); - Cs_period.swap(tmp); + ModuleBase::GlobalFunc::DONE(GlobalV::ofs_running, "out_large_Cs"); + this->Cs_period.clear(); + this->Cs_period.swap(tmp); delete exx_lri_rpa; exx_lri_rpa = nullptr; malloc_trim(0); @@ -347,7 +388,7 @@ void RPA_LRI::out_for_RPA(const UnitCell& ucell, const std::array period = {p_kv->nmp[0], p_kv->nmp[1], p_kv->nmp[2]}; this->Vs_period = RI::RI_Tools::cal_period(Vs_full_IJ, period); - this->out_coulomb_k(ucell, Vs_full_IJ, "coulomb_mat_", exx_full_coulomb); + this->out_coulomb_k(ucell, this->Vs_period, "coulomb_mat_", exx_full_coulomb); Vs_period.clear(); Vs_period.swap(tmp); Cs.clear();