Skip to content

Commit

Permalink
lmp: do not write model deviation if the same step written previously
Browse files Browse the repository at this point in the history
Fix #1311.

#1311  is not clearly described. I check the LAMMPS source code and think the following line is the most close to the description:
https://github.com/lammps/lammps/blob/f0801338f325e185e49a9b5b081455c7964de9d9/src/output.cpp#L260
Signed-off-by: Jinzhe Zeng <[email protected]>
  • Loading branch information
njzjz committed Oct 18, 2023
1 parent 64a5aa8 commit 3f43ad4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
19 changes: 10 additions & 9 deletions source/lmp/pair_deepmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -547,21 +547,20 @@ void PairDeepMD::compute(int eflag, int vflag) {

// int ago = numb_models > 1 ? 0 : neighbor->ago;
int ago = neighbor->ago;
bool model_devi_writeflag = out_freq > 0 &&
update->ntimestep % out_freq == 0 &&
update->ntimestep != model_devi_last_dump;
if (numb_models > 1) {
if (multi_models_no_mod_devi &&
(out_freq > 0 && update->ntimestep % out_freq == 0)) {
if (multi_models_no_mod_devi && model_devi_writeflag) {
ago = 0;
} else if (multi_models_mod_devi &&
(out_freq == 0 || update->ntimestep % out_freq != 0)) {
} else if (multi_models_mod_devi && !model_devi_writeflag) {
ago = 0;
}
}
// compute
single_model = (numb_models == 1);
multi_models_no_mod_devi =
(numb_models > 1 && (out_freq == 0 || update->ntimestep % out_freq != 0));
multi_models_mod_devi =
(numb_models > 1 && (out_freq > 0 && update->ntimestep % out_freq == 0));
multi_models_no_mod_devi = (numb_models > 1 && !model_devi_writeflag);
multi_models_mod_devi = (numb_models > 1 && model_devi_writeflag);
if (do_ghost) {
deepmd_compat::InputNlist lmp_list(list->inum, list->ilist, list->numneigh,
list->firstneigh);
Expand Down Expand Up @@ -715,7 +714,8 @@ void PairDeepMD::compute(int eflag, int vflag) {
scale[1][1] * dvatom[9 * ii + 5] * ener_unit_cvt_factor; // zy
}
}
if (out_freq > 0 && update->ntimestep % out_freq == 0) {
if (model_devi_writeflag) {
model_devi_last_dump = update->ntimestep;
int rank = comm->me;
// std force
if (newton_pair) {
Expand Down Expand Up @@ -989,6 +989,7 @@ void PairDeepMD::settings(int narg, char **arg) {
out_each = 0;
out_rel = 0;
eps = 0.;
model_devi_last_dump = -1;
fparam.clear();
aparam.clear();
while (iarg < narg) {
Expand Down
1 change: 1 addition & 0 deletions source/lmp/pair_deepmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ class PairDeepMD : public Pair {
tagint *tagsend, *tagrecv;
double *stdfsend, *stdfrecv;
std::vector<int> type_idx_map;
int model_devi_last_dump;
};

} // namespace LAMMPS_NS
Expand Down

0 comments on commit 3f43ad4

Please sign in to comment.