Skip to content

1. change Exx_Info_Global::coulomb_param from unordered_map to map (Do not recommend using unordered_map, which has defects in C++11) #6318

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 8 commits into from
Jun 21, 2025
9 changes: 5 additions & 4 deletions source/module_hamilt_general/module_xc/exx_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

#include <vector>
#include <map>
#include <unordered_map>
#include <string>

struct Exx_Info
Expand All @@ -15,7 +14,8 @@ 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::map<Conv_Coulomb_Pot_K::Coulomb_Type, std::vector<std::map<std::string,std::string>>> coulomb_param;

// Fock:
// "alpha": "0"
// "Rcut_type": "limits" / "spencer"
Expand All @@ -34,7 +34,6 @@ struct Exx_Info

bool separate_loop = true;
size_t hybrid_step = 1;
bool exx_symmetry_realspace = true;
};
Exx_Info_Global info_global;

Expand All @@ -52,7 +51,8 @@ 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::map<Conv_Coulomb_Pot_K::Coulomb_Type, std::vector<std::map<std::string,std::string>>> &coulomb_param;


bool real_number = false;

Expand All @@ -66,6 +66,7 @@ struct Exx_Info
double C_grad_R_threshold = 0;
double V_grad_R_threshold = 0;
double ccp_rmesh_times = 10;
bool exx_symmetry_realspace = true;
double kmesh_times = 4;

int abfs_Lmax = 0; // tmp
Expand Down
2 changes: 1 addition & 1 deletion source/module_io/input_conv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,6 @@ void Input_Conv::Convert()
GlobalC::exx_info.info_global.separate_loop = PARAM.inp.exx_separate_loop;
GlobalC::exx_info.info_global.hybrid_step = PARAM.inp.exx_hybrid_step;
GlobalC::exx_info.info_global.mixing_beta_for_loop1 = PARAM.inp.exx_mixing_beta;
GlobalC::exx_info.info_global.exx_symmetry_realspace = PARAM.inp.exx_symmetry_realspace;

GlobalC::exx_info.info_ri.real_number = std::stoi(PARAM.inp.exx_real_number);
GlobalC::exx_info.info_ri.pca_threshold = PARAM.inp.exx_pca_threshold;
Expand All @@ -458,6 +457,7 @@ void Input_Conv::Convert()
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.ccp_rmesh_times = std::stod(PARAM.inp.exx_ccp_rmesh_times);
GlobalC::exx_info.info_ri.exx_symmetry_realspace = PARAM.inp.exx_symmetry_realspace;

#ifdef __EXX
Exx_Abfs::Jle::Lmax = PARAM.inp.exx_opt_orb_lmax;
Expand Down
4 changes: 2 additions & 2 deletions source/module_rdmft/rdmft_pot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ void RDMFT<TK, TR>::cal_V_XC(const UnitCell& ucell)
: RI_2D_Comm::split_m2D_ktoR<double>(ucell,*kv, DM_XC_pointer, *ParaV, nspin, this->exx_spacegroup_symmetry);

// provide the Ds_XC to Vxc_fromRI(V_exx_XC)
if (this->exx_spacegroup_symmetry && GlobalC::exx_info.info_global.exx_symmetry_realspace)
if (this->exx_spacegroup_symmetry && GlobalC::exx_info.info_ri.exx_symmetry_realspace)
{
Vxc_fromRI_d->cal_exx_elec(Ds_XC_d, ucell,*ParaV, &this->symrot_exx);
}
Expand Down Expand Up @@ -291,7 +291,7 @@ void RDMFT<TK, TR>::cal_V_XC(const UnitCell& ucell)
: RI_2D_Comm::split_m2D_ktoR<std::complex<double>>(ucell,*kv, DM_XC_pointer, *ParaV, nspin, this->exx_spacegroup_symmetry);

// // provide the Ds_XC to Vxc_fromRI(V_exx_XC)
if (this->exx_spacegroup_symmetry && GlobalC::exx_info.info_global.exx_symmetry_realspace)
if (this->exx_spacegroup_symmetry && GlobalC::exx_info.info_ri.exx_symmetry_realspace)
{
Vxc_fromRI_c->cal_exx_elec(Ds_XC_c, ucell,*ParaV, &this->symrot_exx);
}
Expand Down
3 changes: 2 additions & 1 deletion source/module_ri/Exx_LRI.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ 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>>>
const std::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);

Expand Down
4 changes: 2 additions & 2 deletions source/module_ri/Exx_LRI_interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ void Exx_LRI_Interface<T, Tdata>::exx_eachiterinit(const int istep,
PARAM.inp.nspin,
this->exx_spacegroup_symmetry);

