From 1dd4a67771ec590ba9708f9b86d6c573d23df80a Mon Sep 17 00:00:00 2001 From: Wengen Ouyang Date: Fri, 3 Dec 2021 17:32:08 +0200 Subject: [PATCH] add keyword for userdefined maxdelcs --- doc/src/pair_sw.rst | 12 +++++++-- examples/sw/in.mos2.sw.mod | 2 +- examples/sw/log.27Oct21.mos2_sw_mod.g++.1 | 30 +++++++++++------------ src/MANYBODY/pair_sw.h | 2 +- src/MANYBODY/pair_sw_mod.cpp | 28 ++++++++++++++++++--- src/MANYBODY/pair_sw_mod.h | 3 +++ 6 files changed, 53 insertions(+), 24 deletions(-) diff --git a/doc/src/pair_sw.rst b/doc/src/pair_sw.rst index 4c62ce3d12..385654344e 100644 --- a/doc/src/pair_sw.rst +++ b/doc/src/pair_sw.rst @@ -21,9 +21,17 @@ Syntax .. code-block:: LAMMPS - pair_style style + pair_style style keyword values * style = *sw* or *sw/mod* +* keyword = *maxdelcs* + + .. parsed-literal:: + + *maxdelcs* value = delta1 delta2 + delta1 = The minimum thershold for cosine of three-body angle + delta2 = The maximum threshold for cosine of three-body angle + Examples """""""" @@ -34,7 +42,7 @@ Examples pair_coeff * * si.sw Si pair_coeff * * GaN.sw Ga N Ga - pair_style sw/mod + pair_style sw/mod maxdelcs 0.25 0.35 pair_coeff * * tmd.sw.mod Mo S S Description diff --git a/examples/sw/in.mos2.sw.mod b/examples/sw/in.mos2.sw.mod index d7f478413f..8fc0991d7f 100644 --- a/examples/sw/in.mos2.sw.mod +++ b/examples/sw/in.mos2.sw.mod @@ -10,7 +10,7 @@ mass * 32.065 # mass of sulphur atom , uint: a.u.=1.66X10^(-27)kg mass 1 95.94 # mass of molebdenum atom , uint: a.u.=1.66X10^(-27)kg ########################## Define potentials ################################ -pair_style sw/mod +pair_style sw/mod maxdelcs 0.25 0.35 pair_coeff * * tmd.sw.mod Mo S S ######################################################################### diff --git a/examples/sw/log.27Oct21.mos2_sw_mod.g++.1 b/examples/sw/log.27Oct21.mos2_sw_mod.g++.1 index bc6b97c053..2ecce024aa 100644 --- a/examples/sw/log.27Oct21.mos2_sw_mod.g++.1 +++ b/examples/sw/log.27Oct21.mos2_sw_mod.g++.1 @@ -1,6 +1,4 @@ -LAMMPS (30 Jul 2021) -OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (../comm.cpp:98) - using 1 OpenMP thread(s) per MPI task +LAMMPS (27 Oct 2021) # monolayer MoS2 units metal boundary p p f @@ -21,15 +19,15 @@ Finding 1-2 1-3 1-4 neighbors ... 0 = max # of 1-4 neighbors 1 = max # of special neighbors special bonds CPU = 0.001 seconds - read_data CPU = 0.005 seconds + read_data CPU = 0.009 seconds mass * 32.065 # mass of sulphur atom , uint: a.u.=1.66X10^(-27)kg mass 1 95.94 # mass of molebdenum atom , uint: a.u.=1.66X10^(-27)kg ########################## Define potentials ################################ -pair_style sw/mod +pair_style sw/mod maxdelcs 0.25 0.35 pair_coeff * * tmd.sw.mod Mo S S -Reading sw/mod potential file tmd.sw.mod with DATE: 2018-03-26 +Reading sw potential file tmd.sw.mod with DATE: 2018-03-26 ######################################################################### ### Simulation settings #### @@ -71,21 +69,21 @@ Step TotEng PotEng KinEng Temp 4000 -899.28397 -920.50737 21.223397 214.06955 4500 -899.28386 -919.79154 20.507685 206.85053 5000 -899.28077 -918.78947 19.508698 196.77425 -Loop time of 2.88628 on 1 procs for 5000 steps with 768 atoms +Loop time of 3.13658 on 1 procs for 5000 steps with 768 atoms -Performance: 149.674 ns/day, 0.160 hours/ns, 1732.334 timesteps/s -99.7% CPU use with 1 MPI tasks x 1 OpenMP threads +Performance: 137.730 ns/day, 0.174 hours/ns, 1594.094 timesteps/s +100.0% CPU use with 1 MPI tasks x no OpenMP threads MPI task timing breakdown: Section | min time | avg time | max time |%varavg| %total --------------------------------------------------------------- -Pair | 2.8297 | 2.8297 | 2.8297 | 0.0 | 98.04 -Bond | 0.00028899 | 0.00028899 | 0.00028899 | 0.0 | 0.01 +Pair | 3.0504 | 3.0504 | 3.0504 | 0.0 | 97.25 +Bond | 0.00073783 | 0.00073783 | 0.00073783 | 0.0 | 0.02 Neigh | 0 | 0 | 0 | 0.0 | 0.00 -Comm | 0.0095191 | 0.0095191 | 0.0095191 | 0.0 | 0.33 -Output | 0.0002787 | 0.0002787 | 0.0002787 | 0.0 | 0.01 -Modify | 0.034603 | 0.034603 | 0.034603 | 0.0 | 1.20 -Other | | 0.01188 | | | 0.41 +Comm | 0.013033 | 0.013033 | 0.013033 | 0.0 | 0.42 +Output | 0.00081458 | 0.00081458 | 0.00081458 | 0.0 | 0.03 +Modify | 0.048235 | 0.048235 | 0.048235 | 0.0 | 1.54 +Other | | 0.02334 | | | 0.74 Nlocal: 768.000 ave 768 max 768 min Histogram: 1 0 0 0 0 0 0 0 0 0 @@ -101,4 +99,4 @@ Ave neighs/atom = 26.666667 Ave special neighs/atom = 0.0000000 Neighbor list builds = 0 Dangerous builds = 0 -Total wall time: 0:00:02 +Total wall time: 0:00:03 diff --git a/src/MANYBODY/pair_sw.h b/src/MANYBODY/pair_sw.h index 4aec682989..6509c460d6 100644 --- a/src/MANYBODY/pair_sw.h +++ b/src/MANYBODY/pair_sw.h @@ -29,7 +29,6 @@ class PairSW : public Pair { PairSW(class LAMMPS *); virtual ~PairSW(); virtual void compute(int, int); - void settings(int, char **); virtual void coeff(int, char **); virtual double init_one(int, int); virtual void init_style(); @@ -54,6 +53,7 @@ class PairSW : public Pair { int maxshort; // size of short neighbor list array int *neighshort; // short neighbor list array + virtual void settings(int, char **); virtual void allocate(); void read_file(char *); virtual void setup_params(); diff --git a/src/MANYBODY/pair_sw_mod.cpp b/src/MANYBODY/pair_sw_mod.cpp index cf6bd14de6..24b2408beb 100644 --- a/src/MANYBODY/pair_sw_mod.cpp +++ b/src/MANYBODY/pair_sw_mod.cpp @@ -18,6 +18,7 @@ #include "pair_sw_mod.h" +#include "error.h" #include "math_const.h" #include @@ -30,6 +31,26 @@ using namespace MathConst; PairSWMOD::PairSWMOD(LAMMPS *lmp) : PairSW(lmp) {} +/* ---------------------------------------------------------------------- + global settings +------------------------------------------------------------------------- */ + +void PairSWMOD::settings(int narg, char **arg) +{ + // process optional keywords + + int iarg = 0; + + while (iarg < narg) { + if (strcmp(arg[iarg],"maxdelcs") == 0) { + if (iarg+3 > narg) error->all(FLERR,"Illegal pair_style command"); + delta1 = utils::numeric(FLERR,arg[iarg+1],false,lmp); + delta2 = utils::numeric(FLERR,arg[iarg+2],false,lmp); + iarg += 3; + } else error->all(FLERR,"Illegal pair_style command"); + } +} + /* ---------------------------------------------------------------------- */ void PairSWMOD::threebody(Param *paramij, Param *paramik, Param *paramijk, @@ -40,8 +61,7 @@ void PairSWMOD::threebody(Param *paramij, Param *paramik, Param *paramijk, double r1,rinvsq1,rainv1,gsrainv1,gsrainvsq1,expgsrainv1; double r2,rinvsq2,rainv2,gsrainv2,gsrainvsq2,expgsrainv2; double rinv12,cs,delcs,delcssq,facexp,facrad,frad1,frad2; - double facang,facang12,csfacang,csfac1,csfac2; - double delta1,delta2,factor; + double facang,facang12,csfacang,csfac1,csfac2,factor; r1 = sqrt(rsq1); rinvsq1 = 1.0/rsq1; @@ -61,8 +81,8 @@ void PairSWMOD::threebody(Param *paramij, Param *paramik, Param *paramijk, cs = (delr1[0]*delr2[0] + delr1[1]*delr2[1] + delr1[2]*delr2[2]) * rinv12; delcs = cs - paramijk->costheta; // Modification to delcs - delta1 = 0.25; - delta2 = 0.35; + //delta1 = 0.25; + //delta2 = 0.35; if(fabs(delcs) >= delta2) delcs = 0.0; else if(fabs(delcs) < delta2 && fabs(delcs) > delta1) { factor = 0.5 + 0.5*cos(MY_PI*(delcs - delta1)/(delta2 - delta1)); diff --git a/src/MANYBODY/pair_sw_mod.h b/src/MANYBODY/pair_sw_mod.h index 2545f689ac..5f01af7964 100644 --- a/src/MANYBODY/pair_sw_mod.h +++ b/src/MANYBODY/pair_sw_mod.h @@ -30,6 +30,9 @@ class PairSWMOD : public PairSW { ~PairSWMOD() {} protected: + double delta1; + double delta2; + void settings(int, char **); void threebody(Param *, Param *, Param *, double, double, double *, double *, double *, double *, int, double &); };