Skip to content

Commit e195da0

Browse files
committed
support rsh functionals
1 parent a78ad6e commit e195da0

File tree

7 files changed

+92
-33
lines changed

7 files changed

+92
-33
lines changed

source/source_hamilt/module_xc/exx_info.h

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ struct Exx_Info
1818

1919
// Fock:
2020
// "alpha": "0"
21-
// "Rcut_type": "limits" / "spencer"
21+
// "singularity_correction": "limits" / "spencer" / "revised_spencer"
2222
// "lambda": "0.3"
23-
// //"Rcut"
23+
// "Rcut"
2424
// Erfc:
2525
// "alpha": "0"
2626
// "omega": "0.11"
27-
// "Rcut_type": "limits"
28-
// //"Rcut"
27+
// "singularity_correction": "limits" / "spencer" / "revised_spencer"
28+
// "Rcut"
2929

3030
Conv_Coulomb_Pot_K::Ccp_Type ccp_type;
3131
double hybrid_alpha = 0.25;
@@ -51,10 +51,7 @@ struct Exx_Info
5151

5252
struct Exx_Info_RI
5353
{
54-
std::map<Conv_Coulomb_Pot_K::Coulomb_Method,
55-
std::pair<bool,
56-
std::map<Conv_Coulomb_Pot_K::Coulomb_Type,
57-
std::vector<std::map<std::string,std::string>>>>> coulomb_settings;
54+
const std::map<Conv_Coulomb_Pot_K::Coulomb_Type, std::vector<std::map<std::string,std::string>>> &coulomb_param;
5855

5956
bool real_number = false;
6057

@@ -72,10 +69,15 @@ struct Exx_Info
7269
double kmesh_times = 4;
7370

7471
int abfs_Lmax = 0; // tmp
72+
73+
Exx_Info_RI(const Exx_Info::Exx_Info_Global& info_global)
74+
: coulomb_param(info_global.coulomb_param)
75+
{
76+
}
7577
};
7678
Exx_Info_RI info_ri;
7779

78-
Exx_Info() : info_lip(this->info_global)
80+
Exx_Info() : info_lip(this->info_global), info_ri(this->info_global)
7981
{
8082
}
8183
};

source/source_io/input_conv.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -362,15 +362,13 @@ void Input_Conv::Convert()
362362
{
363363
if(PARAM.inp.basis_type == "lcao")
364364
{
365-
std::map<Conv_Coulomb_Pot_K::Coulomb_Type, std::vector<std::map<std::string,std::string>>> coulomb_param;
366-
coulomb_param[Conv_Coulomb_Pot_K::Coulomb_Type::Fock].resize(fock_alpha.size());
365+
GlobalC::exx_info.info_global.coulomb_param[Conv_Coulomb_Pot_K::Coulomb_Type::Fock].resize(fock_alpha.size());
367366
for(std::size_t i=0; i<fock_alpha.size(); ++i)
368367
{
369-
coulomb_param[Conv_Coulomb_Pot_K::Coulomb_Type::Fock] = {{
368+
GlobalC::exx_info.info_global.coulomb_param[Conv_Coulomb_Pot_K::Coulomb_Type::Fock] = {{
370369
{"alpha", ModuleBase::GlobalFunc::TO_STRING(fock_alpha[i])},
371-
{"Rcut_type", PARAM.inp.exx_singularity_correction} }};
370+
{"singularity_correction", PARAM.inp.exx_singularity_correction} }};
372371
}
373-
GlobalC::exx_info.info_ri.coulomb_settings[Conv_Coulomb_Pot_K::Coulomb_Method::Center2] = std::make_pair(true, coulomb_param);
374372
}
375373
else if(PARAM.inp.basis_type == "lcao_in_pw")
376374
{
@@ -402,16 +400,14 @@ void Input_Conv::Convert()
402400
assert(erfc_alpha.size() == PARAM.inp.exx_erfc_omega.size());
403401
if(PARAM.inp.basis_type == "lcao")
404402
{
405-
std::map<Conv_Coulomb_Pot_K::Coulomb_Type, std::vector<std::map<std::string,std::string>>> coulomb_param;
406-
coulomb_param[Conv_Coulomb_Pot_K::Coulomb_Type::Erfc].resize(erfc_alpha.size());
403+
GlobalC::exx_info.info_global.coulomb_param[Conv_Coulomb_Pot_K::Coulomb_Type::Erfc].resize(erfc_alpha.size());
407404
for(std::size_t i=0; i<erfc_alpha.size(); ++i)
408405
{
409-
coulomb_param[Conv_Coulomb_Pot_K::Coulomb_Type::Erfc] = {{
406+
GlobalC::exx_info.info_global.coulomb_param[Conv_Coulomb_Pot_K::Coulomb_Type::Erfc] = {{
410407
{"alpha", ModuleBase::GlobalFunc::TO_STRING(erfc_alpha[i])},
411408
{"omega", ModuleBase::GlobalFunc::TO_STRING(PARAM.inp.exx_erfc_omega[i])},
412-
{"Rcut_type", PARAM.inp.exx_singularity_correction} }};
409+
{"singularity_correction", PARAM.inp.exx_singularity_correction} }};
413410
}
414-
GlobalC::exx_info.info_ri.coulomb_settings[Conv_Coulomb_Pot_K::Coulomb_Method::Center2] = std::make_pair(true, coulomb_param);
415411
}
416412
}
417413
}