if (this->exx_spacegroup_symmetry && GlobalC::exx_info.info_global.exx_symmetry_realspace)
if (this->exx_spacegroup_symmetry && GlobalC::exx_info.info_ri.exx_symmetry_realspace)
{ this->cal_exx_elec(Ds, ucell,*dm_in.get_paraV_pointer(), &this->symrot_); }
else
{ this->cal_exx_elec(Ds, ucell,*dm_in.get_paraV_pointer()); }
Expand Down Expand Up @@ -445,7 +445,7 @@ bool Exx_LRI_Interface<T, Tdata>::exx_after_converge(
? RI_2D_Comm::split_m2D_ktoR<Tdata>(ucell,*this->exx_ptr->p_kv, this->mix_DMk_2D.get_DMk_gamma_out(), *dm.get_paraV_pointer(), nspin)
: RI_2D_Comm::split_m2D_ktoR<Tdata>(ucell,*this->exx_ptr->p_kv, this->mix_DMk_2D.get_DMk_k_out(), *dm.get_paraV_pointer(), nspin, this->exx_spacegroup_symmetry);

if (this->exx_spacegroup_symmetry && GlobalC::exx_info.info_global.exx_symmetry_realspace)
if (this->exx_spacegroup_symmetry && GlobalC::exx_info.info_ri.exx_symmetry_realspace)
{ this->cal_exx_elec(Ds, ucell, *dm.get_paraV_pointer(), &this->symrot_); }
else
{ this->cal_exx_elec(Ds, ucell, *dm.get_paraV_pointer()); } // restore DM but not Hexx
Expand Down
5 changes: 2 additions & 3 deletions source/module_ri/RI_Util.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include <array>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>

namespace RI_Util
Expand Down Expand Up @@ -63,9 +62,9 @@ namespace RI_Util
return m_new;
}

std::unordered_map<Conv_Coulomb_Pot_K::Coulomb_Type, std::vector<std::map<std::string,std::string>>>
std::map<Conv_Coulomb_Pot_K::Coulomb_Type, std::vector<std::map<std::string,std::string>>>
update_coulomb_param(
const std::unordered_map<Conv_Coulomb_Pot_K::Coulomb_Type, std::vector<std::map<std::string,std::string>>> &coulomb_param,
const std::map<Conv_Coulomb_Pot_K::Coulomb_Type, std::vector<std::map<std::string,std::string>>> &coulomb_param,
const double volumn,
const int nkstot);
}
Expand Down
6 changes: 3 additions & 3 deletions source/module_ri/RI_Util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ namespace RI_Util
}
*/

inline std::unordered_map<Conv_Coulomb_Pot_K::Coulomb_Type, std::vector<std::map<std::string,std::string>>>
inline std::map<Conv_Coulomb_Pot_K::Coulomb_Type, std::vector<std::map<std::string,std::string>>>
update_coulomb_param(
const std::unordered_map<Conv_Coulomb_Pot_K::Coulomb_Type, std::vector<std::map<std::string,std::string>>> &coulomb_param,
const std::map<Conv_Coulomb_Pot_K::Coulomb_Type, std::vector<std::map<std::string,std::string>>> &coulomb_param,
const double volumn,
const int nkstot)
{
std::unordered_map<Conv_Coulomb_Pot_K::Coulomb_Type, std::vector<std::map<std::string,std::string>>> coulomb_param_updated = coulomb_param;
std::map<Conv_Coulomb_Pot_K::Coulomb_Type, std::vector<std::map<std::string,std::string>>> coulomb_param_updated = coulomb_param;
for(auto &param_list : coulomb_param_updated)
{
for(auto &param : param_list.second)
Expand Down
2 changes: 1 addition & 1 deletion source/module_ri/conv_coulomb_pot_k.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ namespace Conv_Coulomb_Pot_K
template<>
Numerical_Orbital_Lm cal_orbs_ccp<Numerical_Orbital_Lm>(
const Numerical_Orbital_Lm &orbs,
const std::unordered_map<Conv_Coulomb_Pot_K::Coulomb_Type, std::vector<std::map<std::string,std::string>>> &coulomb_param,
const std::map<Conv_Coulomb_Pot_K::Coulomb_Type, std::vector<std::map<std::string,std::string>>> &coulomb_param,
const double rmesh_times)
{
std::vector<double> psik2_ccp(orbs.get_psif().size(), 0.0);
Expand Down
3 changes: 1 addition & 2 deletions source/module_ri/conv_coulomb_pot_k.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

#include <vector>
#include <map>
#include <unordered_map>
#include <string>

namespace Conv_Coulomb_Pot_K
Expand All @@ -17,7 +16,7 @@ namespace Conv_Coulomb_Pot_K

template<typename T> extern T cal_orbs_ccp(
const T &orbs,
const std::unordered_map<Conv_Coulomb_Pot_K::Coulomb_Type, std::vector<std::map<std::string,std::string>>> &coulomb_param,
const std::map<Conv_Coulomb_Pot_K::Coulomb_Type, std::vector<std::map<std::string,std::string>>> &coulomb_param,
const double rmesh_times);

//private:
Expand Down
2 changes: 1 addition & 1 deletion source/module_ri/conv_coulomb_pot_k.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Conv_Coulomb_Pot_K
template< typename T >
std::vector<T> cal_orbs_ccp(
const std::vector<T> & orbs,
const std::unordered_map<Conv_Coulomb_Pot_K::Coulomb_Type, std::vector<std::map<std::string,std::string>>> &coulomb_param,
const std::map<Conv_Coulomb_Pot_K::Coulomb_Type, std::vector<std::map<std::string,std::string>>> &coulomb_param,
const double rmesh_times)
{
std::vector<T> orbs_ccp(orbs.size());
Expand Down
1 change: 1 addition & 0 deletions tests/02_NAO_Gamma/002_NO_GO_AF/threshold
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
threshold 0.000001
Loading