forked from lijiext/lammps
small edits for reformatting
This commit is contained in:
parent
51efee43be
commit
aa70f8cc6b
|
@ -1,266 +1,274 @@
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||||
http://lammps.sandia.gov, Sandia National Laboratories
|
http://lammps.sandia.gov, Sandia National Laboratories
|
||||||
Steve Plimpton, sjplimp@sandia.gov
|
Steve Plimpton, sjplimp@sandia.gov
|
||||||
|
|
||||||
Copyright (2003) Sandia Corporation. Under the terms of Contract
|
Copyright (2003) Sandia Corporation. Under the terms of Contract
|
||||||
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
|
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
|
||||||
certain rights in this software. This software is distributed under
|
certain rights in this software. This software is distributed under
|
||||||
the GNU General Public License.
|
the GNU General Public License.
|
||||||
|
|
||||||
See the README file in the top-level LAMMPS directory.
|
See the README file in the top-level LAMMPS directory.
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
#include "fix_wall_reflect_stochastic.h"
|
#include "fix_wall_reflect_stochastic.h"
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include "atom.h"
|
#include "atom.h"
|
||||||
#include "comm.h"
|
#include "comm.h"
|
||||||
#include "update.h"
|
#include "update.h"
|
||||||
#include "modify.h"
|
#include "modify.h"
|
||||||
#include "domain.h"
|
#include "domain.h"
|
||||||
#include "lattice.h"
|
#include "force.h"
|
||||||
#include "input.h"
|
#include "lattice.h"
|
||||||
#include "variable.h"
|
#include "input.h"
|
||||||
#include "error.h"
|
#include "variable.h"
|
||||||
#include "force.h"
|
#include "random_mars.h"
|
||||||
#include "random_mars.h"
|
#include "error.h"
|
||||||
|
|
||||||
|
using namespace LAMMPS_NS;
|
||||||
using namespace LAMMPS_NS;
|
using namespace FixConst;
|
||||||
using namespace FixConst;
|
|
||||||
|
enum{NONE=0,DIFFUSIVE=1,MAXWELL=2,CERCIGNANILAMPIS=3};
|
||||||
enum{NONE=0,DIFFUSIVE=1,MAXWELL=2,CERCIGNANILAMPIS=3};
|
|
||||||
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
FixWallReflectStochastic::
|
||||||
|
FixWallReflectStochastic(LAMMPS *lmp, int narg, char **arg) :
|
||||||
FixWallReflectStochastic::FixWallReflectStochastic(LAMMPS *lmp, int narg, char **arg) :
|
FixWallReflect(lmp, narg, arg), random(NULL)
|
||||||
FixWallReflect(lmp, narg, arg), random(NULL)
|
{
|
||||||
{
|
if (narg < 8) error->all(FLERR,"Illegal fix wall/reflect/stochastic command");
|
||||||
int arginc,dir;
|
|
||||||
|
if (domain->triclinic != 0)
|
||||||
if (narg < 8) error->all(FLERR,"Illegal fix wall/reflect/stochastic command");
|
error->all(FLERR, "Fix wall/reflect/stochastic cannot be used with "
|
||||||
|
"triclinic simulation box");
|
||||||
if (domain->triclinic != 0) error->all(FLERR, "This fix wall/reflect/stochastic is not incompatible with triclinic simulation box");
|
|
||||||
|
dynamic_group_allow = 1;
|
||||||
dynamic_group_allow = 1;
|
|
||||||
|
// parse args
|
||||||
// parse args
|
|
||||||
|
int arginc;
|
||||||
nwall = 0;
|
|
||||||
int scaleflag = 1;
|
nwall = 0;
|
||||||
reflectionstyle = NONE;
|
int scaleflag = 1;
|
||||||
|
reflectionstyle = NONE;
|
||||||
|
|
||||||
if (strcmp(arg[3],"diffusive") == 0) {
|
if (strcmp(arg[3],"diffusive") == 0) {
|
||||||
reflectionstyle = DIFFUSIVE;
|
reflectionstyle = DIFFUSIVE;
|
||||||
arginc = 6;
|
arginc = 6;
|
||||||
} else if (strcmp(arg[3],"maxwell") == 0) {
|
} else if (strcmp(arg[3],"maxwell") == 0) {
|
||||||
reflectionstyle = MAXWELL;
|
reflectionstyle = MAXWELL;
|
||||||
arginc = 7;
|
arginc = 7;
|
||||||
} else if (strcmp(arg[3],"cercignanilampis") == 0) {
|
} else if (strcmp(arg[3],"cercignanilampis") == 0) {
|
||||||
reflectionstyle = CERCIGNANILAMPIS;
|
reflectionstyle = CERCIGNANILAMPIS;
|
||||||
arginc = 9;
|
arginc = 9;
|
||||||
} else error->all(FLERR,"Illegal fix wall/reflect/stochastic command");
|
} else error->all(FLERR,"Illegal fix wall/reflect/stochastic command");
|
||||||
|
|
||||||
|
|
||||||
seedfix = force->inumeric(FLERR,arg[4]);
|
seedfix = force->inumeric(FLERR,arg[4]);
|
||||||
if (seedfix <=0) error->all(FLERR,"Random seed must be a postive number");
|
if (seedfix <= 0) error->all(FLERR,"Random seed must be a postive number");
|
||||||
random = new RanMars(lmp,seedfix + comm->me);
|
|
||||||
|
int iarg = 5;
|
||||||
int iarg = 5;
|
while (iarg < narg) {
|
||||||
while (iarg < narg) {
|
if ((strcmp(arg[iarg],"xlo") == 0) || (strcmp(arg[iarg],"xhi") == 0) ||
|
||||||
if ((strcmp(arg[iarg],"xlo") == 0) || (strcmp(arg[iarg],"xhi") == 0) ||
|
(strcmp(arg[iarg],"ylo") == 0) || (strcmp(arg[iarg],"yhi") == 0) ||
|
||||||
(strcmp(arg[iarg],"ylo") == 0) || (strcmp(arg[iarg],"yhi") == 0) ||
|
(strcmp(arg[iarg],"zlo") == 0) || (strcmp(arg[iarg],"zhi") == 0)) {
|
||||||
(strcmp(arg[iarg],"zlo") == 0) || (strcmp(arg[iarg],"zhi") == 0)) {
|
if (iarg+2 > narg)
|
||||||
if (iarg+2 > narg) error->all(FLERR,"Illegal fix wall/reflect/stochastic command");
|
error->all(FLERR,"Illegal fix wall/reflect/stochastic command");
|
||||||
|
|
||||||
int newwall;
|
int newwall;
|
||||||
if (strcmp(arg[iarg],"xlo") == 0) newwall = XLO;
|
if (strcmp(arg[iarg],"xlo") == 0) newwall = XLO;
|
||||||
else if (strcmp(arg[iarg],"xhi") == 0) newwall = XHI;
|
else if (strcmp(arg[iarg],"xhi") == 0) newwall = XHI;
|
||||||
else if (strcmp(arg[iarg],"ylo") == 0) newwall = YLO;
|
else if (strcmp(arg[iarg],"ylo") == 0) newwall = YLO;
|
||||||
else if (strcmp(arg[iarg],"yhi") == 0) newwall = YHI;
|
else if (strcmp(arg[iarg],"yhi") == 0) newwall = YHI;
|
||||||
else if (strcmp(arg[iarg],"zlo") == 0) newwall = ZLO;
|
else if (strcmp(arg[iarg],"zlo") == 0) newwall = ZLO;
|
||||||
else if (strcmp(arg[iarg],"zhi") == 0) newwall = ZHI;
|
else if (strcmp(arg[iarg],"zhi") == 0) newwall = ZHI;
|
||||||
|
|
||||||
for (int m = 0; (m < nwall) && (m < 6); m++)
|
for (int m = 0; (m < nwall) && (m < 6); m++)
|
||||||
if (newwall == wallwhich[m])
|
if (newwall == wallwhich[m])
|
||||||
error->all(FLERR,"Wall defined twice in fix wall/reflect/stochastic command");
|
error->all(FLERR,
|
||||||
|
"Fix wall/reflect/stochastic command wall defined twice");
|
||||||
wallwhich[nwall] = newwall;
|
|
||||||
if (strcmp(arg[iarg+1],"EDGE") == 0) {
|
wallwhich[nwall] = newwall;
|
||||||
wallstyle[nwall] = EDGE;
|
if (strcmp(arg[iarg+1],"EDGE") == 0) {
|
||||||
int dim = wallwhich[nwall] / 2;
|
wallstyle[nwall] = EDGE;
|
||||||
int side = wallwhich[nwall] % 2;
|
int dim = wallwhich[nwall] / 2;
|
||||||
if (side == 0) coord0[nwall] = domain->boxlo[dim];
|
int side = wallwhich[nwall] % 2;
|
||||||
else coord0[nwall] = domain->boxhi[dim];
|
if (side == 0) coord0[nwall] = domain->boxlo[dim];
|
||||||
} else {
|
else coord0[nwall] = domain->boxhi[dim];
|
||||||
wallstyle[nwall] = CONSTANT;
|
} else {
|
||||||
coord0[nwall] = force->numeric(FLERR,arg[iarg+1]);
|
wallstyle[nwall] = CONSTANT;
|
||||||
}
|
coord0[nwall] = force->numeric(FLERR,arg[iarg+1]);
|
||||||
|
}
|
||||||
|
|
||||||
walltemp[nwall]= force->numeric(FLERR,arg[iarg+2]);
|
walltemp[nwall]= force->numeric(FLERR,arg[iarg+2]);
|
||||||
|
|
||||||
for (dir = 0; dir < 3; dir++) {
|
for (int dir = 0; dir < 3; dir++) {
|
||||||
wallvel[nwall][dir]= force->numeric(FLERR,arg[iarg+dir+3]);
|
wallvel[nwall][dir]= force->numeric(FLERR,arg[iarg+dir+3]);
|
||||||
int dim = wallwhich[nwall] / 2;
|
int dim = wallwhich[nwall] / 2;
|
||||||
if ((wallvel[nwall][dir] !=0) & (dir == dim)) error->all(FLERR,"The wall velocity must be tangential");
|
if ((wallvel[nwall][dir] !=0) & (dir == dim))
|
||||||
|
error->all(FLERR,"The wall velocity must be tangential");
|
||||||
if (reflectionstyle == CERCIGNANILAMPIS) {
|
|
||||||
wallaccom[nwall][dir]= force->numeric(FLERR,arg[iarg+dir+6]);
|
if (reflectionstyle == CERCIGNANILAMPIS) {
|
||||||
} else if (reflectionstyle == MAXWELL) {
|
wallaccom[nwall][dir]= force->numeric(FLERR,arg[iarg+dir+6]);
|
||||||
wallaccom[nwall][dir]= force->numeric(FLERR,arg[iarg+6]);// One accommodation coefficient for all directions
|
} else if (reflectionstyle == MAXWELL) {
|
||||||
}
|
// one accommodation coefficient for all directions
|
||||||
}
|
wallaccom[nwall][dir]= force->numeric(FLERR,arg[iarg+6]);
|
||||||
|
}
|
||||||
nwall++;
|
}
|
||||||
iarg += arginc;
|
|
||||||
|
nwall++;
|
||||||
} else if (strcmp(arg[iarg],"units") == 0) {
|
iarg += arginc;
|
||||||
if (iarg+2 > narg) error->all(FLERR,"Illegal wall/reflect/stochastic command");
|
|
||||||
if (strcmp(arg[iarg+1],"box") == 0) scaleflag = 0;
|
} else if (strcmp(arg[iarg],"units") == 0) {
|
||||||
else if (strcmp(arg[iarg+1],"lattice") == 0) scaleflag = 1;
|
if (iarg+2 > narg)
|
||||||
else error->all(FLERR,"Illegal fix wall/reflect/stochastic command");
|
error->all(FLERR,"Illegal wall/reflect/stochastic command");
|
||||||
iarg += 2;
|
if (strcmp(arg[iarg+1],"box") == 0) scaleflag = 0;
|
||||||
} else error->all(FLERR,"Illegal fix wall/reflect/stochastic command");
|
else if (strcmp(arg[iarg+1],"lattice") == 0) scaleflag = 1;
|
||||||
}
|
else error->all(FLERR,"Illegal fix wall/reflect/stochastic command");
|
||||||
|
iarg += 2;
|
||||||
// error check
|
} else error->all(FLERR,"Illegal fix wall/reflect/stochastic command");
|
||||||
|
}
|
||||||
if (nwall == 0) error->all(FLERR,"Illegal fix wall command");
|
|
||||||
|
// error check
|
||||||
for (int m = 0; m < nwall; m++) {
|
|
||||||
if ((wallwhich[m] == XLO || wallwhich[m] == XHI) && domain->xperiodic)
|
if (nwall == 0) error->all(FLERR,"Illegal fix wall command");
|
||||||
error->all(FLERR,"Cannot use fix wall/reflect/stochastic in periodic dimension");
|
|
||||||
if ((wallwhich[m] == YLO || wallwhich[m] == YHI) && domain->yperiodic)
|
for (int m = 0; m < nwall; m++) {
|
||||||
error->all(FLERR,"Cannot use fix wall/reflect/stochastic in periodic dimension");
|
if ((wallwhich[m] == XLO || wallwhich[m] == XHI) && domain->xperiodic)
|
||||||
if ((wallwhich[m] == ZLO || wallwhich[m] == ZHI) && domain->zperiodic)
|
error->all(FLERR,"Cannot use fix wall/reflect/stochastic "
|
||||||
error->all(FLERR,"Cannot use fix wall/reflect/stochastic in periodic dimension");
|
"in periodic dimension");
|
||||||
}
|
if ((wallwhich[m] == YLO || wallwhich[m] == YHI) && domain->yperiodic)
|
||||||
|
error->all(FLERR,"Cannot use fix wall/reflect/stochastic "
|
||||||
for (int m = 0; m < nwall; m++)
|
"in periodic dimension");
|
||||||
if ((wallwhich[m] == ZLO || wallwhich[m] == ZHI) && domain->dimension == 2)
|
if ((wallwhich[m] == ZLO || wallwhich[m] == ZHI) && domain->zperiodic)
|
||||||
error->all(FLERR,
|
error->all(FLERR,"Cannot use fix wall/reflect/stochastic "
|
||||||
"Cannot use fix wall/reflect/stochastic zlo/zhi for a 2d simulation");
|
"in periodic dimension");
|
||||||
|
}
|
||||||
// scale factors for CONSTANT walls, VARIABLE wall is not allowed
|
|
||||||
|
for (int m = 0; m < nwall; m++)
|
||||||
int flag = 0;
|
if ((wallwhich[m] == ZLO || wallwhich[m] == ZHI) && domain->dimension == 2)
|
||||||
for (int m = 0; m < nwall; m++)
|
error->all(FLERR,
|
||||||
if (wallstyle[m] != EDGE) flag = 1;
|
"Cannot use fix wall/reflect/stochastic zlo/zhi "
|
||||||
|
"for a 2d simulation");
|
||||||
if (flag) {
|
|
||||||
if (scaleflag) {
|
// scale factors for CONSTANT walls, VARIABLE wall is not allowed
|
||||||
xscale = domain->lattice->xlattice;
|
|
||||||
yscale = domain->lattice->ylattice;
|
int flag = 0;
|
||||||
zscale = domain->lattice->zlattice;
|
for (int m = 0; m < nwall; m++)
|
||||||
}
|
if (wallstyle[m] != EDGE) flag = 1;
|
||||||
else xscale = yscale = zscale = 1.0;
|
|
||||||
|
if (flag) {
|
||||||
for (int m = 0; m < nwall; m++) {
|
if (scaleflag) {
|
||||||
if (wallstyle[m] != CONSTANT) continue;
|
xscale = domain->lattice->xlattice;
|
||||||
if (wallwhich[m] < YLO) coord0[m] *= xscale;
|
yscale = domain->lattice->ylattice;
|
||||||
else if (wallwhich[m] < ZLO) coord0[m] *= yscale;
|
zscale = domain->lattice->zlattice;
|
||||||
else coord0[m] *= zscale;
|
}
|
||||||
}
|
else xscale = yscale = zscale = 1.0;
|
||||||
}
|
|
||||||
|
for (int m = 0; m < nwall; m++) {
|
||||||
}
|
if (wallstyle[m] != CONSTANT) continue;
|
||||||
|
if (wallwhich[m] < YLO) coord0[m] *= xscale;
|
||||||
|
else if (wallwhich[m] < ZLO) coord0[m] *= yscale;
|
||||||
FixWallReflectStochastic::~FixWallReflectStochastic()
|
else coord0[m] *= zscale;
|
||||||
{
|
}
|
||||||
|
}
|
||||||
delete random ;
|
|
||||||
|
// random number generator
|
||||||
}
|
|
||||||
|
random = new RanMars(lmp,seedfix + comm->me);
|
||||||
/* ---------------------------------------------------------------------- */
|
}
|
||||||
|
|
||||||
void FixWallReflectStochastic::wall_particle(int m, int which, double coord)
|
/* ---------------------------------------------------------------------- */
|
||||||
{
|
|
||||||
int i, dir, dim, side, sign;
|
FixWallReflectStochastic::~FixWallReflectStochastic()
|
||||||
double vsave,factor,timecol,difftest,theta;
|
{
|
||||||
|
delete random;
|
||||||
double *rmass;
|
}
|
||||||
double *mass = atom->mass;
|
|
||||||
|
/* ---------------------------------------------------------------------- */
|
||||||
// coord = current position of wall
|
|
||||||
// evaluate variable if necessary, wrap with clear/add
|
void FixWallReflectStochastic::wall_particle(int m, int which, double coord)
|
||||||
|
{
|
||||||
double **x = atom->x;
|
int i, dir, dim, side, sign;
|
||||||
double **v = atom->v;
|
double vsave,factor,timecol,difftest,theta;
|
||||||
int *mask = atom->mask;
|
|
||||||
int *type = atom->type;
|
double *rmass;
|
||||||
int nlocal = atom->nlocal;
|
double *mass = atom->mass;
|
||||||
|
|
||||||
dim = which / 2;
|
// coord = current position of wall
|
||||||
side = which % 2;
|
|
||||||
|
double **x = atom->x;
|
||||||
for (i = 0; i < nlocal; i++) {
|
double **v = atom->v;
|
||||||
if (mask[i] & groupbit) {
|
int *mask = atom->mask;
|
||||||
|
int *type = atom->type;
|
||||||
sign = 0;
|
int nlocal = atom->nlocal;
|
||||||
|
|
||||||
if ((side == 0) & (x[i][dim] < coord)){
|
dim = which / 2;
|
||||||
sign = 1;
|
side = which % 2;
|
||||||
} else if ((side == 1) & (x[i][dim] > coord)){
|
|
||||||
sign = -1;
|
for (i = 0; i < nlocal; i++) {
|
||||||
}
|
if (!(mask[i] & groupbit)) continue;
|
||||||
|
|
||||||
|
sign = 0;
|
||||||
if (sign != 0) {
|
if ((side == 0) & (x[i][dim] < coord)) sign = 1;
|
||||||
if (rmass) theta = force->boltz*walltemp[m]/(rmass[i]*force->mvv2e);// theta = kT/m
|
else if ((side == 1) & (x[i][dim] > coord)) sign = -1;
|
||||||
else theta = force->boltz*walltemp[m]/(mass[type[i]]*force->mvv2e);
|
if (sign == 0) continue;
|
||||||
factor = sqrt(theta);
|
|
||||||
|
// theta = kT/m
|
||||||
timecol= (x[i][dim] - coord)/v[i][dim]; // time travelling after collision
|
|
||||||
|
if (rmass) theta = force->boltz*walltemp[m]/(rmass[i]*force->mvv2e);
|
||||||
if (reflectionstyle == MAXWELL) {difftest = random->uniform(); }// for Maxwell model only
|
else theta = force->boltz*walltemp[m]/(mass[type[i]]*force->mvv2e);
|
||||||
|
factor = sqrt(theta);
|
||||||
for (dir = 0; dir < 3; dir++) {
|
|
||||||
|
// time travelling after collision
|
||||||
x[i][dir] -= v[i][dir]*timecol; // pushing back atoms to the wall position and assign new reflected velocity
|
|
||||||
|
timecol = (x[i][dim]-coord) / v[i][dim];
|
||||||
// Diffusive reflection
|
|
||||||
if (reflectionstyle == DIFFUSIVE){
|
// only needed for Maxwell model
|
||||||
|
|
||||||
if (dir != dim) {
|
if (reflectionstyle == MAXWELL) difftest = random->uniform();
|
||||||
v[i][dir] = wallvel[m][dir] + random->gaussian(0,factor);
|
|
||||||
} else { v[i][dir] = sign*random->rayleigh(factor) ; }
|
for (dir = 0; dir < 3; dir++) {
|
||||||
|
|
||||||
}
|
// pushing back atoms to wall position, assign new reflected velocity
|
||||||
|
|
||||||
// Maxwell reflection
|
x[i][dir] -= v[i][dir]*timecol;
|
||||||
if (reflectionstyle == MAXWELL){
|
|
||||||
|
// diffusive reflection
|
||||||
if (difftest < wallaccom[m][dir]) {
|
|
||||||
if (dir != dim) {
|
if (reflectionstyle == DIFFUSIVE) {
|
||||||
v[i][dir] = wallvel[m][dir] + random->gaussian(0,factor);
|
if (dir != dim)
|
||||||
} else { v[i][dir] = sign*random->rayleigh(factor) ; }
|
v[i][dir] = wallvel[m][dir] + random->gaussian(0,factor);
|
||||||
} else {
|
else v[i][dir] = sign*random->rayleigh(factor);
|
||||||
if (dir == dim) {v[i][dir] = -v[i][dir];
|
|
||||||
}
|
// Maxwell reflection
|
||||||
}
|
|
||||||
}
|
} else if (reflectionstyle == MAXWELL) {
|
||||||
|
if (difftest < wallaccom[m][dir]) {
|
||||||
|
if (dir != dim)
|
||||||
// Cercignani Lampis reflection
|
v[i][dir] = wallvel[m][dir] + random->gaussian(0,factor);
|
||||||
if (reflectionstyle == CERCIGNANILAMPIS){
|
else v[i][dir] = sign*random->rayleigh(factor);
|
||||||
if (dir != dim) {
|
} else {
|
||||||
v[i][dir] = wallvel[m][dir] + random->gaussian((1-wallaccom[m][dir])*(v[i][dir]-wallvel[m][dir]),sqrt((2-wallaccom[m][dir])*wallaccom[m][dir]*theta)) ;
|
if (dir == dim) v[i][dir] = -v[i][dir];
|
||||||
} else { v[i][dir] = random->besselexp(theta, wallaccom[m][dir], v[i][dir]) ; }
|
}
|
||||||
|
|
||||||
}
|
// Cercignani Lampis reflection
|
||||||
|
|
||||||
// update new position due to the new velocity
|
} else if (reflectionstyle == CERCIGNANILAMPIS) {
|
||||||
if (dir != dim) {
|
if (dir != dim)
|
||||||
x[i][dir] += v[i][dir]*timecol; }
|
v[i][dir] = wallvel[m][dir] +
|
||||||
else {x[i][dir] = coord + v[i][dir]*timecol;}
|
random->gaussian((1-wallaccom[m][dir]) *
|
||||||
}// for loop
|
(v[i][dir] - wallvel[m][dir]),
|
||||||
}// if sign
|
sqrt((2-wallaccom[m][dir]) *
|
||||||
}// if mask
|
wallaccom[m][dir]*theta));
|
||||||
}
|
else v[i][dir] = random->besselexp(theta,wallaccom[m][dir],v[i][dir]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// update new position due to the new velocity
|
||||||
|
|
||||||
|
if (dir != dim) x[i][dir] += v[i][dir]*timecol;
|
||||||
|
else x[i][dir] = coord + v[i][dir]*timecol;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,85 +1,80 @@
|
||||||
/* -*- c++ -*- ----------------------------------------------------------
|
/* -*- c++ -*- ----------------------------------------------------------
|
||||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||||
http://lammps.sandia.gov, Sandia National Laboratories
|
http://lammps.sandia.gov, Sandia National Laboratories
|
||||||
Steve Plimpton, sjplimp@sandia.gov
|
Steve Plimpton, sjplimp@sandia.gov
|
||||||
|
|
||||||
Copyright (2003) Sandia Corporation. Under the terms of Contract
|
Copyright (2003) Sandia Corporation. Under the terms of Contract
|
||||||
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
|
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
|
||||||
certain rights in this software. This software is distributed under
|
certain rights in this software. This software is distributed under
|
||||||
the GNU General Public License.
|
the GNU General Public License.
|
||||||
|
|
||||||
See the README file in the top-level LAMMPS directory.
|
See the README file in the top-level LAMMPS directory.
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
#ifdef FIX_CLASS
|
#ifdef FIX_CLASS
|
||||||
|
|
||||||
FixStyle(wall/reflect/stochastic,FixWallReflectStochastic)
|
FixStyle(wall/reflect/stochastic,FixWallReflectStochastic)
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#ifndef LMP_FIX_WALL_REFLECT_STOCHASTIC_H
|
#ifndef LMP_FIX_WALL_REFLECT_STOCHASTIC_H
|
||||||
#define LMP_FIX_WALL_REFLECT_STOCHASTIC_H
|
#define LMP_FIX_WALL_REFLECT_STOCHASTIC_H
|
||||||
|
|
||||||
|
#include "random_mars.h"
|
||||||
#include "random_mars.h"
|
#include "fix_wall_reflect.h"
|
||||||
#include "fix_wall_reflect.h"
|
|
||||||
|
namespace LAMMPS_NS {
|
||||||
namespace LAMMPS_NS {
|
|
||||||
|
class FixWallReflectStochastic : public FixWallReflect {
|
||||||
class FixWallReflectStochastic : public FixWallReflect {
|
public:
|
||||||
public:
|
FixWallReflectStochastic(class LAMMPS *, int, char **);
|
||||||
FixWallReflectStochastic(class LAMMPS *, int, char **);
|
virtual ~FixWallReflectStochastic();
|
||||||
void wall_particle(int m,int which, double coord);
|
|
||||||
virtual ~FixWallReflectStochastic();
|
private:
|
||||||
|
int seedfix;
|
||||||
|
double walltemp[6],wallvel[6][3],wallaccom[6][3];
|
||||||
|
int reflectionstyle;
|
||||||
|
|
||||||
|
class RanMars *random;
|
||||||
protected:
|
|
||||||
class RanMars *random;
|
void wall_particle(int m,int which, double coord);
|
||||||
int seedfix;
|
};
|
||||||
double walltemp[6],wallvel[6][3],wallaccom[6][3];
|
|
||||||
int reflectionstyle;
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
};
|
#endif
|
||||||
|
|
||||||
}
|
/* ERROR/WARNING messages:
|
||||||
|
|
||||||
#endif
|
E: Illegal ... command
|
||||||
#endif
|
|
||||||
|
Self-explanatory. Check the input script syntax and compare to the
|
||||||
/* ERROR/WARNING messages:
|
documentation for the command. You can use -echo screen as a
|
||||||
|
command-line option when running LAMMPS to see the offending line.
|
||||||
E: Illegal ... command
|
|
||||||
|
E: Wall defined twice in fix wall/stochastic command
|
||||||
Self-explanatory. Check the input script syntax and compare to the
|
|
||||||
documentation for the command. You can use -echo screen as a
|
Self-explanatory.
|
||||||
command-line option when running LAMMPS to see the offending line.
|
|
||||||
|
E: Cannot use fix wall/stochastic in periodic dimension
|
||||||
E: Wall defined twice in fix wall/stochastic command
|
|
||||||
|
Self-explanatory.
|
||||||
Self-explanatory.
|
|
||||||
|
E: Cannot use fix wall/stochastic zlo/zhi for a 2d simulation
|
||||||
E: Cannot use fix wall/stochastic in periodic dimension
|
|
||||||
|
Self-explanatory.
|
||||||
Self-explanatory.
|
|
||||||
|
E: Variable name for fix wall/stochastic does not exist
|
||||||
E: Cannot use fix wall/stochastic zlo/zhi for a 2d simulation
|
|
||||||
|
Self-explanatory.
|
||||||
Self-explanatory.
|
|
||||||
|
E: Variable for fix wall/stochastic is invalid style
|
||||||
E: Variable name for fix wall/stochastic does not exist
|
|
||||||
|
Only equal-style variables can be used.
|
||||||
Self-explanatory.
|
|
||||||
|
W: Should not allow rigid bodies to bounce off relecting walls
|
||||||
E: Variable for fix wall/stochastic is invalid style
|
|
||||||
|
LAMMPS allows this, but their dynamics are not computed correctly.
|
||||||
Only equal-style variables can be used.
|
|
||||||
|
*/
|
||||||
W: Should not allow rigid bodies to bounce off relecting walls
|
|
||||||
|
|
||||||
LAMMPS allows this, but their dynamics are not computed correctly.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
|
@ -1,250 +1,243 @@
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||||
http://lammps.sandia.gov, Sandia National Laboratories
|
http://lammps.sandia.gov, Sandia National Laboratories
|
||||||
Steve Plimpton, sjplimp@sandia.gov
|
Steve Plimpton, sjplimp@sandia.gov
|
||||||
|
|
||||||
Copyright (2003) Sandia Corporation. Under the terms of Contract
|
Copyright (2003) Sandia Corporation. Under the terms of Contract
|
||||||
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
|
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
|
||||||
certain rights in this software. This software is distributed under
|
certain rights in this software. This software is distributed under
|
||||||
the GNU General Public License.
|
the GNU General Public License.
|
||||||
|
|
||||||
See the README file in the top-level LAMMPS directory.
|
See the README file in the top-level LAMMPS directory.
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
#include "fix_wall_reflect.h"
|
#include "fix_wall_reflect.h"
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include "atom.h"
|
#include "atom.h"
|
||||||
#include "comm.h"
|
#include "comm.h"
|
||||||
#include "update.h"
|
#include "update.h"
|
||||||
#include "modify.h"
|
#include "modify.h"
|
||||||
#include "domain.h"
|
#include "domain.h"
|
||||||
#include "lattice.h"
|
#include "force.h"
|
||||||
#include "input.h"
|
#include "lattice.h"
|
||||||
#include "variable.h"
|
#include "input.h"
|
||||||
#include "error.h"
|
#include "variable.h"
|
||||||
#include "force.h"
|
#include "error.h"
|
||||||
|
|
||||||
|
using namespace LAMMPS_NS;
|
||||||
using namespace LAMMPS_NS;
|
using namespace FixConst;
|
||||||
using namespace FixConst;
|
|
||||||
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
FixWallReflect::FixWallReflect(LAMMPS *lmp, int narg, char **arg) :
|
||||||
/* ---------------------------------------------------------------------- */
|
Fix(lmp, narg, arg),
|
||||||
|
nwall(0)
|
||||||
FixWallReflect::FixWallReflect(LAMMPS *lmp, int narg, char **arg) :
|
{
|
||||||
Fix(lmp, narg, arg),
|
if (narg < 4) error->all(FLERR,"Illegal fix wall/reflect command");
|
||||||
nwall(0)
|
|
||||||
{
|
// let child class process all args
|
||||||
|
|
||||||
|
if (strcmp(arg[2],"wall/reflect/stochastic") == 0) return;
|
||||||
if (narg < 4) error->all(FLERR,"Illegal fix wall/reflect command");
|
|
||||||
|
dynamic_group_allow = 1;
|
||||||
if (strcmp(arg[2],"wall/reflect/stochastic") == 0) return;// child class can be stochastic
|
|
||||||
|
// parse args
|
||||||
|
|
||||||
dynamic_group_allow = 1;
|
nwall = 0;
|
||||||
|
int scaleflag = 1;
|
||||||
// parse args
|
|
||||||
|
int iarg = 3;
|
||||||
nwall = 0;
|
while (iarg < narg) {
|
||||||
int scaleflag = 1;
|
if ((strcmp(arg[iarg],"xlo") == 0) || (strcmp(arg[iarg],"xhi") == 0) ||
|
||||||
|
(strcmp(arg[iarg],"ylo") == 0) || (strcmp(arg[iarg],"yhi") == 0) ||
|
||||||
int iarg = 3;
|
(strcmp(arg[iarg],"zlo") == 0) || (strcmp(arg[iarg],"zhi") == 0)) {
|
||||||
while (iarg < narg) {
|
if (iarg+2 > narg) error->all(FLERR,"Illegal fix wall/reflect command");
|
||||||
if ((strcmp(arg[iarg],"xlo") == 0) || (strcmp(arg[iarg],"xhi") == 0) ||
|
|
||||||
(strcmp(arg[iarg],"ylo") == 0) || (strcmp(arg[iarg],"yhi") == 0) ||
|
int newwall;
|
||||||
(strcmp(arg[iarg],"zlo") == 0) || (strcmp(arg[iarg],"zhi") == 0)) {
|
if (strcmp(arg[iarg],"xlo") == 0) newwall = XLO;
|
||||||
if (iarg+2 > narg) error->all(FLERR,"Illegal fix wall/reflect command");
|
else if (strcmp(arg[iarg],"xhi") == 0) newwall = XHI;
|
||||||
|
else if (strcmp(arg[iarg],"ylo") == 0) newwall = YLO;
|
||||||
int newwall;
|
else if (strcmp(arg[iarg],"yhi") == 0) newwall = YHI;
|
||||||
if (strcmp(arg[iarg],"xlo") == 0) newwall = XLO;
|
else if (strcmp(arg[iarg],"zlo") == 0) newwall = ZLO;
|
||||||
else if (strcmp(arg[iarg],"xhi") == 0) newwall = XHI;
|
else if (strcmp(arg[iarg],"zhi") == 0) newwall = ZHI;
|
||||||
else if (strcmp(arg[iarg],"ylo") == 0) newwall = YLO;
|
|
||||||
else if (strcmp(arg[iarg],"yhi") == 0) newwall = YHI;
|
for (int m = 0; (m < nwall) && (m < 6); m++)
|
||||||
else if (strcmp(arg[iarg],"zlo") == 0) newwall = ZLO;
|
if (newwall == wallwhich[m])
|
||||||
else if (strcmp(arg[iarg],"zhi") == 0) newwall = ZHI;
|
error->all(FLERR,"Wall defined twice in fix wall/reflect command");
|
||||||
|
|
||||||
for (int m = 0; (m < nwall) && (m < 6); m++)
|
wallwhich[nwall] = newwall;
|
||||||
if (newwall == wallwhich[m])
|
if (strcmp(arg[iarg+1],"EDGE") == 0) {
|
||||||
error->all(FLERR,"Wall defined twice in fix wall/reflect command");
|
wallstyle[nwall] = EDGE;
|
||||||
|
int dim = wallwhich[nwall] / 2;
|
||||||
wallwhich[nwall] = newwall;
|
int side = wallwhich[nwall] % 2;
|
||||||
if (strcmp(arg[iarg+1],"EDGE") == 0) {
|
if (side == 0) coord0[nwall] = domain->boxlo[dim];
|
||||||
wallstyle[nwall] = EDGE;
|
else coord0[nwall] = domain->boxhi[dim];
|
||||||
int dim = wallwhich[nwall] / 2;
|
} else if (strstr(arg[iarg+1],"v_") == arg[iarg+1]) {
|
||||||
int side = wallwhich[nwall] % 2;
|
wallstyle[nwall] = VARIABLE;
|
||||||
if (side == 0) coord0[nwall] = domain->boxlo[dim];
|
int n = strlen(&arg[iarg+1][2]) + 1;
|
||||||
else coord0[nwall] = domain->boxhi[dim];
|
varstr[nwall] = new char[n];
|
||||||
} else if (strstr(arg[iarg+1],"v_") == arg[iarg+1]) {
|
strcpy(varstr[nwall],&arg[iarg+1][2]);
|
||||||
wallstyle[nwall] = VARIABLE;
|
} else {
|
||||||
int n = strlen(&arg[iarg+1][2]) + 1;
|
wallstyle[nwall] = CONSTANT;
|
||||||
varstr[nwall] = new char[n];
|
coord0[nwall] = force->numeric(FLERR,arg[iarg+1]);
|
||||||
strcpy(varstr[nwall],&arg[iarg+1][2]);
|
}
|
||||||
} else {
|
|
||||||
wallstyle[nwall] = CONSTANT;
|
nwall++;
|
||||||
coord0[nwall] = force->numeric(FLERR,arg[iarg+1]);
|
iarg += 2;
|
||||||
}
|
|
||||||
|
} else if (strcmp(arg[iarg],"units") == 0) {
|
||||||
nwall++;
|
if (iarg+2 > narg) error->all(FLERR,"Illegal wall/reflect command");
|
||||||
iarg += 2;
|
if (strcmp(arg[iarg+1],"box") == 0) scaleflag = 0;
|
||||||
|
else if (strcmp(arg[iarg+1],"lattice") == 0) scaleflag = 1;
|
||||||
|
else error->all(FLERR,"Illegal fix wall/reflect command");
|
||||||
} else if (strcmp(arg[iarg],"units") == 0) {
|
iarg += 2;
|
||||||
if (iarg+2 > narg) error->all(FLERR,"Illegal wall/reflect command");
|
|
||||||
if (strcmp(arg[iarg+1],"box") == 0) scaleflag = 0;
|
} else error->all(FLERR,"Illegal fix wall/reflect command");
|
||||||
else if (strcmp(arg[iarg+1],"lattice") == 0) scaleflag = 1;
|
}
|
||||||
else error->all(FLERR,"Illegal fix wall/reflect command");
|
|
||||||
iarg += 2;
|
// error check
|
||||||
} else error->all(FLERR,"Illegal fix wall/reflect command");
|
|
||||||
}
|
if (nwall == 0) error->all(FLERR,"Illegal fix wall command");
|
||||||
|
|
||||||
// error check
|
for (int m = 0; m < nwall; m++) {
|
||||||
|
if ((wallwhich[m] == XLO || wallwhich[m] == XHI) && domain->xperiodic)
|
||||||
if (nwall == 0) error->all(FLERR,"Illegal fix wall command");
|
error->all(FLERR,"Cannot use fix wall/reflect in periodic dimension");
|
||||||
|
if ((wallwhich[m] == YLO || wallwhich[m] == YHI) && domain->yperiodic)
|
||||||
for (int m = 0; m < nwall; m++) {
|
error->all(FLERR,"Cannot use fix wall/reflect in periodic dimension");
|
||||||
if ((wallwhich[m] == XLO || wallwhich[m] == XHI) && domain->xperiodic)
|
if ((wallwhich[m] == ZLO || wallwhich[m] == ZHI) && domain->zperiodic)
|
||||||
error->all(FLERR,"Cannot use fix wall/reflect in periodic dimension");
|
error->all(FLERR,"Cannot use fix wall/reflect in periodic dimension");
|
||||||
if ((wallwhich[m] == YLO || wallwhich[m] == YHI) && domain->yperiodic)
|
}
|
||||||
error->all(FLERR,"Cannot use fix wall/reflect in periodic dimension");
|
|
||||||
if ((wallwhich[m] == ZLO || wallwhich[m] == ZHI) && domain->zperiodic)
|
for (int m = 0; m < nwall; m++)
|
||||||
error->all(FLERR,"Cannot use fix wall/reflect in periodic dimension");
|
if ((wallwhich[m] == ZLO || wallwhich[m] == ZHI) && domain->dimension == 2)
|
||||||
}
|
error->all(FLERR,
|
||||||
|
"Cannot use fix wall/reflect zlo/zhi for a 2d simulation");
|
||||||
for (int m = 0; m < nwall; m++)
|
|
||||||
if ((wallwhich[m] == ZLO || wallwhich[m] == ZHI) && domain->dimension == 2)
|
// scale factors for CONSTANT and VARIABLE walls
|
||||||
error->all(FLERR,
|
|
||||||
"Cannot use fix wall/reflect zlo/zhi for a 2d simulation");
|
int flag = 0;
|
||||||
|
for (int m = 0; m < nwall; m++)
|
||||||
// scale factors for CONSTANT and VARIABLE walls
|
if (wallstyle[m] != EDGE) flag = 1;
|
||||||
|
|
||||||
int flag = 0;
|
if (flag) {
|
||||||
for (int m = 0; m < nwall; m++)
|
if (scaleflag) {
|
||||||
if (wallstyle[m] != EDGE) flag = 1;
|
xscale = domain->lattice->xlattice;
|
||||||
|
yscale = domain->lattice->ylattice;
|
||||||
if (flag) {
|
zscale = domain->lattice->zlattice;
|
||||||
if (scaleflag) {
|
}
|
||||||
xscale = domain->lattice->xlattice;
|
else xscale = yscale = zscale = 1.0;
|
||||||
yscale = domain->lattice->ylattice;
|
|
||||||
zscale = domain->lattice->zlattice;
|
for (int m = 0; m < nwall; m++) {
|
||||||
}
|
if (wallstyle[m] != CONSTANT) continue;
|
||||||
else xscale = yscale = zscale = 1.0;
|
if (wallwhich[m] < YLO) coord0[m] *= xscale;
|
||||||
|
else if (wallwhich[m] < ZLO) coord0[m] *= yscale;
|
||||||
for (int m = 0; m < nwall; m++) {
|
else coord0[m] *= zscale;
|
||||||
if (wallstyle[m] != CONSTANT) continue;
|
}
|
||||||
if (wallwhich[m] < YLO) coord0[m] *= xscale;
|
}
|
||||||
else if (wallwhich[m] < ZLO) coord0[m] *= yscale;
|
|
||||||
else coord0[m] *= zscale;
|
// set varflag if any wall positions are variable
|
||||||
}
|
|
||||||
}
|
varflag = 0;
|
||||||
|
for (int m = 0; m < nwall; m++)
|
||||||
// set varflag if any wall positions are variable
|
if (wallstyle[m] == VARIABLE) varflag = 1;
|
||||||
|
}
|
||||||
varflag = 0;
|
|
||||||
for (int m = 0; m < nwall; m++)
|
/* ---------------------------------------------------------------------- */
|
||||||
if (wallstyle[m] == VARIABLE) varflag = 1;
|
|
||||||
}
|
FixWallReflect::~FixWallReflect()
|
||||||
|
{
|
||||||
|
if (copymode) return;
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
for (int m = 0; m < nwall; m++)
|
||||||
|
if (wallstyle[m] == VARIABLE) delete [] varstr[m];
|
||||||
FixWallReflect::~FixWallReflect()
|
}
|
||||||
{
|
|
||||||
if (copymode) return;
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
for (int m = 0; m < nwall; m++)
|
int FixWallReflect::setmask()
|
||||||
if (wallstyle[m] == VARIABLE) delete [] varstr[m];
|
{
|
||||||
}
|
int mask = 0;
|
||||||
|
mask |= POST_INTEGRATE;
|
||||||
/* ---------------------------------------------------------------------- */
|
mask |= POST_INTEGRATE_RESPA;
|
||||||
|
return mask;
|
||||||
int FixWallReflect::setmask()
|
}
|
||||||
{
|
|
||||||
int mask = 0;
|
/* ---------------------------------------------------------------------- */
|
||||||
mask |= POST_INTEGRATE;
|
|
||||||
mask |= POST_INTEGRATE_RESPA;
|
void FixWallReflect::init()
|
||||||
return mask;
|
{
|
||||||
}
|
for (int m = 0; m < nwall; m++) {
|
||||||
|
if (wallstyle[m] != VARIABLE) continue;
|
||||||
/* ---------------------------------------------------------------------- */
|
varindex[m] = input->variable->find(varstr[m]);
|
||||||
|
if (varindex[m] < 0)
|
||||||
void FixWallReflect::init()
|
error->all(FLERR,"Variable name for fix wall/reflect does not exist");
|
||||||
{
|
if (!input->variable->equalstyle(varindex[m]))
|
||||||
for (int m = 0; m < nwall; m++) {
|
error->all(FLERR,"Variable for fix wall/reflect is invalid style");
|
||||||
if (wallstyle[m] != VARIABLE) continue;
|
}
|
||||||
varindex[m] = input->variable->find(varstr[m]);
|
|
||||||
if (varindex[m] < 0)
|
int nrigid = 0;
|
||||||
error->all(FLERR,"Variable name for fix wall/reflect does not exist");
|
for (int i = 0; i < modify->nfix; i++)
|
||||||
if (!input->variable->equalstyle(varindex[m]))
|
if (modify->fix[i]->rigid_flag) nrigid++;
|
||||||
error->all(FLERR,"Variable for fix wall/reflect is invalid style");
|
|
||||||
}
|
if (nrigid && comm->me == 0)
|
||||||
|
error->warning(FLERR,"Should not allow rigid bodies to bounce off "
|
||||||
int nrigid = 0;
|
"relecting walls");
|
||||||
for (int i = 0; i < modify->nfix; i++)
|
}
|
||||||
if (modify->fix[i]->rigid_flag) nrigid++;
|
|
||||||
|
/* ---------------------------------------------------------------------- */
|
||||||
if (nrigid && comm->me == 0)
|
|
||||||
error->warning(FLERR,"Should not allow rigid bodies to bounce off "
|
void FixWallReflect::post_integrate()
|
||||||
"relecting walls");
|
{
|
||||||
}
|
double coord;
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
// coord = current position of wall
|
||||||
|
// evaluate variable if necessary, wrap with clear/add
|
||||||
void FixWallReflect::post_integrate()
|
|
||||||
{
|
if (varflag) modify->clearstep_compute();
|
||||||
//int m;
|
|
||||||
double coord;
|
for (int m = 0; m < nwall; m++) {
|
||||||
|
if (wallstyle[m] == VARIABLE) {
|
||||||
// coord = current position of wall
|
coord = input->variable->compute_equal(varindex[m]);
|
||||||
// evaluate variable if necessary, wrap with clear/add
|
if (wallwhich[m] < YLO) coord *= xscale;
|
||||||
|
else if (wallwhich[m] < ZLO) coord *= yscale;
|
||||||
|
else coord *= zscale;
|
||||||
|
} else coord = coord0[m];
|
||||||
if (varflag) modify->clearstep_compute();
|
|
||||||
|
wall_particle(m,wallwhich[m],coord);
|
||||||
for (int m = 0; m < nwall; m++) {
|
}
|
||||||
if (wallstyle[m] == VARIABLE) {
|
|
||||||
coord = input->variable->compute_equal(varindex[m]);
|
if (varflag) modify->addstep_compute(update->ntimestep + 1);
|
||||||
if (wallwhich[m] < YLO) coord *= xscale;
|
}
|
||||||
else if (wallwhich[m] < ZLO) coord *= yscale;
|
|
||||||
else coord *= zscale;
|
/* ----------------------------------------------------------------------
|
||||||
} else coord = coord0[m];
|
this method may be overwritten by a child class
|
||||||
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
wall_particle(m,wallwhich[m],coord);
|
void FixWallReflect::wall_particle(int m, int which, double coord)
|
||||||
|
{
|
||||||
|
int i,dim,side;
|
||||||
if (varflag) modify->addstep_compute(update->ntimestep + 1);
|
|
||||||
}
|
double **x = atom->x;
|
||||||
}
|
double **v = atom->v;
|
||||||
|
int *mask = atom->mask;
|
||||||
void FixWallReflect::wall_particle(int m, int which, double coord)
|
int nlocal = atom->nlocal;
|
||||||
{
|
|
||||||
int i, dim, side,sign;
|
dim = which / 2;
|
||||||
|
side = which % 2;
|
||||||
double **x = atom->x;
|
|
||||||
double **v = atom->v;
|
for (i = 0; i < nlocal; i++) {
|
||||||
int *mask = atom->mask;
|
if (mask[i] & groupbit) {
|
||||||
int nlocal = atom->nlocal;
|
if (side == 0) {
|
||||||
|
if (x[i][dim] < coord) {
|
||||||
dim = which / 2;
|
x[i][dim] = coord + (coord - x[i][dim]);
|
||||||
side = which % 2;
|
v[i][dim] = -v[i][dim];
|
||||||
|
}
|
||||||
for (i = 0; i < nlocal; i++)
|
} else {
|
||||||
if (mask[i] & groupbit) {
|
if (x[i][dim] > coord) {
|
||||||
|
x[i][dim] = coord - (x[i][dim] - coord);
|
||||||
if (side == 0) {
|
v[i][dim] = -v[i][dim];
|
||||||
if (x[i][dim] < coord) {
|
}
|
||||||
x[i][dim] = coord + (coord - x[i][dim]);
|
}
|
||||||
v[i][dim] = -v[i][dim];
|
}
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
if (x[i][dim] > coord) {
|
|
||||||
x[i][dim] = coord - (x[i][dim] - coord);
|
|
||||||
v[i][dim] = -v[i][dim];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -26,14 +26,14 @@ namespace LAMMPS_NS {
|
||||||
|
|
||||||
class FixWallReflect : public Fix {
|
class FixWallReflect : public Fix {
|
||||||
public:
|
public:
|
||||||
|
enum{XLO=0,XHI=1,YLO=2,YHI=3,ZLO=4,ZHI=5};
|
||||||
|
enum{NONE=0,EDGE,CONSTANT,VARIABLE};
|
||||||
|
|
||||||
FixWallReflect(class LAMMPS *, int, char **);
|
FixWallReflect(class LAMMPS *, int, char **);
|
||||||
virtual ~FixWallReflect();
|
virtual ~FixWallReflect();
|
||||||
virtual void wall_particle(int m, int which, double coord);
|
|
||||||
int setmask();
|
int setmask();
|
||||||
void init();
|
void init();
|
||||||
void post_integrate();
|
void post_integrate();
|
||||||
enum{XLO=0,XHI=1,YLO=2,YHI=3,ZLO=4,ZHI=5};
|
|
||||||
enum{NONE=0,EDGE,CONSTANT,VARIABLE};
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int nwall;
|
int nwall;
|
||||||
|
@ -43,6 +43,8 @@ class FixWallReflect : public Fix {
|
||||||
int varindex[6];
|
int varindex[6];
|
||||||
int varflag;
|
int varflag;
|
||||||
double xscale,yscale,zscale;
|
double xscale,yscale,zscale;
|
||||||
|
|
||||||
|
virtual void wall_particle(int m, int which, double coord);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,7 +90,6 @@ double RanMars::uniform()
|
||||||
return uni;
|
return uni;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
gaussian RN
|
gaussian RN
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
@ -127,7 +126,6 @@ double RanMars::gaussian(double mu, double sigma)
|
||||||
return v1;
|
return v1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
Rayleigh RN
|
Rayleigh RN
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
@ -136,15 +134,12 @@ double RanMars::rayleigh(double sigma)
|
||||||
{
|
{
|
||||||
double first,v1;
|
double first,v1;
|
||||||
|
|
||||||
if (sigma <= 0) {
|
if (sigma <= 0) error->all(FLERR,"Invalid Rayleigh parameter");
|
||||||
error->all(FLERR,"Invalid Rayleigh parameter");
|
|
||||||
} else {
|
|
||||||
v1 = uniform();
|
|
||||||
first = sigma*sqrt(-2.0*log(v1));
|
|
||||||
return first;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
v1 = uniform();
|
||||||
|
first = sigma*sqrt(-2.0*log(v1));
|
||||||
|
return first;
|
||||||
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
Bessel exponential RN
|
Bessel exponential RN
|
||||||
|
@ -153,20 +148,21 @@ double RanMars::rayleigh(double sigma)
|
||||||
double RanMars::besselexp(double theta, double alpha, double cp)
|
double RanMars::besselexp(double theta, double alpha, double cp)
|
||||||
{
|
{
|
||||||
double first,v1,v2;
|
double first,v1,v2;
|
||||||
if ((theta < 0) || (alpha < 0) || (alpha >1)) {
|
|
||||||
|
if (theta < 0.0 || alpha < 0.0 || alpha < 1.0)
|
||||||
error->all(FLERR,"Invalid Bessel exponential distribution parameters");
|
error->all(FLERR,"Invalid Bessel exponential distribution parameters");
|
||||||
} else {
|
|
||||||
v1 = uniform();
|
v1 = uniform();
|
||||||
v2 = uniform();
|
v2 = uniform();
|
||||||
if (cp < 0) {
|
|
||||||
first = sqrt((1.0-alpha)*cp*cp - 2.0*alpha*theta*log(v1)
|
if (cp < 0.0)
|
||||||
+ 2.0*sqrt(-2.0*theta*(1.0-alpha)*alpha*log(v1))
|
first = sqrt((1.0-alpha)*cp*cp - 2.0*alpha*theta*log(v1) +
|
||||||
* cos(2.0*MathConst::MY_PI*v2)*cp);
|
2.0*sqrt(-2.0*theta*(1.0-alpha)*alpha*log(v1)) *
|
||||||
} else {
|
cos(2.0*MathConst::MY_PI*v2)*cp);
|
||||||
first = -sqrt((1.0-alpha)*cp*cp - 2.0*alpha*theta*log(v1)
|
else
|
||||||
- 2.0*sqrt(-2.0*theta*(1.0-alpha)*alpha*log(v1))
|
first = -sqrt((1.0-alpha)*cp*cp - 2.0*alpha*theta*log(v1) -
|
||||||
* cos(2.0*MathConst::MY_PI*v2)*cp);
|
2.0*sqrt(-2.0*theta*(1.0-alpha)*alpha*log(v1)) *
|
||||||
}
|
cos(2.0*MathConst::MY_PI*v2)*cp);
|
||||||
return first;
|
|
||||||
}
|
return first;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue