Skip to content

Refactor: the ccp parameters to support additional Coulomb matrix construction methods. #6307

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 81 commits into from
Jun 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
c83e361
Use template to reconstruct parse_expression
1041176461 Jan 21, 2023
cdf3c0c
Feature: output R matrix at each MD step
1041176461 Jan 23, 2023
cff6e08
Modify'matrix_HS' to 'matrix' for R matrix output
1041176461 Jan 23, 2023
b9db1f1
Merge branch 'develop' into develop
1041176461 Jan 23, 2023
6c1a77b
Merge branch 'develop' of https://github.com/1041176461/abacus-develo…
1041176461 Jan 31, 2023
cc149a5
Merge branches 'develop' and 'develop' of https://github.com/10411764…
Feb 11, 2023
992ba96
Merge branch 'develop' of https://github.com/1041176461/abacus-develo…
Feb 11, 2023
0c753e2
Merge branch 'deepmodeling:develop' into develop
1041176461 Feb 12, 2023
3fd87f3
Merge branch 'develop' of https://github.com/1041176461/abacus-develo…
Feb 14, 2023
2a81795
Fix: modify index in parse_expression
1041176461 Feb 15, 2023
3523c57
Merge branch 'deepmodeling:develop' into develop
1041176461 Mar 27, 2023
afe397c
Fix: add regfree for parse_expression
May 10, 2023
d7775cf
Merge branch 'develop' into develop
1041176461 May 10, 2023
aad3e5a
Merge branch 'develop' into develop
Qianruipku May 10, 2023
4375864
Merge branch 'deepmodeling:develop' into develop
1041176461 May 21, 2023
d91a9e9
Doc: update phonopy doc
1041176461 Jun 5, 2023
238d73f
Merge branch 'deepmodeling:develop' into develop
1041176461 Jun 5, 2023
cdc685a
Doc: update phonopy doc
1041176461 Jun 5, 2023
47bc26b
Merge branch 'develop' of https://github.com/1041176461/abacus-develo…
1041176461 Jun 5, 2023
2ecdcca
Merge branch 'deepmodeling:develop' into develop
1041176461 Jun 24, 2023
53eeedf
Merge branch 'deepmodeling:develop' into develop
1041176461 Aug 30, 2023
b22769e
Merge branch 'deepmodeling:develop' into develop
1041176461 Sep 4, 2023
89d7394
Merge branch 'deepmodeling:develop' into develop
1041176461 Oct 30, 2023
d09f2d8
Merge branch 'deepmodeling:develop' into develop
1041176461 Apr 8, 2024
2673ecc
fix tdos plot for nspin=2
1041176461 Apr 8, 2024
3d2d8dd
optimize dosplot for nspin=2
1041176461 Apr 8, 2024
d919681
fix legend for dosplot
1041176461 Apr 8, 2024
76defcd
Merge branch 'develop' into develop
1041176461 Apr 8, 2024
560a60c
Merge branch 'deepmodeling:develop' into develop
1041176461 May 8, 2024
47d5cac
Merge branch 'deepmodeling:develop' into develop
1041176461 Jul 3, 2024
8e0c6d8
Merge branch 'deepmodeling:develop' into develop
1041176461 Oct 13, 2024
90e4750
Merge branch 'deepmodeling:develop' into develop
1041176461 Oct 19, 2024
d0bedae
Add files via upload
ESROAMER Nov 2, 2024
25a77b3
Update cal_edm_tddft.cpp
ESROAMER Nov 2, 2024
e21da57
Refactor: modify exx loop for relax/md
1041176461 Nov 2, 2024
74651ac
Update result.ref
ESROAMER Nov 2, 2024
b67c43c
Fix wrong parameters in integrate test
ESROAMER Nov 2, 2024
0cb9cbb
Update result.ref
ESROAMER Nov 2, 2024
2ba948c
Update result.ref
ESROAMER Nov 2, 2024
58cc693
Update result.ref
ESROAMER Nov 2, 2024
6513db5
Update result.ref
ESROAMER Nov 2, 2024
0fc246b
Update result.ref
ESROAMER Nov 2, 2024
0721fbb
Update result.ref
ESROAMER Nov 2, 2024
63e59b5
Update result.ref
ESROAMER Nov 2, 2024
22058e3
Update result.ref
ESROAMER Nov 2, 2024
ced029a
add exx when istep>0
maki49 Nov 2, 2024
7740356
Merge pull request #8 from maki49/new_loop
1041176461 Nov 3, 2024
d15217c
Merge pull request #7 from 1041176461/new_loop
1041176461 Nov 3, 2024
2755221
Merge branch 'develop' into develop
1041176461 Nov 4, 2024
9b7df7d
Update dos.py
1041176461 Nov 4, 2024
a8a9051
Update esolver_sdft_pw.cpp
1041176461 Nov 4, 2024
ba09ba9
Update lcao_before_scf.cpp
1041176461 Nov 4, 2024
f5734d4
Update Exx_LRI_interface.h
1041176461 Nov 4, 2024
cacaf93
Update Exx_LRI_interface.hpp
1041176461 Nov 4, 2024
894cb25
Fix: compile error
1041176461 Nov 4, 2024
7c54ec6
Fix: compile error
1041176461 Nov 4, 2024
8c7c0e6
Fix: change HSE relax/md result.ref for new framework
1041176461 Nov 5, 2024
3df2804
Merge branch 'pr/1041176461/9' into develop
1041176461 Nov 6, 2024
9a820d2
Fix: compile error
1041176461 Nov 6, 2024
ebfdadc
compatible with exx_iter_finish
1041176461 Nov 6, 2024
eca5f43
Merge branch 'deepmodeling:develop' into develop
ESROAMER Nov 7, 2024
bac726b
Add files via upload
ESROAMER Nov 7, 2024
6965e9e
Update esolver_ks_lcao_tddft.h
ESROAMER Nov 8, 2024
09aa1a1
Update esolver_ks_lcao_tddft.cpp
ESROAMER Nov 8, 2024
2373c13
Merge pull request #10 from ESROAMER/no_force
1041176461 Nov 8, 2024
0ca4e04
Merge branch 'deepmodeling-develop' into develop
1041176461 Nov 27, 2024
7e3e147
Merge branch 'develop' of https://github.com/1041176461/abacus-develo…
1041176461 Nov 27, 2024
289036b
Merge branch 'deepmodeling:develop' into develop
1041176461 Jan 6, 2025
db653b7
Fix: support negative value in parse_expression
1041176461 Jan 6, 2025
4b82a10
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] Jan 6, 2025
7e0c98e
Merge branch 'deepmodeling:develop' into develop
1041176461 Jan 30, 2025
eb353a8
Fix: parse_expression for scientific notation
1041176461 Jan 30, 2025
c1235ac
Update input_conv.h
1041176461 Jan 30, 2025
477c87a
Merge branch 'deepmodeling:develop' into develop
1041176461 Feb 22, 2025
15d4fca
Merge branch 'deepmodeling:develop' into develop
1041176461 May 13, 2025
d7771a8
Merge branch 'deepmodeling:develop' into develop
1041176461 Jun 5, 2025
4ee5b2c
Merge branch 'deepmodeling:develop' into develop
1041176461 Jun 17, 2025
a6d828d
add complex erf function
1041176461 Jun 17, 2025
10f97cf
modify ccp framework
1041176461 Jun 17, 2025
c54228e
fix add error
1041176461 Jun 18, 2025
266fc51
Merge branch 'develop' into ccp_framework
1041176461 Jun 18, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions source/module_hamilt_general/module_xc/exx_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ struct Exx_Info
{
bool cal_exx = false;

std::unordered_map<Conv_Coulomb_Pot_K::Coulomb_Type, std::vector<std::map<std::string,std::string>>> coulomb_param;
std::unordered_map<Conv_Coulomb_Pot_K::Coulomb_Method,
std::pair<bool,
std::unordered_map<Conv_Coulomb_Pot_K::Coulomb_Type,
std::vector<std::map<std::string,std::string>>>>> coulomb_settings;
// Fock:
// "alpha": "0"
// "Rcut_type": "limits" / "spencer"
Expand Down Expand Up @@ -52,7 +55,10 @@ struct Exx_Info

struct Exx_Info_RI
{
const std::unordered_map<Conv_Coulomb_Pot_K::Coulomb_Type, std::vector<std::map<std::string,std::string>>> &coulomb_param;
const std::unordered_map<Conv_Coulomb_Pot_K::Coulomb_Method,
std::pair<bool,
std::unordered_map<Conv_Coulomb_Pot_K::Coulomb_Type,
std::vector<std::map<std::string,std::string>>>>> &coulomb_settings;

bool real_number = false;

Expand All @@ -74,7 +80,7 @@ struct Exx_Info
int abfs_Lmax = 0; // tmp

Exx_Info_RI(const Exx_Info::Exx_Info_Global& info_global)
: coulomb_param(info_global.coulomb_param)
: coulomb_settings(info_global.coulomb_settings)
{
}
};
Expand Down
14 changes: 10 additions & 4 deletions source/module_io/input_conv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,35 +328,41 @@ void Input_Conv::Convert()
{
GlobalC::exx_info.info_global.cal_exx = true;
GlobalC::exx_info.info_global.ccp_type = Conv_Coulomb_Pot_K::Ccp_Type::Hf;
GlobalC::exx_info.info_global.coulomb_param[Conv_Coulomb_Pot_K::Coulomb_Type::Fock] = {{
std::unordered_map<Conv_Coulomb_Pot_K::Coulomb_Type, std::vector<std::map<std::string,std::string>>> coulomb_param;
coulomb_param[Conv_Coulomb_Pot_K::Coulomb_Type::Fock] = {{
{"alpha", "1"},
{"Rcut_type", "spencer"},
{"lambda", std::to_string(PARAM.inp.exx_lambda)} }};
GlobalC::exx_info.info_global.coulomb_settings[Conv_Coulomb_Pot_K::Coulomb_Method::Center2] = std::make_pair(true, coulomb_param);
}
// use the error function erf(w|r-r'|), exx just has the short-range part
else if (dft_functional_lower == "hse"
|| dft_functional_lower == "cwp22")
{
GlobalC::exx_info.info_global.cal_exx = true;
GlobalC::exx_info.info_global.ccp_type = Conv_Coulomb_Pot_K::Ccp_Type::Erfc;
GlobalC::exx_info.info_global.coulomb_param[Conv_Coulomb_Pot_K::Coulomb_Type::Erfc] = {{
std::unordered_map<Conv_Coulomb_Pot_K::Coulomb_Type, std::vector<std::map<std::string,std::string>>> coulomb_param;
coulomb_param[Conv_Coulomb_Pot_K::Coulomb_Type::Erfc] = {{
{"alpha", "1"},
{"omega", std::to_string(PARAM.inp.exx_hse_omega)},
{"Rcut_type", "limits"} }};
GlobalC::exx_info.info_global.coulomb_settings[Conv_Coulomb_Pot_K::Coulomb_Method::Center2] = std::make_pair(true, coulomb_param);
}
// use the error function erf(w|r-r'|), exx just has the long-range part
else if ( dft_functional_lower == "wp22" )
{
GlobalC::exx_info.info_global.cal_exx = true;
GlobalC::exx_info.info_global.ccp_type = Conv_Coulomb_Pot_K::Ccp_Type::Erf;
GlobalC::exx_info.info_global.coulomb_param[Conv_Coulomb_Pot_K::Coulomb_Type::Fock] = {{
std::unordered_map<Conv_Coulomb_Pot_K::Coulomb_Type, std::vector<std::map<std::string,std::string>>> coulomb_param;
coulomb_param[Conv_Coulomb_Pot_K::Coulomb_Type::Fock] = {{
{"alpha", "1"},
{"Rcut_type", "spencer"},
{"lambda", std::to_string(PARAM.inp.exx_lambda)} }};
GlobalC::exx_info.info_global.coulomb_param[Conv_Coulomb_Pot_K::Coulomb_Type::Erfc] = {{
coulomb_param[Conv_Coulomb_Pot_K::Coulomb_Type::Erfc] = {{
{"alpha", "-1"},
{"omega", std::to_string(PARAM.inp.exx_hse_omega)},
{"Rcut_type", "limits"} }};
GlobalC::exx_info.info_global.coulomb_settings[Conv_Coulomb_Pot_K::Coulomb_Method::Center2] = std::make_pair(true, coulomb_param);
}
#ifdef __EXX
else if (dft_functional_lower == "opt_orb")
Expand Down
16 changes: 13 additions & 3 deletions source/module_ri/Exx_LRI.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <vector>
#include <array>
#include <map>
#include <unordered_map>
#include <deque>
#include <mpi.h>

Expand All @@ -37,6 +38,15 @@
class OperatorLREXX;
}

template<typename Tdata>
class Exx_Obj
{
// match with Conv_Coulomb_Pot_K::Coulomb_Method
public:
LRI_CV<Tdata> cv;
std::vector<std::vector<std::vector<Numerical_Orbital_Lm>>> abfs_ccp;
};

template<typename Tdata>
class Exx_LRI
{
Expand Down Expand Up @@ -85,9 +95,9 @@ class Exx_LRI

std::vector<std::vector<std::vector<Numerical_Orbital_Lm>>> lcaos;
std::vector<std::vector<std::vector<Numerical_Orbital_Lm>>> abfs;
std::vector<std::vector<std::vector<Numerical_Orbital_Lm>>> abfs_ccp;

LRI_CV<Tdata> cv;
//std::vector<std::vector<std::vector<Numerical_Orbital_Lm>>> abfs_ccp;
std::unordered_map<Conv_Coulomb_Pot_K::Coulomb_Method, Exx_Obj<Tdata>> exx_objs;
//LRI_CV<Tdata> cv;
RI::Exx<TA,Tcell,Ndim,Tdata> exx_lri;

void post_process_Hexx( std::map<TA, std::map<TAC, RI::Tensor<Tdata>>> &Hexxs_io ) const;
Expand Down
99 changes: 65 additions & 34 deletions source/module_ri/Exx_LRI.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,18 @@ void Exx_LRI<Tdata>::init(const MPI_Comm &mpi_comm_in,
{ this->abfs = Exx_Abfs::IO::construct_abfs( abfs_same_atom, orb, this->info.files_abfs, this->info.kmesh_times ); }
Exx_Abfs::Construct_Orbs::print_orbs_size(ucell, this->abfs, GlobalV::ofs_running);

const std::unordered_map<Conv_Coulomb_Pot_K::Coulomb_Type, std::vector<std::map<std::string,std::string>>>
coulomb_param_updated = RI_Util::update_coulomb_param(this->info.coulomb_param, ucell.omega, this->p_kv->get_nkstot_full());
this->abfs_ccp = Conv_Coulomb_Pot_K::cal_orbs_ccp(this->abfs, coulomb_param_updated, this->info.ccp_rmesh_times);

for( size_t T=0; T!=this->abfs.size(); ++T )
{ GlobalC::exx_info.info_ri.abfs_Lmax = std::max( GlobalC::exx_info.info_ri.abfs_Lmax, static_cast<int>(this->abfs[T].size())-1 ); }

this->cv.set_orbitals(
ucell,
orb,
this->lcaos, this->abfs, this->abfs_ccp,
this->info.kmesh_times, this->info.ccp_rmesh_times );

for(const auto &settings_list : this->info.coulomb_settings)
{
const std::unordered_map<Conv_Coulomb_Pot_K::Coulomb_Type, std::vector<std::map<std::string,std::string>>>
coulomb_param_updated = RI_Util::update_coulomb_param(settings_list.second.second, ucell.omega, this->p_kv->get_nkstot_full());
this->exx_objs[settings_list.first].abfs_ccp = Conv_Coulomb_Pot_K::cal_orbs_ccp(this->abfs, coulomb_param_updated, this->info.ccp_rmesh_times);
this->exx_objs[settings_list.first].cv.set_orbitals(ucell, orb,
this->lcaos, this->abfs, this->exx_objs[settings_list.first].abfs_ccp,
this->info.kmesh_times, this->info.ccp_rmesh_times );
}
ModuleBase::timer::tick("Exx_LRI", "init");
}

Expand Down Expand Up @@ -95,26 +94,40 @@ void Exx_LRI<Tdata>::cal_exx_ions(const UnitCell& ucell,
const std::pair<std::vector<TA>, std::vector<std::vector<std::pair<TA,std::array<Tcell,Ndim>>>>>
list_As_Vs = RI::Distribute_Equally::distribute_atoms_periods(this->mpi_comm, atoms, period_Vs, 2, false);

std::map<TA,std::map<TAC,RI::Tensor<Tdata>>>
Vs = this->cv.cal_Vs(ucell,
list_As_Vs.first, list_As_Vs.second[0],
{{"writable_Vws",true}});
this->cv.Vws = LRI_CV_Tools::get_CVws(ucell,Vs);
std::map<TA,std::map<TAC,RI::Tensor<Tdata>>> Vs;
std::map<TA, std::map<TAC, std::array<RI::Tensor<Tdata>, Ndim>>> dVs;
for(const auto &settings_list : this->info.coulomb_settings)
{
std::map<TA,std::map<TAC,RI::Tensor<Tdata>>>
Vs_temp = this->exx_objs[settings_list.first].cv.cal_Vs(ucell,
list_As_Vs.first, list_As_Vs.second[0],
{{"writable_Vws",true}});
this->exx_objs[settings_list.first].cv.Vws = LRI_CV_Tools::get_CVws(ucell,Vs_temp);
Vs = Vs.empty() ? Vs_temp : LRI_CV_Tools::add(Vs, Vs_temp);

if(PARAM.inp.cal_force || PARAM.inp.cal_stress)
{
std::map<TA, std::map<TAC, std::array<RI::Tensor<Tdata>, Ndim>>>
dVs_temp = this->exx_objs[settings_list.first].cv.cal_dVs(ucell,
list_As_Vs.first, list_As_Vs.second[0],
{{"writable_dVws",true}});
this->exx_objs[settings_list.first].cv.dVws = LRI_CV_Tools::get_dCVws(ucell,dVs_temp);
dVs = dVs.empty() ? dVs_temp : LRI_CV_Tools::add(dVs, dVs_temp);
}

}
if (write_cv && GlobalV::MY_RANK == 0)
{ LRI_CV_Tools::write_Vs_abf(Vs, PARAM.globalv.global_out_dir + "Vs"); }
this->exx_lri.set_Vs(std::move(Vs), this->info.V_threshold);

if(PARAM.inp.cal_force || PARAM.inp.cal_stress)
{
std::array<std::map<TA,std::map<TAC,RI::Tensor<Tdata>>>,3>
dVs = this->cv.cal_dVs(ucell,
list_As_Vs.first, list_As_Vs.second[0],
{{"writable_dVws",true}});
this->cv.dVws = LRI_CV_Tools::get_dCVws(ucell,dVs);
this->exx_lri.set_dVs(std::move(dVs), this->info.V_grad_threshold);
std::array<std::map<TA, std::map<TAC, RI::Tensor<Tdata>>>, Ndim>
dVs_order = LRI_CV_Tools::change_order(std::move(dVs));
this->exx_lri.set_dVs(std::move(dVs_order), this->info.V_grad_threshold);
if(PARAM.inp.cal_stress)
{
std::array<std::array<std::map<TA,std::map<TAC,RI::Tensor<Tdata>>>,3>,3> dVRs = LRI_CV_Tools::cal_dMRs(ucell,dVs);
std::array<std::array<std::map<TA,std::map<TAC,RI::Tensor<Tdata>>>,3>,3> dVRs = LRI_CV_Tools::cal_dMRs(ucell,dVs_order);
this->exx_lri.set_dVRs(std::move(dVRs), this->info.V_grad_R_threshold);
}
}
Expand All @@ -123,29 +136,47 @@ void Exx_LRI<Tdata>::cal_exx_ions(const UnitCell& ucell,
const std::pair<std::vector<TA>, std::vector<std::vector<std::pair<TA,std::array<Tcell,Ndim>>>>>
list_As_Cs = RI::Distribute_Equally::distribute_atoms_periods(this->mpi_comm, atoms, period_Cs, 2, false);

std::pair<std::map<TA,std::map<TAC,RI::Tensor<Tdata>>>, std::array<std::map<TA,std::map<TAC,RI::Tensor<Tdata>>>,3>>
Cs_dCs = this->cv.cal_Cs_dCs(
ucell,
list_As_Cs.first, list_As_Cs.second[0],
{{"cal_dC",PARAM.inp.cal_force||PARAM.inp.cal_stress},
{"writable_Cws",true}, {"writable_dCws",true}, {"writable_Vws",false}, {"writable_dVws",false}});
std::map<TA,std::map<TAC,RI::Tensor<Tdata>>> &Cs = std::get<0>(Cs_dCs);
this->cv.Cws = LRI_CV_Tools::get_CVws(ucell,Cs);
std::map<TA,std::map<TAC,RI::Tensor<Tdata>>> Cs;
std::map<TA, std::map<TAC, std::array<RI::Tensor<Tdata>, 3>>> dCs;
for(const auto &settings_list : this->info.coulomb_settings)
{
if(settings_list.second.first)
{
std::pair<std::map<TA, std::map<TAC, RI::Tensor<Tdata>>>,
std::map<TA, std::map<TAC, std::array<RI::Tensor<Tdata>, 3>>>>
Cs_dCs = this->exx_objs[settings_list.first].cv.cal_Cs_dCs(
ucell,
list_As_Cs.first, list_As_Cs.second[0],
{{"cal_dC",PARAM.inp.cal_force||PARAM.inp.cal_stress},
{"writable_Cws",true}, {"writable_dCws",true}, {"writable_Vws",false}, {"writable_dVws",false}});
std::map<TA,std::map<TAC,RI::Tensor<Tdata>>> &Cs_temp = std::get<0>(Cs_dCs);
this->exx_objs[settings_list.first].cv.Cws = LRI_CV_Tools::get_CVws(ucell,Cs_temp);
Cs = Cs.empty() ? Cs_temp : LRI_CV_Tools::add(Cs, Cs_temp);

if(PARAM.inp.cal_force || PARAM.inp.cal_stress)
{
std::map<TA, std::map<TAC, std::array<RI::Tensor<Tdata>, 3>>> &dCs_temp = std::get<1>(Cs_dCs);
this->exx_objs[settings_list.first].cv.dCws = LRI_CV_Tools::get_dCVws(ucell,dCs_temp);
dCs = dCs.empty() ? dCs_temp : LRI_CV_Tools::add(dCs, dCs_temp);
}
}
}
if (write_cv && GlobalV::MY_RANK == 0)
{ LRI_CV_Tools::write_Cs_ao(Cs, PARAM.globalv.global_out_dir + "Cs"); }
this->exx_lri.set_Cs(std::move(Cs), this->info.C_threshold);

if(PARAM.inp.cal_force || PARAM.inp.cal_stress)
{
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(ucell,dCs);
this->exx_lri.set_dCs(std::move(dCs), this->info.C_grad_threshold);
std::array<std::map<TA, std::map<TAC, RI::Tensor<Tdata>>>, Ndim>
dCs_order = LRI_CV_Tools::change_order(std::move(dCs));
this->exx_lri.set_dCs(std::move(dCs_order), this->info.C_grad_threshold);
if(PARAM.inp.cal_stress)
{
std::array<std::array<std::map<TA,std::map<TAC,RI::Tensor<Tdata>>>,3>,3> dCRs = LRI_CV_Tools::cal_dMRs(ucell,dCs);
std::array<std::array<std::map<TA,std::map<TAC,RI::Tensor<Tdata>>>,3>,3> dCRs = LRI_CV_Tools::cal_dMRs(ucell,dCs_order);
this->exx_lri.set_dCRs(std::move(dCRs), this->info.C_grad_R_threshold);
}
}

ModuleBase::timer::tick("Exx_LRI", "cal_exx_ions");
}

Expand Down
6 changes: 3 additions & 3 deletions source/module_ri/LRI_CV.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ class LRI_CV
const std::vector<TA> &list_A0,
const std::vector<TAC> &list_A1,
const std::map<std::string,bool> &flags); // "writable_Vws"
inline std::array<std::map<TA,std::map<TAC,RI::Tensor<Tdata>>>,3>
inline std::map<TA, std::map<TAC, std::array<RI::Tensor<Tdata>, 3>>>
cal_dVs(
const UnitCell &ucell,
const std::vector<TA> &list_A0,
const std::vector<TAC> &list_A1,
const std::map<std::string,bool> &flags); // "writable_dVws"
std::pair<std::map<TA,std::map<TAC,RI::Tensor<Tdata>>>,
std::array<std::map<TA,std::map<TAC,RI::Tensor<Tdata>>>,3>>
std::pair<std::map<TA, std::map<TAC, RI::Tensor<Tdata>>>,
std::map<TA, std::map<TAC, std::array<RI::Tensor<Tdata>, 3>>>>
cal_Cs_dCs(
const UnitCell &ucell,
const std::vector<TA> &list_A0,
Expand Down
29 changes: 15 additions & 14 deletions source/module_ri/LRI_CV.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,14 @@ auto LRI_CV<Tdata>::cal_dVs(
const std::vector<TA> &list_A0,
const std::vector<TAC> &list_A1,
const std::map<std::string,bool> &flags) // + "writable_dVws"
-> std::array<std::map<TA,std::map<TAC,RI::Tensor<Tdata>>>,3>
-> std::map<TA, std::map<TAC, std::array<RI::Tensor<Tdata>, 3>>>
{
ModuleBase::TITLE("LRI_CV","cal_dVs");
const T_func_DPcal_data<std::array<RI::Tensor<Tdata>,3>>
func_DPcal_dV = std::bind(
&LRI_CV<Tdata>::DPcal_dV, this,
std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4);
return LRI_CV_Tools::change_order(
this->cal_datas(ucell,list_A0, list_A1, flags, this->ccp_rmesh_times, func_DPcal_dV));
return this->cal_datas(ucell,list_A0, list_A1, flags, this->ccp_rmesh_times, func_DPcal_dV);
}

template<typename Tdata>
Expand All @@ -163,7 +162,9 @@ auto LRI_CV<Tdata>::cal_Cs_dCs(
const std::vector<TA> &list_A0,
const std::vector<TAC> &list_A1,
const std::map<std::string,bool> &flags) // "cal_dC" + "writable_Cws", "writable_dCws", "writable_Vws", "writable_dVws"
-> std::pair<std::map<TA,std::map<TAC,RI::Tensor<Tdata>>>, std::array<std::map<TA,std::map<TAC,RI::Tensor<Tdata>>>,3>>
-> std::pair<
std::map<TA, std::map<TAC, RI::Tensor<Tdata>>>,
std::map<TA, std::map<TAC, std::array<RI::Tensor<Tdata>, 3>>>>
{
ModuleBase::TITLE("LRI_CV","cal_Cs_dCs");
const T_func_DPcal_data<std::pair<RI::Tensor<Tdata>, std::array<RI::Tensor<Tdata>,3>>>
Expand All @@ -173,16 +174,16 @@ auto LRI_CV<Tdata>::cal_Cs_dCs(
std::map<TA,std::map<TAC, std::pair<RI::Tensor<Tdata>, std::array<RI::Tensor<Tdata>,3>>>>
Cs_dCs_tmp = this->cal_datas(ucell,list_A0, list_A1, flags, std::min(1.0,this->ccp_rmesh_times), func_DPcal_C_dC);

std::map<TA,std::map<TAC,RI::Tensor<Tdata>>> Cs;
std::array<std::map<TA,std::map<TAC,RI::Tensor<Tdata>>>,3> dCs;
for(auto &Cs_dCs_A : Cs_dCs_tmp)
for(auto &Cs_dCs_B : Cs_dCs_A.second)
{
Cs[Cs_dCs_A.first][Cs_dCs_B.first] = std::move(std::get<0>(Cs_dCs_B.second));
if(flags.at("cal_dC"))
for(int ix=0; ix<3; ++ix)
dCs[ix][Cs_dCs_A.first][Cs_dCs_B.first] = std::move(std::get<1>(Cs_dCs_B.second)[ix]);
}
std::map<TA, std::map<TAC, RI::Tensor<Tdata>>> Cs;
std::map<TA, std::map<TAC, std::array<RI::Tensor<Tdata>, 3>>> dCs;
for (auto& Cs_dCs_A: Cs_dCs_tmp)
for (auto& Cs_dCs_B: Cs_dCs_A.second) {
Cs[Cs_dCs_A.first][Cs_dCs_B.first]
= std::move(std::get<0>(Cs_dCs_B.second));
if (flags.at("cal_dC"))
dCs[Cs_dCs_A.first][Cs_dCs_B.first]
= std::move(std::get<1>(Cs_dCs_B.second));
}
return std::make_pair(Cs, dCs);
}

Expand Down
Loading
Loading