Skip to content

Commit

Permalink
Merge branch 'LibRI_loop3' of https://github.com/PeizeLin/abacus-develop
Browse files Browse the repository at this point in the history
 into symexxnew
  • Loading branch information
maki49 committed Jul 30, 2024
2 parents fe4a6b5 + ab01840 commit 0bf4896
Show file tree
Hide file tree
Showing 9 changed files with 78 additions and 10 deletions.
2 changes: 1 addition & 1 deletion deps/LibRI
Submodule LibRI updated 74 files
+41 −0 include/RI/comm/example/Communicate_Map_Combine.h
+39 −1 include/RI/comm/mix/Communicate_Tensors_Map_Judge.h
+17 −1 include/RI/distribute/Distribute_Equally.h
+35 −0 include/RI/distribute/Distribute_Equally.hpp
+23 −10 include/RI/distribute/Divide_Atoms.hpp
+2 −2 include/RI/distribute/Split_Processes.hpp
+2 −1 include/RI/global/Cereal_Types.h
+56 −0 include/RI/global/Map_Operator.h
+2 −1 include/RI/global/Tensor.h
+8 −2 include/RI/global/Tensor.hpp
+51 −0 include/RI/global/Tensor_Multiply-23.hpp
+85 −0 include/RI/global/Tensor_Multiply-32.hpp
+68 −0 include/RI/global/Tensor_Multiply-33.hpp
+13 −0 include/RI/global/Tensor_Multiply.h
+17 −3 include/RI/parallel/Parallel_LRI.h
+18 −8 include/RI/parallel/Parallel_LRI_Equally.h
+121 −6 include/RI/parallel/Parallel_LRI_Equally.hpp
+17 −4 include/RI/physics/Exx.h
+185 −169 include/RI/physics/Exx.hpp
+1 −3 include/RI/physics/GW.h
+18 −13 include/RI/physics/GW.hpp
+0 −1 include/RI/physics/RPA.h
+20 −15 include/RI/physics/RPA.hpp
+0 −59 include/RI/ri/CS_Matrix-set.hpp
+1 −1 include/RI/ri/Cell_Nearest.h
+2 −2 include/RI/ri/Cell_Nearest.hpp
+46 −0 include/RI/ri/Data_Pack.h
+1,213 −0 include/RI/ri/LRI-cal_loop3.hpp
+36 −57 include/RI/ri/LRI-set.hpp
+22 −26 include/RI/ri/LRI.h
+7 −11 include/RI/ri/LRI.hpp
+181 −16 include/RI/ri/LRI_Cal_Aux.h
+26 −24 include/RI/ri/LRI_Cal_Tools.h
+33 −64 include/RI/ri/Label.h
+209 −0 include/RI/ri/Label_Tools.h
+5 −0 include/RI/ri/RI_Tools.h
+29 −0 include/RI/ri/RI_Tools.hpp
+0 −56 include/RI/ri/Save_Load.h
+0 −102 include/RI/ri/Save_Load.hpp
+0 −0 include/RI/ri/bak_LRI-cal-loop4_1/bak-LRI-cal.hpp
+15 −16 include/RI/ri/bak_LRI-cal-loop4_2/CS_Matrix-filter.hpp
+81 −0 include/RI/ri/bak_LRI-cal-loop4_2/CS_Matrix-set.hpp
+14 −9 include/RI/ri/bak_LRI-cal-loop4_2/CS_Matrix.h
+0 −0 include/RI/ri/bak_LRI-cal-loop4_2/CS_Matrix_Tools.h
+1 −1 include/RI/ri/bak_LRI-cal-loop4_2/CS_Matrix_Tools.hpp
+48 −0 include/RI/ri/bak_LRI-cal-loop4_2/Data_Pack.h
+460 −0 include/RI/ri/bak_LRI-cal-loop4_2/Exx.hpp
+4 −1 include/RI/ri/bak_LRI-cal-loop4_2/LRI-cal-loop4-b01.hpp
+4 −1 include/RI/ri/bak_LRI-cal-loop4_2/LRI-cal-loop4-bx2.hpp
+3 −5 include/RI/ri/bak_LRI-cal-loop4_2/LRI-cal-loop4.hpp
+165 −0 include/RI/ri/bak_LRI-cal-loop4_2/LRI-set.hpp
+113 −0 include/RI/ri/bak_LRI-cal-loop4_2/LRI.h
+24 −6 unittests/Test_All.hpp
+9 −9 unittests/comm/mix/Communicate_Tensors-test.hpp
+72 −30 unittests/distribute/Distribute_Equally-test.hpp
+3 −3 unittests/distribute/Divide_Atoms-test.hpp
+6 −6 unittests/distribute/Split_Processes-test.hpp
+2 −2 unittests/global/Blas-test.hpp
+7 −7 unittests/global/Map_Operator-test.hpp
+1 −1 unittests/global/Tensor-test-4.hpp
+0 −1 unittests/global/Tensor-test.h
+54 −0 unittests/global/Tensor_Multiply-23-test.hpp
+92 −0 unittests/global/Tensor_Multiply-32-test.hpp
+73 −0 unittests/global/Tensor_Multiply-33-test.hpp
+42 −0 unittests/global/Tensor_Multiply-test.hpp
+2 −1 unittests/physics/Exx-test.hpp
+0 −1 unittests/physics/GW-test.hpp
+15 −0 unittests/print_stl.h
+3 −15 unittests/ri/CS_Matrix-test.hpp
+1 −1 unittests/ri/Cell_Nearest-test.hpp
+401 −0 unittests/ri/LRI-loop3-test.hpp
+38 −26 unittests/ri/LRI-loop4-test.hpp
+7 −7 unittests/ri/LRI-speed-test.hpp
+0 −58 unittests/ri/Label-test.h
2 changes: 2 additions & 0 deletions source/module_hamilt_general/module_xc/exx_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ struct Exx_Info
double cauchy_threshold = 0;
double C_grad_threshold = 0;
double V_grad_threshold = 0;
double C_grad_R_threshold = 0;
double V_grad_R_threshold = 0;
double cauchy_force_threshold = 0;
double cauchy_stress_threshold = 0;
double ccp_rmesh_times = 10;
Expand Down
2 changes: 2 additions & 0 deletions source/module_io/input_conv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,8 @@ void Input_Conv::Convert()
GlobalC::exx_info.info_ri.cauchy_threshold = PARAM.inp.exx_cauchy_threshold;
GlobalC::exx_info.info_ri.C_grad_threshold = PARAM.inp.exx_c_grad_threshold;
GlobalC::exx_info.info_ri.V_grad_threshold = PARAM.inp.exx_v_grad_threshold;
GlobalC::exx_info.info_ri.C_grad_R_threshold = PARAM.inp.exx_c_grad_r_threshold;
GlobalC::exx_info.info_ri.V_grad_R_threshold = PARAM.inp.exx_v_grad_r_threshold;
GlobalC::exx_info.info_ri.cauchy_force_threshold = PARAM.inp.exx_cauchy_force_threshold;
GlobalC::exx_info.info_ri.cauchy_stress_threshold = PARAM.inp.exx_cauchy_stress_threshold;
GlobalC::exx_info.info_ri.ccp_rmesh_times = std::stod(PARAM.inp.exx_ccp_rmesh_times);
Expand Down
12 changes: 12 additions & 0 deletions source/module_io/read_input_item_exx_dftu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,18 @@ void ReadInput::item_exx()
read_sync_double(input.exx_v_grad_threshold);
this->add_item(item);
}
{
Input_Item item("exx_c_grad_r_threshold");
item.annotation = "threshold to screen nabla C matrix in exx";
read_sync_double(input.exx_c_grad_r_threshold);
this->add_item(item);
}
{
Input_Item item("exx_v_grad_r_threshold");
item.annotation = "threshold to screen nabla V matrix in exx";
read_sync_double(input.exx_v_grad_r_threshold);
this->add_item(item);
}
{
Input_Item item("exx_cauchy_force_threshold");
item.annotation = "threshold to screen exx force using Cauchy-Schwartz inequality";
Expand Down
2 changes: 2 additions & 0 deletions source/module_parameter/input_parameter.h
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,8 @@ struct Input_para
double exx_cauchy_threshold = 1e-07; ///< threshold to screen exx using Cauchy-Schwartz inequality
double exx_c_grad_threshold = 0.0001; ///< threshold to screen nabla C matrix in exx
double exx_v_grad_threshold = 0.1; ///< threshold to screen nabla V matrix in exx
double exx_c_grad_r_threshold = 0.0001; ///< threshold to screen nabla C matrix in exx
double exx_v_grad_r_threshold = 0.1; ///< threshold to screen nabla V matrix in exx
double exx_cauchy_force_threshold = 1e-07; ///< threshold to screen exx force using Cauchy-Schwartz
///< inequality
double exx_cauchy_stress_threshold = 1e-07; ///< threshold to screen exx stress using Cauchy-Schwartz
Expand Down
16 changes: 10 additions & 6 deletions source/module_ri/Exx_LRI.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ void Exx_LRI<Tdata>::cal_exx_ions()
{{"writable_dVws",true}});
this->cv.dVws = LRI_CV_Tools::get_dCVws(dVs);
this->exx_lri.set_dVs(std::move(dVs), this->info.V_grad_threshold);
if(GlobalV::CAL_STRESS)
{
std::array<std::array<std::map<TA,std::map<TAC,RI::Tensor<Tdata>>>,3>,3> dVRs = LRI_CV_Tools::cal_dMRs(dVs);
this->exx_lri.set_dVRs(std::move(dVRs), this->info.V_grad_R_threshold);
}
}

