From 66cc41ea26aabfed24f61373d37828bd27b7d8c5 Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Mon, 4 Dec 2023 23:09:14 -0500 Subject: [PATCH 1/3] lmp: do not apply scale factor to model deviation --- doc/third-party/lammps-command.md | 1 + source/lmp/pair_deepmd.cpp | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/doc/third-party/lammps-command.md b/doc/third-party/lammps-command.md index 023345d638..150d755795 100644 --- a/doc/third-party/lammps-command.md +++ b/doc/third-party/lammps-command.md @@ -82,6 +82,7 @@ Evaluate the interaction of the system by using [Deep Potential][DP] or [Deep Po This pair style takes the deep potential defined in a model file that usually has the .pb extension. The model can be trained and frozen by package [DeePMD-kit](https://github.com/deepmodeling/deepmd-kit), which can have either double or single float precision interface. The model deviation evalulates the consistency of the force predictions from multiple models. By default, only the maximal, minimal and average model deviations are output. If the key `atomic` is set, then the model deviation of force prediction of each atom will be output. +The unit follows [LAMMPS units](#units) and the [scale factor](https://docs.lammps.org/pair_hybrid.html) is not applied. By default, the model deviation is output in absolute value. If the keyword `relative` is set, then the relative model deviation of the force will be output, including values output by the keyword `atomic`. The relative model deviation of the force on atom $i$ is defined by diff --git a/source/lmp/pair_deepmd.cpp b/source/lmp/pair_deepmd.cpp index 600c4cae29..6aea878750 100644 --- a/source/lmp/pair_deepmd.cpp +++ b/source/lmp/pair_deepmd.cpp @@ -767,12 +767,12 @@ void PairDeepMD::compute(int eflag, int vflag) { all_v_avg = sqrt(all_v_avg / 9); } if (rank == 0) { - all_v_max *= scale[1][1] * ener_unit_cvt_factor; - all_v_min *= scale[1][1] * ener_unit_cvt_factor; - all_v_avg *= scale[1][1] * ener_unit_cvt_factor; - all_f_max *= scale[1][1] * force_unit_cvt_factor; - all_f_min *= scale[1][1] * force_unit_cvt_factor; - all_f_avg *= scale[1][1] * force_unit_cvt_factor; + all_v_max *= ener_unit_cvt_factor; + all_v_min *= ener_unit_cvt_factor; + all_v_avg *= ener_unit_cvt_factor; + all_f_max *= force_unit_cvt_factor; + all_f_min *= force_unit_cvt_factor; + all_f_avg *= force_unit_cvt_factor; fp << setw(12) << update->ntimestep << " " << setw(18) << all_v_max << " " << setw(18) << all_v_min << " " << setw(18) << all_v_avg << " " << setw(18) << all_f_max << " " << setw(18) << all_f_min From be475b63e2c829345dfbd38f23d7bb444923c218 Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Tue, 5 Dec 2023 00:54:35 -0500 Subject: [PATCH 2/3] remove scale from std_f_all Signed-off-by: Jinzhe Zeng --- source/lmp/pair_deepmd.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/lmp/pair_deepmd.cpp b/source/lmp/pair_deepmd.cpp index 6aea878750..2f8744b15a 100644 --- a/source/lmp/pair_deepmd.cpp +++ b/source/lmp/pair_deepmd.cpp @@ -799,7 +799,7 @@ void PairDeepMD::compute(int eflag, int vflag) { if (rank == 0) { for (int dd = 0; dd < all_nlocal; ++dd) { std_f_all[tagrecv[dd] - 1] = - stdfrecv[dd] * scale[1][1] * force_unit_cvt_factor; + stdfrecv[dd] * force_unit_cvt_factor; } for (int dd = 0; dd < all_nlocal; ++dd) { fp << " " << setw(18) << std_f_all[dd]; From 744ddd0ee6091768a7e77f8da84eb7e7e0f31306 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 5 Dec 2023 05:54:57 +0000 Subject: [PATCH 3/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- source/lmp/pair_deepmd.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/source/lmp/pair_deepmd.cpp b/source/lmp/pair_deepmd.cpp index 2f8744b15a..645bb9fec9 100644 --- a/source/lmp/pair_deepmd.cpp +++ b/source/lmp/pair_deepmd.cpp @@ -798,8 +798,7 @@ void PairDeepMD::compute(int eflag, int vflag) { displacements, MPI_DOUBLE, 0, world); if (rank == 0) { for (int dd = 0; dd < all_nlocal; ++dd) { - std_f_all[tagrecv[dd] - 1] = - stdfrecv[dd] * force_unit_cvt_factor; + std_f_all[tagrecv[dd] - 1] = stdfrecv[dd] * force_unit_cvt_factor; } for (int dd = 0; dd < all_nlocal; ++dd) { fp << " " << setw(18) << std_f_all[dd];