2006-11-11 07:52:37 +08:00
|
|
|
/* ----------------------------------------------------------------------
|
|
|
|
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
2007-01-30 08:22:05 +08:00
|
|
|
http://lammps.sandia.gov, Sandia National Laboratories
|
|
|
|
Steve Plimpton, sjplimp@sandia.gov
|
2006-11-11 07:52:37 +08:00
|
|
|
|
|
|
|
Copyright (2003) Sandia Corporation. Under the terms of Contract
|
|
|
|
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
|
|
|
|
certain rights in this software. This software is distributed under
|
|
|
|
the GNU General Public License.
|
|
|
|
|
|
|
|
See the README file in the top-level LAMMPS directory.
|
|
|
|
------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
#include "math.h"
|
|
|
|
#include "fix_wall_lj126.h"
|
|
|
|
#include "atom.h"
|
|
|
|
|
2007-01-30 08:22:05 +08:00
|
|
|
using namespace LAMMPS_NS;
|
|
|
|
|
2006-11-11 07:52:37 +08:00
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
2009-11-18 08:59:12 +08:00
|
|
|
FixWallLJ126::FixWallLJ126(LAMMPS *lmp, int narg, char **arg) :
|
|
|
|
FixWall(lmp, narg, arg) {}
|
2006-11-11 07:52:37 +08:00
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
2009-11-18 08:59:12 +08:00
|
|
|
void FixWallLJ126::precompute(int m)
|
2006-11-11 07:52:37 +08:00
|
|
|
{
|
2009-11-18 08:59:12 +08:00
|
|
|
coeff1[m] = 48.0 * epsilon[m] * pow(sigma[m],12.0);
|
|
|
|
coeff2[m] = 24.0 * epsilon[m] * pow(sigma[m],6.0);
|
|
|
|
coeff3[m] = 4.0 * epsilon[m] * pow(sigma[m],12.0);
|
|
|
|
coeff4[m] = 4.0 * epsilon[m] * pow(sigma[m],6.0);
|
2006-11-11 07:52:37 +08:00
|
|
|
|
2009-11-18 08:59:12 +08:00
|
|
|
double r2inv = 1.0/(cutoff[m]*cutoff[m]);
|
|
|
|
double r6inv = r2inv*r2inv*r2inv;
|
|
|
|
offset[m] = r6inv*(coeff3[m]*r6inv - coeff4[m]);
|
2006-11-11 07:52:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------- */
|
|
|
|
|
2009-11-18 08:59:12 +08:00
|
|
|
void FixWallLJ126::wall_particle(int m, double coord)
|
2006-11-11 07:52:37 +08:00
|
|
|
{
|
2009-11-18 08:59:12 +08:00
|
|
|
double delta,rinv,r2inv,r6inv,fwall;
|
2006-11-11 07:52:37 +08:00
|
|
|
|
|
|
|
double **x = atom->x;
|
|
|
|
double **f = atom->f;
|
|
|
|
int *mask = atom->mask;
|
|
|
|
int nlocal = atom->nlocal;
|
|
|
|
|
2009-11-18 08:59:12 +08:00
|
|
|
int dim = m/2;
|
|
|
|
int side = m % 2;
|
2009-11-19 00:01:25 +08:00
|
|
|
if (side == 0) side = -1;
|
2008-10-04 10:38:52 +08:00
|
|
|
|
2006-11-11 07:52:37 +08:00
|
|
|
for (int i = 0; i < nlocal; i++)
|
|
|
|
if (mask[i] & groupbit) {
|
2009-11-19 00:01:25 +08:00
|
|
|
if (side < 0) delta = x[i][dim] - coord;
|
2006-11-11 07:52:37 +08:00
|
|
|
else delta = coord - x[i][dim];
|
|
|
|
if (delta <= 0.0) continue;
|
2009-11-18 08:59:12 +08:00
|
|
|
if (delta > cutoff[m]) continue;
|
2006-11-11 07:52:37 +08:00
|
|
|
rinv = 1.0/delta;
|
|
|
|
r2inv = rinv*rinv;
|
|
|
|
r6inv = r2inv*r2inv*r2inv;
|
2009-11-18 08:59:12 +08:00
|
|
|
fwall = side * r6inv*(coeff1[m]*r6inv - coeff2[m]) * rinv;
|
2007-10-10 01:20:33 +08:00
|
|
|
f[i][dim] -= fwall;
|
2009-11-18 08:59:12 +08:00
|
|
|
ewall[0] += r6inv*(coeff3[m]*r6inv - coeff4[m]) - offset[m];
|
|
|
|
ewall[m+1] += fwall;
|
2006-11-11 07:52:37 +08:00
|
|
|
}
|
|
|
|
}
|