From 8255fca58fd01eb9b0dd6fc933da75d4fd005d3e Mon Sep 17 00:00:00 2001 From: tomswinburne Date: Tue, 23 Mar 2021 12:30:16 +0100 Subject: [PATCH 01/11] darwin library error --- python/lammps/core.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/python/lammps/core.py b/python/lammps/core.py index be026d5e10..b73360a0b2 100644 --- a/python/lammps/core.py +++ b/python/lammps/core.py @@ -126,13 +126,16 @@ class lammps(object): lib_ext = ".dll" modpath = winpath else: + """ import platform - if platform.system() == "Darwin": + if platform.system() == "Darwin": # this flags an error on MacOSX lib_ext = ".dylib" elif platform.system() == "Windows": lib_ext = ".dll" else: lib_ext = ".so" + """ + lib_ext = ".so" if not self.lib: if name: From 7b87b5c80b61f5177052c8b816a79f17a581d098 Mon Sep 17 00:00:00 2001 From: tomswinburne Date: Sun, 27 Jun 2021 15:46:14 +0200 Subject: [PATCH 02/11] snap scaling --- src/MAKE/Makefile.mpi | 6 ++--- src/SNAP/pair_snap.cpp | 51 +++++++++++++++++++++++++++++------------- src/SNAP/pair_snap.h | 2 ++ 3 files changed, 41 insertions(+), 18 deletions(-) diff --git a/src/MAKE/Makefile.mpi b/src/MAKE/Makefile.mpi index 9776b0153e..7b06320f52 100644 --- a/src/MAKE/Makefile.mpi +++ b/src/MAKE/Makefile.mpi @@ -7,12 +7,12 @@ SHELL = /bin/sh # specify flags and libraries needed for your compiler CC = mpicxx -CCFLAGS = -g -O3 +CCFLAGS = -g -O3 -std=c++11 SHFLAGS = -fPIC DEPFLAGS = -M LINK = mpicxx -LINKFLAGS = -g -O3 +LINKFLAGS = -g -O3 -std=c++11 LIB = SIZE = size @@ -28,7 +28,7 @@ SHLIBFLAGS = -shared -rdynamic # LAMMPS ifdef settings # see possible settings in Section 3.5 of the manual -LMP_INC = -DLAMMPS_GZIP -DLAMMPS_MEMALIGN=64 # -DLAMMPS_CXX98 +LMP_INC = -DLAMMPS_GZIP -DLAMMPS_MEMALIGN=64 -DLAMMPS_EXCEPTIONS # MPI library # see discussion in Section 3.4 of the manual diff --git a/src/SNAP/pair_snap.cpp b/src/SNAP/pair_snap.cpp index b8d8333902..da54847820 100644 --- a/src/SNAP/pair_snap.cpp +++ b/src/SNAP/pair_snap.cpp @@ -65,11 +65,13 @@ PairSNAP::~PairSNAP() memory->destroy(beta); memory->destroy(bispectrum); + delete snaptr; if (allocated) { memory->destroy(setflag); memory->destroy(cutsq); + memory->destroy(scale); } } @@ -178,12 +180,12 @@ void PairSNAP::compute(int eflag, int vflag) snaptr->compute_deidrj(fij); - f[i][0] += fij[0]; - f[i][1] += fij[1]; - f[i][2] += fij[2]; - f[j][0] -= fij[0]; - f[j][1] -= fij[1]; - f[j][2] -= fij[2]; + f[i][0] += fij[0] * scale[itype][itype]; + f[i][1] += fij[1] * scale[itype][itype]; + f[i][2] += fij[2] * scale[itype][itype]; + f[j][0] -= fij[0] * scale[itype][itype]; + f[j][1] -= fij[1] * scale[itype][itype]; + f[j][2] -= fij[2] * scale[itype][itype]; // tally per-atom virial contribution @@ -201,7 +203,7 @@ void PairSNAP::compute(int eflag, int vflag) // evdwl = energy of atom I, sum over coeffs_k * Bi_k double* coeffi = coeffelem[ielem]; - evdwl = coeffi[0]; + evdwl = coeffi[0] * scale[itype][itype] ; // snaptr->copy_bi2bvec(); // E = beta.B + 0.5*B^t.alpha.B @@ -209,7 +211,7 @@ void PairSNAP::compute(int eflag, int vflag) // linear contributions for (int icoeff = 0; icoeff < ncoeff; icoeff++) - evdwl += coeffi[icoeff+1]*bispectrum[ii][icoeff]; + evdwl += coeffi[icoeff+1]*bispectrum[ii][icoeff] * scale[itype][itype]; // quadratic contributions @@ -217,10 +219,10 @@ void PairSNAP::compute(int eflag, int vflag) int k = ncoeff+1; for (int icoeff = 0; icoeff < ncoeff; icoeff++) { double bveci = bispectrum[ii][icoeff]; - evdwl += 0.5*coeffi[k++]*bveci*bveci; + evdwl += 0.5*coeffi[k++]*bveci*bveci * scale[itype][itype]; for (int jcoeff = icoeff+1; jcoeff < ncoeff; jcoeff++) { double bvecj = bispectrum[ii][jcoeff]; - evdwl += coeffi[k++]*bveci*bvecj; + evdwl += coeffi[k++]*bveci*bvecj * scale[itype][itype]; } } } @@ -248,18 +250,18 @@ void PairSNAP::compute_beta() double* coeffi = coeffelem[ielem]; for (int icoeff = 0; icoeff < ncoeff; icoeff++) - beta[ii][icoeff] = coeffi[icoeff+1]; + beta[ii][icoeff] = coeffi[icoeff+1] ; if (quadraticflag) { int k = ncoeff+1; for (int icoeff = 0; icoeff < ncoeff; icoeff++) { double bveci = bispectrum[ii][icoeff]; - beta[ii][icoeff] += coeffi[k]*bveci; + beta[ii][icoeff] += coeffi[k] * bveci ; k++; for (int jcoeff = icoeff+1; jcoeff < ncoeff; jcoeff++) { double bvecj = bispectrum[ii][jcoeff]; - beta[ii][icoeff] += coeffi[k]*bvecj; - beta[ii][jcoeff] += coeffi[k]*bveci; + beta[ii][icoeff] += coeffi[k] * bvecj ; + beta[ii][jcoeff] += coeffi[k] * bveci ; k++; } } @@ -354,7 +356,9 @@ void PairSNAP::allocate() memory->create(setflag,n+1,n+1,"pair:setflag"); memory->create(cutsq,n+1,n+1,"pair:cutsq"); + memory->create(scale,n+1,n+1,"pair:scale"); map = new int[n+1]; + } /* ---------------------------------------------------------------------- @@ -374,6 +378,7 @@ void PairSNAP::settings(int narg, char ** /* arg */) void PairSNAP::coeff(int narg, char **arg) { if (!allocated) allocate(); + if (narg != 4 + atom->ntypes) error->all(FLERR,"Incorrect args for pair coefficients"); map_element2type(narg-4,arg+4); @@ -382,6 +387,8 @@ void PairSNAP::coeff(int narg, char **arg) read_files(arg[2],arg[3]); + + if (!quadraticflag) ncoeff = ncoeffall - 1; else { @@ -408,11 +415,16 @@ void PairSNAP::coeff(int narg, char **arg) } // Calculate maximum cutoff for all elements - rcutmax = 0.0; for (int ielem = 0; ielem < nelements; ielem++) rcutmax = MAX(2.0*radelem[ielem]*rcutfac,rcutmax); + // set default scaling + int n = atom->ntypes; + for (int ii = 0; ii < n+1; ii++) + for (int jj = 0; jj < n+1; jj++) + scale[ii][jj] = 1.0; + } /* ---------------------------------------------------------------------- @@ -441,6 +453,7 @@ void PairSNAP::init_style() double PairSNAP::init_one(int i, int j) { if (setflag[i][j] == 0) error->all(FLERR,"All pair coeffs are not set"); + scale[j][i] = scale[i][j]; return (radelem[map[i]] + radelem[map[j]])*rcutfac; } @@ -711,6 +724,7 @@ double PairSNAP::memory_usage() int n = atom->ntypes+1; bytes += (double)n*n*sizeof(int); // setflag bytes += (double)n*n*sizeof(double); // cutsq + bytes += (double)n*n*sizeof(double); // scale bytes += (double)n*sizeof(int); // map bytes += (double)beta_max*ncoeff*sizeof(double); // bispectrum bytes += (double)beta_max*ncoeff*sizeof(double); // beta @@ -720,3 +734,10 @@ double PairSNAP::memory_usage() return bytes; } + +void *PairSNAP::extract(const char *str, int &dim) +{ + dim = 2; + if (strcmp(str,"scale") == 0) return (void *) scale; + return nullptr; +} diff --git a/src/SNAP/pair_snap.h b/src/SNAP/pair_snap.h index 0cc38ef9cb..afce4bf895 100644 --- a/src/SNAP/pair_snap.h +++ b/src/SNAP/pair_snap.h @@ -34,6 +34,7 @@ class PairSNAP : public Pair { virtual void init_style(); virtual double init_one(int, int); virtual double memory_usage(); + virtual void *extract(const char *, int &); double rcutfac, quadraticflag; // declared public to workaround gcc 4.9 int ncoeff; // compiler bug, manifest in KOKKOS package @@ -55,6 +56,7 @@ class PairSNAP : public Pair { double **coeffelem; // element bispectrum coefficients double **beta; // betas for all atoms in list double **bispectrum; // bispectrum components for all atoms in list + double **scale; // for thermodynamic integration int twojmax, switchflag, bzeroflag, bnormflag; int chemflag, wselfallflag; int chunksize; From 5e3fe19c9f991a8f1ffde16efb6d40a5c53aa42f Mon Sep 17 00:00:00 2001 From: tomswinburne Date: Tue, 29 Jun 2021 10:48:19 +0200 Subject: [PATCH 03/11] revert --- python/lammps/core.py | 11 ++++------- src/MAKE/Makefile.mpi | 6 +++--- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/python/lammps/core.py b/python/lammps/core.py index ea038c0920..d26726b176 100644 --- a/python/lammps/core.py +++ b/python/lammps/core.py @@ -123,17 +123,14 @@ class lammps(object): lib_ext = ".dll" modpath = winpath else: - """ import platform - if platform.system() == "Darwin": # this flags an error on MacOSX + if platform.system() == "Darwin": lib_ext = ".dylib" elif platform.system() == "Windows": lib_ext = ".dll" else: lib_ext = ".so" - """ - lib_ext = ".so" - + if not self.lib: if name: libpath = join(modpath,"liblammps_%s" % name + lib_ext) @@ -1573,8 +1570,8 @@ class lammps(object): """Return a string with detailed information about any devices that are usable by the GPU package. - This is a wrapper around the :cpp:func:`lammps_get_gpu_device_info` - function of the C-library interface. + This is a wrapper around the :cpp:func:`lammps_get_gpu_device_info` + function of the C-library interface. :return: GPU device info string :rtype: string diff --git a/src/MAKE/Makefile.mpi b/src/MAKE/Makefile.mpi index 7b06320f52..756c25c7e0 100644 --- a/src/MAKE/Makefile.mpi +++ b/src/MAKE/Makefile.mpi @@ -7,12 +7,12 @@ SHELL = /bin/sh # specify flags and libraries needed for your compiler CC = mpicxx -CCFLAGS = -g -O3 -std=c++11 +CCFLAGS = -g -O3 SHFLAGS = -fPIC DEPFLAGS = -M LINK = mpicxx -LINKFLAGS = -g -O3 -std=c++11 +LINKFLAGS = -g -O3 LIB = SIZE = size @@ -28,7 +28,7 @@ SHLIBFLAGS = -shared -rdynamic # LAMMPS ifdef settings # see possible settings in Section 3.5 of the manual -LMP_INC = -DLAMMPS_GZIP -DLAMMPS_MEMALIGN=64 -DLAMMPS_EXCEPTIONS +LMP_INC = -DLAMMPS_GZIP -DLAMMPS_MEMALIGN=64 # -DLAMMPS_CXX98 # MPI library # see discussion in Section 3.4 of the manual From 49e8fead3ab7db611b4513a017986a94e04a4833 Mon Sep 17 00:00:00 2001 From: tomswinburne Date: Tue, 29 Jun 2021 10:51:10 +0200 Subject: [PATCH 04/11] revert --- python/lammps/core.py | 2 +- src/MAKE/Makefile.mpi | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/python/lammps/core.py b/python/lammps/core.py index d26726b176..a430052b8c 100644 --- a/python/lammps/core.py +++ b/python/lammps/core.py @@ -130,7 +130,7 @@ class lammps(object): lib_ext = ".dll" else: lib_ext = ".so" - + if not self.lib: if name: libpath = join(modpath,"liblammps_%s" % name + lib_ext) diff --git a/src/MAKE/Makefile.mpi b/src/MAKE/Makefile.mpi index 756c25c7e0..9776b0153e 100644 --- a/src/MAKE/Makefile.mpi +++ b/src/MAKE/Makefile.mpi @@ -28,7 +28,7 @@ SHLIBFLAGS = -shared -rdynamic # LAMMPS ifdef settings # see possible settings in Section 3.5 of the manual -LMP_INC = -DLAMMPS_GZIP -DLAMMPS_MEMALIGN=64 # -DLAMMPS_CXX98 +LMP_INC = -DLAMMPS_GZIP -DLAMMPS_MEMALIGN=64 # -DLAMMPS_CXX98 # MPI library # see discussion in Section 3.4 of the manual From 1a662b78d51a69dae94b16e5313da74d4e26e00f Mon Sep 17 00:00:00 2001 From: tomswinburne Date: Tue, 29 Jun 2021 10:53:02 +0200 Subject: [PATCH 05/11] conform --- python/lammps/core.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/lammps/core.py b/python/lammps/core.py index a430052b8c..88eba735b0 100644 --- a/python/lammps/core.py +++ b/python/lammps/core.py @@ -1570,8 +1570,8 @@ class lammps(object): """Return a string with detailed information about any devices that are usable by the GPU package. - This is a wrapper around the :cpp:func:`lammps_get_gpu_device_info` - function of the C-library interface. + This is a wrapper around the :cpp:func:`lammps_get_gpu_device_info` + function of the C-library interface. :return: GPU device info string :rtype: string From a8be4ca4b8de2b22eba46f9028fbbf07abc4fc1e Mon Sep 17 00:00:00 2001 From: tomswinburne Date: Tue, 29 Jun 2021 11:31:49 +0200 Subject: [PATCH 06/11] cleaner implementation --- src/SNAP/pair_snap.cpp | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/SNAP/pair_snap.cpp b/src/SNAP/pair_snap.cpp index da54847820..c9a6747fe4 100644 --- a/src/SNAP/pair_snap.cpp +++ b/src/SNAP/pair_snap.cpp @@ -180,15 +180,21 @@ void PairSNAP::compute(int eflag, int vflag) snaptr->compute_deidrj(fij); - f[i][0] += fij[0] * scale[itype][itype]; - f[i][1] += fij[1] * scale[itype][itype]; - f[i][2] += fij[2] * scale[itype][itype]; - f[j][0] -= fij[0] * scale[itype][itype]; - f[j][1] -= fij[1] * scale[itype][itype]; - f[j][2] -= fij[2] * scale[itype][itype]; + // scaling + fij[0] *= scale[itype][itype]; + fij[1] *= scale[itype][itype]; + fij[2] *= scale[itype][itype]; + + f[i][0] += fij[0]; + f[i][1] += fij[1]; + f[i][2] += fij[2]; + f[j][0] -= fij[0]; + f[j][1] -= fij[1]; + f[j][2] -= fij[2]; // tally per-atom virial contribution + if (vflag) ev_tally_xyz(i,j,nlocal,newton_pair,0.0,0.0, fij[0],fij[1],fij[2], @@ -203,7 +209,7 @@ void PairSNAP::compute(int eflag, int vflag) // evdwl = energy of atom I, sum over coeffs_k * Bi_k double* coeffi = coeffelem[ielem]; - evdwl = coeffi[0] * scale[itype][itype] ; + evdwl = coeffi[0] ; // snaptr->copy_bi2bvec(); // E = beta.B + 0.5*B^t.alpha.B @@ -211,7 +217,7 @@ void PairSNAP::compute(int eflag, int vflag) // linear contributions for (int icoeff = 0; icoeff < ncoeff; icoeff++) - evdwl += coeffi[icoeff+1]*bispectrum[ii][icoeff] * scale[itype][itype]; + evdwl += coeffi[icoeff+1]*bispectrum[ii][icoeff]; // quadratic contributions @@ -219,13 +225,14 @@ void PairSNAP::compute(int eflag, int vflag) int k = ncoeff+1; for (int icoeff = 0; icoeff < ncoeff; icoeff++) { double bveci = bispectrum[ii][icoeff]; - evdwl += 0.5*coeffi[k++]*bveci*bveci * scale[itype][itype]; + evdwl += 0.5*coeffi[k++]*bveci*bveci; for (int jcoeff = icoeff+1; jcoeff < ncoeff; jcoeff++) { double bvecj = bispectrum[ii][jcoeff]; - evdwl += coeffi[k++]*bveci*bvecj * scale[itype][itype]; + evdwl += coeffi[k++]*bveci*bvecj; } } } + evdwl *= scale[itype][itype]; ev_tally_full(i,2.0*evdwl,0.0,0.0,0.0,0.0,0.0); } From ee751cf040f78ccdc2b7ef180b67b85c5e97c86c Mon Sep 17 00:00:00 2001 From: tomswinburne Date: Tue, 6 Jul 2021 10:33:28 +0200 Subject: [PATCH 07/11] remove whitespace --- src/SNAP/pair_snap.cpp | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/src/SNAP/pair_snap.cpp b/src/SNAP/pair_snap.cpp index c9a6747fe4..1fc4112fdb 100644 --- a/src/SNAP/pair_snap.cpp +++ b/src/SNAP/pair_snap.cpp @@ -65,7 +65,6 @@ PairSNAP::~PairSNAP() memory->destroy(beta); memory->destroy(bispectrum); - delete snaptr; if (allocated) { @@ -180,21 +179,15 @@ void PairSNAP::compute(int eflag, int vflag) snaptr->compute_deidrj(fij); - // scaling - fij[0] *= scale[itype][itype]; - fij[1] *= scale[itype][itype]; - fij[2] *= scale[itype][itype]; - - f[i][0] += fij[0]; - f[i][1] += fij[1]; - f[i][2] += fij[2]; - f[j][0] -= fij[0]; - f[j][1] -= fij[1]; - f[j][2] -= fij[2]; + f[i][0] += fij[0] * scale[itype][itype]; + f[i][1] += fij[1] * scale[itype][itype]; + f[i][2] += fij[2] * scale[itype][itype]; + f[j][0] -= fij[0] * scale[itype][itype]; + f[j][1] -= fij[1] * scale[itype][itype]; + f[j][2] -= fij[2] * scale[itype][itype]; // tally per-atom virial contribution - if (vflag) ev_tally_xyz(i,j,nlocal,newton_pair,0.0,0.0, fij[0],fij[1],fij[2], @@ -209,7 +202,7 @@ void PairSNAP::compute(int eflag, int vflag) // evdwl = energy of atom I, sum over coeffs_k * Bi_k double* coeffi = coeffelem[ielem]; - evdwl = coeffi[0] ; + evdwl = coeffi[0]; // snaptr->copy_bi2bvec(); // E = beta.B + 0.5*B^t.alpha.B @@ -257,18 +250,18 @@ void PairSNAP::compute_beta() double* coeffi = coeffelem[ielem]; for (int icoeff = 0; icoeff < ncoeff; icoeff++) - beta[ii][icoeff] = coeffi[icoeff+1] ; + beta[ii][icoeff] = coeffi[icoeff+1]; if (quadraticflag) { int k = ncoeff+1; for (int icoeff = 0; icoeff < ncoeff; icoeff++) { double bveci = bispectrum[ii][icoeff]; - beta[ii][icoeff] += coeffi[k] * bveci ; + beta[ii][icoeff] += coeffi[k]*bveci; k++; for (int jcoeff = icoeff+1; jcoeff < ncoeff; jcoeff++) { double bvecj = bispectrum[ii][jcoeff]; - beta[ii][icoeff] += coeffi[k] * bvecj ; - beta[ii][jcoeff] += coeffi[k] * bveci ; + beta[ii][icoeff] += coeffi[k]*bvecj; + beta[ii][jcoeff] += coeffi[k]*bveci; k++; } } @@ -385,7 +378,6 @@ void PairSNAP::settings(int narg, char ** /* arg */) void PairSNAP::coeff(int narg, char **arg) { if (!allocated) allocate(); - if (narg != 4 + atom->ntypes) error->all(FLERR,"Incorrect args for pair coefficients"); map_element2type(narg-4,arg+4); @@ -394,8 +386,6 @@ void PairSNAP::coeff(int narg, char **arg) read_files(arg[2],arg[3]); - - if (!quadraticflag) ncoeff = ncoeffall - 1; else { @@ -741,7 +731,6 @@ double PairSNAP::memory_usage() return bytes; } - void *PairSNAP::extract(const char *str, int &dim) { dim = 2; From edf623bc822defc9e36c3f14c226d628709e9cb9 Mon Sep 17 00:00:00 2001 From: tomswinburne Date: Tue, 6 Jul 2021 10:33:46 +0200 Subject: [PATCH 08/11] remove whitespace --- src/SNAP/pair_snap.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/SNAP/pair_snap.cpp b/src/SNAP/pair_snap.cpp index 1fc4112fdb..7221c956c8 100644 --- a/src/SNAP/pair_snap.cpp +++ b/src/SNAP/pair_snap.cpp @@ -179,12 +179,12 @@ void PairSNAP::compute(int eflag, int vflag) snaptr->compute_deidrj(fij); - f[i][0] += fij[0] * scale[itype][itype]; - f[i][1] += fij[1] * scale[itype][itype]; - f[i][2] += fij[2] * scale[itype][itype]; - f[j][0] -= fij[0] * scale[itype][itype]; - f[j][1] -= fij[1] * scale[itype][itype]; - f[j][2] -= fij[2] * scale[itype][itype]; + f[i][0] += fij[0]*scale[itype][itype]; + f[i][1] += fij[1]*scale[itype][itype]; + f[i][2] += fij[2]*scale[itype][itype]; + f[j][0] -= fij[0]*scale[itype][itype]; + f[j][1] -= fij[1]*scale[itype][itype]; + f[j][2] -= fij[2]*scale[itype][itype]; // tally per-atom virial contribution From 2c0b87573fa6b52c89ec0ad73e07436b3b79af3c Mon Sep 17 00:00:00 2001 From: tomswinburne Date: Tue, 6 Jul 2021 10:34:59 +0200 Subject: [PATCH 09/11] remove whitespace --- src/SNAP/pair_snap.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/SNAP/pair_snap.cpp b/src/SNAP/pair_snap.cpp index 7221c956c8..b14f1244c6 100644 --- a/src/SNAP/pair_snap.cpp +++ b/src/SNAP/pair_snap.cpp @@ -353,12 +353,10 @@ void PairSNAP::allocate() { allocated = 1; int n = atom->ntypes; - memory->create(setflag,n+1,n+1,"pair:setflag"); memory->create(cutsq,n+1,n+1,"pair:cutsq"); memory->create(scale,n+1,n+1,"pair:scale"); map = new int[n+1]; - } /* ---------------------------------------------------------------------- From 3675bef2b0380cfb0ce3ff500654cf1c3048b6cc Mon Sep 17 00:00:00 2001 From: tomswinburne Date: Tue, 6 Jul 2021 14:06:27 +0200 Subject: [PATCH 10/11] doc --- doc/src/fix_adapt.rst | 2 + doc/src/fix_adapt_fep.rst | 4 +- .../snap/Ni_Zuo_JPCA2020.quadratic.snapcoeff | 1 + .../snap/Ni_Zuo_JPCA2020.quadratic.snapparam | 1 + examples/snap/Ni_Zuo_JPCA2020.snapcoeff | 1 + examples/snap/Ni_Zuo_JPCA2020.snapparam | 1 + examples/snap/in.snap.scale.Ni_Zuo_JCPA2020 | 53 +++++++++++++++++++ src/SNAP/pair_snap.cpp | 1 + 8 files changed, 63 insertions(+), 1 deletion(-) create mode 120000 examples/snap/Ni_Zuo_JPCA2020.quadratic.snapcoeff create mode 120000 examples/snap/Ni_Zuo_JPCA2020.quadratic.snapparam create mode 120000 examples/snap/Ni_Zuo_JPCA2020.snapcoeff create mode 120000 examples/snap/Ni_Zuo_JPCA2020.snapparam create mode 100644 examples/snap/in.snap.scale.Ni_Zuo_JCPA2020 diff --git a/doc/src/fix_adapt.rst b/doc/src/fix_adapt.rst index aa34516d52..a110d93a8d 100644 --- a/doc/src/fix_adapt.rst +++ b/doc/src/fix_adapt.rst @@ -188,6 +188,8 @@ formulas for the meaning of these parameters: +------------------------------------------------------------------------------+--------------------------------------------------+-------------+ | :doc:`reax/c ` | chi, eta, gamma | type global | +------------------------------------------------------------------------------+--------------------------------------------------+-------------+ +| :doc:`snap ` | scale | type pairs | ++------------------------------------------------------------------------------+--------------------------------------------------+-------------+ | :doc:`spin/dmi ` | coulombic_cutoff | type global | +------------------------------------------------------------------------------+--------------------------------------------------+-------------+ | :doc:`spin/exchange ` | coulombic_cutoff | type global | diff --git a/doc/src/fix_adapt_fep.rst b/doc/src/fix_adapt_fep.rst index 81a34ab75e..ce374a29cb 100644 --- a/doc/src/fix_adapt_fep.rst +++ b/doc/src/fix_adapt_fep.rst @@ -173,10 +173,12 @@ styles and their energy formulas for the meaning of these parameters: +------------------------------------------------------------------------------+-------------------------+------------+ | :doc:`nm/cut/coul/cut, nm/cut/coul/long ` | e0,r0,nn,mm | type pairs | +------------------------------------------------------------------------------+-------------------------+------------+ -| :doc:`ufm ` | epsilon,sigma,scale | type pairs | +| :doc:`snap ` | scale | type pairs | +------------------------------------------------------------------------------+-------------------------+------------+ | :doc:`soft ` | a | type pairs | +------------------------------------------------------------------------------+-------------------------+------------+ +| :doc:`ufm ` | epsilon,sigma,scale | type pairs | ++------------------------------------------------------------------------------+-------------------------+------------+ .. note:: diff --git a/examples/snap/Ni_Zuo_JPCA2020.quadratic.snapcoeff b/examples/snap/Ni_Zuo_JPCA2020.quadratic.snapcoeff new file mode 120000 index 0000000000..9401393007 --- /dev/null +++ b/examples/snap/Ni_Zuo_JPCA2020.quadratic.snapcoeff @@ -0,0 +1 @@ +../../potentials/Ni_Zuo_JPCA2020.quadratic.snapcoeff \ No newline at end of file diff --git a/examples/snap/Ni_Zuo_JPCA2020.quadratic.snapparam b/examples/snap/Ni_Zuo_JPCA2020.quadratic.snapparam new file mode 120000 index 0000000000..a47ada019b --- /dev/null +++ b/examples/snap/Ni_Zuo_JPCA2020.quadratic.snapparam @@ -0,0 +1 @@ +../../potentials/Ni_Zuo_JPCA2020.quadratic.snapparam \ No newline at end of file diff --git a/examples/snap/Ni_Zuo_JPCA2020.snapcoeff b/examples/snap/Ni_Zuo_JPCA2020.snapcoeff new file mode 120000 index 0000000000..7211856b43 --- /dev/null +++ b/examples/snap/Ni_Zuo_JPCA2020.snapcoeff @@ -0,0 +1 @@ +../../potentials/Ni_Zuo_JPCA2020.snapcoeff \ No newline at end of file diff --git a/examples/snap/Ni_Zuo_JPCA2020.snapparam b/examples/snap/Ni_Zuo_JPCA2020.snapparam new file mode 120000 index 0000000000..b7fc095fab --- /dev/null +++ b/examples/snap/Ni_Zuo_JPCA2020.snapparam @@ -0,0 +1 @@ +../../potentials/Ni_Zuo_JPCA2020.snapparam \ No newline at end of file diff --git a/examples/snap/in.snap.scale.Ni_Zuo_JCPA2020 b/examples/snap/in.snap.scale.Ni_Zuo_JCPA2020 new file mode 100644 index 0000000000..ee195c11f3 --- /dev/null +++ b/examples/snap/in.snap.scale.Ni_Zuo_JCPA2020 @@ -0,0 +1,53 @@ +# Toy demonstration of SNAP "scale" parameter, using fix/adapt and hybrid/overlay +# Mixing linear and quadratic SNAP Ni potentials by Zuo et al. JCPA 2020 + +# mixing parameter + +variable lambda equal 0.2 + + +# Initialize simulation + +variable nsteps index 100 +variable nrep equal 3 +variable a equal 3.52 +units metal + +# generate the box and atom positions using a FCC lattice +variable nx equal ${nrep} +variable ny equal ${nrep} +variable nz equal ${nrep} + +boundary p p p + +lattice fcc $a +region box block 0 ${nx} 0 ${ny} 0 ${nz} +create_box 1 box +create_atoms 1 box + +mass 1 34. + +# choose bundled SNAP Ni potential from Zuo et al. JCPA 2020 +pair_style hybrid/overlay snap snap +pair_coeff * * snap 1 Ni_Zuo_JPCA2020.snapcoeff Ni_Zuo_JPCA2020.snapparam Ni +pair_coeff * * snap 2 Ni_Zuo_JPCA2020.quadratic.snapcoeff Ni_Zuo_JPCA2020.quadratic.snapparam Ni + +# scale according to mixing parameter +variable l1 equal ${lambda} +variable l2 equal 1.0-${lambda} +fix scale1 all adapt 1 pair snap:1 scale * * v_l1 +fix scale2 all adapt 1 pair snap:2 scale * * v_l2 + +# Setup output +thermo 1 +thermo_modify norm yes + +# Set up NVE run +timestep 0.5e-3 +neighbor 1.0 bin +neigh_modify every 1 delay 0 check yes + +# Run MD +velocity all create 300.0 4928459 loop geom +fix 1 all nve +run ${nsteps} diff --git a/src/SNAP/pair_snap.cpp b/src/SNAP/pair_snap.cpp index b14f1244c6..dd023e096c 100644 --- a/src/SNAP/pair_snap.cpp +++ b/src/SNAP/pair_snap.cpp @@ -165,6 +165,7 @@ void PairSNAP::compute(int eflag, int vflag) // for neighbors of I within cutoff: // compute Fij = dEi/dRj = -dEi/dRi // add to Fi, subtract from Fj + // scaling is that for type I snaptr->compute_yi(beta[ii]); From 40e83088b0c3e2865cda9735807318090751337d Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 6 Jul 2021 11:11:35 -0400 Subject: [PATCH 11/11] update SNAP unit tests for added extract keyword --- unittest/force-styles/tests/manybody-pair-snap.yaml | 3 ++- unittest/force-styles/tests/manybody-pair-snap_chem.yaml | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/unittest/force-styles/tests/manybody-pair-snap.yaml b/unittest/force-styles/tests/manybody-pair-snap.yaml index 139d1b94d0..57e0e9d599 100644 --- a/unittest/force-styles/tests/manybody-pair-snap.yaml +++ b/unittest/force-styles/tests/manybody-pair-snap.yaml @@ -14,7 +14,8 @@ pair_style: hybrid/overlay zbl 4.0 4.8 snap pair_coeff: ! | 1*8 1*8 zbl 73 73 * * snap Ta06A.snapcoeff Ta06A.snapparam Ta Ta Ta Ta Ta Ta Ta Ta -extract: ! "" +extract: ! | + scale 2 natoms: 64 init_vdwl: -473.569864629026 init_coul: 0 diff --git a/unittest/force-styles/tests/manybody-pair-snap_chem.yaml b/unittest/force-styles/tests/manybody-pair-snap_chem.yaml index 39d2abd804..b97709863e 100644 --- a/unittest/force-styles/tests/manybody-pair-snap_chem.yaml +++ b/unittest/force-styles/tests/manybody-pair-snap_chem.yaml @@ -16,7 +16,8 @@ pair_coeff: ! | 1*4 5*8 zbl 49 15 5*8 5*8 zbl 15 15 * * snap InP_JCPA2020.snapcoeff InP_JCPA2020.snapparam In In In In P P P P -extract: ! "" +extract: ! | + scale 2 natoms: 64 init_vdwl: -185.3871232982 init_coul: 0