const std::array<Tcell,Ndim> period_Cs = LRI_CV_Tools::cal_latvec_range<Tcell>(2);
Expand All @@ -160,6 +165,11 @@ void Exx_LRI<Tdata>::cal_exx_ions()
std::array<std::map<TA,std::map<TAC,RI::Tensor<Tdata>>>,3> &dCs = std::get<1>(Cs_dCs);
this->cv.dCws = LRI_CV_Tools::get_dCVws(dCs);
this->exx_lri.set_dCs(std::move(dCs), this->info.C_grad_threshold);
if(GlobalV::CAL_STRESS)
{
std::array<std::array<std::map<TA,std::map<TAC,RI::Tensor<Tdata>>>,3>,3> dCRs = LRI_CV_Tools::cal_dMRs(dCs);
this->exx_lri.set_dCRs(std::move(dCRs), this->info.C_grad_R_threshold);
}
}
ModuleBase::timer::tick("Exx_LRI", "cal_exx_ions");
}
Expand All @@ -174,8 +184,6 @@ void Exx_LRI<Tdata>::cal_exx_elec(const std::vector<std::map<TA, std::map<TAC, R

const std::vector<std::tuple<std::set<TA>, std::set<TA>>> judge = RI_2D_Comm::get_2D_judge(pv);

this->exx_lri.set_csm_threshold(this->info.cauchy_threshold);

this->Hexxs.resize(GlobalV::NSPIN);
this->Eexx = 0;
for(int is=0; is<GlobalV::NSPIN; ++is)
Expand Down Expand Up @@ -247,8 +255,6 @@ void Exx_LRI<Tdata>::cal_exx_force()
{
ModuleBase::TITLE("Exx_LRI","cal_exx_force");
ModuleBase::timer::tick("Exx_LRI", "cal_exx_force");

this->exx_lri.set_csm_threshold(this->info.cauchy_force_threshold);

this->force_exx.create(GlobalC::ucell.nat, Ndim);
for(int is=0; is<GlobalV::NSPIN; ++is)
Expand All @@ -271,8 +277,6 @@ void Exx_LRI<Tdata>::cal_exx_stress()
{
ModuleBase::TITLE("Exx_LRI","cal_exx_stress");
ModuleBase::timer::tick("Exx_LRI", "cal_exx_stress");

this->exx_lri.set_csm_threshold(this->info.cauchy_stress_threshold);

this->stress_exx.create(Ndim, Ndim);
for(int is=0; is<GlobalV::NSPIN; ++is)
Expand Down
7 changes: 6 additions & 1 deletion source/module_ri/LRI_CV_Tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,12 @@ namespace LRI_CV_Tools
template<typename TA, typename Tcell, typename Tdata>
extern std::map<int,std::map<int,std::map<Abfs::Vector3_Order<double>,std::array<RI::Tensor<Tdata>,3>>>>
get_dCVws(
const std::array<std::map<TA,std::map<std::pair<TA,std::array<Tcell,3>>,RI::Tensor<Tdata>>>,3> &dCVs);
const std::array<std::map<TA,std::map<std::pair<TA,std::array<Tcell,3>>,RI::Tensor<Tdata>>>,3> &dCVs);

template<typename TA, typename TC, typename Tdata>
extern std::array<std::array<std::map<TA,std::map<std::pair<TA,TC>,RI::Tensor<Tdata>>>,3>,3>
cal_dMRs(
const std::array<std::map<TA,std::map<std::pair<TA,TC>,RI::Tensor<Tdata>>>,3> &dMs);
}

#include "LRI_CV_Tools.hpp"
Expand Down
41 changes: 41 additions & 0 deletions source/module_ri/LRI_CV_Tools.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,4 +312,45 @@ LRI_CV_Tools::get_dCVws(
return dCVws;
}


// dMRs[ipos0][ipos1] = \nabla_{ipos0} M R_{ipos1}
template<typename TA, typename TC, typename Tdata>
std::array<std::array<std::map<TA,std::map<std::pair<TA,TC>,RI::Tensor<Tdata>>>,3>,3>
LRI_CV_Tools::cal_dMRs(
const std::array<std::map<TA,std::map<std::pair<TA,TC>,RI::Tensor<Tdata>>>,3> &dMs)
{
auto get_R_delta = [&](const TA &iat0, const std::pair<TA,TC> &A1) -> std::array<Tdata,3>
{
const TA iat1 = A1.first;
const TC &cell1 = A1.second;
const int it0 = GlobalC::ucell.iat2it[iat0];
const int ia0 = GlobalC::ucell.iat2ia[iat0];
const int it1 = GlobalC::ucell.iat2it[iat1];
const int ia1 = GlobalC::ucell.iat2ia[iat1];
const ModuleBase::Vector3<double> tau0 = GlobalC::ucell.atoms[it0].tau[ia0];
const ModuleBase::Vector3<double> tau1 = GlobalC::ucell.atoms[it1].tau[ia1];
const Abfs::Vector3_Order<double> R_delta = -tau0+tau1+(RI_Util::array3_to_Vector3(cell1)*GlobalC::ucell.latvec);
return std::array<Tdata,3>{R_delta.x, R_delta.y, R_delta.z};
};
constexpr int Npos = 3;
std::array<std::array<std::map<TA,std::map<std::pair<TA,TC>,RI::Tensor<Tdata>>>,Npos>,Npos> dMRs;
for(int ipos0=0; ipos0<Npos; ++ipos0)
{
for(int ipos1=0; ipos1<Npos; ++ipos1)
{
for(const auto &dMs_A : dMs[ipos0])
{
const TA iat0 = dMs_A.first;
for(const auto &dMs_B : dMs_A.second)
{
const std::pair<TA,TC> A1 = dMs_B.first;
const RI::Tensor<Tdata> &dM = dMs_B.second;
const std::array<Tdata,3> R_delta = get_R_delta(iat0, A1);
dMRs[ipos0][ipos1][iat0][A1] = dM * R_delta[ipos1];
}
}
}
}
return dMRs;
}
#endif
4 changes: 2 additions & 2 deletions toolchain/scripts/stage4/install_libri.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
[ "${BASH_SOURCE[0]}" ] && SCRIPT_NAME="${BASH_SOURCE[0]}" || SCRIPT_NAME=$0
SCRIPT_DIR="$(cd "$(dirname "$SCRIPT_NAME")/.." && pwd -P)"

libri_ver="0.1.1"
libri_sha256="51deb08aa373e54d2c123b57bfd4b3507accac0d496a94b766eaeadccd9e4bd0"
libri_ver="0.2.0"
libri_sha256="ad79dfbc3ed8ff066c85549a2737d29205dbf755b38ea216ab2ab42754f80389"
source "${SCRIPT_DIR}"/common_vars.sh
source "${SCRIPT_DIR}"/tool_kit.sh
source "${SCRIPT_DIR}"/signal_trap.sh
Expand Down

0 comments on commit 0bf4896

Please sign in to comment.