Skip to content

Commit 808c221

Browse files
add a new parameter scf_os_stop
1 parent 4ec6f2a commit 808c221

File tree

5 files changed

+20
-0
lines changed

5 files changed

+20
-0
lines changed

docs/advanced/input_files/input-main.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
- [scf\_thr](#scf_thr)
8989
- [scf\_ene\_thr](#scf_ene_thr)
9090
- [scf\_thr\_type](#scf_thr_type)
91+
- [scf\_os\_stop](#scf_os_stop)
9192
- [scf\_thr\_os](#scf_thr_os)
9293
- [scf\_os\_ndim](#scf_os_ndim)
9394
- [chg\_extrap](#chg_extrap)
@@ -1207,6 +1208,16 @@ Note: In new angle mixing, you should set `mixing_beta_mag >> mixing_beta`. The
12071208

12081209
- **Default**: 1 (plane-wave basis), or 2 (localized atomic orbital basis).
12091210

1211+
### scf_os_stop
1212+
1213+
- **Type**: bool
1214+
- **Description**: The slope threshold to determine if the SCF is stuck in a charge density oscillation. To this end, Least Squares Method is used to calculate the slope of the logarithmically taken drho for the previous `scf_os_ndim` iterations. If the calculated slope is larger than `scf_thr_os`, stop the SCF.
1215+
1216+
- **0**: The SCF will continue to run regardless of whether there is oscillation or not.
1217+
- **1**: If the calculated slope is larger than `scf_thr_os`, stop the SCF.
1218+
1219+
- **Default**: false
1220+
12101221
### scf_thr_os
12111222

12121223
- **Type**: double

source/module_io/read_input_item_elec_stru.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,12 @@ void ReadInput::item_elec_stru()
528528
read_sync_double(input.scf_ene_thr);
529529
this->add_item(item);
530530
}
531+
{
532+
Input_Item item("scf_os_stop");
533+
item.annotation = "whether to stop scf when oscillation is detected";
534+
read_sync_bool(input.scf_os_stop);
535+
this->add_item(item);
536+
}
531537
{
532538
Input_Item item("scf_thr_os");
533539
item.annotation = "charge density threshold for oscillation";

source/module_io/test/read_input_ptest.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ TEST_F(InputParaTest, ParaRead)
164164
EXPECT_EQ(PARAM.inp.test_force, 0);
165165
EXPECT_EQ(param.inp.test_stress, 0);
166166
EXPECT_NEAR(param.inp.scf_thr, 1.0e-8, 1.0e-15);
167+
EXPECT_EQ(param.inp.scf_os_stop, 1);
167168
EXPECT_NEAR(param.inp.scf_thr_os, -0.02, 1.0e-15);
168169
EXPECT_EQ(param.inp.scf_os_ndim, 10);
169170
EXPECT_NEAR(param.inp.scf_ene_thr, 1.0e-6, 1.0e-15);

source/module_io/test/support/INPUT

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ fft_mode 0 #mode of FFTW
5252
pw_diag_thr 0.01 #threshold for eigenvalues is cg electron iterations
5353
scf_thr 1e-08 #charge density error
5454
scf_ene_thr 1e-06 #total energy error threshold
55+
scf_os_stop 1 #whether to stop scf when oscillation is detected
5556
scf_thr_os -0.02 #charge density threshold for oscillation
5657
scf_os_ndim 10 #number of old iterations used for oscillation detection
5758
scf_thr_type 2 #type of the criterion of scf_thr, 1: reci drho for pw, 2: real drho for lcao

source/module_parameter/input_parameter.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ struct Input_para
115115
double scf_ene_thr = -1.0; ///< energy threshold for scf convergence, in eV
116116
int scf_thr_type = -1; ///< type of the criterion of scf_thr, 1: reci drho, 2: real drho
117117
bool final_scf = false; ///< whether to do final scf
118+
bool scf_os_stop = false; ///< whether to stop scf when oscillation is detected
118119
double scf_thr_os = -0.01; ///< drho threshold for oscillation
119120
int scf_os_ndim = 0; ///< number of old iterations used for oscillation detection
120121

0 commit comments

Comments
 (0)