Skip to content

Commit 2d6accb

Browse files
linpeizePeizeLin
andauthored
Exx ccp parameter (#6256)
* add check and update code format in exx (#6244) * fix bug and update code format in exx * Fix bug in Exx_LRI_Interface. Change && to || * update exx in ESolver_KS_LCAO and FORCE_STRESS * update runtime check in Exx_LRI_Interface * move exx_lri_double from ESolver_KS_LCAO to Exx_LRI_Interface --------- Co-authored-by: linpz <linpz@mail.ustc.edu.cn> Conflicts: source/module_ri/Exx_LRI_interface.hpp * refactor RI_Util::get_ccp_parameter() --------- Co-authored-by: linpz <linpz@mail.ustc.edu.cn>
1 parent 9d78d90 commit 2d6accb

File tree

3 files changed

+34
-44
lines changed

3 files changed

+34
-44
lines changed

source/module_ri/Exx_LRI.hpp

Lines changed: 3 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -34,62 +34,22 @@ void Exx_LRI<Tdata>::init(const MPI_Comm &mpi_comm_in,
3434
ModuleBase::TITLE("Exx_LRI","init");
3535
ModuleBase::timer::tick("Exx_LRI", "init");
3636

37-
// if(GlobalC::exx_info.info_global.separate_loop)
38-
// {
39-
// Hexx_para.mixing_mode = Exx_Abfs::Parallel::Communicate::Hexx::Mixing_Mode::No;
40-
// Hexx_para.mixing_beta = 0;
41-
// }
42-
// else
43-
// {
44-
// if("plain"==GlobalC::CHR.mixing_mode)
45-
// Hexx_para.mixing_mode = Exx_Abfs::Parallel::Communicate::Hexx::Mixing_Mode::Plain;
46-
// else if("pulay"==GlobalC::CHR.mixing_mode)
47-
// Hexx_para.mixing_mode = Exx_Abfs::Parallel::Communicate::Hexx::Mixing_Mode::Pulay;
48-
// else
49-
// throw std::invalid_argument("exx mixing error. exx_separate_loop==false, mixing_mode!=plain or pulay");
50-
// Hexx_para.mixing_beta = GlobalC::CHR.mixing_beta;
51-
// }
52-
5337
this->mpi_comm = mpi_comm_in;
5438
this->p_kv = &kv_in;
5539
this->orb_cutoff_ = orb.cutoffs();
56-
const double omega = ucell.omega;
5740

5841
this->lcaos = Exx_Abfs::Construct_Orbs::change_orbs( orb, this->info.kmesh_times );
5942

60-
// #ifdef __MPI
61-
// Exx_Abfs::Util::bcast( this->info.files_abfs, 0, this->mpi_comm );
62-
// #endif
63-
6443
const std::vector<std::vector<std::vector<Numerical_Orbital_Lm>>>
6544
abfs_same_atom = Exx_Abfs::Construct_Orbs::abfs_same_atom(ucell, orb, this->lcaos, this->info.kmesh_times, this->info.pca_threshold );
6645
if(this->info.files_abfs.empty())
6746
{ this->abfs = abfs_same_atom;}
6847
else
6948
{ this->abfs = Exx_Abfs::IO::construct_abfs( abfs_same_atom, orb, this->info.files_abfs, this->info.kmesh_times ); }
70-
Exx_Abfs::Construct_Orbs::print_orbs_size(ucell,this->abfs, GlobalV::ofs_running);
71-
72-
auto get_ccp_parameter = [this,&omega]() -> std::map<std::string,double>
73-
{
74-
switch(this->info.ccp_type)
75-
{
76-
case Conv_Coulomb_Pot_K::Ccp_Type::Ccp:
77-
return {};
78-
case Conv_Coulomb_Pot_K::Ccp_Type::Hf:
79-
{
80-
// 4/3 * pi * Rcut^3 = V_{supercell} = V_{unitcell} * Nk
81-
const int nspin0 = (PARAM.inp.nspin==2) ? 2 : 1;
82-
const double hf_Rcut = std::pow(0.75 * this->p_kv->get_nkstot_full()/nspin0 * omega / (ModuleBase::PI), 1.0/3.0);
83-
return {{"hf_Rcut", hf_Rcut}};
84-
}
85-
case Conv_Coulomb_Pot_K::Ccp_Type::Erfc:
86-
return {{"hse_omega", this->info.hse_omega}};
87-
default:
88-
throw std::domain_error(std::string(__FILE__)+" line "+std::to_string(__LINE__)); break;
89-
}
90-
};
91-
this->abfs_ccp = Conv_Coulomb_Pot_K::cal_orbs_ccp(this->abfs, this->info.ccp_type, get_ccp_parameter(), this->info.ccp_rmesh_times);
49+
Exx_Abfs::Construct_Orbs::print_orbs_size(ucell, this->abfs, GlobalV::ofs_running);
9250

51+
const std::map<std::string,double> ccp_parameter = RI_Util::get_ccp_parameter(this->info, ucell.omega, this->p_kv->get_nkstot_full());
52+
this->abfs_ccp = Conv_Coulomb_Pot_K::cal_orbs_ccp(this->abfs, this->info.ccp_type, ccp_parameter, this->info.ccp_rmesh_times);
9353

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

source/module_ri/RI_Util.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@
66
#ifndef RI_UTIL_H
77
#define RI_UTIL_H
88

9+
#include "module_hamilt_general/module_xc/exx_info.h"
10+
911
#include <RI/global/Array_Operator.h>
1012
#include <RI/global/Global_Func-2.h>
1113

1214
#include <array>
13-
#include <RI/global/Tensor.h>
15+
#include <RI/global/Tensor.h>
1416

1517
namespace RI_Util
1618
{
@@ -56,6 +58,11 @@ namespace RI_Util
5658
m_new(ir, ic) = RI::Global_Func::convert<Tdata>(m_old[ir * nc + ic]);
5759
return m_new;
5860
}
61+
62+
std::map<std::string,double> get_ccp_parameter(
63+
const Exx_Info::Exx_Info_RI &info,
64+
const double volumn,
65+
const int nkstot);
5966
}
6067

6168
#include "RI_Util.hpp"

source/module_ri/RI_Util.hpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,29 @@ namespace RI_Util
6565
return Born_von_Karman_cells;
6666
}
6767
*/
68+
69+
inline std::map<std::string,double> get_ccp_parameter(
70+
const Exx_Info::Exx_Info_RI &info,
71+
const double volumn,
72+
const int nkstot)
73+
{
74+
switch(info.ccp_type)
75+
{
76+
case Conv_Coulomb_Pot_K::Ccp_Type::Ccp:
77+
return {};
78+
case Conv_Coulomb_Pot_K::Ccp_Type::Hf:
79+
{
80+
// 4/3 * pi * Rcut^3 = V_{supercell} = V_{unitcell} * Nk
81+
const int nspin0 = (PARAM.inp.nspin==2) ? 2 : 1;
82+
const double hf_Rcut = std::pow(0.75 * nkstot/nspin0 * volumn / (ModuleBase::PI), 1.0/3.0);
83+
return {{"hf_Rcut", hf_Rcut}};
84+
}
85+
case Conv_Coulomb_Pot_K::Ccp_Type::Erfc:
86+
return {{"hse_omega", info.hse_omega}};
87+
default:
88+
throw std::domain_error(std::string(__FILE__)+" line "+std::to_string(__LINE__)); break;
89+
}
90+
}
6891
}
6992

7093
#endif

0 commit comments

Comments
 (0)