source/source_lcao/module_ri/Exx_LRI.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ class Exx_LRI
9898
std::map<Conv_Coulomb_Pot_K::Coulomb_Method, Exx_Obj<Tdata>> exx_objs;
9999
//LRI_CV<Tdata> cv;
100100
RI::Exx<TA,Tcell,Ndim,Tdata> exx_lri;
101+
std::map<Conv_Coulomb_Pot_K::Coulomb_Method,
102+
std::pair<bool,
103+
std::map<Conv_Coulomb_Pot_K::Coulomb_Type,
104+
std::vector<std::map<std::string,std::string>>>>> coulomb_settings;
101105

102106
void post_process_Hexx( std::map<TA, std::map<TAC, RI::Tensor<Tdata>>> &Hexxs_io ) const;
103107
double post_process_Eexx(const double& Eexx_in) const;

source/source_lcao/module_ri/Exx_LRI.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ void Exx_LRI<Tdata>::init(const MPI_Comm &mpi_comm_in,
5151
for( size_t T=0; T!=this->abfs.size(); ++T )
5252
{ GlobalC::exx_info.info_ri.abfs_Lmax = std::max( GlobalC::exx_info.info_ri.abfs_Lmax, static_cast<int>(this->abfs[T].size())-1 ); }
5353

54-
for(const auto &settings_list : this->info.coulomb_settings)
54+
this->coulomb_settings = RI_Util::update_coulomb_settings(this->info.coulomb_param, ucell, this->p_kv);
55+
56+
for(const auto &settings_list : this->coulomb_settings)
5557
{
56-
const std::map<Conv_Coulomb_Pot_K::Coulomb_Type, std::vector<std::map<std::string,std::string>>>
57-
coulomb_param_updated = RI_Util::update_coulomb_param(settings_list.second.second, ucell, this->p_kv);
58-
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);
58+
this->exx_objs[settings_list.first].abfs_ccp = Conv_Coulomb_Pot_K::cal_orbs_ccp(this->abfs, settings_list.second.second, this->info.ccp_rmesh_times);
5959
this->exx_objs[settings_list.first].cv.set_orbitals(ucell, orb,
6060
this->lcaos, this->abfs, this->exx_objs[settings_list.first].abfs_ccp,
6161
this->info.kmesh_times, this->info.ccp_rmesh_times );
@@ -97,7 +97,7 @@ void Exx_LRI<Tdata>::cal_exx_ions(const UnitCell& ucell,
9797

9898
std::map<TA,std::map<TAC,RI::Tensor<Tdata>>> Vs;
9999
std::map<TA, std::map<TAC, std::array<RI::Tensor<Tdata>, Ndim>>> dVs;
100-
for(const auto &settings_list : this->info.coulomb_settings)
100+
for(const auto &settings_list : this->coulomb_settings)
101101
{
102102
std::map<TA,std::map<TAC,RI::Tensor<Tdata>>>
103103
Vs_temp = this->exx_objs[settings_list.first].cv.cal_Vs(ucell,
@@ -138,7 +138,7 @@ void Exx_LRI<Tdata>::cal_exx_ions(const UnitCell& ucell,
138138

139139
std::map<TA,std::map<TAC,RI::Tensor<Tdata>>> Cs;
140140
std::map<TA, std::map<TAC, std::array<RI::Tensor<Tdata>, 3>>> dCs;
141-
for(const auto &settings_list : this->info.coulomb_settings)
141+
for(const auto &settings_list : this->coulomb_settings)
142142
{
143143
if(settings_list.second.first)
144144
{

source/source_lcao/module_ri/RI_Util.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,15 @@ namespace RI_Util
6868
const std::map<Conv_Coulomb_Pot_K::Coulomb_Type, std::vector<std::map<std::string,std::string>>> &coulomb_param,
6969
const UnitCell &ucell,
7070
const K_Vectors *p_kv);
71+
72+
std::map<Conv_Coulomb_Pot_K::Coulomb_Method,
73+
std::pair<bool,
74+
std::map<Conv_Coulomb_Pot_K::Coulomb_Type,
75+
std::vector<std::map<std::string,std::string>>>>>
76+
update_coulomb_settings(
77+
const std::map<Conv_Coulomb_Pot_K::Coulomb_Type, std::vector<std::map<std::string,std::string>>> &coulomb_param,
78+
const UnitCell &ucell,
79+
const K_Vectors *p_kv);
7180
}
7281

7382
#include "RI_Util.hpp"

source/source_lcao/module_ri/RI_Util.hpp

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,14 @@ namespace RI_Util
7878
{
7979
for(auto &param : param_list.second)
8080
{
81-
if(param.at("Rcut_type") == "spencer")
81+
if(param.at("singularity_correction") == "spencer")
8282
{
8383
// 4/3 * pi * Rcut^3 = V_{supercell} = V_{unitcell} * Nk
8484
const int nspin0 = (PARAM.inp.nspin==2) ? 2 : 1;
8585
const double Rcut = std::pow(0.75 * p_kv->get_nkstot_full()/nspin0 * ucell.omega / (ModuleBase::PI), 1.0/3.0);
8686
param["Rcut"] = ModuleBase::GlobalFunc::TO_STRING(Rcut);
8787
}
88-
else if(param.at("Rcut_type") == "revised_spencer")
88+
else if(param.at("singularity_correction") == "revised_spencer")
8989
{
9090
const double bvk_a1 = ucell.a1.norm() * p_kv->nmp[0];
9191
const double bvk_a2 = ucell.a2.norm() * p_kv->nmp[1];
@@ -97,6 +97,54 @@ namespace RI_Util
9797
}
9898
return coulomb_param_updated;
9999
}
100+
101+
inline std::map<Conv_Coulomb_Pot_K::Coulomb_Method,
102+
std::pair<bool,
103+
std::map<Conv_Coulomb_Pot_K::Coulomb_Type,
104+
std::vector<std::map<std::string,std::string>>>>>
105+
update_coulomb_settings(
106+
const std::map<Conv_Coulomb_Pot_K::Coulomb_Type, std::vector<std::map<std::string,std::string>>> &coulomb_param,
107+
const UnitCell &ucell,
108+
const K_Vectors *p_kv)
109+
{
110+
const std::map<Conv_Coulomb_Pot_K::Coulomb_Type, std::vector<std::map<std::string,std::string>>>
111+
coulomb_param_updated = update_coulomb_param(coulomb_param, ucell, p_kv);
112+
113+
// Separate the parameters into Center2 and Ewald methods
114+
std::map<Conv_Coulomb_Pot_K::Coulomb_Type, std::vector<std::map<std::string,std::string>>> coulomb_param_center2;
115+
std::map<Conv_Coulomb_Pot_K::Coulomb_Type, std::vector<std::map<std::string,std::string>>> coulomb_param_ewald;
116+
for(auto &param_list : coulomb_param_updated)
117+
{
118+
for(auto &param : param_list.second)
119+
{
120+
if(param.at("singularity_correction") == "spencer" || param.at("singularity_correction") == "limits"
121+
|| param.at("singularity_correction") == "revised_spencer")
122+
{
123+
coulomb_param_center2[param_list.first].push_back(param);
124+
}
125+
else if (param.at("singularity_correction") == "massidda" || param.at("singularity_correction") == "carrier" )
126+
{
127+
coulomb_param_ewald[param_list.first].push_back(param);
128+
}
129+
}
130+
}
131+
132+
std::map<Conv_Coulomb_Pot_K::Coulomb_Method,
133+
std::pair<bool,
134+
std::map<Conv_Coulomb_Pot_K::Coulomb_Type,
135+
std::vector<std::map<std::string,std::string>>>>> coulomb_settings;
136+
137+
if(!coulomb_param_center2.empty())
138+
{
139+
coulomb_settings[Conv_Coulomb_Pot_K::Coulomb_Method::Center2] = std::make_pair(true, coulomb_param_center2);
140+
}
141+
if (!coulomb_param_ewald.empty())
142+
{
143+
coulomb_settings[Conv_Coulomb_Pot_K::Coulomb_Method::Ewald] = std::make_pair(true, coulomb_param_ewald);
144+
}
145+
146+
return coulomb_settings;
147+
}
100148
}
101149

102150
#endif

source/source_lcao/module_ri/conv_coulomb_pot_k.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,25 +84,25 @@ namespace Conv_Coulomb_Pot_K
8484
{
8585
for(const auto &param : param_list.second)
8686
{
87-
if(param.at("Rcut_type") == "limits")
87+
if(param.at("singularity_correction") == "limits")
8888
{ psik2_ccp = psik2_ccp + std::stod(param.at("alpha")) * cal_psi_fock_limits( orbs.get_psif() ); }
89-
else if(param.at("Rcut_type") == "spencer" || param.at("Rcut_type") == "revised_spencer")
89+
else if(param.at("singularity_correction") == "spencer" || param.at("singularity_correction") == "revised_spencer")
9090
{ psik2_ccp = psik2_ccp + std::stod(param.at("alpha")) * cal_psi_fock_spencer( orbs.get_psif(), orbs.get_k_radial(), std::stod(param.at("Rcut")) ); }
9191
else
92-
{ throw std::invalid_argument( "Rcut_type = " + param.at("Rcut_type") + " in " + std::string(__FILE__) + " line " + std::to_string(__LINE__) ); }
92+
{ throw std::invalid_argument( "singularity_correction = " + param.at("singularity_correction") + " in " + std::string(__FILE__) + " line " + std::to_string(__LINE__) ); }
9393
}
9494
break;
9595
}
9696
case Conv_Coulomb_Pot_K::Coulomb_Type::Erfc:
9797
{
9898
for(const auto &param : param_list.second)
9999
{
100-
if(param.at("Rcut_type") == "limits")
100+
if(param.at("singularity_correction") == "limits")
101101
{ psik2_ccp = psik2_ccp + std::stod(param.at("alpha")) * cal_psi_erfc_limits( orbs.get_psif(), orbs.get_k_radial(), std::stod(param.at("omega")) ); }
102-
else if(param.at("Rcut_type") == "spencer" || param.at("Rcut_type") == "revised_spencer")
102+
else if(param.at("singularity_correction") == "spencer" || param.at("singularity_correction") == "revised_spencer")
103103
{ psik2_ccp = psik2_ccp + std::stod(param.at("alpha")) * cal_psi_erfc_spencer( orbs.get_psif(), orbs.get_k_radial(), std::stod(param.at("omega")), std::stod(param.at("Rcut")) ); }
104104
else
105-
{ throw std::invalid_argument( "Rcut_type = " + param.at("Rcut_type") + " in " + std::string(__FILE__) + " line " + std::to_string(__LINE__) ); }
105+
{ throw std::invalid_argument( "singularity_correction = " + param.at("singularity_correction") + " in " + std::string(__FILE__) + " line " + std::to_string(__LINE__) ); }
106106
}
107107
break;
108108
}

0 commit comments

Comments
 (0)