Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: set relax_nmax=0 to enable dry run #5595

Merged
merged 3 commits into from
Nov 25, 2024
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
2 changes: 1 addition & 1 deletion docs/advanced/input_files/input-main.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions source/module_io/read_input_item_relax.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
8 changes: 8 additions & 0 deletions source/module_io/test_serial/read_input_item_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion source/module_parameter/input_parameter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading