From 83242e7074f7d4ce95dbef8d1c03cdd2812ac3ad Mon Sep 17 00:00:00 2001 From: Yi-FanLi Date: Fri, 24 Dec 2021 00:10:34 -0500 Subject: [PATCH 1/7] explicitly set neighbor request to full in compute deeptensor/atom to fix bug #1381 --- source/lmp/compute_deeptensor_atom.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/lmp/compute_deeptensor_atom.cpp b/source/lmp/compute_deeptensor_atom.cpp index 85f7d0a332..e29897266a 100644 --- a/source/lmp/compute_deeptensor_atom.cpp +++ b/source/lmp/compute_deeptensor_atom.cpp @@ -70,7 +70,7 @@ void ComputeDeeptensorAtom::init() neighbor->requests[irequest]->half = 0; neighbor->requests[irequest]->pair = 0; neighbor->requests[irequest]->compute = 1; - // neighbor->requests[irequest]->full = 1; + neighbor->requests[irequest]->full = 1; neighbor->requests[irequest]->occasional = 1; } From 19c72f18e559136b848b071ad5b1600809f65bc4 Mon Sep 17 00:00:00 2001 From: Yifan Li Date: Thu, 14 Apr 2022 15:38:01 -0400 Subject: [PATCH 2/7] Corrected the pppm_dplr forward communication for ik differentiation mode at LAMMPS version >= 20210831. --- source/lmp/pppm_dplr.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/lmp/pppm_dplr.cpp b/source/lmp/pppm_dplr.cpp index dc3782e058..1a1070c04f 100644 --- a/source/lmp/pppm_dplr.cpp +++ b/source/lmp/pppm_dplr.cpp @@ -138,7 +138,7 @@ void PPPMDPLR::compute(int eflag, int vflag) #endif else #if LAMMPS_VERSION_NUMBER>=20210831 - gc->forward_comm(GridComm::KSPACE,this,1,sizeof(FFT_SCALAR),FORWARD_IK, + gc->forward_comm(GridComm::KSPACE,this,3,sizeof(FFT_SCALAR),FORWARD_IK, gc_buf1,gc_buf2,MPI_FFT_SCALAR); #else gc->forward_comm_kspace(this,3,sizeof(FFT_SCALAR),FORWARD_IK, From 9e0a8db3b6b4d88d3a960a2099b4c37c102dfa07 Mon Sep 17 00:00:00 2001 From: Yifan Li Date: Sat, 7 May 2022 22:30:56 -0400 Subject: [PATCH 3/7] modify plugin so that it could find lammps in Yi-FanLi repo --- source/lmp/plugin/CMakeLists.txt | 2 +- source/lmp/plugin/deepmdplugin.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/source/lmp/plugin/CMakeLists.txt b/source/lmp/plugin/CMakeLists.txt index f6ce774ca5..a01262c9e3 100644 --- a/source/lmp/plugin/CMakeLists.txt +++ b/source/lmp/plugin/CMakeLists.txt @@ -5,7 +5,7 @@ if (DEFINED LAMMPS_SOURCE_ROOT OR DEFINED LAMMPS_VERSION) cmake_minimum_required(VERSION 3.11) include(FetchContent) FetchContent_Declare(lammps_download - GIT_REPOSITORY https://github.com/lammps/lammps + GIT_REPOSITORY https://github.com/Yi-FanLi/lammps GIT_TAG ${LAMMPS_VERSION} ) FetchContent_GetProperties(lammps_download) diff --git a/source/lmp/plugin/deepmdplugin.cpp b/source/lmp/plugin/deepmdplugin.cpp index 41f2e8557e..e78b15d79e 100644 --- a/source/lmp/plugin/deepmdplugin.cpp +++ b/source/lmp/plugin/deepmdplugin.cpp @@ -6,7 +6,7 @@ #include "pair_deepmd.h" #include "fix_dplr.h" #include "compute_deeptensor_atom.h" -#if LAMMPS_VERSION_NUMBER>=20220328 +#if LAMMPS_VERSION_NUMBER>=20220324 #include "pppm_dplr.h" #endif @@ -27,7 +27,7 @@ static Fix *fixdplr(LAMMPS *lmp, int narg, char **arg) return new FixDPLR(lmp, narg, arg); } -#if LAMMPS_VERSION_NUMBER>=20220328 +#if LAMMPS_VERSION_NUMBER>=20220324 static KSpace *pppmdplr(LAMMPS *lmp) { return new PPPMDPLR(lmp); @@ -60,7 +60,7 @@ extern "C" void lammpsplugin_init(void *lmp, void *handle, void *regfunc) plugin.creator.v2 = (lammpsplugin_factory2 *) &fixdplr; (*register_plugin)(&plugin, lmp); -#if LAMMPS_VERSION_NUMBER>=20220328 +#if LAMMPS_VERSION_NUMBER>=20220324 // lammps/lammps# plugin.style = "kspace"; plugin.name = "pppm/dplr"; From f033fbf7cf81e69d28f449014674e980a4035daa Mon Sep 17 00:00:00 2001 From: Yifan Li Date: Fri, 18 Nov 2022 23:37:28 -0500 Subject: [PATCH 4/7] Corrected convert 0.12 to 1.0 --- deepmd/infer/deep_pot.py | 20 ++++++++++++-------- deepmd/utils/convert.py | 25 ++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 9 deletions(-) diff --git a/deepmd/infer/deep_pot.py b/deepmd/infer/deep_pot.py index c1b4da7250..4b8defd913 100644 --- a/deepmd/infer/deep_pot.py +++ b/deepmd/infer/deep_pot.py @@ -123,7 +123,11 @@ def __init__( # now load tensors to object attributes for attr_name, tensor_name in self.tensors.items(): - self._get_tensor(tensor_name, attr_name) + try: + self._get_tensor(tensor_name, attr_name) + except KeyError: + if attr_name != "t_descriptor": + raise self._run_default_sess() self.tmap = self.tmap.decode('UTF-8').split() @@ -353,21 +357,21 @@ def _prepare_feed_dict( feed_dict_test = {} feed_dict_test[self.t_natoms] = natoms_vec if mixed_type: - feed_dict_test[self.t_type] = atom_types.reshape([-1]) + feed_dict_test[self.t_type] = np.reshape(atom_types, [-1]) else: - feed_dict_test[self.t_type] = np.tile(atom_types, [nframes, 1]).reshape([-1]) - feed_dict_test[self.t_coord] = np.reshape(coords, [-1]) - feed_dict_test[self.t_box ] = np.reshape(cells , [-1]) + feed_dict_test[self.t_type] = (np.tile(atom_types, [nframes, 1])).reshape([-1]) + feed_dict_test[self.t_coord] = coords.reshape([-1]) + feed_dict_test[self.t_box ] = cells if self.has_efield: - feed_dict_test[self.t_efield]= np.reshape(efield, [-1]) + feed_dict_test[self.t_efield]= efield if pbc: feed_dict_test[self.t_mesh ] = make_default_mesh(cells) else: feed_dict_test[self.t_mesh ] = np.array([], dtype = np.int32) if self.has_fparam: - feed_dict_test[self.t_fparam] = np.reshape(fparam, [-1]) + feed_dict_test[self.t_fparam] = fparam if self.has_aparam: - feed_dict_test[self.t_aparam] = np.reshape(aparam, [-1]) + feed_dict_test[self.t_aparam] = aparam return feed_dict_test, imap def _eval_inner( diff --git a/deepmd/utils/convert.py b/deepmd/utils/convert.py index ef5663f75a..70f9c24d0e 100644 --- a/deepmd/utils/convert.py +++ b/deepmd/utils/convert.py @@ -138,7 +138,7 @@ def convert_pbtxt_to_pb(pbtxtfile: str, pbfile: str): def convert_dp012_to_dp10(file: str): - """Convert DP 1.0 graph text to 1.1 graph text. + """Convert DP 0.12 graph text to 1.0 graph text. Parameters ---------- @@ -206,6 +206,29 @@ def convert_dp012_to_dp10(file: str): } } """) + file_content += textwrap.dedent("""\ + node { + name: "model_attr/tmap" + op: "Const" + attr { + key: "dtype" + value { + type: DT_STRING + } + } + attr { + key: "value" + value { + tensor { + dtype: DT_STRING + tensor_shape { + } + string_val: "" + } + } + } + } + """) with open(file, 'w') as fp: fp.write(file_content) From 8f98b54b69d74eaadf0f55c5981e0b99e7a7dea6 Mon Sep 17 00:00:00 2001 From: Yifan Li Date: Sat, 4 Feb 2023 18:07:05 -0500 Subject: [PATCH 5/7] change gridcomm to grid3d to support LAMMPS after commit 72b0a2d --- source/lmp/pppm_dplr.cpp | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/source/lmp/pppm_dplr.cpp b/source/lmp/pppm_dplr.cpp index 0abf8fef7a..fbca1a3dc2 100644 --- a/source/lmp/pppm_dplr.cpp +++ b/source/lmp/pppm_dplr.cpp @@ -6,7 +6,11 @@ #include "domain.h" #include "error.h" #include "force.h" +#if LAMMPS_VERSION_NUMBER >= 20221222 +#include "grid3d.h" +#else #include "gridcomm.h" +#endif #include "math_const.h" #include "memory.h" #include "pppm.h" @@ -109,7 +113,10 @@ void PPPMDPLR::compute(int eflag, int vflag) { // to fully sum contribution in their 3d bricks // remap from 3d decomposition to FFT decomposition -#if LAMMPS_VERSION_NUMBER >= 20210831 +#if LAMMPS_VERSION_NUMBER >= 20221222 + gc->reverse_comm(Grid3d::KSPACE,this,REVERSE_RHO,1,sizeof(FFT_SCALAR), + gc_buf1,gc_buf2,MPI_FFT_SCALAR); +#elif LAMMPS_VERSION_NUMBER >= 20210831 && LAMMPS_VERSION_NUMBER < 20221222 gc->reverse_comm(GridComm::KSPACE, this, 1, sizeof(FFT_SCALAR), REVERSE_RHO, gc_buf1, gc_buf2, MPI_FFT_SCALAR); #else @@ -129,7 +136,10 @@ void PPPMDPLR::compute(int eflag, int vflag) { // to fill ghost cells surrounding their 3d bricks if (differentiation_flag == 1) -#if LAMMPS_VERSION_NUMBER >= 20210831 +#if LAMMPS_VERSION_NUMBER >= 20221222 + gc->reverse_comm(Grid3d::KSPACE,this,REVERSE_RHO,1,sizeof(FFT_SCALAR), + gc_buf1,gc_buf2,MPI_FFT_SCALAR); +#elif LAMMPS_VERSION_NUMBER >= 20210831 && LAMMPS_VERSION_NUMBER < 20221222 gc->forward_comm(GridComm::KSPACE, this, 1, sizeof(FFT_SCALAR), FORWARD_AD, gc_buf1, gc_buf2, MPI_FFT_SCALAR); #else @@ -137,7 +147,10 @@ void PPPMDPLR::compute(int eflag, int vflag) { gc_buf2, MPI_FFT_SCALAR); #endif else -#if LAMMPS_VERSION_NUMBER >= 20210831 +#if LAMMPS_VERSION_NUMBER >= 20221222 + gc->forward_comm(Grid3d::KSPACE,this,FORWARD_IK,3,sizeof(FFT_SCALAR), + gc_buf1,gc_buf2,MPI_FFT_SCALAR); +#elif LAMMPS_VERSION_NUMBER >= 20210831 && LAMMPS_VERSION_NUMBER < 20221222 gc->forward_comm(GridComm::KSPACE, this, 3, sizeof(FFT_SCALAR), FORWARD_IK, gc_buf1, gc_buf2, MPI_FFT_SCALAR); #else @@ -149,7 +162,10 @@ void PPPMDPLR::compute(int eflag, int vflag) { if (evflag_atom) { if (differentiation_flag == 1 && vflag_atom) -#if LAMMPS_VERSION_NUMBER >= 20210831 +#if LAMMPS_VERSION_NUMBER >= 20221222 + gc->forward_comm(Grid3d::KSPACE,this,FORWARD_AD_PERATOM,6,sizeof(FFT_SCALAR), + gc_buf1,gc_buf2,MPI_FFT_SCALAR); +#elif LAMMPS_VERSION_NUMBER >= 20210831 && LAMMPS_VERSION_NUMBER < 20221222 gc->forward_comm(GridComm::KSPACE, this, 6, sizeof(FFT_SCALAR), FORWARD_AD_PERATOM, gc_buf1, gc_buf2, MPI_FFT_SCALAR); #else @@ -157,7 +173,10 @@ void PPPMDPLR::compute(int eflag, int vflag) { gc_buf1, gc_buf2, MPI_FFT_SCALAR); #endif else if (differentiation_flag == 0) -#if LAMMPS_VERSION_NUMBER >= 20210831 +#if LAMMPS_VERSION_NUMBER >= 20221222 + gc->forward_comm(Grid3d::KSPACE,this,FORWARD_IK_PERATOM,7,sizeof(FFT_SCALAR), + gc_buf1,gc_buf2,MPI_FFT_SCALAR); +#elif LAMMPS_VERSION_NUMBER >= 20210831 && LAMMPS_VERSION_NUMBER < 20221222 gc->forward_comm(GridComm::KSPACE, this, 7, sizeof(FFT_SCALAR), FORWARD_IK_PERATOM, gc_buf1, gc_buf2, MPI_FFT_SCALAR); #else From 364ca5cd5dd8828a6210924d8d8b48c0f1a72025 Mon Sep 17 00:00:00 2001 From: Yifan Li Date: Sat, 4 Feb 2023 18:22:21 -0500 Subject: [PATCH 6/7] make deep_pot.py consistent with deepmodeling devel branch --- deepmd/infer/deep_pot.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/deepmd/infer/deep_pot.py b/deepmd/infer/deep_pot.py index 8cc42fc47d..1a7a777b70 100644 --- a/deepmd/infer/deep_pot.py +++ b/deepmd/infer/deep_pot.py @@ -429,7 +429,7 @@ def _prepare_feed_dict( feed_dict_test = {} feed_dict_test[self.t_natoms] = natoms_vec if mixed_type: - feed_dict_test[self.t_type] = np.reshape(atom_types, [-1]) + feed_dict_test[self.t_type] = atom_types.reshape([-1]) else: feed_dict_test[self.t_type] = np.tile(atom_types, [nframes, 1]).reshape( [-1] @@ -449,9 +449,9 @@ def _prepare_feed_dict( else: feed_dict_test[self.t_mesh] = np.array([], dtype=np.int32) if self.has_fparam: - feed_dict_test[self.t_fparam] = fparam + feed_dict_test[self.t_fparam] = np.reshape(fparam, [-1]) if self.has_aparam: - feed_dict_test[self.t_aparam] = aparam + feed_dict_test[self.t_aparam] = np.reshape(aparam, [-1]) return feed_dict_test, imap def _eval_inner( From a879a18ed603fe1af12647340210bc5d803768fc Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 4 Feb 2023 23:27:51 +0000 Subject: [PATCH 7/7] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- source/lmp/pppm_dplr.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/source/lmp/pppm_dplr.cpp b/source/lmp/pppm_dplr.cpp index fbca1a3dc2..892688b340 100644 --- a/source/lmp/pppm_dplr.cpp +++ b/source/lmp/pppm_dplr.cpp @@ -114,8 +114,8 @@ void PPPMDPLR::compute(int eflag, int vflag) { // remap from 3d decomposition to FFT decomposition #if LAMMPS_VERSION_NUMBER >= 20221222 - gc->reverse_comm(Grid3d::KSPACE,this,REVERSE_RHO,1,sizeof(FFT_SCALAR), - gc_buf1,gc_buf2,MPI_FFT_SCALAR); + gc->reverse_comm(Grid3d::KSPACE, this, REVERSE_RHO, 1, sizeof(FFT_SCALAR), + gc_buf1, gc_buf2, MPI_FFT_SCALAR); #elif LAMMPS_VERSION_NUMBER >= 20210831 && LAMMPS_VERSION_NUMBER < 20221222 gc->reverse_comm(GridComm::KSPACE, this, 1, sizeof(FFT_SCALAR), REVERSE_RHO, gc_buf1, gc_buf2, MPI_FFT_SCALAR); @@ -137,8 +137,8 @@ void PPPMDPLR::compute(int eflag, int vflag) { if (differentiation_flag == 1) #if LAMMPS_VERSION_NUMBER >= 20221222 - gc->reverse_comm(Grid3d::KSPACE,this,REVERSE_RHO,1,sizeof(FFT_SCALAR), - gc_buf1,gc_buf2,MPI_FFT_SCALAR); + gc->reverse_comm(Grid3d::KSPACE, this, REVERSE_RHO, 1, sizeof(FFT_SCALAR), + gc_buf1, gc_buf2, MPI_FFT_SCALAR); #elif LAMMPS_VERSION_NUMBER >= 20210831 && LAMMPS_VERSION_NUMBER < 20221222 gc->forward_comm(GridComm::KSPACE, this, 1, sizeof(FFT_SCALAR), FORWARD_AD, gc_buf1, gc_buf2, MPI_FFT_SCALAR); @@ -148,8 +148,8 @@ void PPPMDPLR::compute(int eflag, int vflag) { #endif else #if LAMMPS_VERSION_NUMBER >= 20221222 - gc->forward_comm(Grid3d::KSPACE,this,FORWARD_IK,3,sizeof(FFT_SCALAR), - gc_buf1,gc_buf2,MPI_FFT_SCALAR); + gc->forward_comm(Grid3d::KSPACE, this, FORWARD_IK, 3, sizeof(FFT_SCALAR), + gc_buf1, gc_buf2, MPI_FFT_SCALAR); #elif LAMMPS_VERSION_NUMBER >= 20210831 && LAMMPS_VERSION_NUMBER < 20221222 gc->forward_comm(GridComm::KSPACE, this, 3, sizeof(FFT_SCALAR), FORWARD_IK, gc_buf1, gc_buf2, MPI_FFT_SCALAR); @@ -163,8 +163,8 @@ void PPPMDPLR::compute(int eflag, int vflag) { if (evflag_atom) { if (differentiation_flag == 1 && vflag_atom) #if LAMMPS_VERSION_NUMBER >= 20221222 - gc->forward_comm(Grid3d::KSPACE,this,FORWARD_AD_PERATOM,6,sizeof(FFT_SCALAR), - gc_buf1,gc_buf2,MPI_FFT_SCALAR); + gc->forward_comm(Grid3d::KSPACE, this, FORWARD_AD_PERATOM, 6, + sizeof(FFT_SCALAR), gc_buf1, gc_buf2, MPI_FFT_SCALAR); #elif LAMMPS_VERSION_NUMBER >= 20210831 && LAMMPS_VERSION_NUMBER < 20221222 gc->forward_comm(GridComm::KSPACE, this, 6, sizeof(FFT_SCALAR), FORWARD_AD_PERATOM, gc_buf1, gc_buf2, MPI_FFT_SCALAR); @@ -174,8 +174,8 @@ void PPPMDPLR::compute(int eflag, int vflag) { #endif else if (differentiation_flag == 0) #if LAMMPS_VERSION_NUMBER >= 20221222 - gc->forward_comm(Grid3d::KSPACE,this,FORWARD_IK_PERATOM,7,sizeof(FFT_SCALAR), - gc_buf1,gc_buf2,MPI_FFT_SCALAR); + gc->forward_comm(Grid3d::KSPACE, this, FORWARD_IK_PERATOM, 7, + sizeof(FFT_SCALAR), gc_buf1, gc_buf2, MPI_FFT_SCALAR); #elif LAMMPS_VERSION_NUMBER >= 20210831 && LAMMPS_VERSION_NUMBER < 20221222 gc->forward_comm(GridComm::KSPACE, this, 7, sizeof(FFT_SCALAR), FORWARD_IK_PERATOM, gc_buf1, gc_buf2, MPI_FFT_SCALAR);