Skip to content

Commit 6af3f77

Browse files
committed
add another parameter to save_potential to control if nep.restarts should be written as well
1 parent a1d7e21 commit 6af3f77

3 files changed

Lines changed: 11 additions & 4 deletions

File tree

src/main_nep/parameters.cu

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1316,8 +1316,8 @@ void Parameters::parse_save_potential(const char** param, int num_param)
13161316
{
13171317
is_save_potential_set = true;
13181318

1319-
if (num_param != 3) {
1320-
PRINT_INPUT_ERROR("save_potential should have 2 parameters.\n");
1319+
if (num_param != 4) {
1320+
PRINT_INPUT_ERROR("save_potential should have 3 parameters.\n");
13211321
}
13221322
if (!is_valid_int(param[1], &save_potential)) {
13231323
PRINT_INPUT_ERROR("save_potential interval should be an integer.\n");
@@ -1331,4 +1331,10 @@ void Parameters::parse_save_potential(const char** param, int num_param)
13311331
if (save_potential_format != 0 && save_potential_format != 1) {
13321332
PRINT_INPUT_ERROR("save_potential format should be 0 or 1.");
13331333
}
1334+
if (!is_valid_int(param[3], &save_potential_restart)) {
1335+
PRINT_INPUT_ERROR("save_potential save restart should be an integer.\n");
1336+
}
1337+
if (save_potential_restart != 0 && save_potential_restart != 1) {
1338+
PRINT_INPUT_ERROR("save_potential save restart should be 0 or 1.");
1339+
}
13341340
}

src/main_nep/parameters.cuh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ public:
3131
int population_size; // population size for SNES
3232
int maximum_generation; // maximum number of generations for SNES;
3333
int save_potential; // number of generations between writing a checkpoint nep.txt file.
34-
int save_potential_format; // format of checkpoint nep.txt file name
34+
int save_potential_format; // format of checkpoint nep.txt file name
35+
int save_potential_restart; // if restart files should be written or not. 0=no, 1=yes
3536
int num_neurons1; // number of nuerons in the 1st hidden layer (only one hidden layer)
3637
int basis_size_radial; // for nep3
3738
int basis_size_angular; // for nep3

src/main_nep/snes.cu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ void SNES::compute(Parameters& para, Fitness* fitness_function)
360360
output_mu_and_sigma(para, filename);
361361
}
362362
// Optionally save the nep.restart file at the same time as save_potential
363-
if (0 == (n + 1) % para.save_potential) {
363+
if (0 == (n + 1) % para.save_potential && para.save_potential_restart) {
364364
std::string restart_file;
365365
fitness_function->get_save_potential_label(para, n, restart_file);
366366
restart_file += ".restart";

0 commit comments

Comments
 (0)