Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions source/module_io/input_conv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ void Input_Conv::Convert()
} else if (dft_functional_lower == "hse") {
GlobalC::exx_info.info_global.cal_exx = true;
GlobalC::exx_info.info_global.ccp_type
= Conv_Coulomb_Pot_K::Ccp_Type::Hse;
= Conv_Coulomb_Pot_K::Ccp_Type::Erfc;
} else if (dft_functional_lower == "opt_orb") {
GlobalC::exx_info.info_global.cal_exx = false;
Exx_Abfs::Jle::generate_matrix = true;
Expand All @@ -391,12 +391,12 @@ void Input_Conv::Convert()
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; // use the error function erf(w|r-r'|), exx just has the long-range part
GlobalC::exx_info.info_global.ccp_type = Conv_Coulomb_Pot_K::Ccp_Type::Erf; // use the error function erf(w|r-r'|), exx just has the long-range part
}
else if ( 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::Hse; // use the erfc(w|r-r'|), exx just has the short-range part
GlobalC::exx_info.info_global.ccp_type = Conv_Coulomb_Pot_K::Ccp_Type::Erfc; // use the erfc(w|r-r'|), exx just has the short-range part
}
else {
GlobalC::exx_info.info_global.cal_exx = false;
Expand Down
4 changes: 2 additions & 2 deletions source/module_lr/esolver_lrtd_lcao.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ LR::ESolver_LR<T, TR>::ESolver_LR(ModuleESolver::ESolver_KS_LCAO<T, TR>&& ks_sol
{
// set ccp_type according to the xc_kernel
if (xc_kernel == "hf") { exx_info.info_global.ccp_type = Conv_Coulomb_Pot_K::Ccp_Type::Hf; }
else if (xc_kernel == "hse") { exx_info.info_global.ccp_type = Conv_Coulomb_Pot_K::Ccp_Type::Hse; }
else if (xc_kernel == "hse") { exx_info.info_global.ccp_type = Conv_Coulomb_Pot_K::Ccp_Type::Erfc; }
this->exx_lri = std::make_shared<Exx_LRI<T>>(exx_info.info_ri);
this->exx_lri->init(MPI_COMM_WORLD, this->kv, ks_sol.orb_);
this->exx_lri->cal_exx_ions(input.out_ri_cv);
Expand Down Expand Up @@ -396,7 +396,7 @@ LR::ESolver_LR<T, TR>::ESolver_LR(const Input_para& inp, UnitCell& ucell) : inpu
{
// set ccp_type according to the xc_kernel
if (xc_kernel == "hf") { exx_info.info_global.ccp_type = Conv_Coulomb_Pot_K::Ccp_Type::Hf; }
else if (xc_kernel == "hse") { exx_info.info_global.ccp_type = Conv_Coulomb_Pot_K::Ccp_Type::Hse; }
else if (xc_kernel == "hse") { exx_info.info_global.ccp_type = Conv_Coulomb_Pot_K::Ccp_Type::Erfc; }
this->exx_lri = std::make_shared<Exx_LRI<T>>(exx_info.info_ri);
this->exx_lri->init(MPI_COMM_WORLD, this->kv, orb);
this->exx_lri->cal_exx_ions(input.out_ri_cv);
Expand Down
2 changes: 1 addition & 1 deletion source/module_ri/Exx_LRI.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ void Exx_LRI<Tdata>::init(const MPI_Comm &mpi_comm_in, const K_Vectors &kv_in, c
const double hf_Rcut = std::pow(0.75 * this->p_kv->get_nkstot_full()/nspin0 * GlobalC::ucell.omega / (ModuleBase::PI), 1.0/3.0);
return {{"hf_Rcut", hf_Rcut}};
}
case Conv_Coulomb_Pot_K::Ccp_Type::Hse:
case Conv_Coulomb_Pot_K::Ccp_Type::Erfc:
return {{"hse_omega", this->info.hse_omega}};
default:
throw std::domain_error(std::string(__FILE__)+" line "+std::to_string(__LINE__)); break;
Expand Down
59 changes: 26 additions & 33 deletions source/module_ri/conv_coulomb_pot_k.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ namespace Conv_Coulomb_Pot_K
const std::vector<double> & psif)
{
std::vector<double> psik2_ccp(psif.size());
for( size_t ik=0; ik<psif.size(); ++ik ) {
psik2_ccp[ik] = ModuleBase::FOUR_PI * psif[ik];
}
for( size_t ik=0; ik<psif.size(); ++ik )
{ psik2_ccp[ik] = ModuleBase::FOUR_PI * psif[ik]; }
return psik2_ccp;
}

Expand All @@ -25,22 +24,20 @@ namespace Conv_Coulomb_Pot_K
const double hf_Rcut)
{
std::vector<double> psik2_ccp(psif.size());
for (size_t ik = 0; ik < psif.size(); ++ik) {
psik2_ccp[ik] = ModuleBase::FOUR_PI * psif[ik] * (1 - std::cos(k_radial[ik] * hf_Rcut));
}
for (size_t ik = 0; ik < psif.size(); ++ik)
{ psik2_ccp[ik] = ModuleBase::FOUR_PI * psif[ik] * (1 - std::cos(k_radial[ik] * hf_Rcut)); }
return psik2_ccp;
}


std::vector<double> cal_psi_hse(
std::vector<double> cal_psi_erfc(
const std::vector<double> & psif,
const std::vector<double> & k_radial,
const double hse_omega)
{
std::vector<double> psik2_ccp(psif.size());
for( size_t ik=0; ik<psif.size(); ++ik ) {
psik2_ccp[ik] = ModuleBase::FOUR_PI * psif[ik] * (1-std::exp(-(k_radial[ik]*k_radial[ik])/(4*hse_omega*hse_omega)));
}
for( size_t ik=0; ik<psif.size(); ++ik )
{ psik2_ccp[ik] = ModuleBase::FOUR_PI * psif[ik] * (1-std::exp(-(k_radial[ik]*k_radial[ik])/(4*hse_omega*hse_omega))); }
return psik2_ccp;
}

Expand All @@ -53,10 +50,9 @@ namespace Conv_Coulomb_Pot_K
const double hf_Rcut)
{
std::vector<double> psik2_ccp(psif.size());
for( size_t ik=0; ik<psif.size(); ++ik ) {
psik2_ccp[ik] = ModuleBase::FOUR_PI * psif[ik] * ( std::exp(-(k_radial[ik]*k_radial[ik])/(4*hse_omega*hse_omega)) - std::cos(k_radial[ik] * hf_Rcut) );
}
// psik2_ccp[ik] = ModuleBase::FOUR_PI * psif[ik] * ( std::exp(-(k_radial[ik]*k_radial[ik])/(4*hse_omega*hse_omega)) );
for( size_t ik=0; ik<psif.size(); ++ik )
{ psik2_ccp[ik] = ModuleBase::FOUR_PI * psif[ik] * ( std::exp(-(k_radial[ik]*k_radial[ik])/(4*hse_omega*hse_omega)) - std::cos(k_radial[ik] * hf_Rcut) ); }
// { psik2_ccp[ik] = ModuleBase::FOUR_PI * psif[ik] * ( std::exp(-(k_radial[ik]*k_radial[ik])/(4*hse_omega*hse_omega)) ); }
return psik2_ccp;
}

Expand All @@ -75,30 +71,28 @@ namespace Conv_Coulomb_Pot_K
psik2_ccp = cal_psi_ccp( orbs.get_psif() ); break;
case Ccp_Type::Hf:
psik2_ccp = cal_psi_hf( orbs.get_psif(), orbs.get_k_radial(), parameter.at("hf_Rcut")); break;
case Ccp_Type::Hse:
psik2_ccp = cal_psi_hse( orbs.get_psif(), orbs.get_k_radial(), parameter.at("hse_omega") ); break;
case Ccp_Type::erf:
case Ccp_Type::Erfc:
psik2_ccp = cal_psi_erfc( orbs.get_psif(), orbs.get_k_radial(), parameter.at("hse_omega") ); break;
case Ccp_Type::Erf:
psik2_ccp = cal_psi_erf( orbs.get_psif(), orbs.get_k_radial(), parameter.at("hse_omega"), parameter.at("hf_Rcut") ); break;
default:
throw( ModuleBase::GlobalFunc::TO_STRING(__FILE__)+" line "+ModuleBase::GlobalFunc::TO_STRING(__LINE__) ); break;
throw( std::string(__FILE__) + " line " + std::to_string(__LINE__) ); break;
}

const double dr = orbs.get_rab().back();
const int Nr = (static_cast<int>(orbs.getNr()*rmesh_times)) | 1;

std::vector<double> rab(Nr);
for( size_t ir=0; ir<std::min(orbs.getNr(),Nr); ++ir ) {
rab[ir] = orbs.getRab(ir);
}
for( size_t ir=orbs.getNr(); ir<Nr; ++ir ) {
rab[ir] = dr;
}
for( size_t ir=0; ir<std::min(orbs.getNr(),Nr); ++ir )
{ rab[ir] = orbs.getRab(ir); }
for( size_t ir=orbs.getNr(); ir<Nr; ++ir )
{ rab[ir] = dr; }

std::vector<double> r_radial(Nr);
for( size_t ir=0; ir<std::min(orbs.getNr(),Nr); ++ir ) {
r_radial[ir] = orbs.getRadial(ir);
}
for( size_t ir=orbs.getNr(); ir<Nr; ++ir ) {
r_radial[ir] = orbs.get_r_radial().back() + (ir - orbs.getNr() + 1) * dr;
}
for( size_t ir=0; ir<std::min(orbs.getNr(),Nr); ++ir )
{ r_radial[ir] = orbs.getRadial(ir); }
for( size_t ir=orbs.getNr(); ir<Nr; ++ir )
{ r_radial[ir] = orbs.get_r_radial().back() + (ir - orbs.getNr() + 1) * dr; }

Numerical_Orbital_Lm orbs_ccp;
orbs_ccp.set_orbital_info(
Expand Down Expand Up @@ -126,9 +120,8 @@ namespace Conv_Coulomb_Pot_K
{
for(int ir=orbs.getNr()-1; ir>=0; --ir)
{
if(std::abs(orbs.getPsi(ir))>=psi_threshold) {
return static_cast<double>(ir)/orbs.getNr();
}
if(std::abs(orbs.getPsi(ir))>=psi_threshold)
{ return static_cast<double>(ir)/orbs.getNr(); }
}
return 0.0;
}
Expand Down
4 changes: 2 additions & 2 deletions source/module_ri/conv_coulomb_pot_k.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ namespace Conv_Coulomb_Pot_K
enum class Ccp_Type{ // parameter:
Ccp, //
Hf, // "hf_Rcut"
Hse, // "hse_omega"
erf}; // "hse_omega"
Erfc, // "hse_omega"
Erf}; // "hse_omega", "hf_Rcut"

template<typename T> T cal_orbs_ccp(
const T &orbs,
Expand Down
6 changes: 5 additions & 1 deletion source/module_ri/exx_lip.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,13 +334,17 @@ void Exx_Lip<T, Device>::qkg2_exp(const int ik, const int iq)
this->sum2_factor += this->recip_qkg2[ig] * std::exp(-info.lambda * qkg2);
this->recip_qkg2[ig] = sqrt(this->recip_qkg2[ig]);
}
else if (Conv_Coulomb_Pot_K::Ccp_Type::Hse == info.ccp_type)
else if (Conv_Coulomb_Pot_K::Ccp_Type::Erfc == info.ccp_type)
{
if (std::abs(qkg2) < 1e-10)
{ this->recip_qkg2[ig] = 1.0 / (2 * info.hse_omega); }
else
{ this->recip_qkg2[ig] = sqrt((1 - std::exp(-qkg2 / (4 * info.hse_omega * info.hse_omega))) / qkg2); }
}
else
{
throw( std::string(__FILE__) + " line " + std::to_string(__LINE__) );
}
}
ModuleBase::timer::tick("Exx_Lip", "qkg2_exp");
}
Expand Down
Loading