Skip to content

Commit d0f5f18

Browse files
authored
append to out_file when LAMMPS restarts (#641)
This ensures the out file will not be override when LAMMPS restarts. This commit may be conflicted with #392. Commit @5597ea2b49f96e99a52a9779b04b6c12e5a79a04 should be dropped.
1 parent abee8b9 commit d0f5f18

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

source/lmp/pair_nnp.cpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ PairNNP::PairNNP(LAMMPS *lmp)
206206
if (strcmp(update->unit_style,"metal") != 0) {
207207
error->all(FLERR,"Pair deepmd requires metal unit, please set it by \"units metal\"");
208208
}
209-
restartinfo = 0;
209+
restartinfo = 1;
210210
pppmflag = 1;
211211
respa_enable = 0;
212212
writedata = 0;
@@ -222,6 +222,7 @@ PairNNP::PairNNP(LAMMPS *lmp)
222222
single_model = false;
223223
multi_models_mod_devi = false;
224224
multi_models_no_mod_devi = false;
225+
is_restart = false;
225226
// set comm size needed by this Pair
226227
comm_reverse = 1;
227228

@@ -754,6 +755,7 @@ void PairNNP::settings(int narg, char **arg)
754755

755756
if (comm->me == 0){
756757
if (numb_models > 1 && out_freq > 0){
758+
if (!is_restart) {
757759
fp.open (out_file);
758760
fp << scientific;
759761
fp << "#"
@@ -765,6 +767,10 @@ void PairNNP::settings(int narg, char **arg)
765767
<< setw(18+1) << "min_devi_f"
766768
<< setw(18+1) << "avg_devi_f"
767769
<< endl;
770+
} else {
771+
fp.open (out_file, std::ofstream::out | std::ofstream::app);
772+
fp << scientific;
773+
}
768774
}
769775
string pre = " ";
770776
cout << pre << ">>> Info of model(s):" << endl
@@ -800,6 +806,16 @@ void PairNNP::settings(int narg, char **arg)
800806
all_force.resize(numb_models);
801807
}
802808

809+
void PairDeepMD::read_restart(FILE *)
810+
{
811+
is_restart = true;
812+
}
813+
814+
void PairDeepMD::write_restart(FILE *)
815+
{
816+
// pass
817+
}
818+
803819
/* ----------------------------------------------------------------------
804820
set coeffs for one or more type pairs
805821
------------------------------------------------------------------------- */

source/lmp/pair_nnp.h.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ class PairNNP : public Pair {
5959
void settings(int, char **);
6060
virtual void coeff(int, char **);
6161
void init_style();
62+
virtual void write_restart(FILE *);
63+
virtual void read_restart(FILE *);
6264
double init_one(int i, int j);
6365
int pack_reverse_comm(int, int, double *);
6466
void unpack_reverse_comm(int, int *, double *);
@@ -85,6 +87,7 @@ private:
8587
bool single_model;
8688
bool multi_models_mod_devi;
8789
bool multi_models_no_mod_devi;
90+
bool is_restart;
8891
#ifdef HIGH_PREC
8992
vector<double > fparam;
9093
vector<double > aparam;

0 commit comments

Comments
 (0)