Skip to content

Commit 363f9ba

Browse files
authored
append to out_file when LAMMPS restarts (#640)
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 83fffbe commit 363f9ba

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

source/lmp/pair_deepmd.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ PairDeepMD::PairDeepMD(LAMMPS *lmp)
237237
if (strcmp(update->unit_style,"metal") != 0) {
238238
error->all(FLERR,"Pair deepmd requires metal unit, please set it by \"units metal\"");
239239
}
240+
restartinfo = 1;
240241
pppmflag = 1;
241242
respa_enable = 0;
242243
writedata = 0;
@@ -254,6 +255,7 @@ PairDeepMD::PairDeepMD(LAMMPS *lmp)
254255
single_model = false;
255256
multi_models_mod_devi = false;
256257
multi_models_no_mod_devi = false;
258+
is_restart = false;
257259
// set comm size needed by this Pair
258260
comm_reverse = 1;
259261

@@ -855,6 +857,7 @@ void PairDeepMD::settings(int narg, char **arg)
855857

856858
if (comm->me == 0){
857859
if (numb_models > 1 && out_freq > 0){
860+
if (!is_restart) {
858861
fp.open (out_file);
859862
fp << scientific;
860863
fp << "#"
@@ -866,6 +869,10 @@ void PairDeepMD::settings(int narg, char **arg)
866869
<< setw(18+1) << "min_devi_f"
867870
<< setw(18+1) << "avg_devi_f"
868871
<< endl;
872+
} else {
873+
fp.open (out_file, std::ofstream::out | std::ofstream::app);
874+
fp << scientific;
875+
}
869876
}
870877
string pre = " ";
871878
cout << pre << ">>> Info of model(s):" << endl
@@ -901,6 +908,16 @@ void PairDeepMD::settings(int narg, char **arg)
901908
all_force.resize(numb_models);
902909
}
903910

911+
void PairDeepMD::read_restart(FILE *)
912+
{
913+
is_restart = true;
914+
}
915+
916+
void PairDeepMD::write_restart(FILE *)
917+
{
918+
// pass
919+
}
920+
904921
/* ----------------------------------------------------------------------
905922
set coeffs for one or more type pairs
906923
------------------------------------------------------------------------- */

source/lmp/pair_deepmd.h.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ class PairDeepMD : public Pair {
4646
void settings(int, char **);
4747
virtual void coeff(int, char **);
4848
void init_style();
49+
virtual void write_restart(FILE *);
50+
virtual void read_restart(FILE *);
4951
double init_one(int i, int j);
5052
int pack_reverse_comm(int, int, double *);
5153
void unpack_reverse_comm(int, int *, double *);
@@ -75,6 +77,7 @@ private:
7577
bool single_model;
7678
bool multi_models_mod_devi;
7779
bool multi_models_no_mod_devi;
80+
bool is_restart;
7881
#ifdef HIGH_PREC
7982
std::vector<double > fparam;
8083
std::vector<double > aparam;

0 commit comments

Comments
 (0)