From 8e995f29bdb3d1d67e07bf59958d482d748dfb0d Mon Sep 17 00:00:00 2001 From: athomps Date: Sat, 4 Oct 2008 02:38:52 +0000 Subject: [PATCH] Added vel keyword to fix_styles wall_lj93 and wall_lj126 git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@2151 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- doc/fix_wall_lj126.txt | 19 +++++++++++++++++-- doc/fix_wall_lj93.txt | 21 ++++++++++++++++++--- src/fix_wall_lj126.cpp | 26 +++++++++++++++++++++++--- src/fix_wall_lj126.h | 1 + src/fix_wall_lj93.cpp | 23 +++++++++++++++++++++-- src/fix_wall_lj93.h | 1 + 6 files changed, 81 insertions(+), 10 deletions(-) diff --git a/doc/fix_wall_lj126.txt b/doc/fix_wall_lj126.txt index 99627b3f29..e77969b67f 100644 --- a/doc/fix_wall_lj126.txt +++ b/doc/fix_wall_lj126.txt @@ -10,7 +10,7 @@ fix wall/lj126 command :h3 [Syntax:] -fix ID group-ID wall/lj126 style coord epsilon sigma cutoff :pre +fix ID group-ID wall/lj126 style coord epsilon sigma cutoff keyword values ... :pre ID, group-ID are documented in "fix"_fix.html command wall/lj126 = style name of this fix command @@ -19,10 +19,16 @@ coord = position of wall epsilon = Lennard-Jones epsilon for wall-particle interaction sigma = Lennard-Jones sigma for wall-particle interaction cutoff = distance from wall at which wall-particle interaction is cut off :ul +one or more keyword/value pairs may be appended :l +keyword = {vel} :l + {vel} args = v + v = velocity of wall (velocity units) +:ule [Examples:] fix wallhi all wall/lj126 xhi 10.0 1.0 1.0 1.12 :pre +fix leftwall all wall/lj126 zlo 0.0 1.0 1.0 0.858 vel 1.0 [Description:] @@ -41,6 +47,12 @@ provided by the "fix wall/lj93"_fix_wall_lj93.html command. The wall potential is shifted so that the energy of a wall-particle interaction is 0.0 at the cutoff distance. +If the {vel} keyword is specified, the position of wall will move during the +simulation, based on its initial position (coord) and the specified +velocity (vel). Note that if you do multiple runs, the initial position +of the indenter (x,y,z) does not change, so it will continue to move +at the specified velocity. + [Restart, fix_modify, output, run start/stop, minimize info:] No information about this fix is written to "binary restart @@ -77,4 +89,7 @@ Any dimension (xyz) that has a LJ 12/6 wall must be non-periodic. "fix wall/reflect"_fix_wall_reflect.html, "fix wall/lj93"_fix_wall_lj93.html -[Default:] none +[Default:] + +The option defaults are vel = 0. + diff --git a/doc/fix_wall_lj93.txt b/doc/fix_wall_lj93.txt index bfff4ef17c..3faecd30ba 100644 --- a/doc/fix_wall_lj93.txt +++ b/doc/fix_wall_lj93.txt @@ -10,7 +10,7 @@ fix wall/lj93 command :h3 [Syntax:] -fix ID group-ID wall/lj93 style coord epsilon sigma cutoff :pre +fix ID group-ID wall/lj93 style coord epsilon sigma cutoff keyword values ... :pre ID, group-ID are documented in "fix"_fix.html command wall/lj93 = style name of this fix command @@ -18,11 +18,17 @@ style = {xlo} or {xhi} or {ylo} or {yhi} or {zlo} or {zhi} coord = position of wall epsilon = Lennard-Jones epsilon for wall-particle interaction sigma = Lennard-Jones sigma for wall-particle interaction -cutoff = distance from wall at which wall-particle interaction is cut off :ul +cutoff = distance from wall at which wall-particle interaction is cut off :l +one or more keyword/value pairs may be appended :l +keyword = {vel} :l + {vel} args = v + v = velocity of wall (velocity units) +:ule [Examples:] fix wallhi all wall/lj93 xhi 10.0 1.0 1.0 2.5 :pre +fix leftwall all wall/lj93 zlo 0.0 1.0 1.0 0.858 vel 1.0 [Description:] @@ -42,6 +48,12 @@ wall/lj126"_fix_wall_lj126.html command. The wall potential is shifted so that the energy of a wall-particle interaction is 0.0 at the cutoff distance. +If the {vel} keyword is specified, the position of wall will move during the +simulation, based on its initial position (coord) and the specified +velocity (vel). Note that if you do multiple runs, the initial position +of the indenter (x,y,z) does not change, so it will continue to move +at the specified velocity. + [Restart, fix_modify, output, run start/stop, minimize info:] No information about this fix is written to "binary restart @@ -78,4 +90,7 @@ Any dimension (xyz) that has a LJ 9/3 wall must be non-periodic. "fix wall/reflect"_fix_wall_reflect.html, "fix wall/lj126"_fix_wall_lj126.html -[Default:] none +[Default:] + +The option defaults are vel = 0. + diff --git a/src/fix_wall_lj126.cpp b/src/fix_wall_lj126.cpp index 6da5f511ae..3b39ecb6bf 100644 --- a/src/fix_wall_lj126.cpp +++ b/src/fix_wall_lj126.cpp @@ -33,7 +33,7 @@ using namespace LAMMPS_NS; FixWallLJ126::FixWallLJ126(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg) { - if (narg != 8) error->all("Illegal fix wall/lj126 command"); + if (narg < 8) error->all("Illegal fix wall/lj126 command"); scalar_flag = 1; vector_flag = 1; @@ -42,7 +42,11 @@ FixWallLJ126::FixWallLJ126(LAMMPS *lmp, int narg, char **arg) : extscalar = 1; extvector = 1; - if (strcmp(arg[3],"xlo") == 0) { + // set defaults + + vel = 0.0; + +if (strcmp(arg[3],"xlo") == 0) { dim = 0; side = -1; } else if (strcmp(arg[3],"xhi") == 0) { @@ -62,11 +66,20 @@ FixWallLJ126::FixWallLJ126(LAMMPS *lmp, int narg, char **arg) : side = 1; } else error->all("Illegal fix wall/lj126 command"); - coord = atof(arg[4]); + coord0 = atof(arg[4]); epsilon = atof(arg[5]); sigma = atof(arg[6]); cutoff = atof(arg[7]); + int iarg = 8; + while (iarg < narg) { + if (strcmp(arg[iarg],"vel") == 0) { + if (iarg+2 > narg) error->all("Illegal fix wall/lj126 command"); + vel = atof(arg[iarg+1]); + iarg += 2; + } else error->all("Illegal fix wall/lj126 command"); + } + coeff1 = 48.0 * epsilon * pow(sigma,12.0); coeff2 = 24.0 * epsilon * pow(sigma,6.0); coeff3 = 4.0 * epsilon * pow(sigma,12.0); @@ -140,6 +153,13 @@ void FixWallLJ126::post_force(int vflag) wall[0] = wall[1] = wall[2] = wall[3] = 0.0; wall_flag = 0; + // coord = current position of wall + // coord0 = initial position of wall + + double delt = (update->ntimestep - update->beginstep) * update->dt; + double coord = coord0 + delt*vel; + + for (int i = 0; i < nlocal; i++) if (mask[i] & groupbit) { if (side == -1) delta = x[i][dim] - coord; diff --git a/src/fix_wall_lj126.h b/src/fix_wall_lj126.h index 39678cc8fd..b31a8089f4 100644 --- a/src/fix_wall_lj126.h +++ b/src/fix_wall_lj126.h @@ -36,6 +36,7 @@ class FixWallLJ126 : public Fix { double coord,epsilon,sigma,cutoff; double coeff1,coeff2,coeff3,coeff4,offset; double wall[4],wall_all[4]; + double vel,coord0; int wall_flag; int nlevels_respa; }; diff --git a/src/fix_wall_lj93.cpp b/src/fix_wall_lj93.cpp index 34cb4fd09b..716c43caa7 100644 --- a/src/fix_wall_lj93.cpp +++ b/src/fix_wall_lj93.cpp @@ -29,7 +29,7 @@ using namespace LAMMPS_NS; FixWallLJ93::FixWallLJ93(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg) { - if (narg != 8) error->all("Illegal fix wall/lj93 command"); + if (narg < 8) error->all("Illegal fix wall/lj93 command"); scalar_flag = 1; vector_flag = 1; @@ -38,6 +38,10 @@ FixWallLJ93::FixWallLJ93(LAMMPS *lmp, int narg, char **arg) : extscalar = 1; extvector = 1; + // set defaults + + vel = 0.0; + if (strcmp(arg[3],"xlo") == 0) { dim = 0; side = -1; @@ -58,11 +62,20 @@ FixWallLJ93::FixWallLJ93(LAMMPS *lmp, int narg, char **arg) : side = 1; } else error->all("Illegal fix wall/lj93 command"); - coord = atof(arg[4]); + coord0 = atof(arg[4]); epsilon = atof(arg[5]); sigma = atof(arg[6]); cutoff = atof(arg[7]); + int iarg = 8; + while (iarg < narg) { + if (strcmp(arg[iarg],"vel") == 0) { + if (iarg+2 > narg) error->all("Illegal fix wall/lj93 command"); + vel = atof(arg[iarg+1]); + iarg += 2; + } else error->all("Illegal fix wall/lj93 command"); + } + coeff1 = 6.0/5.0 * epsilon * pow(sigma,9.0); coeff2 = 3.0 * epsilon * pow(sigma,3.0); coeff3 = 2.0/15.0 * epsilon * pow(sigma,9.0); @@ -137,6 +150,12 @@ void FixWallLJ93::post_force(int vflag) wall[0] = wall[1] = wall[2] = wall[3] = 0.0; wall_flag = 0; + // coord = current position of wall + // coord0 = initial position of wall + + double delt = (update->ntimestep - update->beginstep) * update->dt; + double coord = coord0 + delt*vel; + for (int i = 0; i < nlocal; i++) if (mask[i] & groupbit) { if (side == -1) delta = x[i][dim] - coord; diff --git a/src/fix_wall_lj93.h b/src/fix_wall_lj93.h index b5a5986086..1836a7f1ad 100644 --- a/src/fix_wall_lj93.h +++ b/src/fix_wall_lj93.h @@ -37,6 +37,7 @@ class FixWallLJ93 : public Fix { double coord,epsilon,sigma,cutoff; double coeff1,coeff2,coeff3,coeff4,offset; double wall[4],wall_all[4]; + double vel,coord0; int wall_flag; int nlevels_respa; };