Skip to content

Commit 94481a6

Browse files
authored
Merge pull request #1105 from ouqi0711/develop
Enables the energy calculation with SCAN0 functional in LCAO basis
2 parents 8942e0e + 7c6e54f commit 94481a6

26 files changed

+137
-73
lines changed

source/input.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2742,7 +2742,7 @@ void Input::Check(void)
27422742
}
27432743
}
27442744

2745-
if (dft_functional == "hf" || dft_functional == "pbe0" || dft_functional == "hse")
2745+
if (dft_functional == "hf" || dft_functional == "pbe0" || dft_functional == "hse" || dft_functional == "scan0")
27462746
{
27472747
if (exx_hybrid_alpha < 0 || exx_hybrid_alpha > 1)
27482748
{

source/input_conv.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ void Input_Conv::Convert(void)
307307
if (GlobalV::MY_RANK == 0)
308308
system(command0.c_str());
309309
if (INPUT.dft_functional == "hf" || INPUT.dft_functional == "pbe0" || INPUT.dft_functional == "hse"
310-
|| INPUT.dft_functional == "opt_orb")
310+
|| INPUT.dft_functional == "opt_orb" || INPUT.dft_functional == "scan0" )
311311
{
312312
GlobalC::restart.info_save.save_charge = true;
313313
GlobalC::restart.info_save.save_H = true;
@@ -321,7 +321,7 @@ void Input_Conv::Convert(void)
321321
{
322322
GlobalC::restart.folder = GlobalV::global_out_dir + "restart/";
323323
if (INPUT.dft_functional == "hf" || INPUT.dft_functional == "pbe0" || INPUT.dft_functional == "hse"
324-
|| INPUT.dft_functional == "opt_orb")
324+
|| INPUT.dft_functional == "opt_orb" || INPUT.dft_functional == "scan0")
325325
{
326326
GlobalC::restart.info_load.load_charge = true;
327327
}
@@ -346,6 +346,10 @@ void Input_Conv::Convert(void)
346346
{
347347
GlobalC::exx_global.info.hybrid_type = Exx_Global::Hybrid_Type::PBE0;
348348
}
349+
else if (INPUT.dft_functional == "scan0")
350+
{
351+
GlobalC::exx_global.info.hybrid_type = Exx_Global::Hybrid_Type::SCAN0;
352+
}
349353
else if (INPUT.dft_functional == "hse")
350354
{
351355
GlobalC::exx_global.info.hybrid_type = Exx_Global::Hybrid_Type::HSE;

source/module_cell/read_atoms.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ int UnitCell_pseudo::read_atom_species(std::ifstream &ifa, std::ofstream &ofs_ru
112112
#ifdef __MPI
113113
if( Exx_Global::Hybrid_Type::HF == GlobalC::exx_lcao.info.hybrid_type ||
114114
Exx_Global::Hybrid_Type::PBE0 == GlobalC::exx_lcao.info.hybrid_type ||
115-
Exx_Global::Hybrid_Type::HSE == GlobalC::exx_lcao.info.hybrid_type )
115+
Exx_Global::Hybrid_Type::HSE == GlobalC::exx_lcao.info.hybrid_type ||
116+
Exx_Global::Hybrid_Type::SCAN0 == GlobalC::exx_lcao.info.hybrid_type)
116117
{
117118
if( ModuleBase::GlobalFunc::SCAN_BEGIN(ifa, "ABFS_ORBITAL") )
118119
{

source/module_elecstate/elecstate_lcao.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ void ElecStateLCAO::psiToRho(const psi::Psi<std::complex<double>>& psi)
5757
Gint_inout inout(this->loc->DM_R, this->charge, Gint_Tools::job_type::rho);
5858
this->uhm->GK.cal_gint(&inout);
5959

60-
if (XC_Functional::get_func_type() == 3)
60+
if (XC_Functional::get_func_type() == 3 || XC_Functional::get_func_type() == 5)
6161
{
6262
ModuleBase::GlobalFunc::ZEROS(this->charge->kin_r[0], this->charge->nrxx);
6363
Gint_inout inout1(this->loc->DM_R, this->charge, Gint_Tools::job_type::tau);
@@ -113,7 +113,7 @@ void ElecStateLCAO::psiToRho(const psi::Psi<double>& psi)
113113
ModuleBase::GlobalFunc::NOTE("Calculate the charge on real space grid!");
114114
Gint_inout inout(this->loc->DM, this->charge,Gint_Tools::job_type::rho);
115115
this->uhm->GG.cal_gint(&inout);
116-
if (XC_Functional::get_func_type() == 3)
116+
if (XC_Functional::get_func_type() == 3 || XC_Functional::get_func_type() == 5)
117117
{
118118
for (int is = 0; is < GlobalV::NSPIN; is++)
119119
{

source/module_esolver/esolver_ks.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ namespace ModuleESolver
5555
{
5656
XC_Functional::set_xc_type("pbe");
5757
}
58+
else if (ucell.atoms[0].xc_func == "SCAN0")
59+
{
60+
XC_Functional::set_xc_type("scan");
61+
}
5862
else
5963
{
6064
XC_Functional::set_xc_type(ucell.atoms[0].xc_func);

source/module_esolver/esolver_ks_lcao.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ namespace ModuleESolver
5252
{
5353
case Exx_Global::Hybrid_Type::HF:
5454
case Exx_Global::Hybrid_Type::PBE0:
55+
case Exx_Global::Hybrid_Type::SCAN0:
5556
case Exx_Global::Hybrid_Type::HSE:
5657
XC_Functional::set_xc_type(ucell.atoms[0].xc_func);
5758
break;
@@ -113,6 +114,7 @@ namespace ModuleESolver
113114
{
114115
case Exx_Global::Hybrid_Type::HF:
115116
case Exx_Global::Hybrid_Type::PBE0:
117+
case Exx_Global::Hybrid_Type::SCAN0:
116118
case Exx_Global::Hybrid_Type::HSE:
117119
GlobalC::exx_lcao.init();
118120
break;
@@ -413,7 +415,7 @@ namespace ModuleESolver
413415

414416
#ifdef __MPI
415417
// calculate exact-exchange
416-
if (XC_Functional::get_func_type() == 4)
418+
if (XC_Functional::get_func_type() == 4 || XC_Functional::get_func_type() == 5)
417419
{
418420
if (!GlobalC::exx_global.info.separate_loop)
419421
{
@@ -478,7 +480,7 @@ namespace ModuleESolver
478480
GlobalC::en.set_exx();
479481

480482
// Peize Lin add 2020.04.04
481-
if (XC_Functional::get_func_type() == 4)
483+
if (XC_Functional::get_func_type() == 4 || XC_Functional::get_func_type() == 5)
482484
{
483485
if (GlobalC::restart.info_load.load_H && GlobalC::restart.info_load.load_H_finish && !GlobalC::restart.info_load.restart_exx)
484486
{

source/module_esolver/esolver_ks_lcao_elec.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ namespace ModuleESolver
156156
{
157157
Gint_inout inout(this->LOC.DM, (Charge*)(&GlobalC::CHR), Gint_Tools::job_type::rho);
158158
this->UHM.GG.cal_gint(&inout);
159-
if (XC_Functional::get_func_type() == 3)
159+
if (XC_Functional::get_func_type() == 3 || XC_Functional::get_func_type()==5)
160160
{
161161
for(int is=0; is<GlobalV::NSPIN; is++)
162162
{
@@ -170,7 +170,7 @@ namespace ModuleESolver
170170
{
171171
Gint_inout inout(this->LOC.DM_R, (Charge*)(&GlobalC::CHR), Gint_Tools::job_type::rho);
172172
this->UHM.GK.cal_gint(&inout);
173-
if (XC_Functional::get_func_type() == 3)
173+
if (XC_Functional::get_func_type() == 3 || XC_Functional::get_func_type()==5)
174174
{
175175
for(int is=0; is<GlobalV::NSPIN; is++)
176176
{
@@ -234,7 +234,8 @@ namespace ModuleESolver
234234
{
235235
if (Exx_Global::Hybrid_Type::HF == GlobalC::exx_lcao.info.hybrid_type
236236
|| Exx_Global::Hybrid_Type::PBE0 == GlobalC::exx_lcao.info.hybrid_type
237-
|| Exx_Global::Hybrid_Type::HSE == GlobalC::exx_lcao.info.hybrid_type)
237+
|| Exx_Global::Hybrid_Type::HSE == GlobalC::exx_lcao.info.hybrid_type
238+
|| Exx_Global::Hybrid_Type::SCAN0 == GlobalC::exx_lcao.info.hybrid_type)
238239
{
239240
GlobalC::exx_lcao.cal_exx_ions(*this->LOWF.ParaV);
240241
}
@@ -316,6 +317,7 @@ namespace ModuleESolver
316317
{
317318
case Exx_Global::Hybrid_Type::HF:
318319
case Exx_Global::Hybrid_Type::PBE0:
320+
case Exx_Global::Hybrid_Type::SCAN0:
319321
case Exx_Global::Hybrid_Type::HSE:
320322
GlobalC::exx_lcao.cal_exx_elec_nscf(this->LOWF.ParaV[0]);
321323
break;

source/module_esolver/esolver_ks_pw.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ namespace ModuleESolver
128128
{
129129
case Exx_Global::Hybrid_Type::HF:
130130
case Exx_Global::Hybrid_Type::PBE0:
131+
case Exx_Global::Hybrid_Type::SCAN0:
131132
case Exx_Global::Hybrid_Type::HSE:
132133
GlobalC::exx_lip.init(&GlobalC::kv, &GlobalC::wf, GlobalC::wfcpw, GlobalC::rhopw, &GlobalC::ucell);
133134
break;

source/module_hamilt/hamilt_lcao.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ template <> void HamiltLCAO<double>::updateHk(const int ik)
7272
for (int ir = 0; ir < GlobalC::rhopw->nrxx; ir++)
7373
{
7474
GlobalC::pot.vr_eff1[ir] = GlobalC::pot.vr_eff(GlobalV::CURRENT_SPIN, ir);
75-
if(XC_Functional::get_func_type()==3)
75+
if(XC_Functional::get_func_type()==3 || XC_Functional::get_func_type()==5)
7676
{
7777
GlobalC::pot.vofk_eff1[ir] = GlobalC::pot.vofk(GlobalV::CURRENT_SPIN, ir);
7878
}
@@ -154,7 +154,7 @@ template <> void HamiltLCAO<std::complex<double>>::updateHk(const int ik)
154154
for (int ir = 0; ir < GlobalC::rhopw->nrxx; ir++)
155155
{
156156
GlobalC::pot.vr_eff1[ir] = GlobalC::pot.vr_eff(GlobalV::CURRENT_SPIN, ir);
157-
if(XC_Functional::get_func_type()==3)
157+
if(XC_Functional::get_func_type()==3 || XC_Functional::get_func_type()==5)
158158
{
159159
GlobalC::pot.vofk_eff1[ir] = GlobalC::pot.vofk(GlobalV::CURRENT_SPIN, ir);
160160
}
@@ -177,7 +177,7 @@ template <> void HamiltLCAO<std::complex<double>>::updateHk(const int ik)
177177
// rememeber to delete the #include
178178
if (GlobalV::VL_IN_H)
179179
{
180-
if(XC_Functional::get_func_type()==3)
180+
if(XC_Functional::get_func_type()==3 || XC_Functional::get_func_type()==5)
181181
{
182182
Gint_inout inout(GlobalC::pot.vr_eff1, GlobalC::pot.vofk_eff1, 0, Gint_Tools::job_type::vlocal_meta);
183183
this->uhm->GK.cal_gint(&inout);
@@ -198,13 +198,13 @@ template <> void HamiltLCAO<std::complex<double>>::updateHk(const int ik)
198198
for (int ir = 0; ir < GlobalC::rhopw->nrxx; ir++)
199199
{
200200
GlobalC::pot.vr_eff1[ir] = GlobalC::pot.vr_eff(is, ir);
201-
if(XC_Functional::get_func_type()==3)
201+
if(XC_Functional::get_func_type()==3 || XC_Functional::get_func_type()==5)
202202
{
203203
GlobalC::pot.vofk_eff1[ir] = GlobalC::pot.vofk(is, ir);
204204
}
205205
}
206206

207-
if(XC_Functional::get_func_type()==3)
207+
if(XC_Functional::get_func_type()==3 || XC_Functional::get_func_type()==5)
208208
{
209209
Gint_inout inout(GlobalC::pot.vr_eff1, GlobalC::pot.vofk_eff1, is, Gint_Tools::job_type::vlocal_meta);
210210
this->uhm->GK.cal_gint(&inout);

source/module_xc/exx_global.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
struct Exx_Global
77
{
8-
enum class Hybrid_Type {No,HF,PBE0,HSE,Generate_Matrix};
8+
enum class Hybrid_Type {No,HF,PBE0,HSE,SCAN0,Generate_Matrix};
99
struct Exx_Info
1010
{
1111
Exx_Global::Hybrid_Type hybrid_type;

0 commit comments

Comments
 (0)