From 660c44514afa6c862e9d411cb854ec8526ba0da0 Mon Sep 17 00:00:00 2001 From: YuLiu98 Date: Mon, 25 Nov 2024 11:36:14 +0800 Subject: [PATCH 1/2] Feature: set relax_nmax=0 to enable dry run --- source/module_io/read_input_item_relax.cpp | 7 +++++-- source/module_io/test_serial/read_input_item_test.cpp | 8 ++++++++ source/module_parameter/input_parameter.h | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/source/module_io/read_input_item_relax.cpp b/source/module_io/read_input_item_relax.cpp index e39abb57d0..28a0de7ecd 100644 --- a/source/module_io/read_input_item_relax.cpp +++ b/source/module_io/read_input_item_relax.cpp @@ -54,11 +54,14 @@ void ReadInput::item_relax() = {"scf", "nscf", "get_S", "get_pchg", "get_wf", "test_memory", "test_neighbour", "gen_bessel"}; if (std::find(singlelist.begin(), singlelist.end(), calculation) != singlelist.end()) { - para.input.relax_nmax = 1; + if (para.input.relax_nmax != 0) + { + para.input.relax_nmax = 1; + } } else if (calculation == "relax" || calculation == "cell-relax") { - if (para.input.relax_nmax == 0) // default value + if (para.input.relax_nmax < 0) { para.input.relax_nmax = 50; } diff --git a/source/module_io/test_serial/read_input_item_test.cpp b/source/module_io/test_serial/read_input_item_test.cpp index 13fae166a5..5ec1ba146e 100644 --- a/source/module_io/test_serial/read_input_item_test.cpp +++ b/source/module_io/test_serial/read_input_item_test.cpp @@ -608,9 +608,17 @@ TEST_F(InputTest, Item_test) it->second.reset_value(it->second, param); EXPECT_EQ(param.input.relax_nmax, 1); + param.input.relax_nmax = 0; + it->second.reset_value(it->second, param); + EXPECT_EQ(param.input.relax_nmax, 0); + param.input.calculation = "relax"; param.input.relax_nmax = 0; it->second.reset_value(it->second, param); + EXPECT_EQ(param.input.relax_nmax, 0); + + param.input.relax_nmax = -1; + it->second.reset_value(it->second, param); EXPECT_EQ(param.input.relax_nmax, 50); } { // out_stru diff --git a/source/module_parameter/input_parameter.h b/source/module_parameter/input_parameter.h index d002229191..9984bd2c33 100644 --- a/source/module_parameter/input_parameter.h +++ b/source/module_parameter/input_parameter.h @@ -152,7 +152,7 @@ struct Input_para bool relax_new = true; bool relax = false; ///< allow relaxation along the specific direction double relax_scale_force = 0.5; - int relax_nmax = 0; ///< number of max ionic iter + int relax_nmax = -1; ///< number of max ionic iter double relax_cg_thr = 0.5; ///< threshold when cg to bfgs, pengfei add 2011-08-15 double force_thr = -1; ///< threshold of force in unit (Ry/Bohr) double force_thr_ev = -1; ///< threshold of force in unit (eV/Angstrom) From c2c67dffc7a8112d21d75228381c09e9972c16b5 Mon Sep 17 00:00:00 2001 From: YuLiu98 Date: Mon, 25 Nov 2024 14:38:57 +0800 Subject: [PATCH 2/2] update docs --- docs/advanced/input_files/input-main.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/advanced/input_files/input-main.md b/docs/advanced/input_files/input-main.md index 05bce64ccb..775da12cd7 100644 --- a/docs/advanced/input_files/input-main.md +++ b/docs/advanced/input_files/input-main.md @@ -1389,7 +1389,7 @@ These variables are used to control the geometry relaxation. ### relax_nmax - **Type**: Integer -- **Description**: The maximal number of ionic iteration steps, the minimum value is 1. +- **Description**: The maximal number of ionic iteration steps. If set to 0, the code performs a quick "dry run", stopping just after initialization. This is useful to check for input correctness and to have the summary printed. - **Default**: 1 for SCF, 50 for relax and cell-relax calcualtions ### relax_cg_thr