Skip to content

Commit

Permalink
append to out_file when LAMMPS restarts (#640)
Browse files Browse the repository at this point in the history
This ensures the out file will not be override when LAMMPS restarts.
This commit may be conflicted with #392. Commit
@5597ea2b49f96e99a52a9779b04b6c12e5a79a04 should be dropped.
  • Loading branch information
njzjz authored May 18, 2021
1 parent 83fffbe commit 363f9ba
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
17 changes: 17 additions & 0 deletions source/lmp/pair_deepmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ PairDeepMD::PairDeepMD(LAMMPS *lmp)
if (strcmp(update->unit_style,"metal") != 0) {
error->all(FLERR,"Pair deepmd requires metal unit, please set it by \"units metal\"");
}
restartinfo = 1;
pppmflag = 1;
respa_enable = 0;
writedata = 0;
Expand All @@ -254,6 +255,7 @@ PairDeepMD::PairDeepMD(LAMMPS *lmp)
single_model = false;
multi_models_mod_devi = false;
multi_models_no_mod_devi = false;
is_restart = false;
// set comm size needed by this Pair
comm_reverse = 1;

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

if (comm->me == 0){
if (numb_models > 1 && out_freq > 0){
if (!is_restart) {
fp.open (out_file);
fp << scientific;
fp << "#"
Expand All @@ -866,6 +869,10 @@ void PairDeepMD::settings(int narg, char **arg)
<< setw(18+1) << "min_devi_f"
<< setw(18+1) << "avg_devi_f"
<< endl;
} else {
fp.open (out_file, std::ofstream::out | std::ofstream::app);
fp << scientific;
}
}
string pre = " ";
cout << pre << ">>> Info of model(s):" << endl
Expand Down Expand Up @@ -901,6 +908,16 @@ void PairDeepMD::settings(int narg, char **arg)
all_force.resize(numb_models);
}

void PairDeepMD::read_restart(FILE *)
{
is_restart = true;
}

void PairDeepMD::write_restart(FILE *)
{
// pass
}

/* ----------------------------------------------------------------------
set coeffs for one or more type pairs
------------------------------------------------------------------------- */
Expand Down
3 changes: 3 additions & 0 deletions source/lmp/pair_deepmd.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ class PairDeepMD : public Pair {
void settings(int, char **);
virtual void coeff(int, char **);
void init_style();
virtual void write_restart(FILE *);
virtual void read_restart(FILE *);
double init_one(int i, int j);
int pack_reverse_comm(int, int, double *);
void unpack_reverse_comm(int, int *, double *);
Expand Down Expand Up @@ -75,6 +77,7 @@ private:
bool single_model;
bool multi_models_mod_devi;
bool multi_models_no_mod_devi;
bool is_restart;
#ifdef HIGH_PREC
std::vector<double > fparam;
std::vector<double > aparam;
Expand Down

0 comments on commit 363f9ba

Please sign in to comment.