From 92ae92e88e9e72e1175dfae96696fc6f5f9b3c1b Mon Sep 17 00:00:00 2001 From: njzjz Date: Tue, 16 Jul 2019 23:33:49 +0800 Subject: [PATCH 1/2] print each atom's deviation --- source/lmp/pair_nnp.cpp | 14 ++++++++++++-- source/lmp/pair_nnp.h.in | 1 + 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/source/lmp/pair_nnp.cpp b/source/lmp/pair_nnp.cpp index ee46fe2d02..83692b01f6 100644 --- a/source/lmp/pair_nnp.cpp +++ b/source/lmp/pair_nnp.cpp @@ -49,6 +49,7 @@ PairNNP::PairNNP(LAMMPS *lmp) numb_types = 0; numb_models = 0; out_freq = 0; + out_each = 0; scale = NULL; // set comm size needed by this Pair @@ -328,10 +329,13 @@ void PairNNP::compute(int eflag, int vflag) << " " << setw(18) << all_e_avg << " " << setw(18) << all_f_max << " " << setw(18) << all_f_min - << " " << setw(18) << all_f_avg + << " " << setw(18) << all_f_avg; // << " " << setw(18) << avg_e // << " " << setw(18) << std_e_1 / all_nlocal - << endl; + if (out_each == 1){ + for (int dd = 0; dd < all_nlocal; ++dd) fp << " " << setw(18) << std_f[dd]; + } + fp << endl; } } } @@ -415,6 +419,7 @@ is_key (const string& input) keys.push_back("out_freq"); keys.push_back("out_file"); keys.push_back("fparam"); + keys.push_back("out_each"); for (int ii = 0; ii < keys.size(); ++ii){ if (input == keys[ii]) { @@ -460,6 +465,7 @@ void PairNNP::settings(int narg, char **arg) out_freq = 100; out_file = "model_devi.out"; + out_each = 0; fparam.clear(); while (iarg < narg) { if (! is_key(arg[iarg])) { @@ -486,6 +492,10 @@ void PairNNP::settings(int narg, char **arg) } iarg += 1 + dim_fparam ; } + else if (string(arg[iarg]) == string("out_each")) { + out_each = 1; + iarg += 1; + } } if (out_freq < 0) error->all(FLERR,"Illegal out_freq, should be >= 0"); diff --git a/source/lmp/pair_nnp.h.in b/source/lmp/pair_nnp.h.in index edb4aee9aa..508816feda 100644 --- a/source/lmp/pair_nnp.h.in +++ b/source/lmp/pair_nnp.h.in @@ -79,6 +79,7 @@ private: int out_freq; string out_file; int dim_fparam; + int out_each; #ifdef HIGH_PREC vector fparam; #else From 9f6f3a53786fceaf7c48ed8d30ccfbbe025c248d Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Wed, 17 Jul 2019 20:36:42 +0800 Subject: [PATCH 2/2] add comment --- source/lmp/pair_nnp.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/lmp/pair_nnp.cpp b/source/lmp/pair_nnp.cpp index 83692b01f6..e7db39c4f3 100644 --- a/source/lmp/pair_nnp.cpp +++ b/source/lmp/pair_nnp.cpp @@ -333,6 +333,9 @@ void PairNNP::compute(int eflag, int vflag) // << " " << setw(18) << avg_e // << " " << setw(18) << std_e_1 / all_nlocal if (out_each == 1){ + // TODO: Fix two problems: + // 1. If the atom_style is not atomic (e.g. charge), the order of std_f is different from that of atom ids. + // 2. std_f is not gathered by MPI. for (int dd = 0; dd < all_nlocal; ++dd) fp << " " << setw(18) << std_f[dd]; } fp << endl;