Skip to content

Commit 2188e72

Browse files
Refactor
1 parent e046090 commit 2188e72

File tree

3 files changed

+28
-4
lines changed

3 files changed

+28
-4
lines changed

source/source_esolver/esolver_ks_pw.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -599,9 +599,7 @@ void ESolver_KS_PW<T, Device>::iter_finish(UnitCell& ucell, const int istep, int
599599
}
600600
else if (PARAM.inp.exx_thr_type == "density")
601601
{
602-
conv_esolver = exx_helper.cal_psi_diff(this->kspw_psi) < PARAM.inp.exx_psi_thr
603-
|| exx_helper.exx_after_converge(iter);
604-
exx_helper.set_psi(this->kspw_psi);
602+
conv_esolver = exx_helper.exx_after_converge(iter);
605603
}
606604
if (!conv_esolver)
607605
{

source/source_io/module_parameter/input_parameter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ struct Input_para
654654
// EXX for planewave basis, rhx0820 2025-03-10
655655
bool exxace = true; // exxace, exact exchange for planewave basis, https://doi.org/10.1021/acs.jctc.6b00092
656656
bool exx_gamma_extrapolation = true; // gamma point extrapolation for exx, https://doi.org/10.1103/PhysRevB.79.205114
657-
std::string exx_thr_type = "energy"; // threshold type for exx outer loop, energy or density
657+
std::string exx_thr_type = "density"; // threshold type for exx outer loop, energy or density
658658
double exx_ene_thr = 1e-5; // threshold for exx outer loop when exx_thr_type = energy
659659

660660
// ==== #Parameters (23.XC external parameterization) ========

source/source_io/read_input_item_other.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,32 @@ void ReadInput::item_others()
545545
read_sync_bool(input.exx_gamma_extrapolation);
546546
this->add_item(item);
547547
}
548+
{
549+
Input_Item item("exx_thr_type");
550+
item.annotation = "threshold type for exx outer loop, energy or density";
551+
read_sync_string(input.exx_thr_type);
552+
item.check_value = [](const Input_Item& item, const Parameter& para) {
553+
std::string thr_type = para.input.exx_thr_type;
554+
std::transform(thr_type.begin(), thr_type.end(), thr_type.begin(), ::tolower);
555+
if (thr_type != "energy" && thr_type != "density")
556+
{
557+
ModuleBase::WARNING_QUIT("ReadInput", "exx_thr_type should be energy or density");
558+
}
559+
};
560+
this->add_item(item);
561+
}
562+
{
563+
Input_Item item("exx_ene_thr");
564+
item.annotation = "threshold for exx outer loop when exx_thr_type = energy";
565+
read_sync_double(input.exx_ene_thr);
566+
item.check_value = [](const Input_Item& item, const Parameter& para) {
567+
if (para.input.exx_ene_thr <= 0)
568+
{
569+
ModuleBase::WARNING_QUIT("ReadInput", "exx_ene_thr must > 0");
570+
}
571+
};
572+
this->add_item(item);
573+
}
548574

549575
}
550576
} // namespace ModuleIO

0 commit comments

Comments
 (0)