git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@622 f3b2605a-c512-4ea7-a41b-209d697bcdaa

This commit is contained in:
sjplimp
2007-06-20 13:17:59 +00:00
parent bde732bced
commit aaed6ebc33
131 changed files with 4277 additions and 2222 deletions

40
src/ASPHERE/Install.csh Normal file
View File

@ -0,0 +1,40 @@
# Install/unInstall package classes in LAMMPS
if ($1 == 1) then
cp style_asphere.h ..
cp atom_vec_ellipsoid.cpp ..
cp compute_temp_asphere.cpp ..
cp fix_npt_asphere.cpp ..
cp fix_nve_asphere.cpp ..
cp fix_nvt_asphere.cpp ..
cp pair_gayberne.cpp ..
cp atom_vec_ellipsoid.h ..
cp compute_temp_asphere.h ..
cp fix_npt_asphere.h ..
cp fix_nve_asphere.h ..
cp fix_nvt_asphere.h ..
cp pair_gayberne.h ..
else if ($1 == 0) then
rm ../style_asphere.h
touch ../style_asphere.h
rm ../atom_vec_ellipsoid.cpp
rm ../compute_temp_asphere.cpp
rm ../fix_npt_asphere.cpp
rm ../fix_nve_asphere.cpp
rm ../fix_nvt_asphere.cpp
rm ../pair_gayberne.cpp
rm ../atom_vec_ellipsoid.h
rm ../compute_temp_asphere.h
rm ../fix_npt_asphere.h
rm ../fix_nve_asphere.h
rm ../fix_nvt_asphere.h
rm ../pair_gayberne.h
endif

View File

@ -0,0 +1,609 @@
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
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.
------------------------------------------------------------------------- */
/* ----------------------------------------------------------------------
Contributing author: Mike Brown (SNL)
------------------------------------------------------------------------- */
#include "stdlib.h"
#include "atom_vec_ellipsoid.h"
#include "math_extra.h"
#include "atom.h"
#include "force.h"
#include "domain.h"
#include "modify.h"
#include "fix.h"
#include "memory.h"
#include "error.h"
using namespace LAMMPS_NS;
#define DELTA 10000
/* ---------------------------------------------------------------------- */
AtomVecEllipsoid::AtomVecEllipsoid(LAMMPS *lmp, int narg, char **arg) :
AtomVec(lmp, narg, arg)
{
mass_type = 1;
shape_type = 1;
comm_x_only = comm_f_only = 0;
size_comm = 7;
size_reverse = 6;
size_border = 10;
size_data_atom = 9;
size_data_vel = 7;
xcol_data = 3;
}
/* ---------------------------------------------------------------------- */
void AtomVecEllipsoid::init()
{
if (force->dimension == 2)
error->all("Cannot use atom style ellipsoid for 2d simulation");
}
/* ----------------------------------------------------------------------
grow atom arrays
n = 0 grows arrays by DELTA
n > 0 allocates arrays to size n
------------------------------------------------------------------------- */
void AtomVecEllipsoid::grow(int n)
{
if (n == 0) nmax += DELTA;
else nmax = n;
atom->nmax = nmax;
tag = atom->tag = (int *)
memory->srealloc(atom->tag,nmax*sizeof(int),"atom:tag");
type = atom->type = (int *)
memory->srealloc(atom->type,nmax*sizeof(int),"atom:type");
mask = atom->mask = (int *)
memory->srealloc(atom->mask,nmax*sizeof(int),"atom:mask");
image = atom->image = (int *)
memory->srealloc(atom->image,nmax*sizeof(int),"atom:image");
x = atom->x = memory->grow_2d_double_array(atom->x,nmax,3,"atom:x");
v = atom->v = memory->grow_2d_double_array(atom->v,nmax,3,"atom:v");
f = atom->f = memory->grow_2d_double_array(atom->f,nmax,3,"atom:f");
quat = atom->quat =
memory->grow_2d_double_array(atom->quat,nmax,4,"atom:quat");
angmom = atom->angmom =
memory->grow_2d_double_array(atom->angmom,nmax,3,"atom:angmom");
torque = atom->torque =
memory->grow_2d_double_array(atom->torque,nmax,3,"atom:torque");
if (atom->nextra_grow)
for (int iextra = 0; iextra < atom->nextra_grow; iextra++)
modify->fix[atom->extra_grow[iextra]]->grow_arrays(nmax);
}
/* ---------------------------------------------------------------------- */
void AtomVecEllipsoid::copy(int i, int j)
{
tag[j] = tag[i];
type[j] = type[i];
mask[j] = mask[i];
image[j] = image[i];
x[j][0] = x[i][0];
x[j][1] = x[i][1];
x[j][2] = x[i][2];
v[j][0] = v[i][0];
v[j][1] = v[i][1];
v[j][2] = v[i][2];
quat[j][0] = quat[i][0];
quat[j][1] = quat[i][1];
quat[j][2] = quat[i][2];
quat[j][3] = quat[i][3];
angmom[j][0] = angmom[i][0];
angmom[j][1] = angmom[i][1];
angmom[j][2] = angmom[i][2];
if (atom->nextra_grow)
for (int iextra = 0; iextra < atom->nextra_grow; iextra++)
modify->fix[atom->extra_grow[iextra]]->copy_arrays(i,j);
}
/* ---------------------------------------------------------------------- */
int AtomVecEllipsoid::pack_comm(int n, int *list, double *buf,
int pbc_flag, int *pbc)
{
int i,j,m;
double dx,dy,dz;
m = 0;
if (pbc_flag == 0) {
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = x[j][0];
buf[m++] = x[j][1];
buf[m++] = x[j][2];
buf[m++] = quat[j][0];
buf[m++] = quat[j][1];
buf[m++] = quat[j][2];
buf[m++] = quat[j][3];
}
} else {
if (domain->triclinic == 0) {
dx = pbc[0]*domain->xprd;
dy = pbc[1]*domain->yprd;
dz = pbc[2]*domain->zprd;
} else {
dx = pbc[0]*domain->xprd + pbc[5]*domain->xy + pbc[4]*domain->xz;
dy = pbc[1]*domain->yprd + pbc[3]*domain->yz;
dz = pbc[2]*domain->zprd;
}
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = x[j][0] + dx;
buf[m++] = x[j][1] + dy;
buf[m++] = x[j][2] + dz;
buf[m++] = quat[j][0];
buf[m++] = quat[j][1];
buf[m++] = quat[j][2];
buf[m++] = quat[j][3];
}
}
return m;
}
/* ---------------------------------------------------------------------- */
void AtomVecEllipsoid::unpack_comm(int n, int first, double *buf)
{
int i,m,last;
m = 0;
last = first + n;
for (i = first; i < last; i++) {
x[i][0] = buf[m++];
x[i][1] = buf[m++];
x[i][2] = buf[m++];
quat[i][0] = buf[m++];
quat[i][1] = buf[m++];
quat[i][2] = buf[m++];
quat[i][3] = buf[m++];
}
}
/* ---------------------------------------------------------------------- */
int AtomVecEllipsoid::pack_reverse(int n, int first, double *buf)
{
int i,m,last;
m = 0;
last = first + n;
for (i = first; i < last; i++) {
buf[m++] = f[i][0];
buf[m++] = f[i][1];
buf[m++] = f[i][2];
buf[m++] = torque[i][0];
buf[m++] = torque[i][1];
buf[m++] = torque[i][2];
}
return m;
}
/* ---------------------------------------------------------------------- */
void AtomVecEllipsoid::unpack_reverse(int n, int *list, double *buf)
{
int i,j,m;
m = 0;
for (i = 0; i < n; i++) {
j = list[i];
f[j][0] += buf[m++];
f[j][1] += buf[m++];
f[j][2] += buf[m++];
torque[j][0] += buf[m++];
torque[j][1] += buf[m++];
torque[j][2] += buf[m++];
}
}
/* ---------------------------------------------------------------------- */
int AtomVecEllipsoid::pack_border(int n, int *list, double *buf,
int pbc_flag, int *pbc)
{
int i,j,m;
double dx,dy,dz;
m = 0;
if (pbc_flag == 0) {
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = x[j][0];
buf[m++] = x[j][1];
buf[m++] = x[j][2];
buf[m++] = tag[j];
buf[m++] = type[j];
buf[m++] = mask[j];
buf[m++] = quat[j][0];
buf[m++] = quat[j][1];
buf[m++] = quat[j][2];
buf[m++] = quat[j][3];
}
} else {
if (domain->triclinic == 0) {
dx = pbc[0]*domain->xprd;
dy = pbc[1]*domain->yprd;
dz = pbc[2]*domain->zprd;
} else {
dx = pbc[0];
dy = pbc[1];
dz = pbc[2];
}
for (i = 0; i < n; i++) {
j = list[i];
buf[m++] = x[j][0] + dx;
buf[m++] = x[j][1] + dy;
buf[m++] = x[j][2] + dz;
buf[m++] = tag[j];
buf[m++] = type[j];
buf[m++] = mask[j];
buf[m++] = quat[j][0];
buf[m++] = quat[j][1];
buf[m++] = quat[j][2];
buf[m++] = quat[j][3];
}
}
return m;
}
/* ---------------------------------------------------------------------- */
void AtomVecEllipsoid::unpack_border(int n, int first, double *buf)
{
int i,m,last;
m = 0;
last = first + n;
for (i = first; i < last; i++) {
if (i == nmax) grow(0);
x[i][0] = buf[m++];
x[i][1] = buf[m++];
x[i][2] = buf[m++];
tag[i] = static_cast<int> (buf[m++]);
type[i] = static_cast<int> (buf[m++]);
mask[i] = static_cast<int> (buf[m++]);
quat[i][0] = buf[m++];
quat[i][1] = buf[m++];
quat[i][2] = buf[m++];
quat[i][3] = buf[m++];
}
}
/* ----------------------------------------------------------------------
pack data for atom I for sending to another proc
xyz must be 1st 3 values, so comm::exchange() can test on them
------------------------------------------------------------------------- */
int AtomVecEllipsoid::pack_exchange(int i, double *buf)
{
int m = 1;
buf[m++] = x[i][0];
buf[m++] = x[i][1];
buf[m++] = x[i][2];
buf[m++] = v[i][0];
buf[m++] = v[i][1];
buf[m++] = v[i][2];
buf[m++] = tag[i];
buf[m++] = type[i];
buf[m++] = mask[i];
buf[m++] = image[i];
buf[m++] = quat[i][0];
buf[m++] = quat[i][1];
buf[m++] = quat[i][2];
buf[m++] = quat[i][3];
buf[m++] = angmom[i][0];
buf[m++] = angmom[i][1];
buf[m++] = angmom[i][2];
if (atom->nextra_grow)
for (int iextra = 0; iextra < atom->nextra_grow; iextra++)
m += modify->fix[atom->extra_grow[iextra]]->pack_exchange(i,&buf[m]);
buf[0] = m;
return m;
}
/* ---------------------------------------------------------------------- */
int AtomVecEllipsoid::unpack_exchange(double *buf)
{
int nlocal = atom->nlocal;
if (nlocal == nmax) grow(0);
int m = 1;
x[nlocal][0] = buf[m++];
x[nlocal][1] = buf[m++];
x[nlocal][2] = buf[m++];
v[nlocal][0] = buf[m++];
v[nlocal][1] = buf[m++];
v[nlocal][2] = buf[m++];
tag[nlocal] = static_cast<int> (buf[m++]);
type[nlocal] = static_cast<int> (buf[m++]);
mask[nlocal] = static_cast<int> (buf[m++]);
image[nlocal] = static_cast<int> (buf[m++]);
quat[nlocal][0] = buf[m++];
quat[nlocal][1] = buf[m++];
quat[nlocal][2] = buf[m++];
quat[nlocal][3] = buf[m++];
angmom[nlocal][0] = buf[m++];
angmom[nlocal][1] = buf[m++];
angmom[nlocal][2] = buf[m++];
if (atom->nextra_grow)
for (int iextra = 0; iextra < atom->nextra_grow; iextra++)
m += modify->fix[atom->extra_grow[iextra]]->
unpack_exchange(nlocal,&buf[m]);
atom->nlocal++;
return m;
}
/* ----------------------------------------------------------------------
size of restart data for all atoms owned by this proc
include extra data stored by fixes
------------------------------------------------------------------------- */
int AtomVecEllipsoid::size_restart()
{
int i;
int nlocal = atom->nlocal;
int n = 18 * nlocal;
if (atom->nextra_restart)
for (int iextra = 0; iextra < atom->nextra_restart; iextra++)
for (i = 0; i < nlocal; i++)
n += modify->fix[atom->extra_restart[iextra]]->size_restart(i);
return n;
}
/* ----------------------------------------------------------------------
pack atom I's data for restart file including extra quantities
xyz must be 1st 3 values, so that read_restart can test on them
molecular types may be negative, but write as positive
------------------------------------------------------------------------- */
int AtomVecEllipsoid::pack_restart(int i, double *buf)
{
int m = 1;
buf[m++] = x[i][0];
buf[m++] = x[i][1];
buf[m++] = x[i][2];
buf[m++] = tag[i];
buf[m++] = type[i];
buf[m++] = mask[i];
buf[m++] = image[i];
buf[m++] = v[i][0];
buf[m++] = v[i][1];
buf[m++] = v[i][2];
buf[m++] = quat[i][0];
buf[m++] = quat[i][1];
buf[m++] = quat[i][2];
buf[m++] = quat[i][3];
buf[m++] = angmom[i][0];
buf[m++] = angmom[i][1];
buf[m++] = angmom[i][2];
if (atom->nextra_restart)
for (int iextra = 0; iextra < atom->nextra_restart; iextra++)
m += modify->fix[atom->extra_restart[iextra]]->pack_restart(i,&buf[m]);
buf[0] = m;
return m;
}
/* ----------------------------------------------------------------------
unpack data for one atom from restart file including extra quantities
------------------------------------------------------------------------- */
int AtomVecEllipsoid::unpack_restart(double *buf)
{
int nlocal = atom->nlocal;
if (nlocal == nmax) {
grow(0);
if (atom->nextra_store)
atom->extra = memory->grow_2d_double_array(atom->extra,nmax,
atom->nextra_store,
"atom:extra");
}
int m = 1;
x[nlocal][0] = buf[m++];
x[nlocal][1] = buf[m++];
x[nlocal][2] = buf[m++];
tag[nlocal] = static_cast<int> (buf[m++]);
type[nlocal] = static_cast<int> (buf[m++]);
mask[nlocal] = static_cast<int> (buf[m++]);
image[nlocal] = static_cast<int> (buf[m++]);
v[nlocal][0] = buf[m++];
v[nlocal][1] = buf[m++];
v[nlocal][2] = buf[m++];
quat[nlocal][0] = buf[m++];
quat[nlocal][1] = buf[m++];
quat[nlocal][2] = buf[m++];
quat[nlocal][3] = buf[m++];
angmom[nlocal][0] = buf[m++];
angmom[nlocal][1] = buf[m++];
angmom[nlocal][2] = buf[m++];
double **extra = atom->extra;
if (atom->nextra_store) {
int size = static_cast<int> (buf[0]) - m;
for (int i = 0; i < size; i++) extra[nlocal][i] = buf[m++];
}
atom->nlocal++;
return m;
}
/* ----------------------------------------------------------------------
create one atom of itype at coord
set other values to defaults
------------------------------------------------------------------------- */
void AtomVecEllipsoid::create_atom(int itype, double *coord)
{
int nlocal = atom->nlocal;
if (nlocal == nmax) grow(0);
tag[nlocal] = 0;
type[nlocal] = itype;
x[nlocal][0] = coord[0];
x[nlocal][1] = coord[1];
x[nlocal][2] = coord[2];
mask[nlocal] = 1;
image[nlocal] = (512 << 20) | (512 << 10) | 512;
v[nlocal][0] = 0.0;
v[nlocal][1] = 0.0;
v[nlocal][2] = 0.0;
quat[nlocal][0] = 1.0;
quat[nlocal][1] = 0.0;
quat[nlocal][2] = 0.0;
quat[nlocal][3] = 0.0;
angmom[nlocal][0] = 0.0;
angmom[nlocal][1] = 0.0;
angmom[nlocal][2] = 0.0;
atom->nlocal++;
}
/* ----------------------------------------------------------------------
unpack one line from Atoms section of data file
initialize other atom quantities
------------------------------------------------------------------------- */
void AtomVecEllipsoid::data_atom(double *coord, int imagetmp, char **values)
{
int nlocal = atom->nlocal;
if (nlocal == nmax) grow(0);
tag[nlocal] = atoi(values[0]);
if (tag[nlocal] <= 0)
error->one("Invalid atom ID in Atoms section of data file");
type[nlocal] = atoi(values[1]);
if (type[nlocal] <= 0 || type[nlocal] > atom->ntypes)
error->one("Invalid atom type in Atoms section of data file");
x[nlocal][0] = coord[0];
x[nlocal][1] = coord[1];
x[nlocal][2] = coord[2];
quat[nlocal][0] = atof(values[5]);
quat[nlocal][1] = atof(values[6]);
quat[nlocal][2] = atof(values[7]);
quat[nlocal][3] = atof(values[8]);
MathExtra::normalize4(quat[nlocal]);
image[nlocal] = imagetmp;
mask[nlocal] = 1;
v[nlocal][0] = 0.0;
v[nlocal][1] = 0.0;
v[nlocal][2] = 0.0;
angmom[nlocal][0] = 0.0;
angmom[nlocal][1] = 0.0;
angmom[nlocal][2] = 0.0;
atom->nlocal++;
}
/* ----------------------------------------------------------------------
unpack hybrid quantities from one line in Atoms section of data file
initialize other atom quantities for this sub-style
------------------------------------------------------------------------- */
int AtomVecEllipsoid::data_atom_hybrid(int nlocal, char **values)
{
quat[nlocal][0] = atof(values[0]);
quat[nlocal][1] = atof(values[1]);
quat[nlocal][2] = atof(values[2]);
quat[nlocal][3] = atof(values[3]);
MathExtra::normalize4(quat[nlocal]);
v[nlocal][0] = 0.0;
v[nlocal][1] = 0.0;
v[nlocal][2] = 0.0;
angmom[nlocal][0] = 0.0;
angmom[nlocal][1] = 0.0;
angmom[nlocal][2] = 0.0;
return 0;
}
/* ----------------------------------------------------------------------
unpack one line from Velocities section of data file
------------------------------------------------------------------------- */
void AtomVecEllipsoid::data_vel(int m, char **values)
{
v[m][0] = atof(values[0]);
v[m][1] = atof(values[1]);
v[m][2] = atof(values[2]);
angmom[m][0] = atof(values[3]);
angmom[m][1] = atof(values[4]);
angmom[m][2] = atof(values[5]);
}
/* ----------------------------------------------------------------------
unpack hybrid quantities from one line in Velocities section of data file
------------------------------------------------------------------------- */
int AtomVecEllipsoid::data_vel_hybrid(int m, char **values)
{
angmom[m][0] = atof(values[0]);
angmom[m][1] = atof(values[1]);
angmom[m][2] = atof(values[2]);
return 3;
}
/* ----------------------------------------------------------------------
return # of bytes of allocated memory
------------------------------------------------------------------------- */
int AtomVecEllipsoid::memory_usage()
{
int bytes = 0;
if (atom->memcheck("tag")) bytes += nmax * sizeof(int);
if (atom->memcheck("type")) bytes += nmax * sizeof(int);
if (atom->memcheck("mask")) bytes += nmax * sizeof(int);
if (atom->memcheck("image")) bytes += nmax * sizeof(int);
if (atom->memcheck("x")) bytes += nmax*3 * sizeof(double);
if (atom->memcheck("v")) bytes += nmax*3 * sizeof(double);
if (atom->memcheck("f")) bytes += nmax*3 * sizeof(double);
if (atom->memcheck("quat")) bytes += nmax*4 * sizeof(double);
if (atom->memcheck("angmom")) bytes += nmax*3 * sizeof(double);
if (atom->memcheck("torque")) bytes += nmax*3 * sizeof(double);
return bytes;
}

View File

@ -0,0 +1,54 @@
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
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.
------------------------------------------------------------------------- */
#ifndef ATOM_VEC_ELLIPSOID_H
#define ATOM_VEC_ELLIPSOID_H
#include "atom_vec.h"
namespace LAMMPS_NS {
class AtomVecEllipsoid : public AtomVec {
public:
AtomVecEllipsoid(class LAMMPS *, int, char **);
virtual ~AtomVecEllipsoid() {}
void init();
void grow(int);
void copy(int, int);
virtual int pack_comm(int, int *, double *, int, int *);
virtual void unpack_comm(int, int, double *);
int pack_reverse(int, int, double *);
void unpack_reverse(int, int *, double *);
virtual int pack_border(int, int *, double *, int, int *);
virtual void unpack_border(int, int, double *);
int pack_exchange(int, double *);
int unpack_exchange(double *);
int size_restart();
int pack_restart(int, double *);
int unpack_restart(double *);
void create_atom(int, double *);
void data_atom(double *, int, char **);
int data_atom_hybrid(int, char **);
void data_vel(int, char **);
int data_vel_hybrid(int, char **);
int memory_usage();
private:
int *tag,*type,*mask,*image;
double **x,**v,**f;
double **angmom,**torque,**quat;
};
}
#endif

View File

@ -0,0 +1,227 @@
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
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.
------------------------------------------------------------------------- */
/* ----------------------------------------------------------------------
Contributing author: Mike Brown (SNL)
------------------------------------------------------------------------- */
#include "mpi.h"
#include "compute_temp_asphere.h"
#include "math_extra.h"
#include "atom.h"
#include "force.h"
#include "modify.h"
#include "fix.h"
#include "group.h"
#include "memory.h"
#include "error.h"
using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */
ComputeTempAsphere::ComputeTempAsphere(LAMMPS *lmp, int narg, char **arg) :
Compute(lmp, narg, arg)
{
if (narg != 3) error->all("Illegal compute temp command");
if (atom->quat == NULL || atom->angmom == NULL)
error->all("Compute temp/asphere requires atom attributes quat, angmom");
scalar_flag = vector_flag = 1;
size_vector = 6;
extensive = 0;
tempflag = 1;
vector = new double[6];
inertia =
memory->create_2d_double_array(atom->ntypes+1,3,"fix_temp_sphere:inertia");
}
/* ---------------------------------------------------------------------- */
ComputeTempAsphere::~ComputeTempAsphere()
{
delete [] vector;
memory->destroy_2d_double_array(inertia);
}
/* ---------------------------------------------------------------------- */
void ComputeTempAsphere::init()
{
fix_dof = 0;
for (int i = 0; i < modify->nfix; i++)
fix_dof += modify->fix[i]->dof(igroup);
recount();
calculate_inertia();
}
/* ---------------------------------------------------------------------- */
void ComputeTempAsphere::recount()
{
double natoms = group->count(igroup);
dof = force->dimension * natoms;
dof -= extra_dof + fix_dof;
// add rotational degrees of freedom
// 0 for sphere, 2 for uniaxial, 3 for biaxial
double **shape = atom->shape;
int *type = atom->type;
int *mask = atom->mask;
int nlocal = atom->nlocal;
int itype;
int rot_dof = 0;
for (int i = 0; i < nlocal; i++)
if (mask[i] & groupbit) {
itype = type[i];
if (shape[itype][0] == shape[itype][1] &&
shape[itype][1] == shape[itype][2]) continue;
else if (shape[itype][0] == shape[itype][1] ||
shape[itype][1] == shape[itype][2] ||
shape[itype][0] == shape[itype][2]) rot_dof += 2;
else rot_dof += 3;
}
int rot_total;
MPI_Allreduce(&rot_dof,&rot_total,1,MPI_INT,MPI_SUM,world);
dof += rot_total;
if (dof > 0) tfactor = force->mvv2e / (dof * force->boltz);
else tfactor = 0.0;
}
/* ---------------------------------------------------------------------- */
double ComputeTempAsphere::compute_scalar()
{
double **v = atom->v;
double **quat = atom->quat;
double **angmom = atom->angmom;
double *mass = atom->mass;
int *type = atom->type;
int *mask = atom->mask;
int nlocal = atom->nlocal;
int itype;
double wbody[3];
double rot[3][3];
double t = 0.0;
for (int i = 0; i < nlocal; i++)
if (mask[i] & groupbit) {
// translational kinetic energy
itype = type[i];
t += (v[i][0]*v[i][0] + v[i][1]*v[i][1] + v[i][2]*v[i][2]) * mass[itype];
// wbody = angular velocity in body frame
MathExtra::quat_to_mat(quat[i],rot);
MathExtra::transpose_times_column3(rot,angmom[i],wbody);
wbody[0] /= inertia[itype][0];
wbody[1] /= inertia[itype][1];
wbody[2] /= inertia[itype][2];
// rotational kinetic energy
t += inertia[itype][0]*wbody[0]*wbody[0]+
inertia[itype][1]*wbody[1]*wbody[1]+
inertia[itype][2]*wbody[2]*wbody[2];
}
MPI_Allreduce(&t,&scalar,1,MPI_DOUBLE,MPI_SUM,world);
if (dynamic) recount();
scalar *= tfactor;
return scalar;
}
/* ---------------------------------------------------------------------- */
void ComputeTempAsphere::compute_vector()
{
int i;
double **v = atom->v;
double **quat = atom->quat;
double **angmom = atom->angmom;
double *mass = atom->mass;
int *type = atom->type;
int *mask = atom->mask;
int nlocal = atom->nlocal;
int itype;
double wbody[3];
double rot[3][3];
double massone,t[6];
for (i = 0; i < 6; i++) t[i] = 0.0;
for (i = 0; i < nlocal; i++)
if (mask[i] & groupbit) {
// translational kinetic energy
itype = type[i];
massone = mass[itype];
t[0] += massone * v[i][0]*v[i][0];
t[1] += massone * v[i][1]*v[i][1];
t[2] += massone * v[i][2]*v[i][2];
t[3] += massone * v[i][0]*v[i][1];
t[4] += massone * v[i][0]*v[i][2];
t[5] += massone * v[i][1]*v[i][2];
// wbody = angular velocity in body frame
MathExtra::quat_to_mat(quat[i],rot);
MathExtra::transpose_times_column3(rot,angmom[i],wbody);
wbody[0] /= inertia[itype][0];
wbody[1] /= inertia[itype][1];
wbody[2] /= inertia[itype][2];
// rotational kinetic energy
t[0] += inertia[itype][0]*wbody[0]*wbody[0];
t[1] += inertia[itype][1]*wbody[1]*wbody[1];
t[2] += inertia[itype][2]*wbody[2]*wbody[2];
t[3] += inertia[itype][0]*wbody[0]*wbody[1];
t[4] += inertia[itype][1]*wbody[0]*wbody[2];
t[5] += inertia[itype][2]*wbody[1]*wbody[2];
}
MPI_Allreduce(t,vector,6,MPI_DOUBLE,MPI_SUM,world);
for (i = 0; i < 6; i++) vector[i] *= force->mvv2e;
}
/* ----------------------------------------------------------------------
principal moments of inertia for ellipsoids
------------------------------------------------------------------------- */
void ComputeTempAsphere::calculate_inertia()
{
double *mass = atom->mass;
double **shape = atom->shape;
for (int i = 1; i <= atom->ntypes; i++) {
inertia[i][0] = mass[i] *
(shape[i][1]*shape[i][1]+shape[i][2]*shape[i][2]) / 5.0;
inertia[i][1] = mass[i] *
(shape[i][0]*shape[i][0]+shape[i][2]*shape[i][2]) / 5.0;
inertia[i][2] = mass[i] *
(shape[i][0]*shape[i][0]+shape[i][1]*shape[i][1]) / 5.0;
}
}

View File

@ -0,0 +1,40 @@
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
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.
------------------------------------------------------------------------- */
#ifndef COMPUTE_TEMP_ASPHERE_H
#define COMPUTE_TEMP_ASPHERE_H
#include "compute.h"
namespace LAMMPS_NS {
class ComputeTempAsphere : public Compute {
public:
ComputeTempAsphere(class LAMMPS *, int, char **);
~ComputeTempAsphere();
void init();
double compute_scalar();
void compute_vector();
private:
int fix_dof;
double tfactor;
double **inertia;
void recount();
void calculate_inertia();
};
}
#endif

236
src/ASPHERE/fix_nve_asphere.cpp Executable file
View File

@ -0,0 +1,236 @@
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
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.
------------------------------------------------------------------------- */
/* ----------------------------------------------------------------------
Contributing author: Mike Brown (SNL)
------------------------------------------------------------------------- */
#include "math.h"
#include "stdio.h"
#include "string.h"
#include "fix_nve_asphere.h"
#include "math_extra.h"
#include "atom.h"
#include "force.h"
#include "update.h"
#include "memory.h"
#include "error.h"
#define TOLERANCE 1.0e-6
#define EPSILON 1.0e-7
using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */
FixNVEASphere::FixNVEASphere(LAMMPS *lmp, int narg, char **arg) :
Fix(lmp, narg, arg)
{
if (narg < 3) error->all("Illegal fix nve/asphere command");
if (atom->quat == NULL || atom->angmom == NULL || atom->torque == NULL)
error->all("Fix nve/asphere requires atom attributes "
"quat, angmom, torque");
inertia =
memory->create_2d_double_array(atom->ntypes+1,3,"fix_temp_sphere:inertia");
}
/* ---------------------------------------------------------------------- */
FixNVEASphere::~FixNVEASphere()
{
memory->destroy_2d_double_array(inertia);
}
/* ---------------------------------------------------------------------- */
int FixNVEASphere::setmask()
{
int mask = 0;
mask |= INITIAL_INTEGRATE;
mask |= FINAL_INTEGRATE;
return mask;
}
/* ---------------------------------------------------------------------- */
void FixNVEASphere::init()
{
dtv = update->dt;
dtf = 0.5 * update->dt * force->ftm2v;
dtq = 0.5 * update->dt;
calculate_inertia();
}
/* ---------------------------------------------------------------------- */
void FixNVEASphere::initial_integrate()
{
double dtfm;
double **x = atom->x;
double **v = atom->v;
double **f = atom->f;
double **quat = atom->quat;
double **angmom = atom->angmom;
double **torque = atom->torque;
double *mass = atom->mass;
int *type = atom->type;
int *mask = atom->mask;
int nlocal = atom->nlocal;
for (int i = 0; i < atom->nlocal; i++)
if (mask[i] & groupbit) {
dtfm = dtf / mass[type[i]];
v[i][0] += dtfm * f[i][0];
v[i][1] += dtfm * f[i][1];
v[i][2] += dtfm * f[i][2];
x[i][0] += dtv * v[i][0];
x[i][1] += dtv * v[i][1];
x[i][2] += dtv * v[i][2];
// update angular momentum by 1/2 step
// update quaternion a full step via Richardson iteration
// returns new normalized quaternion
angmom[i][0] += dtf * torque[i][0];
angmom[i][1] += dtf * torque[i][1];
angmom[i][2] += dtf * torque[i][2];
richardson(quat[i],angmom[i],inertia[type[i]]);
}
}
/* ---------------------------------------------------------------------- */
void FixNVEASphere::final_integrate()
{
double dtfm;
double **v = atom->v;
double **f = atom->f;
double **angmom = atom->angmom;
double **torque = atom->torque;
double *mass = atom->mass;
int *type = atom->type;
int *mask = atom->mask;
int nlocal = atom->nlocal;
for (int i = 0; i < nlocal; i++)
if (mask[i] & groupbit) {
dtfm = dtf / mass[atom->type[i]];
v[i][0] += dtfm * f[i][0];
v[i][1] += dtfm * f[i][1];
v[i][2] += dtfm * f[i][2];
angmom[i][0] += dtf * torque[i][0];
angmom[i][1] += dtf * torque[i][1];
angmom[i][2] += dtf * torque[i][2];
}
}
/* ----------------------------------------------------------------------
Richardson iteration to update quaternion accurately
------------------------------------------------------------------------- */
void FixNVEASphere::richardson(double *q, double *m, double *moments)
{
// compute omega at 1/2 step from m at 1/2 step and q at 0
double w[3];
omega_from_mq(q,m,moments,w);
// full update from dq/dt = 1/2 w q
double wq[4];
MathExtra::multiply_vec_quat(w,q,wq);
double qfull[4];
qfull[0] = q[0] + dtq * wq[0];
qfull[1] = q[1] + dtq * wq[1];
qfull[2] = q[2] + dtq * wq[2];
qfull[3] = q[3] + dtq * wq[3];
MathExtra::normalize4(qfull);
// 1st half of update from dq/dt = 1/2 w q
double qhalf[4];
qhalf[0] = q[0] + 0.5*dtq * wq[0];
qhalf[1] = q[1] + 0.5*dtq * wq[1];
qhalf[2] = q[2] + 0.5*dtq * wq[2];
qhalf[3] = q[3] + 0.5*dtq * wq[3];
MathExtra::normalize4(qhalf);
// re-compute omega at 1/2 step from m at 1/2 step and q at 1/2 step
// recompute wq
omega_from_mq(qhalf,m,moments,w);
MathExtra::multiply_vec_quat(w,qhalf,wq);
// 2nd half of update from dq/dt = 1/2 w q
qhalf[0] += 0.5*dtq * wq[0];
qhalf[1] += 0.5*dtq * wq[1];
qhalf[2] += 0.5*dtq * wq[2];
qhalf[3] += 0.5*dtq * wq[3];
MathExtra::normalize4(qhalf);
// corrected Richardson update
q[0] = 2.0*qhalf[0] - qfull[0];
q[1] = 2.0*qhalf[1] - qfull[1];
q[2] = 2.0*qhalf[2] - qfull[2];
q[3] = 2.0*qhalf[3] - qfull[3];
MathExtra::normalize4(q);
}
/* ----------------------------------------------------------------------
compute omega from angular momentum
w = omega = angular velocity in space frame
wbody = angular velocity in body frame
project space-frame angular momentum onto body axes
and divide by principal moments
------------------------------------------------------------------------- */
void FixNVEASphere::omega_from_mq(double *q, double *m, double *moments,
double *w)
{
double rot[3][3];
MathExtra::quat_to_mat(q,rot);
double wbody[3];
MathExtra::transpose_times_column3(rot,m,wbody);
wbody[0] /= moments[0];
wbody[1] /= moments[1];
wbody[2] /= moments[2];
MathExtra::times_column3(rot,wbody,w);
}
/* ----------------------------------------------------------------------
principal moments of inertia for ellipsoids
------------------------------------------------------------------------- */
void FixNVEASphere::calculate_inertia()
{
double *mass = atom->mass;
double **shape = atom->shape;
for (int i = 1; i <= atom->ntypes; i++) {
inertia[i][0] = mass[i] *
(shape[i][1]*shape[i][1]+shape[i][2]*shape[i][2]) / 5.0;
inertia[i][1] = mass[i] *
(shape[i][0]*shape[i][0]+shape[i][2]*shape[i][2]) / 5.0;
inertia[i][2] = mass[i] *
(shape[i][0]*shape[i][0]+shape[i][1]*shape[i][1]) / 5.0;
}
}

40
src/ASPHERE/fix_nve_asphere.h Executable file
View File

@ -0,0 +1,40 @@
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
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.
------------------------------------------------------------------------- */
#ifndef FIX_NVE_ASPHERE_H
#define FIX_NVE_ASPHERE_H
#include "fix.h"
namespace LAMMPS_NS {
class FixNVEASphere : public Fix {
public:
FixNVEASphere(class LAMMPS *, int, char **);
~FixNVEASphere();
int setmask();
void init();
void initial_integrate();
void final_integrate();
private:
double dtv,dtf,dtq;
double **inertia;
void richardson(double *, double *, double *);
void omega_from_mq(double *, double *, double *, double *);
void calculate_inertia();
};
}
#endif

698
src/ASPHERE/pair_gayberne.cpp Executable file
View File

@ -0,0 +1,698 @@
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
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.
------------------------------------------------------------------------- */
/* ----------------------------------------------------------------------
Contributing author: Mike Brown (SNL)
------------------------------------------------------------------------- */
#include "math.h"
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#include "pair_gayberne.h"
#include "math_extra.h"
#include "atom.h"
#include "comm.h"
#include "force.h"
#include "neighbor.h"
#include "update.h"
#include "integrate.h"
#include "respa.h"
#include "memory.h"
#include "error.h"
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define MAX(a,b) ((a) > (b) ? (a) : (b))
using namespace LAMMPS_NS;
enum{SPHERE_SPHERE,SPHERE_ELLIPSE,ELLIPSE_ELLIPSE};
/* ---------------------------------------------------------------------- */
PairGayBerne::PairGayBerne(LAMMPS *lmp) : Pair(lmp)
{
respa_enable = 0;
single_enable = 0;
}
/* ----------------------------------------------------------------------
free all arrays
------------------------------------------------------------------------- */
PairGayBerne::~PairGayBerne()
{
if (allocated) {
memory->destroy_2d_int_array(setflag);
memory->destroy_2d_double_array(cutsq);
memory->destroy_2d_int_array(form);
memory->destroy_2d_double_array(epsi);
memory->destroy_2d_double_array(sig);
memory->destroy_2d_double_array(shape);
memory->destroy_2d_double_array(well);
memory->destroy_2d_double_array(cut);
memory->destroy_2d_double_array(lj1);
memory->destroy_2d_double_array(lj2);
memory->destroy_2d_double_array(lj3);
memory->destroy_2d_double_array(lj4);
delete [] lshape;
}
}
/* ---------------------------------------------------------------------- */
void PairGayBerne::compute(int eflag, int vflag)
{
int i,j,k,m,numneigh;
double one_eng,rsq;
double fforce[3],ttor[3],rtor[3],r12[3];
double a1[3][3],b1[3][3],g1[3][3],a2[3][3],b2[3][3],g2[3][3],temp[3][3];
int *neighs;
double factor_lj;
double **f;
eng_vdwl = 0.0;
if (vflag) for (i = 0; i < 6; i++) virial[i] = 0.0;
if (vflag == 2) f = update->f_pair;
else f = atom->f;
double **x = atom->x;
double **quat = atom->quat;
double **tor = atom->torque;
int *type = atom->type;
int nlocal = atom->nlocal;
int nall = atom->nlocal + atom->nghost;
double *special_lj = force->special_lj;
int newton_pair = force->newton_pair;
// loop over neighbors of my atoms
for (i = 0; i < nlocal; i++) {
neighs = neighbor->firstneigh[i];
numneigh = neighbor->numneigh[i];
// precomputations for force calculation
MathExtra::quat_to_mat_trans(quat[i],a1);
MathExtra::diag_times3(well[type[i]],a1,temp);
MathExtra::transpose_times3(a1,temp,b1);
MathExtra::diag_times3(shape[type[i]],a1,temp);
MathExtra::transpose_times3(a1,temp,g1);
for (k = 0; k < numneigh; k++) {
j = neighs[k];
if (j < nall) factor_lj = 1.0;
else {
factor_lj = special_lj[j/nall];
j %= nall;
}
// r12 = center to center vector
r12[0] = x[j][0]-x[i][0];
r12[1] = x[j][1]-x[i][1];
r12[2] = x[j][2]-x[i][2];
rsq = MathExtra::dot3(r12,r12);
// compute if less than cutoff
if (rsq < cutsq[type[i]][type[j]]) {
switch (form[itype][jtype]) {
case SPHERE_SPHERE:
r2inv = 1.0/rsq;
r6inv = r2inv*r2inv*r2inv;
forcelj = r6inv * (lj1[itype][jtype]*r6inv - lj2[itype][jtype]);
forcelj *= -r2inv;
if (eflag) phi = r6inv*(r6inv*lj3[itype][jtype]-lj4[itype][jtype]) -
offset[itype][jtype];
fforce[0] = r12[0]*forcelj;
fforce[1] = r12[1]*forcelj;
fforce[2] = r12[2]*forcelj;
ttor[0] = ttor[1] = ttor[2] = 0.0;
break;
case SPHERE_ELLIPSE:
MathExtra::quat_to_mat_trans(quat[j],a2);
MathExtra::diag_times3(well[type[j]],a2,temp);
MathExtra::transpose_times3(a2,temp,b2);
MathExtra::diag_times3(shape[type[j]],a2,temp);
MathExtra::transpose_times3(a2,temp,g2);
one_eng = gayberne_analytic(i,j,a1,a2,b1,b2,g1,g2,r12,rsq,
fforce,ttor,rtor);
break;
case ELLIPSE_ELLIPSE:
MathExtra::quat_to_mat_trans(quat[j],a2);
MathExtra::diag_times3(well[type[j]],a2,temp);
MathExtra::transpose_times3(a2,temp,b2);
MathExtra::diag_times3(shape[type[j]],a2,temp);
MathExtra::transpose_times3(a2,temp,g2);
one_eng = gayberne_analytic(i,j,a1,a2,b1,b2,g1,g2,r12,rsq,
fforce,ttor,rtor);
break;
}
fforce[0] *= factor_lj;
fforce[1] *= factor_lj;
fforce[2] *= factor_lj;
ttor[0] *= factor_lj;
ttor[1] *= factor_lj;
ttor[2] *= factor_lj;
f[i][0] += fforce[0];
f[i][1] += fforce[1];
f[i][2] += fforce[2];
tor[i][0] += ttor[0];
tor[i][1] += ttor[1];
tor[i][2] += ttor[2];
if (newton_pair || j < nlocal) {
rtor[0] *= factor_lj;
rtor[1] *= factor_lj;
rtor[2] *= factor_lj;
f[j][0] -= fforce[0];
f[j][1] -= fforce[1];
f[j][2] -= fforce[2];
tor[j][0] += rtor[0];
tor[j][1] += rtor[1];
tor[j][2] += rtor[2];
}
if (eflag) {
if (newton_pair || j < nlocal) eng_vdwl += factor_lj*one_eng;
else eng_vdwl += 0.5*factor_lj*one_eng;
}
if (vflag == 1) {
if (newton_pair == 0 && j >= nlocal)
for (m = 0; m < 6; m++) fforce[m] *= 0.5;
virial[0] += r12[0]*r12[0]*fforce[0];
virial[1] += r12[1]*r12[1]*fforce[1];
virial[2] += r12[2]*r12[2]*fforce[2];
virial[3] += r12[0]*r12[1]*fforce[0];
virial[4] += r12[0]*r12[2]*fforce[1];
virial[5] += r12[1]*r12[2]*fforce[2];
}
}
}
}
if (vflag == 2) virial_compute();
}
/* ----------------------------------------------------------------------
allocate all arrays
------------------------------------------------------------------------- */
void PairGayBerne::allocate()
{
allocated = 1;
int n = atom->ntypes;
setflag = memory->create_2d_int_array(n+1,n+1,"pair:setflag");
for (int i = 1; i <= n; i++)
for (int j = i; j <= n; j++)
setflag[i][j] = 0;
cutsq = memory->create_2d_double_array(n+1,n+1,"pair:cutsq");
form = memory->create_2d_int_array(n+1,n+1,"pair:form");
epsi = memory->create_2d_double_array(n+1,n+1,"pair:epsi");
sig = memory->create_2d_double_array(n+1,n+1,"pair:sig");
shape = memory->create_2d_double_array(n+1,3,"pair:shape");
well = memory->create_2d_double_array(n+1,3,"pair:well");
cut = memory->create_2d_double_array(n+1,n+1,"pair:cut");
lj1 = memory->create_2d_double_array(n+1,n+1,"pair:lj1");
lj2 = memory->create_2d_double_array(n+1,n+1,"pair:lj2");
lj3 = memory->create_2d_double_array(n+1,n+1,"pair:lj3");
lj4 = memory->create_2d_double_array(n+1,n+1,"pair:lj4");
lshape = new double[n+1];
}
/* ----------------------------------------------------------------------
global settings
------------------------------------------------------------------------- */
void PairGayBerne::settings(int narg, char **arg)
{
if (narg != 4) error->all("Illegal pair_style command");
gamma = atof(arg[0]);
upsilon = atof(arg[1])/2.0;
mu = atof(arg[2]);
cut_global = atof(arg[3]);
// reset cutoffs that have been explicitly set
if (allocated) {
int i,j;
for (i = 1; i <= atom->ntypes; i++)
for (j = i+1; j <= atom->ntypes; j++)
if (setflag[i][j]) cut[i][j] = cut_global;
}
}
/* ----------------------------------------------------------------------
set coeffs for one or more type pairs
------------------------------------------------------------------------- */
void PairGayBerne::coeff(int narg, char **arg)
{
if (narg < 10 || narg > 11)
error->all("Incorrect args for pair coefficients");
if (!allocated) allocate();
int ilo,ihi,jlo,jhi;
force->bounds(arg[0],atom->ntypes,ilo,ihi);
force->bounds(arg[1],atom->ntypes,jlo,jhi);
double epsi_one = atof(arg[2]);
double sig_one = atof(arg[3]);
double eia_one = atof(arg[4]);
double eib_one = atof(arg[5]);
double eic_one = atof(arg[6]);
double eja_one = atof(arg[7]);
double ejb_one = atof(arg[8]);
double ejc_one = atof(arg[9]);
double cut_one = cut_global;
if (narg == 11) cut_one = atof(arg[10]);
int count = 0;
for (int i = ilo; i <= ihi; i++) {
for (int j = MAX(jlo,i); j <= jhi; j++) {
epsi[i][j] = epsi_one;
sig[i][j] = sig_one;
cut[i][j] = cut_one;
if (i == j) {
well[i][0] = pow(ea_one,-1.0/mu);
well[i][1] = pow(eb_one,-1.0/mu);
well[i][2] = pow(ec_one,-1.0/mu);
}
setflag[i][j] = 1;
count++;
}
}
if (count == 0) error->all("Incorrect args for pair coefficients");
}
/* ----------------------------------------------------------------------
init for one type pair i,j and corresponding j,i
------------------------------------------------------------------------- */
double PairGayBerne::init_one(int i, int j)
{
if (setflag[i][j] == 0) {
epsi[i][j] = mix_energy(epsi[i][i],epsi[j][j],sig[i][i],sig[j][j]);
sig[i][j] = mix_distance(sig[i][i],sig[j][j]);
cut[i][j] = mix_distance(cut[i][i],cut[j][j]);
}
int itype = 0;
if (atom->shape[i][0] != atom->shape[i][1] ||
atom->shape[i][0] != atom->shape[i][2] ||
atom->shape[i][1] != atom->shape[i][2]) itype = 0;
if (atom->shape[i][0] != atom->shape[i][1] ||
atom->shape[i][0] != atom->shape[i][2] ||
atom->shape[i][1] != atom->shape[i][2]) itype = 0;
if (itype = 0 && jtype = 0) form[i][j] = SPHERE_SPHERE;
else if (itype = 0 || jtype == 0) form[i][j] = SPHERE_ELLIPSE;
else form[i][j] = ELLIPSE_ELLIPSE;
form[j][i] = form[i][j];
epsi[j][i] = epsi[i][j];
sig[j][i] = sig[i][j];
cut[j][i] = cut[i][j];
return cut[i][j];
}
/* ----------------------------------------------------------------------
check for necessary atom arrays
------------------------------------------------------------------------- */
void PairGayBerne::init_style()
{
if (atom->quat == NULL || atom->torque == NULL)
error->all("Pair gayberne requires atom attributes quat, torque");
// per-type shape precalculations
for (int i = 1; i <= atom->ntypes; i++) {
double *one = atom->shape[i];
shape[i][0] = one[0]*one[0];
shape[i][1] = one[1]*one[1];
shape[i][2] = one[2]*one[2];
lshape[i] = (one[0]*one[1]+one[2]*one[2])*sqrt(one[0]*one[1]);
}
}
/* ----------------------------------------------------------------------
proc 0 writes to restart file
------------------------------------------------------------------------- */
void PairGayBerne::write_restart(FILE *fp)
{
write_restart_settings(fp);
int i,j;
for (i = 1; i <= atom->ntypes; i++) {
fwrite(&well[i][0],sizeof(double),3,fp);
for (j = i; j <= atom->ntypes; j++) {
fwrite(&setflag[i][j],sizeof(int),1,fp);
if (setflag[i][j]) {
fwrite(&epsi[i][j],sizeof(double),1,fp);
fwrite(&sig[i][j],sizeof(double),1,fp);
fwrite(&cut[i][j],sizeof(double),1,fp);
}
}
}
}
/* ----------------------------------------------------------------------
proc 0 reads from restart file, bcasts
------------------------------------------------------------------------- */
void PairGayBerne::read_restart(FILE *fp)
{
read_restart_settings(fp);
allocate();
int i,j;
int me = comm->me;
for (i = 1; i <= atom->ntypes; i++) {
if (me == 0) fread(&well[i][0],sizeof(double),3,fp);
MPI_Bcast(&well[i][0],3,MPI_DOUBLE,0,world);
for (j = i; j <= atom->ntypes; j++) {
if (me == 0) fread(&setflag[i][j],sizeof(int),1,fp);
MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world);
if (setflag[i][j]) {
if (me == 0) {
fread(&epsi[i][j],sizeof(double),1,fp);
fread(&sig[i][j],sizeof(double),1,fp);
fread(&cut[i][j],sizeof(double),1,fp);
}
MPI_Bcast(&epsi[i][j],1,MPI_DOUBLE,0,world);
MPI_Bcast(&sig[i][j],1,MPI_DOUBLE,0,world);
MPI_Bcast(&cut[i][j],1,MPI_DOUBLE,0,world);
}
}
}
}
/* ----------------------------------------------------------------------
proc 0 writes to restart file
------------------------------------------------------------------------- */
void PairGayBerne::write_restart_settings(FILE *fp)
{
fwrite(&gamma,sizeof(double),1,fp);
fwrite(&upsilon,sizeof(double),1,fp);
fwrite(&mu,sizeof(double),1,fp);
fwrite(&cut_global,sizeof(double),1,fp);
fwrite(&mix_flag,sizeof(int),1,fp);
}
/* ----------------------------------------------------------------------
proc 0 reads from restart file, bcasts
------------------------------------------------------------------------- */
void PairGayBerne::read_restart_settings(FILE *fp)
{
int me = comm->me;
if (me == 0) {
fread(&gamma,sizeof(double),1,fp);
fread(&upsilon,sizeof(double),1,fp);
fread(&mu,sizeof(double),1,fp);
fread(&cut_global,sizeof(double),1,fp);
fread(&mix_flag,sizeof(int),1,fp);
}
MPI_Bcast(&gamma,1,MPI_DOUBLE,0,world);
MPI_Bcast(&upsilon,1,MPI_DOUBLE,0,world);
MPI_Bcast(&mu,1,MPI_DOUBLE,0,world);
MPI_Bcast(&cut_global,1,MPI_DOUBLE,0,world);
MPI_Bcast(&mix_flag,1,MPI_INT,0,world);
}
/* ----------------------------------------------------------------------
compute analytic energy, force (fforce), and torque (ttor & rtor)
based on rotation matrices a and precomputed matrices b and g
if newton is off, rtor is not calculated for ghost atoms
------------------------------------------------------------------------- */
double PairGayBerne::gayberne_analytic(const int i,const int j,double a1[3][3],
double a2[3][3], double b1[3][3],
double b2[3][3], double g1[3][3],
double g2[3][3], double *r12,
const double rsq, double *fforce,
double *ttor, double *rtor)
{
double tempv[3], tempv2[3];
double temp[3][3];
double temp1,temp2,temp3;
int *type = atom->type;
int newton_pair = force->newton_pair;
int nlocal = atom->nlocal;
double r12hat[3];
MathExtra::normalize3(r12,r12hat);
double r = sqrt(rsq);
// compute distance of closest approach
double g12[3][3];
MathExtra::plus3(g1,g2,g12);
double kappa[3];
MathExtra::mldivide3(g12,r12,kappa,error);
// tempv = G12^-1*r12hat
tempv[0] = kappa[0]/r;
tempv[1] = kappa[1]/r;
tempv[2] = kappa[2]/r;
double sigma12 = MathExtra::dot3(r12hat,tempv);
sigma12 = pow(0.5*sigma12,-0.5);
double h12 = r-sigma12;
// energy
// compute u_r
double varrho = sig[type[i]][type[j]]/(h12+gamma*sig[type[i]][type[j]]);
double varrho6 = pow(varrho,6.0);
double varrho12 = varrho6*varrho6;
double u_r = 4.0*epsi[type[i]][type[j]]*(varrho12-varrho6);
// compute eta_12
double eta = 2.0*lshape[type[i]]*lshape[type[j]];
double det_g12 = MathExtra::det3(g12);
eta = pow(eta/det_g12,upsilon);
// compute chi_12
double b12[3][3];
double iota[3];
MathExtra::plus3(b1,b2,b12);
MathExtra::mldivide3(b12,r12,iota,error);
// tempv = G12^-1*r12hat
tempv[0] = iota[0]/r;
tempv[1] = iota[1]/r;
tempv[2] = iota[2]/r;
double chi = MathExtra::dot3(r12hat,tempv);
chi = pow(chi*2.0,mu);
// force
// compute dUr/dr
temp1 = (2.0*varrho12*varrho-varrho6*varrho)/sig[type[i]][type[j]];
temp1 = temp1*24.0*epsi[type[i]][type[j]];
double u_slj = temp1*pow(sigma12,3.0)/2.0;
double dUr[3];
temp2 = MathExtra::dot3(kappa,r12hat);
double uslj_rsq = u_slj/rsq;
dUr[0] = temp1*r12hat[0]+uslj_rsq*(kappa[0]-temp2*r12hat[0]);
dUr[1] = temp1*r12hat[1]+uslj_rsq*(kappa[1]-temp2*r12hat[1]);
dUr[2] = temp1*r12hat[2]+uslj_rsq*(kappa[2]-temp2*r12hat[2]);
// compute dChi_12/dr
double dchi[3];
temp1 = MathExtra::dot3(iota,r12hat);
temp2 = -4.0/rsq*mu*pow(chi,(mu-1.0)/mu);
dchi[0] = temp2*(iota[0]-temp1*r12hat[0]);
dchi[1] = temp2*(iota[1]-temp1*r12hat[1]);
dchi[2] = temp2*(iota[2]-temp1*r12hat[2]);
temp1 = -eta*u_r;
temp2 = eta*chi;
fforce[0] = temp1*dchi[0]-temp2*dUr[0];
fforce[1] = temp1*dchi[1]-temp2*dUr[1];
fforce[2] = temp1*dchi[2]-temp2*dUr[2];
// torque for particle 1 and 2
// compute dUr
tempv[0] = -uslj_rsq*kappa[0];
tempv[1] = -uslj_rsq*kappa[1];
tempv[2] = -uslj_rsq*kappa[2];
MathExtra::row_times3(kappa,g1,tempv2);
MathExtra::cross3(tempv,tempv2,dUr);
double dUr2[3];
if (newton_pair || j < nlocal) {
MathExtra::row_times3(kappa,g2,tempv2);
MathExtra::cross3(tempv,tempv2,dUr2);
}
// compute d_chi
MathExtra::row_times3(iota,b1,tempv);
MathExtra::cross3(tempv,iota,dchi);
temp1 = -4.0/rsq;
dchi[0] *= temp1;
dchi[1] *= temp1;
dchi[2] *= temp1;
double dchi2[3];
if (newton_pair || j < nlocal) {
MathExtra::row_times3(iota,b2,tempv);
MathExtra::cross3(tempv,iota,dchi2);
dchi2[0] *= temp1;
dchi2[1] *= temp1;
dchi2[2] *= temp1;
}
// compute d_eta
double deta[3];
deta[0] = deta[1] = deta[2] = 0.0;
compute_eta_torque(g12,a1,shape[type[i]],temp);
temp1 = -eta*upsilon;
for (unsigned m = 0; m < 3; m++) {
for (unsigned y = 0; y < 3; y++) tempv[y] = temp1*temp[m][y];
MathExtra::cross3(a1[m],tempv,tempv2);
deta[0] += tempv2[0];
deta[1] += tempv2[1];
deta[2] += tempv2[2];
}
// compute d_eta for particle 2
double deta2[3];
if (newton_pair || j < nlocal) {
deta2[0] = deta2[1] = deta2[2] = 0.0;
compute_eta_torque(g12,a2,shape[type[j]],temp);
for (unsigned m = 0; m < 3; m++) {
for (unsigned y = 0; y < 3; y++) tempv[y] = temp1*temp[m][y];
MathExtra::cross3(a2[m],tempv,tempv2);
deta2[0] += tempv2[0];
deta2[1] += tempv2[1];
deta2[2] += tempv2[2];
}
}
// torque
temp1 = u_r*eta;
temp2 = u_r*chi;
temp3 = chi*eta;
ttor[0] = (temp1*dchi[0]+temp2*deta[0]+temp3*dUr[0]) * -1.0;
ttor[1] = (temp1*dchi[1]+temp2*deta[1]+temp3*dUr[1]) * -1.0;
ttor[2] = (temp1*dchi[2]+temp2*deta[2]+temp3*dUr[2]) * -1.0;
if (newton_pair || j < nlocal) {
rtor[0] = (temp1*dchi2[0]+temp2*deta2[0]+temp3*dUr2[0]) * -1.0;
rtor[1] = (temp1*dchi2[1]+temp2*deta2[1]+temp3*dUr2[1]) * -1.0;
rtor[2] = (temp1*dchi2[2]+temp2*deta2[2]+temp3*dUr2[2]) * -1.0;
}
return temp1*chi;
}
/* ----------------------------------------------------------------------
torque contribution from eta
computes trace in the last doc equation for the torque derivative
code comes from symbolic solver dump
m is g12, m2 is a_i, s is the shape for the particle
------------------------------------------------------------------------- */
void PairGayBerne::compute_eta_torque(double m[3][3], double m2[3][3],
double *s, double ans[3][3])
{
double den = m[1][0]*m[0][2]*m[2][1]-m[0][0]*m[1][2]*m[2][1]-
m[0][2]*m[2][0]*m[1][1]+m[0][1]*m[2][0]*m[1][2]-
m[1][0]*m[0][1]*m[2][2]+m[0][0]*m[1][1]*m[2][2];
ans[0][0] = s[0]*(m[1][2]*m[0][1]*m2[0][2]+2.0*m[1][1]*m[2][2]*m2[0][0]-
m[1][1]*m2[0][2]*m[0][2]-2.0*m[1][2]*m2[0][0]*m[2][1]+
m2[0][1]*m[0][2]*m[2][1]-m2[0][1]*m[0][1]*m[2][2]-
m[1][0]*m[2][2]*m2[0][1]+m[2][0]*m[1][2]*m2[0][1]+
m[1][0]*m2[0][2]*m[2][1]-m2[0][2]*m[2][0]*m[1][1])/den;
ans[0][1] = s[0]*(m[0][2]*m2[0][0]*m[2][1]-m[2][2]*m2[0][0]*m[0][1]+
2.0*m[0][0]*m[2][2]*m2[0][1]-m[0][0]*m2[0][2]*m[1][2]-
2.0*m[2][0]*m[0][2]*m2[0][1]+m2[0][2]*m[1][0]*m[0][2]-
m[2][2]*m[1][0]*m2[0][0]+m[2][0]*m2[0][0]*m[1][2]+
m[2][0]*m2[0][2]*m[0][1]-m2[0][2]*m[0][0]*m[2][1])/den;
ans[0][2] = s[0]*(m[0][1]*m[1][2]*m2[0][0]-m[0][2]*m2[0][0]*m[1][1]-
m[0][0]*m[1][2]*m2[0][1]+m[1][0]*m[0][2]*m2[0][1]-
m2[0][1]*m[0][0]*m[2][1]-m[2][0]*m[1][1]*m2[0][0]+
2.0*m[1][1]*m[0][0]*m2[0][2]-2.0*m[1][0]*m2[0][2]*m[0][1]+
m[1][0]*m[2][1]*m2[0][0]+m[2][0]*m2[0][1]*m[0][1])/den;
ans[1][0] = s[1]*(-m[1][1]*m2[1][2]*m[0][2]+2.0*m[1][1]*m[2][2]*m2[1][0]+
m[1][2]*m[0][1]*m2[1][2]-2.0*m[1][2]*m2[1][0]*m[2][1]+
m2[1][1]*m[0][2]*m[2][1]-m2[1][1]*m[0][1]*m[2][2]-
m[1][0]*m[2][2]*m2[1][1]+m[2][0]*m[1][2]*m2[1][1]-
m2[1][2]*m[2][0]*m[1][1]+m[1][0]*m2[1][2]*m[2][1])/den;
ans[1][1] = s[1]*(m[0][2]*m2[1][0]*m[2][1]-m[0][1]*m[2][2]*m2[1][0]+
2.0*m[2][2]*m[0][0]*m2[1][1]-m2[1][2]*m[0][0]*m[1][2]-
2.0*m[2][0]*m2[1][1]*m[0][2]-m[1][0]*m[2][2]*m2[1][0]+
m[2][0]*m[1][2]*m2[1][0]+m[1][0]*m2[1][2]*m[0][2]-
m[0][0]*m2[1][2]*m[2][1]+m2[1][2]*m[0][1]*m[2][0])/den;
ans[1][2] = s[1]*(m[0][1]*m[1][2]*m2[1][0]-m[0][2]*m2[1][0]*m[1][1]-
m[0][0]*m[1][2]*m2[1][1]+m[1][0]*m[0][2]*m2[1][1]+
2.0*m[1][1]*m[0][0]*m2[1][2]-m[0][0]*m2[1][1]*m[2][1]+
m[0][1]*m[2][0]*m2[1][1]-m2[1][0]*m[2][0]*m[1][1]-
2.0*m[1][0]*m[0][1]*m2[1][2]+m[1][0]*m2[1][0]*m[2][1])/den;
ans[2][0] = s[2]*(-m[1][1]*m[0][2]*m2[2][2]+m[0][1]*m[1][2]*m2[2][2]+
2.0*m[1][1]*m2[2][0]*m[2][2]-m[0][1]*m2[2][1]*m[2][2]+
m[0][2]*m[2][1]*m2[2][1]-2.0*m2[2][0]*m[2][1]*m[1][2]-
m[1][0]*m2[2][1]*m[2][2]+m[1][2]*m[2][0]*m2[2][1]-
m[1][1]*m[2][0]*m2[2][2]+m[2][1]*m[1][0]*m2[2][2])/den;
ans[2][1] = s[2]*-(m[0][1]*m[2][2]*m2[2][0]-m[0][2]*m2[2][0]*m[2][1]-
2.0*m2[2][1]*m[0][0]*m[2][2]+m[1][2]*m2[2][2]*m[0][0]+
2.0*m2[2][1]*m[0][2]*m[2][0]+m[1][0]*m2[2][0]*m[2][2]-
m[1][0]*m[0][2]*m2[2][2]-m[1][2]*m[2][0]*m2[2][0]+
m[0][0]*m2[2][2]*m[2][1]-m2[2][2]*m[0][1]*m[2][0])/den;
ans[2][2] = s[2]*(m[0][1]*m[1][2]*m2[2][0]-m[0][2]*m2[2][0]*m[1][1]-
m[0][0]*m[1][2]*m2[2][1]+m[1][0]*m[0][2]*m2[2][1]-
m[1][1]*m[2][0]*m2[2][0]-m[2][1]*m2[2][1]*m[0][0]+
2.0*m[1][1]*m2[2][2]*m[0][0]+m[2][1]*m[1][0]*m2[2][0]+
m[2][0]*m[0][1]*m2[2][1]-2.0*m2[2][2]*m[1][0]*m[0][1])/den;
}

57
src/ASPHERE/pair_gayberne.h Executable file
View File

@ -0,0 +1,57 @@
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
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.
------------------------------------------------------------------------- */
#ifndef PAIR_GAYBERNE_H
#define PAIR_GAYBERNE_H
#include "pair.h"
namespace LAMMPS_NS {
class PairGayBerne : public Pair {
public:
PairGayBerne(LAMMPS *lmp);
~PairGayBerne();
void compute(int, int);
void settings(int, char **);
void coeff(int, char **);
double init_one(int, int);
void init_style();
void write_restart(FILE *);
void read_restart(FILE *);
void write_restart_settings(FILE *);
void read_restart_settings(FILE *);
protected:
double cut_global;
double **cut;
double gamma,upsilon,mu; // Gay-Berne parameters
double **shape; // radii in x, y and z SQUARED
double *lshape; // precalculation based on the shape
double **well; // well depth scaling along each axis
// raised to -1.0/mu
double **epsi,**sig; // epsilon and sigma values for atom-type pairs
void allocate();
double gayberne_analytic(const int i, const int j, double a1[3][3],
double a2[3][3], double b1[3][3], double b2[3][3],
double g1[3][3], double g2[3][3], double *r12,
const double rsq, double *fforce, double *ttor,
double *rtor);
void compute_eta_torque(double m[3][3], double m2[3][3],
double *s, double ans[3][3]);
};
}
#endif

View File

@ -0,0 +1,48 @@
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
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.
------------------------------------------------------------------------- */
#ifdef AtomInclude
#include "atom_vec_ellipsoid.h"
#endif
#ifdef AtomClass
AtomStyle(ellipsoid,AtomVecEllipsoid)
# endif
#ifdef ComputeInclude
#include "compute_temp_asphere.h"
#endif
#ifdef ComputeClass
ComputeStyle(temp/asphere,ComputeTempAsphere)
#endif
#ifdef FixInclude
#include "fix_nve_asphere.h"
#include "fix_nvt_asphere.h"
#include "fix_npt_asphere.h"
#endif
#ifdef FixClass
FixStyle(nve/asphere,FixNVEASphere)
FixStyle(nvt/asphere,FixNVTASphere)
FixStyle(npt/asphere,FixNPTASphere)
#endif
#ifdef PairInclude
#include "pair_gayberne.h"
#endif
#ifdef PairClass
PairStyle(gayberne,PairGayBerne)
#endif

View File

@ -123,21 +123,13 @@ void PairLJClass2::compute(int eflag, int vflag)
} }
if (vflag == 1) { if (vflag == 1) {
if (newton_pair || j < nlocal) { if (newton_pair == 0 && j >= nlocal) fforce *= 0.5;
virial[0] += delx*delx*fforce; virial[0] += delx*delx*fforce;
virial[1] += dely*dely*fforce; virial[1] += dely*dely*fforce;
virial[2] += delz*delz*fforce; virial[2] += delz*delz*fforce;
virial[3] += delx*dely*fforce; virial[3] += delx*dely*fforce;
virial[4] += delx*delz*fforce; virial[4] += delx*delz*fforce;
virial[5] += dely*delz*fforce; virial[5] += dely*delz*fforce;
} else {
virial[0] += 0.5*delx*delx*fforce;
virial[1] += 0.5*dely*dely*fforce;
virial[2] += 0.5*delz*delz*fforce;
virial[3] += 0.5*delx*dely*fforce;
virial[4] += 0.5*delx*delz*fforce;
virial[5] += 0.5*dely*delz*fforce;
}
} }
} }
} }

View File

@ -147,21 +147,13 @@ void PairLJClass2CoulCut::compute(int eflag, int vflag)
} }
if (vflag == 1) { if (vflag == 1) {
if (newton_pair || j < nlocal) { if (newton_pair == 0 && j >= nlocal) fforce *= 0.5;
virial[0] += delx*delx*fforce; virial[0] += delx*delx*fforce;
virial[1] += dely*dely*fforce; virial[1] += dely*dely*fforce;
virial[2] += delz*delz*fforce; virial[2] += delz*delz*fforce;
virial[3] += delx*dely*fforce; virial[3] += delx*dely*fforce;
virial[4] += delx*delz*fforce; virial[4] += delx*delz*fforce;
virial[5] += dely*delz*fforce; virial[5] += dely*delz*fforce;
} else {
virial[0] += 0.5*delx*delx*fforce;
virial[1] += 0.5*dely*dely*fforce;
virial[2] += 0.5*delz*delz*fforce;
virial[3] += 0.5*delx*dely*fforce;
virial[4] += 0.5*delx*delz*fforce;
virial[5] += 0.5*dely*delz*fforce;
}
} }
} }
} }
@ -335,10 +327,8 @@ double PairLJClass2CoulCut::init_one(int i, int j)
void PairLJClass2CoulCut::init_style() void PairLJClass2CoulCut::init_style()
{ {
// require an atom style with charge defined
if (atom->q == NULL) if (atom->q == NULL)
error->all("Must use charged atom style with this pair style"); error->all("Pair style lj/class2/coul/cut requires atom attribute q");
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------

View File

@ -164,21 +164,13 @@ void PairLJClass2CoulLong::compute(int eflag, int vflag)
} }
if (vflag == 1) { if (vflag == 1) {
if (newton_pair || j < nlocal) { if (newton_pair == 0 && j >= nlocal) fforce *= 0.5;
virial[0] += delx*delx*fforce; virial[0] += delx*delx*fforce;
virial[1] += dely*dely*fforce; virial[1] += dely*dely*fforce;
virial[2] += delz*delz*fforce; virial[2] += delz*delz*fforce;
virial[3] += delx*dely*fforce; virial[3] += delx*dely*fforce;
virial[4] += delx*delz*fforce; virial[4] += delx*delz*fforce;
virial[5] += dely*delz*fforce; virial[5] += dely*delz*fforce;
} else {
virial[0] += 0.5*delx*delx*fforce;
virial[1] += 0.5*dely*dely*fforce;
virial[2] += 0.5*delz*delz*fforce;
virial[3] += 0.5*delx*dely*fforce;
virial[4] += 0.5*delx*delz*fforce;
virial[5] += 0.5*dely*delz*fforce;
}
} }
} }
} }
@ -341,10 +333,8 @@ double PairLJClass2CoulLong::init_one(int i, int j)
void PairLJClass2CoulLong::init_style() void PairLJClass2CoulLong::init_style()
{ {
// require an atom style with charge defined
if (atom->q == NULL) if (atom->q == NULL)
error->all("Must use charged atom style with this pair style"); error->all("Pair style lj/class2/coul/long requires atom attribute q");
cut_coulsq = cut_coul * cut_coul; cut_coulsq = cut_coul * cut_coul;

View File

@ -39,23 +39,6 @@ AtomVecDPD::AtomVecDPD(LAMMPS *lmp, int narg, char **arg) :
xcol_data = 3; xcol_data = 3;
} }
/* ----------------------------------------------------------------------
zero auxiliary data for n ghost atoms
data in border(), not including x,tag,type,mask
grow() is here since zero_ghost called first in hybrid::unpack_border()
------------------------------------------------------------------------- */
void AtomVecDPD::zero_ghost(int n, int first)
{
int last = first + n;
for (int i = first; i < last; i++) {
if (i == nmax) atom->avec->grow(0);
v[i][0] = 0.0;
v[i][1] = 0.0;
v[i][2] = 0.0;
}
}
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
int AtomVecDPD::pack_comm(int n, int *list, double *buf, int AtomVecDPD::pack_comm(int n, int *list, double *buf,
@ -225,4 +208,3 @@ int AtomVecDPD::unpack_border_one(int i, double *buf)
v[i][2] = buf[2]; v[i][2] = buf[2];
return 3; return 3;
} }

View File

@ -147,21 +147,13 @@ void PairDPD::compute(int eflag, int vflag)
} }
if (vflag == 1) { if (vflag == 1) {
if (newton_pair || j < nlocal) { if (newton_pair == 0 && j >= nlocal) fforce *= 0.5;
virial[0] += delx*delx*fforce; virial[0] += delx*delx*fforce;
virial[1] += dely*dely*fforce; virial[1] += dely*dely*fforce;
virial[2] += delz*delz*fforce; virial[2] += delz*delz*fforce;
virial[3] += delx*dely*fforce; virial[3] += delx*dely*fforce;
virial[4] += delx*delz*fforce; virial[4] += delx*delz*fforce;
virial[5] += dely*delz*fforce; virial[5] += dely*delz*fforce;
} else {
virial[0] += 0.5*delx*delx*fforce;
virial[1] += 0.5*dely*dely*fforce;
virial[2] += 0.5*delz*delz*fforce;
virial[3] += 0.5*delx*dely*fforce;
virial[4] += 0.5*delx*delz*fforce;
virial[5] += 0.5*dely*delz*fforce;
}
} }
} }
} }
@ -277,14 +269,14 @@ double PairDPD::init_one(int i, int j)
void PairDPD::init_style() void PairDPD::init_style()
{ {
// check that atom style is dpd // check that atom style is dpd or hybrid with dpd
// else compute() will not have ghost atom velocities // else compute() will not have ghost atom velocities
if (atom->check_style("dpd") == 0) if (atom->style_match("dpd") == 0)
error->all("Must use atom style dpd with pair style dpd"); error->all("Pair style dpd requires atom style dpd");
// if newton off, forces between atoms ij will be double computed // if newton off, forces between atoms ij will be double computed
// using different random numbers // using different random numbers
if (force->newton_pair == 0 && comm->me == 0) error->warning( if (force->newton_pair == 0 && comm->me == 0) error->warning(
"DPD potential needs newton pair on for momentum conservation"); "DPD potential needs newton pair on for momentum conservation");

View File

@ -87,66 +87,6 @@ void AtomVecGranular::grow(int n)
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
void AtomVecGranular::reset_ptrs()
{
tag = atom->tag;
type = atom->type;
mask = atom->mask;
image = atom->image;
x = atom->x;
v = atom->v;
f = atom->f;
radius = atom->radius;
density = atom->density;
rmass = atom->rmass;
xphi = atom->xphi;
omega = atom->omega;
torque = atom->torque;
}
/* ----------------------------------------------------------------------
zero auxiliary data for owned atom I
data in copy(), not including tag,type,mask,image,x,v
------------------------------------------------------------------------- */
void AtomVecGranular::zero_owned(int i)
{
radius[i] = 0.0;
density[i] = 0.0;
rmass[i] = 0.0;
xphi[i][0] = 0.0;
xphi[i][1] = 0.0;
xphi[i][2] = 0.0;
omega[i][0] = 0.0;
omega[i][1] = 0.0;
omega[i][2] = 0.0;
}
/* ----------------------------------------------------------------------
zero auxiliary data for n ghost atoms
data in border(), not including x,tag,type,mask
grow() is here since zero_ghost called first in hybrid::unpack_border()
------------------------------------------------------------------------- */
void AtomVecGranular::zero_ghost(int n, int first)
{
int last = first + n;
for (int i = first; i < last; i++) {
if (i == nmax) atom->avec->grow(0);
v[i][0] = 0.0;
v[i][1] = 0.0;
v[i][2] = 0.0;
radius[i] = 0.0;
rmass[i] = 0.0;
omega[i][0] = 0.0;
omega[i][1] = 0.0;
omega[i][2] = 0.0;
}
}
/* ---------------------------------------------------------------------- */
void AtomVecGranular::copy(int i, int j) void AtomVecGranular::copy(int i, int j)
{ {
tag[j] = tag[i]; tag[j] = tag[i];
@ -537,16 +477,6 @@ int AtomVecGranular::size_restart()
return n; return n;
} }
/* ----------------------------------------------------------------------
size of restart data for atom I
do not include extra data stored by fixes, included by caller
------------------------------------------------------------------------- */
int AtomVecGranular::size_restart_one(int i)
{
return 19;
}
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
pack atom I's data for restart file including extra quantities pack atom I's data for restart file including extra quantities
xyz must be 1st 3 values, so that read_restart can test on them xyz must be 1st 3 values, so that read_restart can test on them
@ -641,7 +571,7 @@ int AtomVecGranular::unpack_restart(double *buf)
set other values to defaults set other values to defaults
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void AtomVecGranular::create_atom(int itype, double *coord, int ihybrid) void AtomVecGranular::create_atom(int itype, double *coord)
{ {
int nlocal = atom->nlocal; int nlocal = atom->nlocal;
if (nlocal == nmax) grow(0); if (nlocal == nmax) grow(0);
@ -679,8 +609,7 @@ void AtomVecGranular::create_atom(int itype, double *coord, int ihybrid)
initialize other atom quantities initialize other atom quantities
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void AtomVecGranular::data_atom(double *coord, int imagetmp, char **values, void AtomVecGranular::data_atom(double *coord, int imagetmp, char **values)
int ihybrid)
{ {
int nlocal = atom->nlocal; int nlocal = atom->nlocal;
if (nlocal == nmax) grow(0); if (nlocal == nmax) grow(0);
@ -722,15 +651,57 @@ void AtomVecGranular::data_atom(double *coord, int imagetmp, char **values,
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
unpack a single line from Velocity section of data file unpack hybrid quantities from one line in Atoms section of data file
initialize other atom quantities for this sub-style
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void AtomVecGranular::data_vel(int m, char *line, int ihybrid) int AtomVecGranular::data_atom_hybrid(int nlocal, char **values)
{ {
int tmp; radius[nlocal] = 0.5 * atof(values[0]);
sscanf(line,"%d %lg %lg %lg %lg %lg %lg", density[nlocal] = atof(values[1]);
&tmp,&v[m][0],&v[m][1],&v[m][2], if (force->dimension == 3)
&omega[m][0],&omega[m][1],&omega[m][2]); rmass[nlocal] = 4.0*PI/3.0 *
radius[nlocal]*radius[nlocal]*radius[nlocal] * density[nlocal];
else
rmass[nlocal] = PI * radius[nlocal]*radius[nlocal] * density[nlocal];
v[nlocal][0] = 0.0;
v[nlocal][1] = 0.0;
v[nlocal][2] = 0.0;
xphi[nlocal][0] = 0.0;
xphi[nlocal][1] = 0.0;
xphi[nlocal][2] = 0.0;
omega[nlocal][0] = 0.0;
omega[nlocal][1] = 0.0;
omega[nlocal][2] = 0.0;
return 2;
}
/* ----------------------------------------------------------------------
unpack one line from Velocities section of data file
------------------------------------------------------------------------- */
void AtomVecGranular::data_vel(int m, char **values)
{
v[m][0] = atof(values[0]);
v[m][1] = atof(values[1]);
v[m][2] = atof(values[2]);
omega[m][0] = atof(values[3]);
omega[m][1] = atof(values[4]);
omega[m][2] = atof(values[5]);
}
/* ----------------------------------------------------------------------
unpack hybrid quantities from one line in Velocities section of data file
------------------------------------------------------------------------- */
int AtomVecGranular::data_vel_hybrid(int m, char **values)
{
omega[m][0] = atof(values[0]);
omega[m][1] = atof(values[1]);
omega[m][2] = atof(values[2]);
return 3;
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------

View File

@ -23,9 +23,6 @@ class AtomVecGranular : public AtomVec {
AtomVecGranular(class LAMMPS *, int, char **); AtomVecGranular(class LAMMPS *, int, char **);
~AtomVecGranular() {} ~AtomVecGranular() {}
void grow(int); void grow(int);
void reset_ptrs();
void zero_owned(int);
void zero_ghost(int, int);
void copy(int, int); void copy(int, int);
int pack_comm(int, int *, double *, int, int *); int pack_comm(int, int *, double *, int, int *);
int pack_comm_one(int, double *); int pack_comm_one(int, double *);
@ -42,12 +39,13 @@ class AtomVecGranular : public AtomVec {
int pack_exchange(int, double *); int pack_exchange(int, double *);
int unpack_exchange(double *); int unpack_exchange(double *);
int size_restart(); int size_restart();
int size_restart_one(int);
int pack_restart(int, double *); int pack_restart(int, double *);
int unpack_restart(double *); int unpack_restart(double *);
void create_atom(int, double *, int); void create_atom(int, double *);
void data_atom(double *, int, char **, int); void data_atom(double *, int, char **);
void data_vel(int, char *, int); int data_atom_hybrid(int, char **);
void data_vel(int, char **);
int data_vel_hybrid(int, char **);
int memory_usage(); int memory_usage();
private: private:

View File

@ -27,8 +27,8 @@ FixFreeze::FixFreeze(LAMMPS *lmp, int narg, char **arg) :
{ {
if (narg != 3) error->all("Illegal fix freeze command"); if (narg != 3) error->all("Illegal fix freeze command");
if (atom->check_style("granular") == 0) if (atom->torque == NULL)
error->all("Must use fix freeze with atom style granular"); error->all("Fix freeze requires atom attribute torque");
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -50,7 +50,7 @@ void FixFreeze::init()
int count = 0; int count = 0;
for (int i = 0; i < modify->nfix; i++) for (int i = 0; i < modify->nfix; i++)
if (strcmp(modify->fix[i]->style,"freeze") == 0) count++; if (strcmp(modify->fix[i]->style,"freeze") == 0) count++;
if (count > 1) error->all("More than one freeze fix"); if (count > 1) error->all("More than one fix freeze");
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */

View File

@ -46,8 +46,8 @@ FixGranDiag::FixGranDiag(LAMMPS *lmp, int narg, char **arg) :
if (nevery <= 0) error->all("Illegal fix gran/diag command"); if (nevery <= 0) error->all("Illegal fix gran/diag command");
first = 1; first = 1;
if (atom->check_style("granular") == 0) if (atom->radius == NULL || atom->rmass == NULL || atom->omega == NULL)
error->all("Must use fix gran/diag with atom style granular"); error->all("Fix gran/diag requires atom attributes radius, rmass, omega");
MPI_Comm_rank(world,&me); MPI_Comm_rank(world,&me);
if (me == 0) { if (me == 0) {

View File

@ -33,8 +33,9 @@ FixNVEGran::FixNVEGran(LAMMPS *lmp, int narg, char **arg) :
{ {
if (narg != 3) error->all("Illegal fix nve/gran command"); if (narg != 3) error->all("Illegal fix nve/gran command");
if (atom->check_style("granular") == 0) if (atom->xphi == NULL || atom->omega == NULL || atom->torque == NULL)
error->all("Must use fix nve/gran with atom style granular"); error->all("Fix nve/gran requires atom attributes "
"xphi, omega, torque");
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */

View File

@ -42,8 +42,10 @@ FixPour::FixPour(LAMMPS *lmp, int narg, char **arg) :
{ {
if (narg < 6) error->all("Illegal fix pour command"); if (narg < 6) error->all("Illegal fix pour command");
if (atom->check_style("granular") == 0) /*
error->all("Must use fix pour with atom style granular"); if (atom->radius == NULL || atom->rmass == NULL)
error->all("Fix pour requires atom attributes radius, rmass");
*/
if (domain->triclinic) error->all("Cannot use fix pour with triclinic box"); if (domain->triclinic) error->all("Cannot use fix pour with triclinic box");
@ -71,10 +73,8 @@ FixPour::FixPour(LAMMPS *lmp, int narg, char **arg) :
while (iarg < narg) { while (iarg < narg) {
if (strcmp(arg[iarg],"region") == 0) { if (strcmp(arg[iarg],"region") == 0) {
if (iarg+2 > narg) error->all("Illegal fix pour command"); if (iarg+2 > narg) error->all("Illegal fix pour command");
for (iregion = 0; iregion < domain->nregion; iregion++) iregion = domain->find_region(arg[iarg+1]);
if (strcmp(arg[iarg+1],domain->regions[iregion]->id) == 0) break; if (iregion == -1) error->all("Fix pour region ID does not exist");
if (iregion == domain->nregion)
error->all("Fix pour region ID does not exist");
iarg += 2; iarg += 2;
} else if (strcmp(arg[iarg],"diam") == 0) { } else if (strcmp(arg[iarg],"diam") == 0) {
if (iarg+3 > narg) error->all("Illegal fix pour command"); if (iarg+3 > narg) error->all("Illegal fix pour command");
@ -455,7 +455,7 @@ void FixPour::pre_exchange()
coord[0] >= sublo[0] && coord[0] < subhi[0]) flag = 1; coord[0] >= sublo[0] && coord[0] < subhi[0]) flag = 1;
if (flag) { if (flag) {
avec->create_atom(ntype,coord,0); avec->create_atom(ntype,coord);
m = atom->nlocal - 1; m = atom->nlocal - 1;
atom->type[m] = ntype; atom->type[m] = ntype;
atom->radius[m] = radtmp; atom->radius[m] = radtmp;

View File

@ -44,9 +44,9 @@ FixWallGran::FixWallGran(LAMMPS *lmp, int narg, char **arg) :
Fix(lmp, narg, arg) Fix(lmp, narg, arg)
{ {
if (narg < 4) error->all("Illegal fix wall/gran command"); if (narg < 4) error->all("Illegal fix wall/gran command");
if (atom->check_style("granular") == 0) if (atom->radius == NULL || atom->omega == NULL || atom->torque == NULL)
error->all("Must use fix wall/gran with atom style granular"); error->all("Fix wall/gran requires atom attributes radius, omega, torque");
restart_peratom = 1; restart_peratom = 1;

View File

@ -325,6 +325,9 @@ void PairGranHistory::init_style()
{ {
int i; int i;
if (atom->radius == NULL || atom->omega == NULL || atom->torque == NULL)
error->all("Pair granular requires atom attributes radius, omega, torque");
xkkt = xkk * 2.0/7.0; xkkt = xkk * 2.0/7.0;
dt = update->dt; dt = update->dt;
double gammas = 0.5*gamman; double gammas = 0.5*gamman;
@ -332,12 +335,6 @@ void PairGranHistory::init_style()
gamman_dl = gamman/dt; gamman_dl = gamman/dt;
gammas_dl = gammas/dt; gammas_dl = gammas/dt;
// check that atom style is granular
// else compute() will update illegal arrays
if (atom->check_style("granular") == 0)
error->all("Must use atom style granular with pair style granular");
// if shear history is stored: // if shear history is stored:
// check if newton flag is valid // check if newton flag is valid
// if first init, create Fix needed for storing shear history // if first init, create Fix needed for storing shear history

View File

@ -164,21 +164,13 @@ void PairBuckCoulLong::compute(int eflag, int vflag)
} }
if (vflag == 1) { if (vflag == 1) {
if (newton_pair || j < nlocal) { if (newton_pair == 0 && j >= nlocal) fforce *= 0.5;
virial[0] += delx*delx*fforce; virial[0] += delx*delx*fforce;
virial[1] += dely*dely*fforce; virial[1] += dely*dely*fforce;
virial[2] += delz*delz*fforce; virial[2] += delz*delz*fforce;
virial[3] += delx*dely*fforce; virial[3] += delx*dely*fforce;
virial[4] += delx*delz*fforce; virial[4] += delx*delz*fforce;
virial[5] += dely*delz*fforce; virial[5] += dely*delz*fforce;
} else {
virial[0] += 0.5*delx*delx*fforce;
virial[1] += 0.5*dely*dely*fforce;
virial[2] += 0.5*delz*delz*fforce;
virial[3] += 0.5*delx*dely*fforce;
virial[4] += 0.5*delx*delz*fforce;
virial[5] += 0.5*dely*delz*fforce;
}
} }
} }
} }
@ -308,10 +300,8 @@ double PairBuckCoulLong::init_one(int i, int j)
void PairBuckCoulLong::init_style() void PairBuckCoulLong::init_style()
{ {
// require an atom style with charge defined
if (atom->q == NULL) if (atom->q == NULL)
error->all("Must use charged atom style with this pair style"); error->all("Pair style buck/coul/long requires atom attribute q");
cut_coulsq = cut_coul * cut_coul; cut_coulsq = cut_coul * cut_coul;

View File

@ -208,21 +208,13 @@ void PairLJCharmmCoulLong::compute(int eflag, int vflag)
} }
if (vflag == 1) { if (vflag == 1) {
if (newton_pair || j < nlocal) { if (newton_pair == 0 && j >= nlocal) fforce *= 0.5;
virial[0] += delx*delx*fforce; virial[0] += delx*delx*fforce;
virial[1] += dely*dely*fforce; virial[1] += dely*dely*fforce;
virial[2] += delz*delz*fforce; virial[2] += delz*delz*fforce;
virial[3] += delx*dely*fforce; virial[3] += delx*dely*fforce;
virial[4] += delx*delz*fforce; virial[4] += delx*delz*fforce;
virial[5] += dely*delz*fforce; virial[5] += dely*delz*fforce;
} else {
virial[0] += 0.5*delx*delx*fforce;
virial[1] += 0.5*dely*dely*fforce;
virial[2] += 0.5*delz*delz*fforce;
virial[3] += 0.5*delx*dely*fforce;
virial[4] += 0.5*delx*delz*fforce;
virial[5] += 0.5*dely*delz*fforce;
}
} }
} }
} }
@ -614,22 +606,14 @@ void PairLJCharmmCoulLong::compute_outer(int eflag, int vflag)
} }
fforce = (forcecoul + factor_lj*forcelj) * r2inv; fforce = (forcecoul + factor_lj*forcelj) * r2inv;
if (newton_pair || j < nlocal) { if (newton_pair == 0 && j >= nlocal) fforce *= 0.5;
virial[0] += delx*delx*fforce; virial[0] += delx*delx*fforce;
virial[1] += dely*dely*fforce; virial[1] += dely*dely*fforce;
virial[2] += delz*delz*fforce; virial[2] += delz*delz*fforce;
virial[3] += delx*dely*fforce; virial[3] += delx*dely*fforce;
virial[4] += delx*delz*fforce; virial[4] += delx*delz*fforce;
virial[5] += dely*delz*fforce; virial[5] += dely*delz*fforce;
} else {
virial[0] += 0.5*delx*delx*fforce;
virial[1] += 0.5*dely*dely*fforce;
virial[2] += 0.5*delz*delz*fforce;
virial[3] += 0.5*delx*dely*fforce;
virial[4] += 0.5*delx*delz*fforce;
virial[5] += 0.5*dely*delz*fforce;
}
} }
} }
} }
@ -763,10 +747,8 @@ double PairLJCharmmCoulLong::init_one(int i, int j)
void PairLJCharmmCoulLong::init_style() void PairLJCharmmCoulLong::init_style()
{ {
// require an atom style with charge defined
if (atom->q == NULL) if (atom->q == NULL)
error->all("Must use charged atom style with this pair style"); error->all("Pair style lj/charmm/coul/long requires atom attribute q");
// require cut_lj_inner < cut_lj // require cut_lj_inner < cut_lj

View File

@ -193,21 +193,13 @@ void PairLJCutCoulLong::compute(int eflag, int vflag)
} }
if (vflag == 1) { if (vflag == 1) {
if (newton_pair || j < nlocal) { if (newton_pair == 0 && j >= nlocal) fforce *= 0.5;
virial[0] += delx*delx*fforce; virial[0] += delx*delx*fforce;
virial[1] += dely*dely*fforce; virial[1] += dely*dely*fforce;
virial[2] += delz*delz*fforce; virial[2] += delz*delz*fforce;
virial[3] += delx*dely*fforce; virial[3] += delx*dely*fforce;
virial[4] += delx*delz*fforce; virial[4] += delx*delz*fforce;
virial[5] += dely*delz*fforce; virial[5] += dely*delz*fforce;
} else {
virial[0] += 0.5*delx*delx*fforce;
virial[1] += 0.5*dely*dely*fforce;
virial[2] += 0.5*delz*delz*fforce;
virial[3] += 0.5*delx*dely*fforce;
virial[4] += 0.5*delx*delz*fforce;
virial[5] += 0.5*dely*delz*fforce;
}
} }
} }
} }
@ -562,22 +554,14 @@ void PairLJCutCoulLong::compute_outer(int eflag, int vflag)
forcelj = r6inv * (lj1[itype][jtype]*r6inv - lj2[itype][jtype]); forcelj = r6inv * (lj1[itype][jtype]*r6inv - lj2[itype][jtype]);
fforce = (forcecoul + factor_lj*forcelj) * r2inv; fforce = (forcecoul + factor_lj*forcelj) * r2inv;
if (newton_pair || j < nlocal) { if (newton_pair == 0 && j >= nlocal) fforce *= 0.5;
virial[0] += delx*delx*fforce; virial[0] += delx*delx*fforce;
virial[1] += dely*dely*fforce; virial[1] += dely*dely*fforce;
virial[2] += delz*delz*fforce; virial[2] += delz*delz*fforce;
virial[3] += delx*dely*fforce; virial[3] += delx*dely*fforce;
virial[4] += delx*delz*fforce; virial[4] += delx*delz*fforce;
virial[5] += dely*delz*fforce; virial[5] += dely*delz*fforce;
} else {
virial[0] += 0.5*delx*delx*fforce;
virial[1] += 0.5*dely*dely*fforce;
virial[2] += 0.5*delz*delz*fforce;
virial[3] += 0.5*delx*dely*fforce;
virial[4] += 0.5*delx*delz*fforce;
virial[5] += 0.5*dely*delz*fforce;
}
} }
} }
} }
@ -737,10 +721,8 @@ void PairLJCutCoulLong::init_style()
{ {
int i,j; int i,j;
// require an atom style with charge defined
if (atom->q == NULL) if (atom->q == NULL)
error->all("Must use charged atom style with this pair style"); error->all("Pair style lj/cut/coul/long requires atom attribute q");
cut_coulsq = cut_coul * cut_coul; cut_coulsq = cut_coul * cut_coul;

View File

@ -411,7 +411,7 @@ void PairLJCutCoulLongTIP4P::init_style()
if (!force->newton_pair) if (!force->newton_pair)
error->all("Pair style lj/cut/coul/long/tip4p requires newton pair on"); error->all("Pair style lj/cut/coul/long/tip4p requires newton pair on");
if (atom->q == NULL) if (atom->q == NULL)
error->all("Must use charged atom style with this pair style"); error->all("Pair style lj/cut/coul/long/tip4p requires atom attribute q");
cut_coulsq = cut_coul * cut_coul; cut_coulsq = cut_coul * cut_coul;

View File

@ -4,12 +4,14 @@ if ($1 == 1) then
cp style_manybody.h .. cp style_manybody.h ..
cp pair_airebo.cpp ..
cp pair_eam.cpp .. cp pair_eam.cpp ..
cp pair_eam_alloy.cpp .. cp pair_eam_alloy.cpp ..
cp pair_eam_fs.cpp .. cp pair_eam_fs.cpp ..
cp pair_sw.cpp .. cp pair_sw.cpp ..
cp pair_tersoff.cpp .. cp pair_tersoff.cpp ..
cp pair_airebo.h ..
cp pair_eam.h .. cp pair_eam.h ..
cp pair_eam_alloy.h .. cp pair_eam_alloy.h ..
cp pair_eam_fs.h .. cp pair_eam_fs.h ..
@ -21,12 +23,14 @@ else if ($1 == 0) then
rm ../style_manybody.h rm ../style_manybody.h
touch ../style_manybody.h touch ../style_manybody.h
rm ../pair_airebo.cpp
rm ../pair_eam.cpp rm ../pair_eam.cpp
rm ../pair_eam_alloy.cpp rm ../pair_eam_alloy.cpp
rm ../pair_eam_fs.cpp rm ../pair_eam_fs.cpp
rm ../pair_sw.cpp rm ../pair_sw.cpp
rm ../pair_tersoff.cpp rm ../pair_tersoff.cpp
rm ../pair_airebo.h
rm ../pair_eam.h rm ../pair_eam.h
rm ../pair_eam_alloy.h rm ../pair_eam_alloy.h
rm ../pair_eam_fs.h rm ../pair_eam_fs.h

View File

@ -266,15 +266,15 @@ void PairEAM::compute(int eflag, int vflag)
phi = z2*recip; phi = z2*recip;
phip = z2p*recip - phi*recip; phip = z2p*recip - phi*recip;
psip = fp[i]*rhojp + fp[j]*rhoip + phip; psip = fp[i]*rhojp + fp[j]*rhoip + phip;
fforce = psip*recip; fforce = -psip*recip;
f[i][0] -= delx*fforce; f[i][0] += delx*fforce;
f[i][1] -= dely*fforce; f[i][1] += dely*fforce;
f[i][2] -= delz*fforce; f[i][2] += delz*fforce;
if (newton_pair || j < nlocal) { if (newton_pair || j < nlocal) {
f[j][0] += delx*fforce; f[j][0] -= delx*fforce;
f[j][1] += dely*fforce; f[j][1] -= dely*fforce;
f[j][2] += delz*fforce; f[j][2] -= delz*fforce;
} }
if (eflag) { if (eflag) {
@ -283,21 +283,13 @@ void PairEAM::compute(int eflag, int vflag)
} }
if (vflag == 1) { if (vflag == 1) {
if (newton_pair || j < nlocal) { if (newton_pair == 0 && j >= nlocal) fforce *= 0.5;
virial[0] -= delx*delx*fforce; virial[0] += delx*delx*fforce;
virial[1] -= dely*dely*fforce; virial[1] += dely*dely*fforce;
virial[2] -= delz*delz*fforce; virial[2] += delz*delz*fforce;
virial[3] -= delx*dely*fforce; virial[3] += delx*dely*fforce;
virial[4] -= delx*delz*fforce; virial[4] += delx*delz*fforce;
virial[5] -= dely*delz*fforce; virial[5] += dely*delz*fforce;
} else {
virial[0] -= 0.5*delx*delx*fforce;
virial[1] -= 0.5*dely*dely*fforce;
virial[2] -= 0.5*delz*delz*fforce;
virial[3] -= 0.5*delx*dely*fforce;
virial[4] -= 0.5*delx*delz*fforce;
virial[5] -= 0.5*dely*delz*fforce;
}
} }
} }
} }

View File

@ -12,6 +12,7 @@
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#ifdef PairInclude #ifdef PairInclude
#include "pair_airebo.h"
#include "pair_eam.h" #include "pair_eam.h"
#include "pair_eam_alloy.h" #include "pair_eam_alloy.h"
#include "pair_eam_fs.h" #include "pair_eam_fs.h"
@ -20,6 +21,7 @@
#endif #endif
#ifdef PairClass #ifdef PairClass
PairStyle(airebo,PairAIREBO)
PairStyle(eam,PairEAM) PairStyle(eam,PairEAM)
PairStyle(eam/alloy,PairEAMAlloy) PairStyle(eam/alloy,PairEAMAlloy)
PairStyle(eam/fs,PairEAMFS) PairStyle(eam/fs,PairEAMFS)

View File

@ -108,59 +108,9 @@ void AtomVecAngle::grow(int n)
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
void AtomVecAngle::reset_ptrs() void AtomVecAngle::reset_special()
{ {
tag = atom->tag;
type = atom->type;
mask = atom->mask;
image = atom->image;
x = atom->x;
v = atom->v;
f = atom->f;
molecule = atom->molecule;
nspecial = atom->nspecial;
special = atom->special; special = atom->special;
num_bond = atom->num_bond;
bond_type = atom->bond_type;
bond_atom = atom->bond_atom;
num_angle = atom->num_angle;
angle_type = atom->angle_type;
angle_atom1 = atom->angle_atom1;
angle_atom2 = atom->angle_atom2;
angle_atom3 = atom->angle_atom3;
}
/* ----------------------------------------------------------------------
zero auxiliary data for owned atom I
data in copy(), not including tag,type,mask,image,x,v
------------------------------------------------------------------------- */
void AtomVecAngle::zero_owned(int i)
{
molecule[i] = 0;
num_bond[i] = 0;
num_angle[i] = 0;
nspecial[i][0] = 0;
nspecial[i][1] = 0;
nspecial[i][2] = 0;
}
/* ----------------------------------------------------------------------
zero auxiliary data for n ghost atoms
data in border(), not including x,tag,type,mask
grow() is here since zero_ghost called first in hybrid::unpack_border()
------------------------------------------------------------------------- */
void AtomVecAngle::zero_ghost(int n, int first)
{
int last = first + n;
for (int i = first; i < last; i++) {
if (i == nmax) atom->avec->grow(0);
molecule[i] = 0;
}
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -492,17 +442,6 @@ int AtomVecAngle::size_restart()
return n; return n;
} }
/* ----------------------------------------------------------------------
size of restart data for atom I
do not include extra data stored by fixes, included by caller
------------------------------------------------------------------------- */
int AtomVecAngle::size_restart_one(int i)
{
int n = 14 + 2*num_bond[i] + 4*num_angle[i];
return n;
}
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
pack atom I's data for restart file including extra quantities pack atom I's data for restart file including extra quantities
xyz must be 1st 3 values, so that read_restart can test on them xyz must be 1st 3 values, so that read_restart can test on them
@ -609,7 +548,7 @@ int AtomVecAngle::unpack_restart(double *buf)
set other values to defaults set other values to defaults
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void AtomVecAngle::create_atom(int itype, double *coord, int ihybrid) void AtomVecAngle::create_atom(int itype, double *coord)
{ {
int nlocal = atom->nlocal; int nlocal = atom->nlocal;
if (nlocal == nmax) grow(0); if (nlocal == nmax) grow(0);
@ -637,8 +576,7 @@ void AtomVecAngle::create_atom(int itype, double *coord, int ihybrid)
initialize other atom quantities initialize other atom quantities
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void AtomVecAngle::data_atom(double *coord, int imagetmp, char **values, void AtomVecAngle::data_atom(double *coord, int imagetmp, char **values)
int ihybrid)
{ {
int nlocal = atom->nlocal; int nlocal = atom->nlocal;
if (nlocal == nmax) grow(0); if (nlocal == nmax) grow(0);
@ -669,6 +607,24 @@ void AtomVecAngle::data_atom(double *coord, int imagetmp, char **values,
atom->nlocal++; atom->nlocal++;
} }
/* ----------------------------------------------------------------------
unpack hybrid quantities from one line in Atoms section of data file
initialize other atom quantities for this sub-style
------------------------------------------------------------------------- */
int AtomVecAngle::data_atom_hybrid(int nlocal, char **values)
{
molecule[nlocal] = atoi(values[0]);
v[nlocal][0] = 0.0;
v[nlocal][1] = 0.0;
v[nlocal][2] = 0.0;
num_bond[nlocal] = 0;
num_angle[nlocal] = 0;
return 1;
}
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
return # of bytes of allocated memory return # of bytes of allocated memory
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */

View File

@ -22,9 +22,7 @@ class AtomVecAngle : public AtomVec {
public: public:
AtomVecAngle(class LAMMPS *, int, char **); AtomVecAngle(class LAMMPS *, int, char **);
void grow(int); void grow(int);
void reset_ptrs(); void reset_special();
void zero_owned(int);
void zero_ghost(int, int);
void copy(int, int); void copy(int, int);
int pack_comm(int, int *, double *, int, int *); int pack_comm(int, int *, double *, int, int *);
void unpack_comm(int, int, double *); void unpack_comm(int, int, double *);
@ -37,11 +35,11 @@ class AtomVecAngle : public AtomVec {
int pack_exchange(int, double *); int pack_exchange(int, double *);
int unpack_exchange(double *); int unpack_exchange(double *);
int size_restart(); int size_restart();
int size_restart_one(int);
int pack_restart(int, double *); int pack_restart(int, double *);
int unpack_restart(double *); int unpack_restart(double *);
void create_atom(int, double *, int); void create_atom(int, double *);
void data_atom(double *, int, char **, int); void data_atom(double *, int, char **);
int data_atom_hybrid(int, char **);
int memory_usage(); int memory_usage();
private: private:

View File

@ -92,52 +92,9 @@ void AtomVecBond::grow(int n)
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
void AtomVecBond::reset_ptrs() void AtomVecBond::reset_special()
{ {
tag = atom->tag;
type = atom->type;
mask = atom->mask;
image = atom->image;
x = atom->x;
v = atom->v;
f = atom->f;
molecule = atom->molecule;
nspecial = atom->nspecial;
special = atom->special; special = atom->special;
num_bond = atom->num_bond;
bond_type = atom->bond_type;
bond_atom = atom->bond_atom;
}
/* ----------------------------------------------------------------------
zero auxiliary data for owned atom I
data in copy(), not including tag,type,mask,image,x,v
------------------------------------------------------------------------- */
void AtomVecBond::zero_owned(int i)
{
molecule[i] = 0;
num_bond[i] = 0;
nspecial[i][0] = 0;
nspecial[i][1] = 0;
nspecial[i][2] = 0;
}
/* ----------------------------------------------------------------------
zero auxiliary data for n ghost atoms
data in border(), not including x,tag,type,mask
grow() is here since zero_ghost called first in hybrid::unpack_border()
------------------------------------------------------------------------- */
void AtomVecBond::zero_ghost(int n, int first)
{
int last = first + n;
for (int i = first; i < last; i++) {
if (i == nmax) atom->avec->grow(0);
molecule[i] = 0;
}
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -445,17 +402,6 @@ int AtomVecBond::size_restart()
return n; return n;
} }
/* ----------------------------------------------------------------------
size of restart data for atom I
do not include extra data stored by fixes, included by caller
------------------------------------------------------------------------- */
int AtomVecBond::size_restart_one(int i)
{
int n = 13 + 2*num_bond[i];
return n;
}
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
pack atom I's data for restart file including extra quantities pack atom I's data for restart file including extra quantities
xyz must be 1st 3 values, so that read_restart can test on them xyz must be 1st 3 values, so that read_restart can test on them
@ -546,7 +492,7 @@ int AtomVecBond::unpack_restart(double *buf)
set other values to defaults set other values to defaults
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void AtomVecBond::create_atom(int itype, double *coord, int ihybrid) void AtomVecBond::create_atom(int itype, double *coord)
{ {
int nlocal = atom->nlocal; int nlocal = atom->nlocal;
if (nlocal == nmax) grow(0); if (nlocal == nmax) grow(0);
@ -573,8 +519,7 @@ void AtomVecBond::create_atom(int itype, double *coord, int ihybrid)
initialize other atom quantities initialize other atom quantities
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void AtomVecBond::data_atom(double *coord, int imagetmp, char **values, void AtomVecBond::data_atom(double *coord, int imagetmp, char **values)
int ihybrid)
{ {
int nlocal = atom->nlocal; int nlocal = atom->nlocal;
if (nlocal == nmax) grow(0); if (nlocal == nmax) grow(0);
@ -604,6 +549,23 @@ void AtomVecBond::data_atom(double *coord, int imagetmp, char **values,
atom->nlocal++; atom->nlocal++;
} }
/* ----------------------------------------------------------------------
unpack hybrid quantities from one line in Atoms section of data file
initialize other atom quantities for this sub-style
------------------------------------------------------------------------- */
int AtomVecBond::data_atom_hybrid(int nlocal, char **values)
{
molecule[nlocal] = atoi(values[0]);
v[nlocal][0] = 0.0;
v[nlocal][1] = 0.0;
v[nlocal][2] = 0.0;
num_bond[nlocal] = 0;
return 1;
}
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
return # of bytes of allocated memory return # of bytes of allocated memory
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */

View File

@ -22,9 +22,7 @@ class AtomVecBond : public AtomVec {
public: public:
AtomVecBond(class LAMMPS *, int, char **); AtomVecBond(class LAMMPS *, int, char **);
void grow(int); void grow(int);
void reset_ptrs(); void reset_special();
void zero_owned(int);
void zero_ghost(int, int);
void copy(int, int); void copy(int, int);
int pack_comm(int, int *, double *, int, int *); int pack_comm(int, int *, double *, int, int *);
void unpack_comm(int, int, double *); void unpack_comm(int, int, double *);
@ -37,11 +35,11 @@ class AtomVecBond : public AtomVec {
int pack_exchange(int, double *); int pack_exchange(int, double *);
int unpack_exchange(double *); int unpack_exchange(double *);
int size_restart(); int size_restart();
int size_restart_one(int);
int pack_restart(int, double *); int pack_restart(int, double *);
int unpack_restart(double *); int unpack_restart(double *);
void create_atom(int, double *, int); void create_atom(int, double *);
void data_atom(double *, int, char **, int); void data_atom(double *, int, char **);
int data_atom_hybrid(int, char **);
int memory_usage(); int memory_usage();
private: private:

View File

@ -148,78 +148,9 @@ void AtomVecFull::grow(int n)
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
void AtomVecFull::reset_ptrs() void AtomVecFull::reset_special()
{ {
tag = atom->tag;
type = atom->type;
mask = atom->mask;
image = atom->image;
x = atom->x;
v = atom->v;
f = atom->f;
q = atom->q;
molecule = atom->molecule;
nspecial = atom->nspecial;
special = atom->special; special = atom->special;
num_bond = atom->num_bond;
bond_type = atom->bond_type;
bond_atom = atom->bond_atom;
num_angle = atom->num_angle;
angle_type = atom->angle_type;
angle_atom1 = atom->angle_atom1;
angle_atom2 = atom->angle_atom2;
angle_atom3 = atom->angle_atom3;
num_dihedral = atom->num_dihedral;
dihedral_type = atom->dihedral_type;
dihedral_atom1 = atom->dihedral_atom1;
dihedral_atom2 = atom->dihedral_atom2;
dihedral_atom3 = atom->dihedral_atom3;
dihedral_atom4 = atom->dihedral_atom4;
num_improper = atom->num_improper;
improper_type = atom->improper_type;
improper_atom1 = atom->improper_atom1;
improper_atom2 = atom->improper_atom2;
improper_atom3 = atom->improper_atom3;
improper_atom4 = atom->improper_atom4;
}
/* ----------------------------------------------------------------------
zero auxiliary data for owned atom I
data in copy(), not including tag,type,mask,image,x,v
------------------------------------------------------------------------- */
void AtomVecFull::zero_owned(int i)
{
q[i] = 0.0;
molecule[i] = 0;
num_bond[i] = 0;
num_angle[i] = 0;
num_dihedral[i] = 0;
num_improper[i] = 0;
nspecial[i][0] = 0;
nspecial[i][1] = 0;
nspecial[i][2] = 0;
}
/* ----------------------------------------------------------------------
zero auxiliary data for n ghost atoms
data in border(), not including x,tag,type,mask
grow() is here since zero_ghost called first in hybrid::unpack_border()
------------------------------------------------------------------------- */
void AtomVecFull::zero_ghost(int n, int first)
{
int last = first + n;
for (int i = first; i < last; i++) {
if (i == nmax) atom->avec->grow(0);
q[i] = 0.0;
molecule[i] = 0;
}
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -614,18 +545,6 @@ int AtomVecFull::size_restart()
return n; return n;
} }
/* ----------------------------------------------------------------------
size of restart data for atom I
do not include extra data stored by fixes, included by caller
------------------------------------------------------------------------- */
int AtomVecFull::size_restart_one(int i)
{
int n = 17 + 2*num_bond[i] + 4*num_angle[i] +
5*num_dihedral[i] + 5*num_improper[i];
return n;
}
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
pack atom I's data for restart file including extra quantities pack atom I's data for restart file including extra quantities
xyz must be 1st 3 values, so that read_restart can test on them xyz must be 1st 3 values, so that read_restart can test on them
@ -770,7 +689,7 @@ int AtomVecFull::unpack_restart(double *buf)
set other values to defaults set other values to defaults
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void AtomVecFull::create_atom(int itype, double *coord, int ihybrid) void AtomVecFull::create_atom(int itype, double *coord)
{ {
int nlocal = atom->nlocal; int nlocal = atom->nlocal;
if (nlocal == nmax) grow(0); if (nlocal == nmax) grow(0);
@ -801,8 +720,7 @@ void AtomVecFull::create_atom(int itype, double *coord, int ihybrid)
initialize other atom quantities initialize other atom quantities
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void AtomVecFull::data_atom(double *coord, int imagetmp, char **values, void AtomVecFull::data_atom(double *coord, int imagetmp, char **values)
int ihybrid)
{ {
int nlocal = atom->nlocal; int nlocal = atom->nlocal;
if (nlocal == nmax) grow(0); if (nlocal == nmax) grow(0);
@ -837,6 +755,27 @@ void AtomVecFull::data_atom(double *coord, int imagetmp, char **values,
atom->nlocal++; atom->nlocal++;
} }
/* ----------------------------------------------------------------------
unpack hybrid quantities from one line in Atoms section of data file
initialize other atom quantities for this sub-style
------------------------------------------------------------------------- */
int AtomVecFull::data_atom_hybrid(int nlocal, char **values)
{
molecule[nlocal] = atoi(values[1]);
q[nlocal] = atof(values[3]);
v[nlocal][0] = 0.0;
v[nlocal][1] = 0.0;
v[nlocal][2] = 0.0;
num_bond[nlocal] = 0;
num_angle[nlocal] = 0;
num_dihedral[nlocal] = 0;
num_improper[nlocal] = 0;
return 2;
}
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
return # of bytes of allocated memory return # of bytes of allocated memory
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */

View File

@ -22,9 +22,7 @@ class AtomVecFull : public AtomVec {
public: public:
AtomVecFull(class LAMMPS *, int, char **); AtomVecFull(class LAMMPS *, int, char **);
void grow(int); void grow(int);
void reset_ptrs(); void reset_special();
void zero_owned(int);
void zero_ghost(int, int);
void copy(int, int); void copy(int, int);
int pack_comm(int, int *, double *, int, int *); int pack_comm(int, int *, double *, int, int *);
void unpack_comm(int, int, double *); void unpack_comm(int, int, double *);
@ -37,11 +35,11 @@ class AtomVecFull : public AtomVec {
int pack_exchange(int, double *); int pack_exchange(int, double *);
int unpack_exchange(double *); int unpack_exchange(double *);
int size_restart(); int size_restart();
int size_restart_one(int);
int pack_restart(int, double *); int pack_restart(int, double *);
int unpack_restart(double *); int unpack_restart(double *);
void create_atom(int, double *, int); void create_atom(int, double *);
void data_atom(double *, int, char **, int); void data_atom(double *, int, char **);
int data_atom_hybrid(int, char **);
int memory_usage(); int memory_usage();
private: private:

View File

@ -146,75 +146,9 @@ void AtomVecMolecular::grow(int n)
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
void AtomVecMolecular::reset_ptrs() void AtomVecMolecular::reset_special()
{ {
tag = atom->tag;
type = atom->type;
mask = atom->mask;
image = atom->image;
x = atom->x;
v = atom->v;
f = atom->f;
molecule = atom->molecule;
nspecial = atom->nspecial;
special = atom->special; special = atom->special;
num_bond = atom->num_bond;
bond_type = atom->bond_type;
bond_atom = atom->bond_atom;
num_angle = atom->num_angle;
angle_type = atom->angle_type;
angle_atom1 = atom->angle_atom1;
angle_atom2 = atom->angle_atom2;
angle_atom3 = atom->angle_atom3;
num_dihedral = atom->num_dihedral;
dihedral_type = atom->dihedral_type;
dihedral_atom1 = atom->dihedral_atom1;
dihedral_atom2 = atom->dihedral_atom2;
dihedral_atom3 = atom->dihedral_atom3;
dihedral_atom4 = atom->dihedral_atom4;
num_improper = atom->num_improper;
improper_type = atom->improper_type;
improper_atom1 = atom->improper_atom1;
improper_atom2 = atom->improper_atom2;
improper_atom3 = atom->improper_atom3;
improper_atom4 = atom->improper_atom4;
}
/* ----------------------------------------------------------------------
zero auxiliary data for owned atom I
data in copy(), not including tag,type,mask,image,x,v
------------------------------------------------------------------------- */
void AtomVecMolecular::zero_owned(int i)
{
molecule[i] = 0;
num_bond[i] = 0;
num_angle[i] = 0;
num_dihedral[i] = 0;
num_improper[i] = 0;
nspecial[i][0] = 0;
nspecial[i][1] = 0;
nspecial[i][2] = 0;
}
/* ----------------------------------------------------------------------
zero auxiliary data for n ghost atoms
data in border(), not including x,tag,type,mask
grow() is here since zero_ghost called first in hybrid::unpack_border()
------------------------------------------------------------------------- */
void AtomVecMolecular::zero_ghost(int n, int first)
{
int last = first + n;
for (int i = first; i < last; i++) {
if (i == nmax) atom->avec->grow(0);
molecule[i] = 0;
}
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -601,18 +535,6 @@ int AtomVecMolecular::size_restart()
return n; return n;
} }
/* ----------------------------------------------------------------------
size of restart data for atom I
do not include extra data stored by fixes, included by caller
------------------------------------------------------------------------- */
int AtomVecMolecular::size_restart_one(int i)
{
int n = 16 + 2*num_bond[i] + 4*num_angle[i] +
5*num_dihedral[i] + 5*num_improper[i];
return n;
}
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
pack atom I's data for restart file including extra quantities pack atom I's data for restart file including extra quantities
xyz must be 1st 3 values, so that read_restart can test on them xyz must be 1st 3 values, so that read_restart can test on them
@ -755,7 +677,7 @@ int AtomVecMolecular::unpack_restart(double *buf)
set other values to defaults set other values to defaults
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void AtomVecMolecular::create_atom(int itype, double *coord, int ihybrid) void AtomVecMolecular::create_atom(int itype, double *coord)
{ {
int nlocal = atom->nlocal; int nlocal = atom->nlocal;
if (nlocal == nmax) grow(0); if (nlocal == nmax) grow(0);
@ -785,8 +707,7 @@ void AtomVecMolecular::create_atom(int itype, double *coord, int ihybrid)
initialize other atom quantities initialize other atom quantities
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void AtomVecMolecular::data_atom(double *coord, int imagetmp, char **values, void AtomVecMolecular::data_atom(double *coord, int imagetmp, char **values)
int ihybrid)
{ {
int nlocal = atom->nlocal; int nlocal = atom->nlocal;
if (nlocal == nmax) grow(0); if (nlocal == nmax) grow(0);
@ -819,6 +740,26 @@ void AtomVecMolecular::data_atom(double *coord, int imagetmp, char **values,
atom->nlocal++; atom->nlocal++;
} }
/* ----------------------------------------------------------------------
unpack hybrid quantities from one line in Atoms section of data file
initialize other atom quantities for this sub-style
------------------------------------------------------------------------- */
int AtomVecMolecular::data_atom_hybrid(int nlocal, char **values)
{
molecule[nlocal] = atoi(values[0]);
v[nlocal][0] = 0.0;
v[nlocal][1] = 0.0;
v[nlocal][2] = 0.0;
num_bond[nlocal] = 0;
num_angle[nlocal] = 0;
num_dihedral[nlocal] = 0;
num_improper[nlocal] = 0;
return 1;
}
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
return # of bytes of allocated memory return # of bytes of allocated memory
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */

View File

@ -22,9 +22,7 @@ class AtomVecMolecular : public AtomVec {
public: public:
AtomVecMolecular(class LAMMPS *, int, char **); AtomVecMolecular(class LAMMPS *, int, char **);
void grow(int); void grow(int);
void reset_ptrs(); void reset_special();
void zero_owned(int);
void zero_ghost(int, int);
void copy(int, int); void copy(int, int);
int pack_comm(int, int *, double *, int, int *); int pack_comm(int, int *, double *, int, int *);
void unpack_comm(int, int, double *); void unpack_comm(int, int, double *);
@ -37,11 +35,11 @@ class AtomVecMolecular : public AtomVec {
int pack_exchange(int, double *); int pack_exchange(int, double *);
int unpack_exchange(double *); int unpack_exchange(double *);
int size_restart(); int size_restart();
int size_restart_one(int);
int pack_restart(int, double *); int pack_restart(int, double *);
int unpack_restart(double *); int unpack_restart(double *);
void create_atom(int, double *, int); void create_atom(int, double *);
void data_atom(double *, int, char **, int); void data_atom(double *, int, char **);
int data_atom_hybrid(int, char **);
int memory_usage(); int memory_usage();
private: private:

View File

@ -175,21 +175,13 @@ void PairLJCharmmCoulCharmm::compute(int eflag, int vflag)
} }
if (vflag == 1) { if (vflag == 1) {
if (newton_pair || j < nlocal) { if (newton_pair == 0 && j >= nlocal) fforce *= 0.5;
virial[0] += delx*delx*fforce; virial[0] += delx*delx*fforce;
virial[1] += dely*dely*fforce; virial[1] += dely*dely*fforce;
virial[2] += delz*delz*fforce; virial[2] += delz*delz*fforce;
virial[3] += delx*dely*fforce; virial[3] += delx*dely*fforce;
virial[4] += delx*delz*fforce; virial[4] += delx*delz*fforce;
virial[5] += dely*delz*fforce; virial[5] += dely*delz*fforce;
} else {
virial[0] += 0.5*delx*delx*fforce;
virial[1] += 0.5*dely*dely*fforce;
virial[2] += 0.5*delz*delz*fforce;
virial[3] += 0.5*delx*dely*fforce;
virial[4] += 0.5*delx*delz*fforce;
virial[5] += 0.5*dely*delz*fforce;
}
} }
} }
} }
@ -331,10 +323,8 @@ double PairLJCharmmCoulCharmm::init_one(int i, int j)
void PairLJCharmmCoulCharmm::init_style() void PairLJCharmmCoulCharmm::init_style()
{ {
// require an atom style with charge defined
if (atom->q == NULL) if (atom->q == NULL)
error->all("Must use charged atom style with this pair style"); error->all("Pair style lj/charmm/coul/charmm requires atom attribute q");
// require cut_lj_inner < cut_lj, cut_coul_inner < cut_coul // require cut_lj_inner < cut_lj, cut_coul_inner < cut_coul

View File

@ -141,21 +141,13 @@ void PairLJCharmmCoulCharmmImplicit::compute(int eflag, int vflag)
} }
if (vflag == 1) { if (vflag == 1) {
if (newton_pair || j < nlocal) { if (newton_pair == 0 && j >= nlocal) fforce *= 0.5;
virial[0] += delx*delx*fforce; virial[0] += delx*delx*fforce;
virial[1] += dely*dely*fforce; virial[1] += dely*dely*fforce;
virial[2] += delz*delz*fforce; virial[2] += delz*delz*fforce;
virial[3] += delx*dely*fforce; virial[3] += delx*dely*fforce;
virial[4] += delx*delz*fforce; virial[4] += delx*delz*fforce;
virial[5] += dely*delz*fforce; virial[5] += dely*delz*fforce;
} else {
virial[0] += 0.5*delx*delx*fforce;
virial[1] += 0.5*dely*dely*fforce;
virial[2] += 0.5*delz*delz*fforce;
virial[3] += 0.5*delx*dely*fforce;
virial[4] += 0.5*delx*delz*fforce;
virial[5] += 0.5*dely*delz*fforce;
}
} }
} }
} }

View File

@ -43,21 +43,23 @@ makelist:
package: package:
@echo 'Available packages:' @echo 'Available packages:'
@echo ' class2, dpd, granular, kspace, manybody,' @echo ' asphere, class2, colloid, dipole, dpd, granular,'
@echo ' meam, molecule, opt, poems, xtc' @echo ' kspace, manybody, meam, molecule, opt, poems, xtc'
@echo 'make yes-name to include a package' @echo 'make yes-name to include a package'
@echo 'make no-name to exclude a package' @echo 'make no-name to exclude a package'
@echo 'make yes-all to include all packages' @echo 'make yes-all to include all packages'
@echo 'make no-all to exclude all packages' @echo 'make no-all to exclude all packages'
yes-all: yes-all:
make yes-class2 yes-dpd yes-granular yes-kspace \ make yes-asphere yes-class2 yes-colloid yes-dpd yes-granular \
yes-manybody yes-meam yes-molecule yes-opt yes-poems yes-xtc yes-kspace yes-manybody yes-meam yes-molecule yes-opt yes-poems yes-xtc
no-all: no-all:
@echo 'Removing files, ignore any rm errors ...' @echo 'Removing files, ignore any rm errors ...'
# @cd ASPHERE; csh -f Install.csh 0 @cd ASPHERE; csh -f Install.csh 0
@cd CLASS2; csh -f Install.csh 0 @cd CLASS2; csh -f Install.csh 0
@cd COLLOID; csh -f Install.csh 0
@cd DIPOLE; csh -f Install.csh 0
@cd DPD; csh -f Install.csh 0 @cd DPD; csh -f Install.csh 0
@cd GRANULAR; csh -f Install.csh 0 @cd GRANULAR; csh -f Install.csh 0
@cd KSPACE; csh -f Install.csh 0 @cd KSPACE; csh -f Install.csh 0
@ -69,12 +71,12 @@ no-all:
@cd XTC; csh -f Install.csh 0 @cd XTC; csh -f Install.csh 0
@make clean @make clean
#yes-asphere: yes-asphere:
# @cd ASPHERE; csh -f Install.csh 1 @cd ASPHERE; csh -f Install.csh 1
#no-asphere: no-asphere:
# @echo 'Removing files, ignore any rm errors ...' @echo 'Removing files, ignore any rm errors ...'
# @cd ASPHERE; csh -f Install.csh 0 @cd ASPHERE; csh -f Install.csh 0
# @make clean @make clean
yes-class2: yes-class2:
@cd CLASS2; csh -f Install.csh 1 @cd CLASS2; csh -f Install.csh 1
@ -83,6 +85,20 @@ no-class2:
@cd CLASS2; csh -f Install.csh 0 @cd CLASS2; csh -f Install.csh 0
@make clean @make clean
yes-colloid:
@cd COLLOID; csh -f Install.csh 1
no-colloid:
@echo 'Removing files, ignore any rm errors ...'
@cd COLLOID; csh -f Install.csh 0
@make clean
yes-dipole:
@cd DIPOLE; csh -f Install.csh 1
no-dipole:
@echo 'Removing files, ignore any rm errors ...'
@cd DIPOLE; csh -f Install.csh 0
@make clean
yes-dpd: yes-dpd:
@cd DPD; csh -f Install.csh 1 @cd DPD; csh -f Install.csh 1
no-dpd: no-dpd:
@ -149,8 +165,10 @@ no-xtc:
# update src files with package files # update src files with package files
package-update: package-update:
# @csh -f Package.csh ASPHERE update @csh -f Package.csh ASPHERE update
@csh -f Package.csh CLASS2 update @csh -f Package.csh CLASS2 update
@csh -f Package.csh COLLOID update
@csh -f Package.csh DIPOLE update
@csh -f Package.csh DPD update @csh -f Package.csh DPD update
@csh -f Package.csh GRANULAR update @csh -f Package.csh GRANULAR update
@csh -f Package.csh KSPACE update @csh -f Package.csh KSPACE update
@ -164,8 +182,10 @@ package-update:
# overwrite package files with src files # overwrite package files with src files
package-overwrite: package-overwrite:
# @csh -f Package.csh ASPHERE overwrite @csh -f Package.csh ASPHERE overwrite
@csh -f Package.csh CLASS2 overwrite @csh -f Package.csh CLASS2 overwrite
@csh -f Package.csh COLLOID overwrite
@csh -f Package.csh DIPOLE overwrite
@csh -f Package.csh DPD overwrite @csh -f Package.csh DPD overwrite
@csh -f Package.csh GRANULAR overwrite @csh -f Package.csh GRANULAR overwrite
@csh -f Package.csh KSPACE overwrite @csh -f Package.csh KSPACE overwrite
@ -179,8 +199,10 @@ package-overwrite:
# check differences between src and pacakge files # check differences between src and pacakge files
package-check: package-check:
# @csh -f Package.csh ASPHERE check @csh -f Package.csh ASPHERE check
@csh -f Package.csh CLASS2 check @csh -f Package.csh CLASS2 check
@csh -f Package.csh COLLOID check
@csh -f Package.csh DIPOLE check
@csh -f Package.csh DPD check @csh -f Package.csh DPD check
@csh -f Package.csh GRANULAR check @csh -f Package.csh GRANULAR check
@csh -f Package.csh KSPACE check @csh -f Package.csh KSPACE check

View File

@ -7,9 +7,9 @@ SHELL = /bin/sh
ROOT = lmp ROOT = lmp
EXE = lib$(ROOT)_$@.a EXE = lib$(ROOT)_$@.a
SRC = angle.cpp angle_charmm.cpp angle_cosine.cpp angle_cosine_squared.cpp angle_harmonic.cpp angle_hybrid.cpp atom.cpp atom_vec.cpp atom_vec_angle.cpp atom_vec_atomic.cpp atom_vec_bond.cpp atom_vec_charge.cpp atom_vec_full.cpp atom_vec_hybrid.cpp atom_vec_molecular.cpp bond.cpp bond_fene.cpp bond_fene_expand.cpp bond_harmonic.cpp bond_hybrid.cpp bond_morse.cpp bond_nonlinear.cpp bond_quartic.cpp comm.cpp compute.cpp compute_centro_atom.cpp compute_epair_atom.cpp compute_etotal_atom.cpp compute_ke_atom.cpp compute_pressure.cpp compute_rotate_dipole.cpp compute_rotate_gran.cpp compute_stress_atom.cpp compute_temp.cpp compute_temp_partial.cpp compute_temp_ramp.cpp compute_temp_region.cpp create_atoms.cpp create_box.cpp delete_atoms.cpp delete_bonds.cpp dihedral.cpp dihedral_charmm.cpp dihedral_harmonic.cpp dihedral_helix.cpp dihedral_hybrid.cpp dihedral_multi_harmonic.cpp dihedral_opls.cpp displace_atoms.cpp domain.cpp dump.cpp dump_atom.cpp dump_bond.cpp dump_custom.cpp dump_dcd.cpp dump_xyz.cpp error.cpp ewald.cpp fft3d.cpp fft3d_wrap.cpp finish.cpp fix.cpp fix_add_force.cpp fix_ave_force.cpp fix_com.cpp fix_deposit.cpp fix_drag.cpp fix_efield.cpp fix_enforce2d.cpp fix_gravity.cpp fix_gyration.cpp fix_indent.cpp fix_langevin.cpp fix_line_force.cpp fix_minimize.cpp fix_momentum.cpp fix_msd.cpp fix_nph.cpp fix_npt.cpp fix_nve.cpp fix_nvt.cpp fix_orient_fcc.cpp fix_plane_force.cpp fix_print.cpp fix_rdf.cpp fix_recenter.cpp fix_respa.cpp fix_rigid.cpp fix_set_force.cpp fix_shake.cpp fix_shear_history.cpp fix_spring.cpp fix_spring_rg.cpp fix_spring_self.cpp fix_temp_rescale.cpp fix_tmd.cpp fix_uniaxial.cpp fix_viscous.cpp fix_volume_rescale.cpp fix_wall_lj126.cpp fix_wall_lj93.cpp fix_wall_reflect.cpp fix_wiggle.cpp force.cpp group.cpp improper.cpp improper_cvff.cpp improper_harmonic.cpp improper_hybrid.cpp input.cpp kspace.cpp lammps.cpp lattice.cpp library.cpp memory.cpp min.cpp min_cg.cpp min_cg_fr.cpp min_sd.cpp minimize.cpp modify.cpp neigh_bond.cpp neigh_full.cpp neigh_gran.cpp neigh_half.cpp neigh_respa.cpp neighbor.cpp output.cpp pack.cpp pair.cpp pair_buck.cpp pair_buck_coul_cut.cpp pair_buck_coul_long.cpp pair_eam.cpp pair_eam_alloy.cpp pair_eam_fs.cpp pair_hybrid.cpp pair_lj_charmm_coul_charmm.cpp pair_lj_charmm_coul_charmm_implicit.cpp pair_lj_charmm_coul_long.cpp pair_lj_cut.cpp pair_lj_cut_coul_cut.cpp pair_lj_cut_coul_debye.cpp pair_lj_cut_coul_long.cpp pair_lj_cut_coul_long_tip4p.cpp pair_lj_expand.cpp pair_lj_smooth.cpp pair_morse.cpp pair_soft.cpp pair_sw.cpp pair_table.cpp pair_tersoff.cpp pair_yukawa.cpp pppm.cpp pppm_tip4p.cpp random_mars.cpp random_park.cpp read_data.cpp read_restart.cpp region.cpp region_block.cpp region_cylinder.cpp region_intersect.cpp region_prism.cpp region_sphere.cpp region_union.cpp remap.cpp remap_wrap.cpp replicate.cpp respa.cpp run.cpp set.cpp shell.cpp special.cpp temper.cpp thermo.cpp timer.cpp universe.cpp update.cpp variable.cpp velocity.cpp verlet.cpp write_restart.cpp SRC = angle.cpp angle_charmm.cpp angle_class2.cpp angle_cosine.cpp angle_cosine_squared.cpp angle_harmonic.cpp angle_hybrid.cpp atom.cpp atom_vec.cpp atom_vec_angle.cpp atom_vec_atomic.cpp atom_vec_bond.cpp atom_vec_charge.cpp atom_vec_dpd.cpp atom_vec_ellipsoid.cpp atom_vec_full.cpp atom_vec_granular.cpp atom_vec_hybrid.cpp atom_vec_molecular.cpp bond.cpp bond_class2.cpp bond_fene.cpp bond_fene_expand.cpp bond_harmonic.cpp bond_hybrid.cpp bond_morse.cpp bond_nonlinear.cpp bond_quartic.cpp comm.cpp compute.cpp compute_centro_atom.cpp compute_coord_atom.cpp compute_epair_atom.cpp compute_etotal_atom.cpp compute_ke_atom.cpp compute_pressure.cpp compute_rotate_dipole.cpp compute_rotate_gran.cpp compute_stress_atom.cpp compute_temp.cpp compute_temp_asphere.cpp compute_temp_partial.cpp compute_temp_ramp.cpp compute_temp_region.cpp compute_variable.cpp compute_variable_atom.cpp create_atoms.cpp create_box.cpp delete_atoms.cpp delete_bonds.cpp dihedral.cpp dihedral_charmm.cpp dihedral_class2.cpp dihedral_harmonic.cpp dihedral_helix.cpp dihedral_hybrid.cpp dihedral_multi_harmonic.cpp dihedral_opls.cpp displace_atoms.cpp domain.cpp dump.cpp dump_atom.cpp dump_bond.cpp dump_custom.cpp dump_dcd.cpp dump_xtc.cpp dump_xyz.cpp error.cpp ewald.cpp fft3d.cpp fft3d_wrap.cpp finish.cpp fix.cpp fix_add_force.cpp fix_ave_force.cpp fix_ave_spatial.cpp fix_ave_time.cpp fix_com.cpp fix_deposit.cpp fix_drag.cpp fix_efield.cpp fix_enforce2d.cpp fix_freeze.cpp fix_gran_diag.cpp fix_gravity.cpp fix_gyration.cpp fix_heat.cpp fix_indent.cpp fix_langevin.cpp fix_line_force.cpp fix_minimize.cpp fix_momentum.cpp fix_msd.cpp fix_nph.cpp fix_npt.cpp fix_npt_asphere.cpp fix_nve.cpp fix_nve_asphere.cpp fix_nve_gran.cpp fix_nve_noforce.cpp fix_nvt.cpp fix_nvt_asphere.cpp fix_orient_fcc.cpp fix_plane_force.cpp fix_pour.cpp fix_print.cpp fix_rdf.cpp fix_recenter.cpp fix_respa.cpp fix_rigid.cpp fix_set_force.cpp fix_shake.cpp fix_shear_history.cpp fix_spring.cpp fix_spring_rg.cpp fix_spring_self.cpp fix_temp_rescale.cpp fix_tmd.cpp fix_uniaxial.cpp fix_viscous.cpp fix_volume_rescale.cpp fix_wall_gran.cpp fix_wall_lj126.cpp fix_wall_lj93.cpp fix_wall_reflect.cpp fix_wiggle.cpp force.cpp group.cpp improper.cpp improper_class2.cpp improper_cvff.cpp improper_harmonic.cpp improper_hybrid.cpp input.cpp kspace.cpp lammps.cpp lattice.cpp library.cpp memory.cpp min.cpp min_cg.cpp min_cg_fr.cpp min_sd.cpp minimize.cpp modify.cpp neigh_bond.cpp neigh_full.cpp neigh_gran.cpp neigh_half.cpp neigh_respa.cpp neigh_stencil.cpp neighbor.cpp output.cpp pack.cpp pair.cpp pair_airebo.cpp pair_buck.cpp pair_buck_coul_cut.cpp pair_buck_coul_long.cpp pair_dpd.cpp pair_eam.cpp pair_eam_alloy.cpp pair_eam_alloy_opt.cpp pair_eam_fs.cpp pair_eam_fs_opt.cpp pair_eam_opt.cpp pair_gayberne.cpp pair_gran_hertzian.cpp pair_gran_history.cpp pair_gran_no_history.cpp pair_hybrid.cpp pair_lj_charmm_coul_charmm.cpp pair_lj_charmm_coul_charmm_implicit.cpp pair_lj_charmm_coul_long.cpp pair_lj_charmm_coul_long_opt.cpp pair_lj_class2.cpp pair_lj_class2_coul_cut.cpp pair_lj_class2_coul_long.cpp pair_lj_cut.cpp pair_lj_cut_coul_cut.cpp pair_lj_cut_coul_debye.cpp pair_lj_cut_coul_long.cpp pair_lj_cut_coul_long_tip4p.cpp pair_lj_cut_opt.cpp pair_lj_expand.cpp pair_lj_smooth.cpp pair_morse.cpp pair_morse_opt.cpp pair_soft.cpp pair_sw.cpp pair_table.cpp pair_tersoff.cpp pair_yukawa.cpp pppm.cpp pppm_tip4p.cpp random_mars.cpp random_park.cpp read_data.cpp read_restart.cpp region.cpp region_block.cpp region_cylinder.cpp region_intersect.cpp region_prism.cpp region_sphere.cpp region_union.cpp remap.cpp remap_wrap.cpp replicate.cpp respa.cpp run.cpp set.cpp shell.cpp special.cpp temper.cpp thermo.cpp timer.cpp universe.cpp update.cpp variable.cpp velocity.cpp verlet.cpp write_restart.cpp
INC = angle.h angle_charmm.h angle_cosine.h angle_cosine_squared.h angle_harmonic.h angle_hybrid.h atom.h atom_vec.h atom_vec_angle.h atom_vec_atomic.h atom_vec_bond.h atom_vec_charge.h atom_vec_full.h atom_vec_hybrid.h atom_vec_molecular.h bond.h bond_fene.h bond_fene_expand.h bond_harmonic.h bond_hybrid.h bond_morse.h bond_nonlinear.h bond_quartic.h comm.h compute.h compute_centro_atom.h compute_epair_atom.h compute_etotal_atom.h compute_ke_atom.h compute_pressure.h compute_rotate_dipole.h compute_rotate_gran.h compute_stress_atom.h compute_temp.h compute_temp_partial.h compute_temp_ramp.h compute_temp_region.h create_atoms.h create_box.h delete_atoms.h delete_bonds.h dihedral.h dihedral_charmm.h dihedral_harmonic.h dihedral_helix.h dihedral_hybrid.h dihedral_multi_harmonic.h dihedral_opls.h displace_atoms.h domain.h dump.h dump_atom.h dump_bond.h dump_custom.h dump_dcd.h dump_xyz.h error.h ewald.h fft3d.h fft3d_wrap.h finish.h fix.h fix_add_force.h fix_ave_force.h fix_com.h fix_deposit.h fix_drag.h fix_efield.h fix_enforce2d.h fix_gravity.h fix_gyration.h fix_indent.h fix_langevin.h fix_line_force.h fix_minimize.h fix_momentum.h fix_msd.h fix_nph.h fix_npt.h fix_nve.h fix_nvt.h fix_orient_fcc.h fix_plane_force.h fix_print.h fix_rdf.h fix_recenter.h fix_respa.h fix_rigid.h fix_set_force.h fix_shake.h fix_shear_history.h fix_spring.h fix_spring_rg.h fix_spring_self.h fix_temp_rescale.h fix_tmd.h fix_uniaxial.h fix_viscous.h fix_volume_rescale.h fix_wall_lj126.h fix_wall_lj93.h fix_wall_reflect.h fix_wiggle.h force.h group.h improper.h improper_cvff.h improper_harmonic.h improper_hybrid.h input.h integrate.h kspace.h lammps.h lattice.h library.h memory.h min.h min_cg.h min_cg_fr.h min_sd.h minimize.h modify.h neighbor.h output.h pack.h pair.h pair_buck.h pair_buck_coul_cut.h pair_buck_coul_long.h pair_eam.h pair_eam_alloy.h pair_eam_fs.h pair_hybrid.h pair_lj_charmm_coul_charmm.h pair_lj_charmm_coul_charmm_implicit.h pair_lj_charmm_coul_long.h pair_lj_cut.h pair_lj_cut_coul_cut.h pair_lj_cut_coul_debye.h pair_lj_cut_coul_long.h pair_lj_cut_coul_long_tip4p.h pair_lj_expand.h pair_lj_smooth.h pair_morse.h pair_soft.h pair_sw.h pair_table.h pair_tersoff.h pair_yukawa.h pointers.h pppm.h pppm_tip4p.h random_mars.h random_park.h read_data.h read_restart.h region.h region_block.h region_cylinder.h region_intersect.h region_prism.h region_sphere.h region_union.h remap.h remap_wrap.h replicate.h respa.h run.h set.h shell.h special.h style.h style_class2.h style_dpd.h style_granular.h style_kspace.h style_manybody.h style_meam.h style_molecule.h style_opt.h style_poems.h style_user.h style_xtc.h temper.h thermo.h timer.h universe.h update.h variable.h velocity.h verlet.h write_restart.h INC = angle.h angle_charmm.h angle_class2.h angle_cosine.h angle_cosine_squared.h angle_harmonic.h angle_hybrid.h atom.h atom_vec.h atom_vec_angle.h atom_vec_atomic.h atom_vec_bond.h atom_vec_charge.h atom_vec_dpd.h atom_vec_ellipsoid.h atom_vec_full.h atom_vec_granular.h atom_vec_hybrid.h atom_vec_molecular.h bond.h bond_class2.h bond_fene.h bond_fene_expand.h bond_harmonic.h bond_hybrid.h bond_morse.h bond_nonlinear.h bond_quartic.h comm.h compute.h compute_centro_atom.h compute_coord_atom.h compute_epair_atom.h compute_etotal_atom.h compute_ke_atom.h compute_pressure.h compute_rotate_dipole.h compute_rotate_gran.h compute_stress_atom.h compute_temp.h compute_temp_asphere.h compute_temp_partial.h compute_temp_ramp.h compute_temp_region.h compute_variable.h compute_variable_atom.h create_atoms.h create_box.h delete_atoms.h delete_bonds.h dihedral.h dihedral_charmm.h dihedral_class2.h dihedral_harmonic.h dihedral_helix.h dihedral_hybrid.h dihedral_multi_harmonic.h dihedral_opls.h displace_atoms.h domain.h dump.h dump_atom.h dump_bond.h dump_custom.h dump_dcd.h dump_xtc.h dump_xyz.h error.h ewald.h fft3d.h fft3d_wrap.h finish.h fix.h fix_add_force.h fix_ave_force.h fix_ave_spatial.h fix_ave_time.h fix_com.h fix_deposit.h fix_drag.h fix_efield.h fix_enforce2d.h fix_freeze.h fix_gran_diag.h fix_gravity.h fix_gyration.h fix_heat.h fix_indent.h fix_langevin.h fix_line_force.h fix_minimize.h fix_momentum.h fix_msd.h fix_nph.h fix_npt.h fix_npt_asphere.h fix_nve.h fix_nve_asphere.h fix_nve_gran.h fix_nve_noforce.h fix_nvt.h fix_nvt_asphere.h fix_orient_fcc.h fix_plane_force.h fix_pour.h fix_print.h fix_rdf.h fix_recenter.h fix_respa.h fix_rigid.h fix_set_force.h fix_shake.h fix_shear_history.h fix_spring.h fix_spring_rg.h fix_spring_self.h fix_temp_rescale.h fix_tmd.h fix_uniaxial.h fix_viscous.h fix_volume_rescale.h fix_wall_gran.h fix_wall_lj126.h fix_wall_lj93.h fix_wall_reflect.h fix_wiggle.h force.h group.h improper.h improper_class2.h improper_cvff.h improper_harmonic.h improper_hybrid.h input.h integrate.h kspace.h lammps.h lattice.h library.h math_extra.h matho.h memory.h min.h min_cg.h min_cg_fr.h min_sd.h minimize.h modify.h neighbor.h output.h pack.h pair.h pair_airebo.h pair_buck.h pair_buck_coul_cut.h pair_buck_coul_long.h pair_dpd.h pair_eam.h pair_eam_alloy.h pair_eam_alloy_opt.h pair_eam_fs.h pair_eam_fs_opt.h pair_eam_opt.h pair_gayberne.h pair_gran_hertzian.h pair_gran_history.h pair_gran_no_history.h pair_hybrid.h pair_lj_charmm_coul_charmm.h pair_lj_charmm_coul_charmm_implicit.h pair_lj_charmm_coul_long.h pair_lj_charmm_coul_long_opt.h pair_lj_class2.h pair_lj_class2_coul_cut.h pair_lj_class2_coul_long.h pair_lj_cut.h pair_lj_cut_coul_cut.h pair_lj_cut_coul_debye.h pair_lj_cut_coul_long.h pair_lj_cut_coul_long_tip4p.h pair_lj_cut_opt.h pair_lj_expand.h pair_lj_smooth.h pair_morse.h pair_morse_opt.h pair_soft.h pair_sw.h pair_table.h pair_tersoff.h pair_yukawa.h pointers.h pppm.h pppm_tip4p.h random_mars.h random_park.h read_data.h read_restart.h region.h region_block.h region_cylinder.h region_intersect.h region_prism.h region_sphere.h region_union.h remap.h remap_wrap.h replicate.h respa.h run.h set.h shell.h special.h style.h style_asphere.h style_class2.h style_dpd.h style_granular.h style_kspace.h style_manybody.h style_meam.h style_molecule.h style_opt.h style_poems.h style_user.h style_xtc.h temper.h thermo.h timer.h universe.h update.h variable.h vector.h velocity.h verlet.h write_restart.h
OBJ = $(SRC:.cpp=.o) OBJ = $(SRC:.cpp=.o)

View File

@ -286,15 +286,15 @@ void PairEAMOpt::eval()
double phi = z2*recip; double phi = z2*recip;
double phip = z2p*recip - phi*recip; double phip = z2p*recip - phi*recip;
double psip = fp[i]*rhojp + fp[j]*rhoip + phip; double psip = fp[i]*rhojp + fp[j]*rhoip + phip;
double fforce = psip*recip; double fforce = -psip*recip;
tmpfx += delx*fforce; tmpfx += delx*fforce;
tmpfy += dely*fforce; tmpfy += dely*fforce;
tmpfz += delz*fforce; tmpfz += delz*fforce;
if (NEWTON_PAIR || j < nlocal) { if (NEWTON_PAIR || j < nlocal) {
ff[j].x += delx*fforce; ff[j].x -= delx*fforce;
ff[j].y += dely*fforce; ff[j].y -= dely*fforce;
ff[j].z += delz*fforce; ff[j].z -= delz*fforce;
} }
if (EFLAG) { if (EFLAG) {
@ -303,27 +303,19 @@ void PairEAMOpt::eval()
} }
if (VFLAG == 1) { if (VFLAG == 1) {
if (NEWTON_PAIR || j < nlocal) { if (NEWTON_PAIR == 0 && j >= nlocal) fforce *= 0.5;
virial[0] -= delx*delx*fforce; virial[0] += delx*delx*fforce;
virial[1] -= dely*dely*fforce; virial[1] += dely*dely*fforce;
virial[2] -= delz*delz*fforce; virial[2] += delz*delz*fforce;
virial[3] -= delx*dely*fforce; virial[3] += delx*dely*fforce;
virial[4] -= delx*delz*fforce; virial[4] += delx*delz*fforce;
virial[5] -= dely*delz*fforce; virial[5] += dely*delz*fforce;
} else {
virial[0] -= 0.5*delx*delx*fforce;
virial[1] -= 0.5*dely*dely*fforce;
virial[2] -= 0.5*delz*delz*fforce;
virial[3] -= 0.5*delx*dely*fforce;
virial[4] -= 0.5*delx*delz*fforce;
virial[5] -= 0.5*dely*delz*fforce;
}
} }
} }
} }
ff[i].x -= tmpfx; ff[i].x += tmpfx;
ff[i].y -= tmpfy; ff[i].y += tmpfy;
ff[i].z -= tmpfz; ff[i].z += tmpfz;
} }
free(fast_alpha); fast_alpha = 0; free(fast_alpha); fast_alpha = 0;

View File

@ -218,21 +218,13 @@ void PairLJCharmmCoulLongOpt::eval()
} }
if (VFLAG == 1) { if (VFLAG == 1) {
if (NEWTON_PAIR || j < nlocal) { if (NEWTON_PAIR == 0 && j >= nlocal) fforce *= 0.5;
virial[0] += delx*delx*fforce; virial[0] += delx*delx*fforce;
virial[1] += dely*dely*fforce; virial[1] += dely*dely*fforce;
virial[2] += delz*delz*fforce; virial[2] += delz*delz*fforce;
virial[3] += delx*dely*fforce; virial[3] += delx*dely*fforce;
virial[4] += delx*delz*fforce; virial[4] += delx*delz*fforce;
virial[5] += dely*delz*fforce; virial[5] += dely*delz*fforce;
} else {
virial[0] += 0.5*delx*delx*fforce;
virial[1] += 0.5*dely*dely*fforce;
virial[2] += 0.5*delz*delz*fforce;
virial[3] += 0.5*delx*dely*fforce;
virial[4] += 0.5*delx*delz*fforce;
virial[5] += 0.5*dely*delz*fforce;
}
} }
} }
} else { } else {
@ -330,21 +322,13 @@ void PairLJCharmmCoulLongOpt::eval()
} }
if (VFLAG == 1) { if (VFLAG == 1) {
if (NEWTON_PAIR || j < nlocal) { if (NEWTON_PAIR == 0 && j >= nlocal) fforce *= 0.5;
virial[0] += delx*delx*fforce; virial[0] += delx*delx*fforce;
virial[1] += dely*dely*fforce; virial[1] += dely*dely*fforce;
virial[2] += delz*delz*fforce; virial[2] += delz*delz*fforce;
virial[3] += delx*dely*fforce; virial[3] += delx*dely*fforce;
virial[4] += delx*delz*fforce; virial[4] += delx*delz*fforce;
virial[5] += dely*delz*fforce; virial[5] += dely*delz*fforce;
} else {
virial[0] += 0.5*delx*delx*fforce;
virial[1] += 0.5*dely*dely*fforce;
virial[2] += 0.5*delz*delz*fforce;
virial[3] += 0.5*delx*dely*fforce;
virial[4] += 0.5*delx*delz*fforce;
virial[5] += 0.5*dely*delz*fforce;
}
} }
} }
} }

View File

@ -135,21 +135,13 @@ void PairLJCutOpt::eval()
} }
if (VFLAG == 1) { if (VFLAG == 1) {
if (NEWTON_PAIR || j < nlocal) { if (NEWTON_PAIR == 0 && j >= nlocal) fforce *= 0.5;
virial[0] += delx*delx*fforce; virial[0] += delx*delx*fforce;
virial[1] += dely*dely*fforce; virial[1] += dely*dely*fforce;
virial[2] += delz*delz*fforce; virial[2] += delz*delz*fforce;
virial[3] += delx*dely*fforce; virial[3] += delx*dely*fforce;
virial[4] += delx*delz*fforce; virial[4] += delx*delz*fforce;
virial[5] += dely*delz*fforce; virial[5] += dely*delz*fforce;
} else {
virial[0] += 0.5*delx*delx*fforce;
virial[1] += 0.5*dely*dely*fforce;
virial[2] += 0.5*delz*delz*fforce;
virial[3] += 0.5*delx*dely*fforce;
virial[4] += 0.5*delx*delz*fforce;
virial[5] += 0.5*dely*delz*fforce;
}
} }
} }
@ -191,21 +183,13 @@ void PairLJCutOpt::eval()
} }
if (VFLAG == 1) { if (VFLAG == 1) {
if (NEWTON_PAIR || j < nlocal) { if (NEWTON_PAIR == 0 && j >= nlocal) fforce *= 0.5;
virial[0] += delx*delx*fforce; virial[0] += delx*delx*fforce;
virial[1] += dely*dely*fforce; virial[1] += dely*dely*fforce;
virial[2] += delz*delz*fforce; virial[2] += delz*delz*fforce;
virial[3] += delx*dely*fforce; virial[3] += delx*dely*fforce;
virial[4] += delx*delz*fforce; virial[4] += delx*delz*fforce;
virial[5] += dely*delz*fforce; virial[5] += dely*delz*fforce;
} else {
virial[0] += 0.5*delx*delx*fforce;
virial[1] += 0.5*dely*dely*fforce;
virial[2] += 0.5*delz*delz*fforce;
virial[3] += 0.5*delx*dely*fforce;
virial[4] += 0.5*delx*delz*fforce;
virial[5] += 0.5*dely*delz*fforce;
}
} }
} }
} }

View File

@ -143,21 +143,13 @@ void PairMorseOpt::eval()
} }
if (VFLAG == 1) { if (VFLAG == 1) {
if (NEWTON_PAIR || j < nlocal) { if (NEWTON_PAIR == 0 && j >= nlocal) fforce *= 0.5;
virial[0] += delx*delx*fforce; virial[0] += delx*delx*fforce;
virial[1] += dely*dely*fforce; virial[1] += dely*dely*fforce;
virial[2] += delz*delz*fforce; virial[2] += delz*delz*fforce;
virial[3] += delx*dely*fforce; virial[3] += delx*dely*fforce;
virial[4] += delx*delz*fforce; virial[4] += delx*delz*fforce;
virial[5] += dely*delz*fforce; virial[5] += dely*delz*fforce;
} else {
virial[0] += 0.5*delx*delx*fforce;
virial[1] += 0.5*dely*dely*fforce;
virial[2] += 0.5*delz*delz*fforce;
virial[3] += 0.5*delx*dely*fforce;
virial[4] += 0.5*delx*delz*fforce;
virial[5] += 0.5*dely*delz*fforce;
}
} }
} }
} else { } else {
@ -196,21 +188,13 @@ void PairMorseOpt::eval()
} }
if (VFLAG == 1) { if (VFLAG == 1) {
if (NEWTON_PAIR || j < nlocal) { if (NEWTON_PAIR == 0 && j >= nlocal) fforce *= 0.5;
virial[0] += delx*delx*fforce; virial[0] += delx*delx*fforce;
virial[1] += dely*dely*fforce; virial[1] += dely*dely*fforce;
virial[2] += delz*delz*fforce; virial[2] += delz*delz*fforce;
virial[3] += delx*dely*fforce; virial[3] += delx*dely*fforce;
virial[4] += delx*delz*fforce; virial[4] += delx*delz*fforce;
virial[5] += dely*delz*fforce; virial[5] += dely*delz*fforce;
} else {
virial[0] += 0.5*delx*delx*fforce;
virial[1] += 0.5*dely*dely*fforce;
virial[2] += 0.5*delz*delz*fforce;
virial[3] += 0.5*delx*dely*fforce;
virial[4] += 0.5*delx*delz*fforce;
virial[5] += 0.5*dely*delz*fforce;
}
} }
} }
} }

View File

@ -55,6 +55,8 @@ FixPOEMS::FixPOEMS(LAMMPS *lmp, int narg, char **arg) :
{ {
int i,j,ibody; int i,j,ibody;
rigid_flag = 1;
virial_flag = 1;
MPI_Comm_rank(world,&me); MPI_Comm_rank(world,&me);
// can't use with pure granular style since mass arrays are different // can't use with pure granular style since mass arrays are different

View File

@ -61,7 +61,7 @@ Atom::Atom(LAMMPS *lmp) : Pointers(lmp)
molecule = NULL; molecule = NULL;
q = NULL; q = NULL;
mu = NULL; mu = NULL;
xphi = omega = torque = NULL; xphi = quat = omega = angmom = torque = NULL;
radius = density = rmass = vfrac = NULL; radius = density = rmass = vfrac = NULL;
maxspecial = 1; maxspecial = 1;
@ -82,12 +82,12 @@ Atom::Atom(LAMMPS *lmp) : Pointers(lmp)
improper_type = improper_atom1 = improper_atom2 = NULL; improper_type = improper_atom1 = improper_atom2 = NULL;
improper_atom3 = improper_atom4 = NULL; improper_atom3 = improper_atom4 = NULL;
hybrid = NULL;
// ntype-length arrays // ntype-length arrays
mass = NULL; mass = NULL;
mass_setflag = NULL; mass_setflag = NULL;
shape = NULL;
shape_setflag = NULL;
dipole = NULL; dipole = NULL;
dipole_setflag = NULL; dipole_setflag = NULL;
@ -143,8 +143,11 @@ Atom::~Atom()
memory->sfree(q); memory->sfree(q);
memory->destroy_2d_double_array(mu); memory->destroy_2d_double_array(mu);
memory->destroy_2d_double_array(xphi); memory->destroy_2d_double_array(xphi);
memory->destroy_2d_double_array(quat);
memory->destroy_2d_double_array(omega); memory->destroy_2d_double_array(omega);
memory->destroy_2d_double_array(angmom);
memory->destroy_2d_double_array(torque); memory->destroy_2d_double_array(torque);
memory->sfree(radius); memory->sfree(radius);
memory->sfree(density); memory->sfree(density);
memory->sfree(rmass); memory->sfree(rmass);
@ -179,12 +182,12 @@ Atom::~Atom()
memory->destroy_2d_int_array(improper_atom3); memory->destroy_2d_int_array(improper_atom3);
memory->destroy_2d_int_array(improper_atom4); memory->destroy_2d_int_array(improper_atom4);
memory->sfree(hybrid);
// delete per-type arrays // delete per-type arrays
delete [] mass; delete [] mass;
delete [] mass_setflag; delete [] mass_setflag;
memory->destroy_2d_double_array(shape);
delete [] shape_setflag;
delete [] dipole; delete [] dipole;
delete [] dipole_setflag; delete [] dipole_setflag;
@ -250,6 +253,7 @@ void Atom::init()
// check arrays that are atom type in length // check arrays that are atom type in length
check_mass(); check_mass();
check_shape();
check_dipole(); check_dipole();
// init sub-style // init sub-style
@ -258,11 +262,11 @@ void Atom::init()
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
check if atom style matches style return 1 if style matches atom style hybrid sub-style
if hybrid, any sub-style can be a match else return 0
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
int Atom::check_style(char *style) int Atom::style_match(char *style)
{ {
if (strcmp(atom_style,style) == 0) return 1; if (strcmp(atom_style,style) == 0) return 1;
else if (strcmp(atom_style,"hybrid") == 0) { else if (strcmp(atom_style,"hybrid") == 0) {
@ -612,10 +616,10 @@ int Atom::count_words(char *line)
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
unpack n lines from Atom section of data file unpack n lines from Atom section of data file
set all atom values and defaults call style-specific routine to parse line
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void Atom::data_atoms(int n, char *buf, int ihybrid) void Atom::data_atoms(int n, char *buf)
{ {
int m,imagedata,xptr,iptr; int m,imagedata,xptr,iptr;
double xdata[3],lamda[3],sublo[3],subhi[3]; double xdata[3],lamda[3],sublo[3],subhi[3];
@ -627,7 +631,6 @@ void Atom::data_atoms(int n, char *buf, int ihybrid)
int nwords = count_words(buf); int nwords = count_words(buf);
*next = '\n'; *next = '\n';
avec->data_params(ihybrid);
if (nwords != avec->size_data_atom && nwords != avec->size_data_atom + 3) if (nwords != avec->size_data_atom && nwords != avec->size_data_atom + 3)
error->all("Incorrect atom format in data file"); error->all("Incorrect atom format in data file");
@ -671,7 +674,8 @@ void Atom::data_atoms(int n, char *buf, int ihybrid)
// loop over lines of atom data // loop over lines of atom data
// tokenize the line into values // tokenize the line into values
// extract xyz coords and image flags, remap them // extract xyz coords and image flags
// remap atom into simulation box
// if atom is in my sub-domain, unpack its values // if atom is in my sub-domain, unpack its values
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
@ -699,7 +703,7 @@ void Atom::data_atoms(int n, char *buf, int ihybrid)
if (coord[0] >= sublo[0] && coord[0] < subhi[0] && if (coord[0] >= sublo[0] && coord[0] < subhi[0] &&
coord[1] >= sublo[1] && coord[1] < subhi[1] && coord[1] >= sublo[1] && coord[1] < subhi[1] &&
coord[2] >= sublo[2] && coord[2] < subhi[2]) coord[2] >= sublo[2] && coord[2] < subhi[2])
avec->data_atom(xdata,imagedata,values,ihybrid); avec->data_atom(xdata,imagedata,values);
buf = next + 1; buf = next + 1;
} }
@ -713,9 +717,9 @@ void Atom::data_atoms(int n, char *buf, int ihybrid)
call style-specific routine to parse line call style-specific routine to parse line
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void Atom::data_vels(int n, char *buf, int ihybrid) void Atom::data_vels(int n, char *buf)
{ {
int m,tagtmp; int j,m,tagdata;
char *next; char *next;
next = strchr(buf,'\n'); next = strchr(buf,'\n');
@ -723,19 +727,31 @@ void Atom::data_vels(int n, char *buf, int ihybrid)
int nwords = count_words(buf); int nwords = count_words(buf);
*next = '\n'; *next = '\n';
avec->data_params(ihybrid);
if (nwords != avec->size_data_vel) if (nwords != avec->size_data_vel)
error->all("Incorrect velocity format in data file"); error->all("Incorrect velocity format in data file");
char **values = new char*[nwords];
// loop over lines of atom velocities
// tokenize the line into values
// if I own atom tag, unpack its values
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
next = strchr(buf,'\n'); next = strchr(buf,'\n');
*next = '\0';
sscanf(buf,"%d",&tagtmp); values[0] = strtok(buf," \t\n\r\f");
if (tagtmp <= 0 || tagtmp > map_tag_max) for (j = 1; j < nwords; j++)
values[j] = strtok(NULL," \t\n\r\f");
tagdata = atoi(values[0]);
if (tagdata <= 0 || tagdata > map_tag_max)
error->one("Invalid atom ID in Velocities section of data file"); error->one("Invalid atom ID in Velocities section of data file");
if ((m = map(tagtmp)) >= 0) avec->data_vel(m,buf,ihybrid); if ((m = map(tagdata)) >= 0) avec->data_vel(m,&values[1]);
buf = next + 1; buf = next + 1;
} }
delete [] values;
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
@ -950,6 +966,11 @@ void Atom::allocate_type_arrays()
mass_setflag = new int[ntypes+1]; mass_setflag = new int[ntypes+1];
for (int itype = 1; itype <= ntypes; itype++) mass_setflag[itype] = 0; for (int itype = 1; itype <= ntypes; itype++) mass_setflag[itype] = 0;
} }
if (avec->shape_type) {
shape = memory->create_2d_double_array(ntypes+1,3,"atom:shape");
shape_setflag = new int[ntypes+1];
for (int itype = 1; itype <= ntypes; itype++) shape_setflag[itype] = 0;
}
if (avec->dipole_type) { if (avec->dipole_type) {
dipole = new double[ntypes+1]; dipole = new double[ntypes+1];
dipole_setflag = new int[ntypes+1]; dipole_setflag = new int[ntypes+1];
@ -968,7 +989,8 @@ void Atom::set_mass(char *str)
int itype; int itype;
double mass_one; double mass_one;
sscanf(str,"%d %lg",&itype,&mass_one); int n = sscanf(str,"%d %lg",&itype,&mass_one);
if (n != 2) error->all("Invalid mass line in data file");
if (itype < 1 || itype > ntypes) error->all("Invalid type for mass set"); if (itype < 1 || itype > ntypes) error->all("Invalid type for mass set");
@ -1032,6 +1054,79 @@ void Atom::check_mass()
if (mass_setflag[itype] == 0) error->all("All masses are not set"); if (mass_setflag[itype] == 0) error->all("All masses are not set");
} }
/* ----------------------------------------------------------------------
set particle shape and flag it as set
called from reading of data file
------------------------------------------------------------------------- */
void Atom::set_shape(char *str)
{
if (shape == NULL) error->all("Cannot set shape for this atom style");
int itype;
double a,b,c;
int n = sscanf(str,"%d %lg %lg %lg",&itype,&a,&b,&c);
if (n != 4) error->all("Invalid shape line in data file");
if (itype < 1 || itype > ntypes) error->all("Invalid type for shape set");
// store shape as radius, though specified as diameter
shape[itype][0] = 0.5*a;
shape[itype][1] = 0.5*b;
shape[itype][2] = 0.5*c;
shape_setflag[itype] = 1;
}
/* ----------------------------------------------------------------------
set one or more particle shapes and flag them as set
called from reading of input script
------------------------------------------------------------------------- */
void Atom::set_shape(int narg, char **arg)
{
if (shape == NULL) error->all("Cannot set shape for this atom style");
int lo,hi;
force->bounds(arg[0],ntypes,lo,hi);
if (lo < 1 || hi > ntypes)
error->all("Invalid type for shape set");
// store shape as radius, though specified as diameter
for (int itype = lo; itype <= hi; itype++) {
shape[itype][0] = 0.5*atof(arg[1]);
shape[itype][1] = 0.5*atof(arg[2]);
shape[itype][2] = 0.5*atof(arg[3]);
shape_setflag[itype] = 1;
}
}
/* ----------------------------------------------------------------------
set all particle shapes as read in from restart file
------------------------------------------------------------------------- */
void Atom::set_shape(double **values)
{
for (int itype = 1; itype <= ntypes; itype++) {
shape[itype][0] = values[itype][0];
shape[itype][1] = values[itype][1];
shape[itype][2] = values[itype][2];
shape_setflag[itype] = 1;
}
}
/* ----------------------------------------------------------------------
check that all particle shapes have been set
------------------------------------------------------------------------- */
void Atom::check_shape()
{
if (shape == NULL) return;
for (int itype = 1; itype <= ntypes; itype++)
if (shape_setflag[itype] == 0) error->all("All shapes are not set");
}
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
set a dipole moment and flag it as set set a dipole moment and flag it as set
called from reading of data file called from reading of data file
@ -1043,7 +1138,8 @@ void Atom::set_dipole(char *str)
int i; int i;
double dipole_one; double dipole_one;
sscanf(str,"%d %lg",&i,&dipole_one); int n = sscanf(str,"%d %lg",&i,&dipole_one);
if (n != 2) error->all("Invalid shape line in data file");
dipole[i] = dipole_one; dipole[i] = dipole_one;
dipole_setflag[i] = 1; dipole_setflag[i] = 1;

View File

@ -43,7 +43,7 @@ class Atom : protected Pointers {
int *molecule; int *molecule;
double *q,**mu; double *q,**mu;
double **xphi,**omega,**torque; double **xphi,**quat,**omega,**angmom,**torque;
double *radius,*density,*rmass,*vfrac; double *radius,*density,*rmass,*vfrac;
int maxspecial; int maxspecial;
@ -65,18 +65,14 @@ class Atom : protected Pointers {
int **improper_type; int **improper_type;
int **improper_atom1,**improper_atom2,**improper_atom3,**improper_atom4; int **improper_atom1,**improper_atom2,**improper_atom3,**improper_atom4;
int *hybrid;
// extra peratom info in restart file destined for fix & diag // extra peratom info in restart file destined for fix & diag
double **extra; double **extra;
// per-type arrays // per-type arrays
double *mass; double *mass,**shape,*dipole;
int *mass_setflag; int *mass_setflag,*shape_setflag,*dipole_setflag;
double *dipole;
int *dipole_setflag;
// callback ptrs for atom arrays managed by fix classes // callback ptrs for atom arrays managed by fix classes
@ -97,8 +93,7 @@ class Atom : protected Pointers {
class AtomVec *new_avec(char *, int, char **); class AtomVec *new_avec(char *, int, char **);
void init(); void init();
int check_style(char *); int style_match(char *);
int style2arg(char **);
void modify_params(int, char **); void modify_params(int, char **);
void tag_extend(); void tag_extend();
int tag_consecutive(); int tag_consecutive();
@ -106,8 +101,8 @@ class Atom : protected Pointers {
int parse_data(char *); int parse_data(char *);
int count_words(char *); int count_words(char *);
void data_atoms(int, char *, int); void data_atoms(int, char *);
void data_vels(int, char *, int); void data_vels(int, char *);
void data_bonds(int, char *); void data_bonds(int, char *);
void data_angles(int, char *); void data_angles(int, char *);
void data_dihedrals(int, char *); void data_dihedrals(int, char *);
@ -119,6 +114,10 @@ class Atom : protected Pointers {
void set_mass(int, char **); void set_mass(int, char **);
void set_mass(double *); void set_mass(double *);
void check_mass(); void check_mass();
void set_shape(char *);
void set_shape(int, char **);
void set_shape(double **);
void check_shape();
void set_dipole(char *); void set_dipole(char *);
void set_dipole(int, char **); void set_dipole(int, char **);
void set_dipole(double *); void set_dipole(double *);

View File

@ -11,7 +11,7 @@
See the README file in the top-level LAMMPS directory. See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include "string.h" #include "stdlib.h"
#include "atom_vec.h" #include "atom_vec.h"
#include "atom.h" #include "atom.h"
@ -24,19 +24,19 @@ AtomVec::AtomVec(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp)
nmax = 0; nmax = 0;
molecular = 0; molecular = 0;
bonds_allow = angles_allow = dihedrals_allow = impropers_allow = 0; bonds_allow = angles_allow = dihedrals_allow = impropers_allow = 0;
mass_type = dipole_type = 0; mass_type = shape_type = dipole_type = 0;
comm_x_only = comm_f_only = 1; comm_x_only = comm_f_only = 1;
size_comm = size_reverse = size_border = 0; size_comm = size_reverse = size_border = 0;
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
unpack a single line from Velocity section of data file unpack one line from Velocities section of data file
individual style may override this
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void AtomVec::data_vel(int m, char *line, int ihybrid) void AtomVec::data_vel(int m, char **values)
{ {
int tmp;
double **v = atom->v; double **v = atom->v;
sscanf(line,"%d %lg %lg %lg",&tmp,&v[m][0],&v[m][1],&v[m][2]); v[m][0] = atof(values[0]);
v[m][1] = atof(values[1]);
v[m][2] = atof(values[2]);
} }

View File

@ -24,6 +24,7 @@ class AtomVec : protected Pointers {
int bonds_allow,angles_allow; // 1 if bonds, angles are used int bonds_allow,angles_allow; // 1 if bonds, angles are used
int dihedrals_allow,impropers_allow; // 1 if dihedrals, impropers used int dihedrals_allow,impropers_allow; // 1 if dihedrals, impropers used
int mass_type; // 1 if per-type masses int mass_type; // 1 if per-type masses
int shape_type; // 1 if per-type shape array
int dipole_type; // 1 if per-type dipole moments int dipole_type; // 1 if per-type dipole moments
int comm_x_only; // 1 if only exchange x in forward comm int comm_x_only; // 1 if only exchange x in forward comm
int comm_f_only; // 1 if only exchange f in reverse comm int comm_f_only; // 1 if only exchange f in reverse comm
@ -39,9 +40,7 @@ class AtomVec : protected Pointers {
virtual void init() {} virtual void init() {}
virtual void grow(int) = 0; virtual void grow(int) = 0;
virtual void reset_ptrs() = 0; virtual void reset_special() {}
virtual void zero_owned(int) {}
virtual void zero_ghost(int,int) {}
virtual void copy(int, int) = 0; virtual void copy(int, int) = 0;
virtual int pack_comm(int, int *, double *, int, int *) = 0; virtual int pack_comm(int, int *, double *, int, int *) = 0;
@ -63,14 +62,14 @@ class AtomVec : protected Pointers {
virtual int unpack_exchange(double *) = 0; virtual int unpack_exchange(double *) = 0;
virtual int size_restart() = 0; virtual int size_restart() = 0;
virtual int size_restart_one(int) = 0;
virtual int pack_restart(int, double *) = 0; virtual int pack_restart(int, double *) = 0;
virtual int unpack_restart(double *) = 0; virtual int unpack_restart(double *) = 0;
virtual void create_atom(int, double *, int) = 0; virtual void create_atom(int, double *) = 0;
virtual void data_atom(double *, int, char **, int) = 0; virtual void data_atom(double *, int, char **) = 0;
virtual void data_vel(int, char *, int); virtual int data_atom_hybrid(int, char **) = 0;
virtual void data_params(int) {} virtual void data_vel(int, char **);
virtual int data_vel_hybrid(int, char **) {return 0;}
virtual int memory_usage() = 0; virtual int memory_usage() = 0;

View File

@ -69,19 +69,6 @@ void AtomVecAtomic::grow(int n)
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
void AtomVecAtomic::reset_ptrs()
{
tag = atom->tag;
type = atom->type;
mask = atom->mask;
image = atom->image;
x = atom->x;
v = atom->v;
f = atom->f;
}
/* ---------------------------------------------------------------------- */
void AtomVecAtomic::copy(int i, int j) void AtomVecAtomic::copy(int i, int j)
{ {
tag[j] = tag[i]; tag[j] = tag[i];
@ -318,16 +305,6 @@ int AtomVecAtomic::size_restart()
return n; return n;
} }
/* ----------------------------------------------------------------------
size of restart data for atom I
do not include extra data stored by fixes, included by caller
------------------------------------------------------------------------- */
int AtomVecAtomic::size_restart_one(int i)
{
return 11;
}
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
pack atom I's data for restart file including extra quantities pack atom I's data for restart file including extra quantities
xyz must be 1st 3 values, so that read_restart can test on them xyz must be 1st 3 values, so that read_restart can test on them
@ -398,7 +375,7 @@ int AtomVecAtomic::unpack_restart(double *buf)
set other values to defaults set other values to defaults
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void AtomVecAtomic::create_atom(int itype, double *coord, int ihybrid) void AtomVecAtomic::create_atom(int itype, double *coord)
{ {
int nlocal = atom->nlocal; int nlocal = atom->nlocal;
if (nlocal == nmax) grow(0); if (nlocal == nmax) grow(0);
@ -422,8 +399,7 @@ void AtomVecAtomic::create_atom(int itype, double *coord, int ihybrid)
initialize other atom quantities initialize other atom quantities
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void AtomVecAtomic::data_atom(double *coord, int imagetmp, char **values, void AtomVecAtomic::data_atom(double *coord, int imagetmp, char **values)
int ihybrid)
{ {
int nlocal = atom->nlocal; int nlocal = atom->nlocal;
if (nlocal == nmax) grow(0); if (nlocal == nmax) grow(0);
@ -450,6 +426,20 @@ void AtomVecAtomic::data_atom(double *coord, int imagetmp, char **values,
atom->nlocal++; atom->nlocal++;
} }
/* ----------------------------------------------------------------------
unpack hybrid quantities from one line in Atoms section of data file
initialize other atom quantities for this sub-style
------------------------------------------------------------------------- */
int AtomVecAtomic::data_atom_hybrid(int nlocal, char **values)
{
v[nlocal][0] = 0.0;
v[nlocal][1] = 0.0;
v[nlocal][2] = 0.0;
return 0;
}
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
return # of bytes of allocated memory return # of bytes of allocated memory
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */

View File

@ -23,7 +23,6 @@ class AtomVecAtomic : public AtomVec {
AtomVecAtomic(class LAMMPS *, int, char **); AtomVecAtomic(class LAMMPS *, int, char **);
virtual ~AtomVecAtomic() {} virtual ~AtomVecAtomic() {}
void grow(int); void grow(int);
void reset_ptrs();
void copy(int, int); void copy(int, int);
virtual int pack_comm(int, int *, double *, int, int *); virtual int pack_comm(int, int *, double *, int, int *);
virtual void unpack_comm(int, int, double *); virtual void unpack_comm(int, int, double *);
@ -34,11 +33,11 @@ class AtomVecAtomic : public AtomVec {
int pack_exchange(int, double *); int pack_exchange(int, double *);
int unpack_exchange(double *); int unpack_exchange(double *);
int size_restart(); int size_restart();
int size_restart_one(int);
int pack_restart(int, double *); int pack_restart(int, double *);
int unpack_restart(double *); int unpack_restart(double *);
void create_atom(int, double *, int); void create_atom(int, double *);
void data_atom(double *, int, char **, int); void data_atom(double *, int, char **);
int data_atom_hybrid(int, char **);
int memory_usage(); int memory_usage();
protected: protected:

View File

@ -72,46 +72,6 @@ void AtomVecCharge::grow(int n)
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
void AtomVecCharge::reset_ptrs()
{
tag = atom->tag;
type = atom->type;
mask = atom->mask;
image = atom->image;
x = atom->x;
v = atom->v;
f = atom->f;
q = atom->q;
}
/* ----------------------------------------------------------------------
zero auxiliary data for owned atom I
data in copy(), not including tag,type,mask,image,x,v
------------------------------------------------------------------------- */
void AtomVecCharge::zero_owned(int i)
{
q[i] = 0.0;
}
/* ----------------------------------------------------------------------
zero auxiliary data for n ghost atoms
data in border(), not including x,tag,type,mask
grow() is here since zero_ghost called first in hybrid::unpack_border()
------------------------------------------------------------------------- */
void AtomVecCharge::zero_ghost(int n, int first)
{
int last = first + n;
for (int i = first; i < last; i++) {
if (i == nmax) atom->avec->grow(0);
q[i] = 0.0;
}
}
/* ---------------------------------------------------------------------- */
void AtomVecCharge::copy(int i, int j) void AtomVecCharge::copy(int i, int j)
{ {
tag[j] = tag[i]; tag[j] = tag[i];
@ -373,16 +333,6 @@ int AtomVecCharge::size_restart()
return n; return n;
} }
/* ----------------------------------------------------------------------
size of restart data for atom I
do not include extra data stored by fixes, included by caller
------------------------------------------------------------------------- */
int AtomVecCharge::size_restart_one(int i)
{
return 12;
}
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
pack atom I's data for restart file including extra quantities pack atom I's data for restart file including extra quantities
xyz must be 1st 3 values, so that read_restart can test on them xyz must be 1st 3 values, so that read_restart can test on them
@ -457,7 +407,7 @@ int AtomVecCharge::unpack_restart(double *buf)
set other values to defaults set other values to defaults
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void AtomVecCharge::create_atom(int itype, double *coord, int ihybrid) void AtomVecCharge::create_atom(int itype, double *coord)
{ {
int nlocal = atom->nlocal; int nlocal = atom->nlocal;
if (nlocal == nmax) grow(0); if (nlocal == nmax) grow(0);
@ -483,8 +433,7 @@ void AtomVecCharge::create_atom(int itype, double *coord, int ihybrid)
initialize other atom quantities initialize other atom quantities
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void AtomVecCharge::data_atom(double *coord, int imagetmp, char **values, void AtomVecCharge::data_atom(double *coord, int imagetmp, char **values)
int ihybrid)
{ {
int nlocal = atom->nlocal; int nlocal = atom->nlocal;
if (nlocal == nmax) grow(0); if (nlocal == nmax) grow(0);
@ -513,6 +462,22 @@ void AtomVecCharge::data_atom(double *coord, int imagetmp, char **values,
atom->nlocal++; atom->nlocal++;
} }
/* ----------------------------------------------------------------------
unpack hybrid quantities from one line in Atoms section of data file
initialize other atom quantities for this sub-style
------------------------------------------------------------------------- */
int AtomVecCharge::data_atom_hybrid(int nlocal, char **values)
{
q[nlocal] = atof(values[0]);
v[nlocal][0] = 0.0;
v[nlocal][1] = 0.0;
v[nlocal][2] = 0.0;
return 1;
}
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
return # of bytes of allocated memory return # of bytes of allocated memory
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */

View File

@ -22,9 +22,6 @@ class AtomVecCharge : public AtomVec {
public: public:
AtomVecCharge(class LAMMPS *, int, char **); AtomVecCharge(class LAMMPS *, int, char **);
void grow(int); void grow(int);
void reset_ptrs();
void zero_owned(int);
void zero_ghost(int, int);
void copy(int, int); void copy(int, int);
int pack_comm(int, int *, double *, int, int *); int pack_comm(int, int *, double *, int, int *);
void unpack_comm(int, int, double *); void unpack_comm(int, int, double *);
@ -37,11 +34,11 @@ class AtomVecCharge : public AtomVec {
int pack_exchange(int, double *); int pack_exchange(int, double *);
int unpack_exchange(double *); int unpack_exchange(double *);
int size_restart(); int size_restart();
int size_restart_one(int);
int pack_restart(int, double *); int pack_restart(int, double *);
int unpack_restart(double *); int unpack_restart(double *);
void create_atom(int, double *, int); void create_atom(int, double *);
void data_atom(double *, int, char **, int); void data_atom(double *, int, char **);
int data_atom_hybrid(int, char **);
int memory_usage(); int memory_usage();
private: private:

View File

@ -1,4 +1,3 @@
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
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
@ -12,6 +11,7 @@
See the README file in the top-level LAMMPS directory. See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include "stdlib.h"
#include "string.h" #include "string.h"
#include "atom_vec_hybrid.h" #include "atom_vec_hybrid.h"
#include "atom.h" #include "atom.h"
@ -33,7 +33,7 @@ using namespace LAMMPS_NS;
AtomVecHybrid::AtomVecHybrid(LAMMPS *lmp, int narg, char **arg) : AtomVecHybrid::AtomVecHybrid(LAMMPS *lmp, int narg, char **arg) :
AtomVec(lmp, narg, arg) AtomVec(lmp, narg, arg)
{ {
int i,m; int i,k;
if (narg < 1) error->all("Illegal atom_style command"); if (narg < 1) error->all("Illegal atom_style command");
@ -44,8 +44,8 @@ AtomVecHybrid::AtomVecHybrid(LAMMPS *lmp, int narg, char **arg) :
keywords = new char*[nstyles]; keywords = new char*[nstyles];
for (i = 0; i < narg; i++) { for (i = 0; i < narg; i++) {
for (m = 0; m < i; m++) for (k = 0; k < i; k++)
if (strcmp(arg[i],keywords[m]) == 0) if (strcmp(arg[i],keywords[k]) == 0)
error->all("Atom style hybrid cannot use same atom style twice"); error->all("Atom style hybrid cannot use same atom style twice");
if (strcmp(arg[i],"hybrid") == 0) if (strcmp(arg[i],"hybrid") == 0)
error->all("Atom style hybrid cannot have hybrid as an argument"); error->all("Atom style hybrid cannot have hybrid as an argument");
@ -55,21 +55,31 @@ AtomVecHybrid::AtomVecHybrid(LAMMPS *lmp, int narg, char **arg) :
} }
// hybrid settings are MAX or MIN of sub-style settings // hybrid settings are MAX or MIN of sub-style settings
// size_border has +1 for hybrid[] value that is also communicated // hybrid sizes are minimial values plus extra values for each sub-style
for (m = 0; m < nstyles; m++) { size_comm = 3;
molecular = MAX(molecular,styles[m]->molecular); size_reverse = 3;
bonds_allow = MAX(bonds_allow,styles[m]->bonds_allow); size_border = 6;
angles_allow = MAX(angles_allow,styles[m]->angles_allow); size_data_atom = 5;
dihedrals_allow = MAX(dihedrals_allow,styles[m]->dihedrals_allow); size_data_vel = 4;
impropers_allow = MAX(impropers_allow,styles[m]->impropers_allow); xcol_data = 3;
mass_type = MAX(mass_type,styles[m]->mass_type);
dipole_type = MAX(dipole_type,styles[m]->dipole_type); for (k = 0; k < nstyles; k++) {
comm_x_only = MIN(comm_x_only,styles[m]->comm_x_only); molecular = MAX(molecular,styles[k]->molecular);
comm_f_only = MIN(comm_f_only,styles[m]->comm_f_only); bonds_allow = MAX(bonds_allow,styles[k]->bonds_allow);
size_comm = MAX(size_comm,styles[m]->size_comm); angles_allow = MAX(angles_allow,styles[k]->angles_allow);
size_reverse = MAX(size_reverse,styles[m]->size_reverse); dihedrals_allow = MAX(dihedrals_allow,styles[k]->dihedrals_allow);
size_border = MAX(size_border,styles[m]->size_border) + 1; impropers_allow = MAX(impropers_allow,styles[k]->impropers_allow);
mass_type = MAX(mass_type,styles[k]->mass_type);
shape_type = MAX(shape_type,styles[k]->shape_type);
dipole_type = MAX(dipole_type,styles[k]->dipole_type);
comm_x_only = MIN(comm_x_only,styles[k]->comm_x_only);
comm_f_only = MIN(comm_f_only,styles[k]->comm_f_only);
size_comm += styles[k]->size_comm - 3;
size_reverse += styles[k]->size_reverse - 3;
size_border += styles[k]->size_border - 6;
size_data_atom += styles[k]->size_data_atom - 5;
size_data_vel += styles[k]->size_data_vel - 4;
} }
} }
@ -77,9 +87,9 @@ AtomVecHybrid::AtomVecHybrid(LAMMPS *lmp, int narg, char **arg) :
AtomVecHybrid::~AtomVecHybrid() AtomVecHybrid::~AtomVecHybrid()
{ {
for (int m = 0; m < nstyles; m++) delete styles[m]; for (int k = 0; k < nstyles; k++) delete styles[k];
delete [] styles; delete [] styles;
for (int m = 0; m < nstyles; m++) delete [] keywords[m]; for (int k = 0; k < nstyles; k++) delete [] keywords[k];
delete [] keywords; delete [] keywords;
} }
@ -97,7 +107,7 @@ void AtomVecHybrid::grow(int n)
int tmp = atom->nextra_grow; int tmp = atom->nextra_grow;
atom->nextra_grow = 0; atom->nextra_grow = 0;
for (int m = 0; m < nstyles; m++) styles[m]->grow(nmax); for (int k = 0; k < nstyles; k++) styles[k]->grow(nmax);
atom->nextra_grow = tmp; atom->nextra_grow = tmp;
// pointers for arrays used directly by hybrid style // pointers for arrays used directly by hybrid style
@ -110,9 +120,6 @@ void AtomVecHybrid::grow(int n)
v = atom->v; v = atom->v;
f = atom->f; f = atom->f;
hybrid = atom->hybrid = (int *)
memory->srealloc(atom->hybrid,nmax*sizeof(int),"atom:hybrid");
if (atom->nextra_grow) if (atom->nextra_grow)
for (int iextra = 0; iextra < atom->nextra_grow; iextra++) for (int iextra = 0; iextra < atom->nextra_grow; iextra++)
modify->fix[atom->extra_grow[iextra]]->grow_arrays(nmax); modify->fix[atom->extra_grow[iextra]]->grow_arrays(nmax);
@ -120,33 +127,25 @@ void AtomVecHybrid::grow(int n)
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
void AtomVecHybrid::reset_ptrs() void AtomVecHybrid::reset_special()
{ {
for (int m = 0; m < nstyles; m++) styles[m]->reset_ptrs(); for (int k = 0; k < nstyles; k++) styles[k]->reset_special();
tag = atom->tag;
type = atom->type;
mask = atom->mask;
image = atom->image;
x = atom->x;
v = atom->v;
f = atom->f;
hybrid = atom->hybrid;
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
copy array values based on hybrid style of atom i copy array values for all sub-styles
zero auxiliary arrays for all other styles before copy
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void AtomVecHybrid::copy(int i, int j) void AtomVecHybrid::copy(int i, int j)
{ {
int ihybrid = hybrid[i]; int tmp = atom->nextra_grow;
for (int m = 0; m < nstyles; m++) atom->nextra_grow = 0;
if (m != ihybrid) styles[m]->zero_owned(j); for (int k = 0; k < nstyles; k++) styles[k]->copy(i,j);
styles[ihybrid]->copy(i,j); atom->nextra_grow = tmp;
hybrid[j] = ihybrid;
if (atom->nextra_grow)
for (int iextra = 0; iextra < atom->nextra_grow; iextra++)
modify->fix[atom->extra_grow[iextra]]->copy_arrays(i,j);
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -154,7 +153,7 @@ void AtomVecHybrid::copy(int i, int j)
int AtomVecHybrid::pack_comm(int n, int *list, double *buf, int AtomVecHybrid::pack_comm(int n, int *list, double *buf,
int pbc_flag, int *pbc) int pbc_flag, int *pbc)
{ {
int i,j,m; int i,j,k,m;
double dx,dy,dz; double dx,dy,dz;
m = 0; m = 0;
@ -164,7 +163,8 @@ int AtomVecHybrid::pack_comm(int n, int *list, double *buf,
buf[m++] = x[j][0]; buf[m++] = x[j][0];
buf[m++] = x[j][1]; buf[m++] = x[j][1];
buf[m++] = x[j][2]; buf[m++] = x[j][2];
m += styles[hybrid[j]]->pack_comm_one(j,&buf[m]); for (k = 0; k < nstyles; k++)
m += styles[k]->pack_comm_one(j,&buf[m]);
} }
} else { } else {
if (domain->triclinic == 0) { if (domain->triclinic == 0) {
@ -181,7 +181,8 @@ int AtomVecHybrid::pack_comm(int n, int *list, double *buf,
buf[m++] = x[j][0] + dx; buf[m++] = x[j][0] + dx;
buf[m++] = x[j][1] + dy; buf[m++] = x[j][1] + dy;
buf[m++] = x[j][2] + dz; buf[m++] = x[j][2] + dz;
m += styles[hybrid[j]]->pack_comm_one(j,&buf[m]); for (k = 0; k < nstyles; k++)
m += styles[k]->pack_comm_one(j,&buf[m]);
} }
} }
return m; return m;
@ -191,15 +192,16 @@ int AtomVecHybrid::pack_comm(int n, int *list, double *buf,
void AtomVecHybrid::unpack_comm(int n, int first, double *buf) void AtomVecHybrid::unpack_comm(int n, int first, double *buf)
{ {
int i,m,last; int i,k,last;
m = 0; int m = 0;
last = first + n; last = first + n;
for (i = first; i < last; i++) { for (i = first; i < last; i++) {
x[i][0] = buf[m++]; x[i][0] = buf[m++];
x[i][1] = buf[m++]; x[i][1] = buf[m++];
x[i][2] = buf[m++]; x[i][2] = buf[m++];
m += styles[hybrid[i]]->unpack_comm_one(i,&buf[m]); for (k = 0; k < nstyles; k++)
m += styles[k]->unpack_comm_one(i,&buf[m]);
} }
} }
@ -207,15 +209,16 @@ void AtomVecHybrid::unpack_comm(int n, int first, double *buf)
int AtomVecHybrid::pack_reverse(int n, int first, double *buf) int AtomVecHybrid::pack_reverse(int n, int first, double *buf)
{ {
int i,m,last; int i,k,last;
m = 0; int m = 0;
last = first + n; last = first + n;
for (i = first; i < last; i++) { for (i = first; i < last; i++) {
buf[m++] = f[i][0]; buf[m++] = f[i][0];
buf[m++] = f[i][1]; buf[m++] = f[i][1];
buf[m++] = f[i][2]; buf[m++] = f[i][2];
m += styles[hybrid[i]]->pack_reverse_one(i,&buf[m]); for (k = 0; k < nstyles; k++)
m += styles[k]->pack_reverse_one(i,&buf[m]);
} }
return m; return m;
} }
@ -224,7 +227,7 @@ int AtomVecHybrid::pack_reverse(int n, int first, double *buf)
void AtomVecHybrid::unpack_reverse(int n, int *list, double *buf) void AtomVecHybrid::unpack_reverse(int n, int *list, double *buf)
{ {
int i,j,m; int i,j,k,m;
m = 0; m = 0;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
@ -232,7 +235,8 @@ void AtomVecHybrid::unpack_reverse(int n, int *list, double *buf)
f[j][0] += buf[m++]; f[j][0] += buf[m++];
f[j][1] += buf[m++]; f[j][1] += buf[m++];
f[j][2] += buf[m++]; f[j][2] += buf[m++];
m += styles[hybrid[j]]->unpack_reverse_one(j,&buf[m]); for (k = 0; k < nstyles; k++)
m += styles[k]->unpack_reverse_one(j,&buf[m]);
} }
} }
@ -241,7 +245,7 @@ void AtomVecHybrid::unpack_reverse(int n, int *list, double *buf)
int AtomVecHybrid::pack_border(int n, int *list, double *buf, int AtomVecHybrid::pack_border(int n, int *list, double *buf,
int pbc_flag, int *pbc) int pbc_flag, int *pbc)
{ {
int i,j,m; int i,j,k,m;
double dx,dy,dz; double dx,dy,dz;
m = 0; m = 0;
@ -254,8 +258,8 @@ int AtomVecHybrid::pack_border(int n, int *list, double *buf,
buf[m++] = tag[j]; buf[m++] = tag[j];
buf[m++] = type[j]; buf[m++] = type[j];
buf[m++] = mask[j]; buf[m++] = mask[j];
buf[m++] = hybrid[j]; for (k = 0; k < nstyles; k++)
m += styles[hybrid[j]]->pack_border_one(j,&buf[m]); m += styles[k]->pack_border_one(j,&buf[m]);
} }
} else { } else {
if (domain->triclinic == 0) { if (domain->triclinic == 0) {
@ -275,24 +279,18 @@ int AtomVecHybrid::pack_border(int n, int *list, double *buf,
buf[m++] = tag[j]; buf[m++] = tag[j];
buf[m++] = type[j]; buf[m++] = type[j];
buf[m++] = mask[j]; buf[m++] = mask[j];
buf[m++] = hybrid[j]; for (k = 0; k < nstyles; k++)
m += styles[hybrid[j]]->pack_border_one(j,&buf[m]); m += styles[k]->pack_border_one(j,&buf[m]);
} }
} }
return m; return m;
} }
/* ---------------------------------------------------------------------- /* ---------------------------------------------------------------------- */
unpack border ghost atom data
zero auxiliary ghost arrays for all styles before unpack
grow() is called in zero_ghost() and here (in case zero_ghost is no-op)
------------------------------------------------------------------------- */
void AtomVecHybrid::unpack_border(int n, int first, double *buf) void AtomVecHybrid::unpack_border(int n, int first, double *buf)
{ {
int i,m,last; int i,k,m,last;
for (m = 0; m < nstyles; m++) styles[m]->zero_ghost(n,first);
m = 0; m = 0;
last = first + n; last = first + n;
@ -304,30 +302,40 @@ void AtomVecHybrid::unpack_border(int n, int first, double *buf)
tag[i] = static_cast<int> (buf[m++]); tag[i] = static_cast<int> (buf[m++]);
type[i] = static_cast<int> (buf[m++]); type[i] = static_cast<int> (buf[m++]);
mask[i] = static_cast<int> (buf[m++]); mask[i] = static_cast<int> (buf[m++]);
hybrid[i] = static_cast<int> (buf[m++]); for (k = 0; k < nstyles; k++)
m += styles[hybrid[i]]->unpack_border_one(i,&buf[m]); m += styles[k]->unpack_border_one(i,&buf[m]);
} }
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
pack data for atom I for sending to another proc pack data for atom I for sending to another proc
sub-style does packing pack each sub-style one after the other
append hybrid[i] and increment count stored in buf[0]
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
int AtomVecHybrid::pack_exchange(int i, double *buf) int AtomVecHybrid::pack_exchange(int i, double *buf)
{ {
int m = styles[hybrid[i]]->pack_exchange(i,buf); int k;
buf[m++] = hybrid[i];
buf[0] = m; int tmp = atom->nextra_grow;
atom->nextra_grow = 0;
int m = 0;
for (k = 0; k < nstyles; k++)
m += styles[k]->pack_exchange(i,&buf[m]);
atom->nextra_grow = tmp;
if (atom->nextra_grow)
for (int iextra = 0; iextra < atom->nextra_grow; iextra++)
m += modify->fix[atom->extra_grow[iextra]]->pack_exchange(i,&buf[m]);
return m; return m;
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
unpack data for single atom received from another proc unpack data for single atom received from another proc
sub-style does unpacking unpack each sub-style one after the other
grow() must occur here so arrays for all sub-styles are grown grow() occurs here so arrays for all sub-styles are grown
extract hybrid[nlocal] from end of buf
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
int AtomVecHybrid::unpack_exchange(double *buf) int AtomVecHybrid::unpack_exchange(double *buf)
@ -335,9 +343,23 @@ int AtomVecHybrid::unpack_exchange(double *buf)
int nlocal = atom->nlocal; int nlocal = atom->nlocal;
if (nlocal == nmax) grow(0); if (nlocal == nmax) grow(0);
int m = static_cast<int> (buf[0]); int tmp = atom->nextra_grow;
hybrid[nlocal] = static_cast<int> (buf[m-1]); atom->nextra_grow = 0;
int tmp = styles[hybrid[nlocal]]->unpack_exchange(buf);
int m = 0;
for (int k = 0; k < nstyles; k++) {
m += styles[k]->unpack_exchange(buf);
atom->nlocal--;
}
atom->nextra_grow = tmp;
if (atom->nextra_grow)
for (int iextra = 0; iextra < atom->nextra_grow; iextra++)
m += modify->fix[atom->extra_grow[iextra]]->
unpack_exchange(nlocal,&buf[m]);
atom->nlocal++;
return m; return m;
} }
@ -348,19 +370,19 @@ int AtomVecHybrid::unpack_exchange(double *buf)
int AtomVecHybrid::size_restart() int AtomVecHybrid::size_restart()
{ {
int i; int tmp = atom->nextra_restart;
int nlocal = atom->nlocal; atom->nextra_restart = 0;
// nlocal is added for per-atom hybrid value appended by pack_restart()
int n = 0; int n = 0;
for (i = 0; i < nlocal; i++) for (int k = 0; k < nstyles; k++)
n += styles[hybrid[i]]->size_restart_one(i); n += styles[k]->size_restart();
n += nlocal;
atom->nextra_restart = tmp;
int nlocal = atom->nlocal;
if (atom->nextra_restart) if (atom->nextra_restart)
for (int iextra = 0; iextra < atom->nextra_restart; iextra++) for (int iextra = 0; iextra < atom->nextra_restart; iextra++)
for (i = 0; i < nlocal; i++) for (int i = 0; i < nlocal; i++)
n += modify->fix[atom->extra_restart[iextra]]->size_restart(i); n += modify->fix[atom->extra_restart[iextra]]->size_restart(i);
return n; return n;
@ -368,24 +390,33 @@ int AtomVecHybrid::size_restart()
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
pack atom I's data for restart file including extra quantities pack atom I's data for restart file including extra quantities
sub-style does packing xyz must be 1st 3 values, so that read_restart can test on them
append hybrid[i] and increment count stored in buf[0] pack each sub-style one after the other
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
int AtomVecHybrid::pack_restart(int i, double *buf) int AtomVecHybrid::pack_restart(int i, double *buf)
{ {
int m = styles[hybrid[i]]->pack_restart(i,buf); int tmp = atom->nextra_restart;
buf[m++] = hybrid[i]; atom->nextra_restart = 0;
int m = 0;
for (int k = 0; k < nstyles; k++)
m += styles[k]->pack_restart(i,&buf[m]);
atom->nextra_restart = tmp;
if (atom->nextra_restart)
for (int iextra = 0; iextra < atom->nextra_restart; iextra++)
m += modify->fix[atom->extra_restart[iextra]]->pack_restart(i,&buf[m]);
buf[0] = m; buf[0] = m;
return m; return m;
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
unpack data for one atom from restart file including extra quantities unpack data for one atom from restart file including extra quantities
sub-style does unpacking unpack each sub-style one after the other
grow() must occur here so arrays for all sub-styles are grown grow() occurs here so arrays for all sub-styles are grown
zero auxiliary arrays for all other styles before unpack
extract hybrid[nlocal] from end of buf
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
int AtomVecHybrid::unpack_restart(double *buf) int AtomVecHybrid::unpack_restart(double *buf)
@ -399,74 +430,93 @@ int AtomVecHybrid::unpack_restart(double *buf)
"atom:extra"); "atom:extra");
} }
int m = static_cast<int> (buf[0]); int tmp = atom->nextra_store;
int ihybrid = static_cast<int> (buf[m-1]); atom->nextra_store = 0;
for (int m = 0; m < nstyles; m++)
if (m != ihybrid) styles[m]->zero_owned(nlocal);
hybrid[nlocal] = ihybrid;
// size of extra unpack in sub-style includes end-of-buf entry of hybrid int m = 0;
// avoid this by resetting buf[0] to one less for (int k = 0; k < nstyles; k++) {
m += styles[k]->unpack_restart(&buf[m]);
atom->nlocal--;
}
atom->nextra_store = tmp;
buf[0] = m-1; double **extra = atom->extra;
int tmp = styles[ihybrid]->unpack_restart(buf); if (atom->nextra_store) {
int size = static_cast<int> (buf[0]) - m;
for (int i = 0; i < size; i++) extra[nlocal][i] = buf[m++];
}
atom->nlocal++;
return m; return m;
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
create one atom of itype at coord for ihybrid style create one atom of itype at coord
sub-style does create create each sub-style one after the other
grow() must occur here so arrays for all sub-styles are grown grow() occurs here so arrays for all sub-styles are grown
zero auxiliary arrays for all other styles before create
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void AtomVecHybrid::create_atom(int itype, double *coord, int ihybrid) void AtomVecHybrid::create_atom(int itype, double *coord)
{ {
int nlocal = atom->nlocal; int nlocal = atom->nlocal;
if (nlocal == nmax) grow(0); if (nlocal == nmax) grow(0);
for (int m = 0; m < nstyles; m++) for (int k = 0; k < nstyles; k++) {
if (m != ihybrid) styles[m]->zero_owned(nlocal); styles[k]->create_atom(itype,coord);
hybrid[nlocal] = ihybrid; atom->nlocal--;
styles[ihybrid]->create_atom(itype,coord,0); }
atom->nlocal++;
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
unpack one line from Atoms section of data file unpack one line from Atoms section of data file
zero auxiliary arrays for all other styles before unpack grow() occurs here so arrays for all sub-styles are grown
sub-style will increment nlocal
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void AtomVecHybrid::data_atom(double *coord, int imagetmp, char **values, void AtomVecHybrid::data_atom(double *coord, int imagetmp, char **values)
int ihybrid)
{ {
int nlocal = atom->nlocal; int nlocal = atom->nlocal;
if (nlocal == nmax) grow(0); if (nlocal == nmax) grow(0);
for (int m = 0; m < nstyles; m++) tag[nlocal] = atoi(values[0]);
if (m != ihybrid) styles[m]->zero_owned(nlocal); if (tag[nlocal] <= 0)
hybrid[nlocal] = ihybrid; error->one("Invalid atom ID in Atoms section of data file");
styles[ihybrid]->data_atom(coord,imagetmp,values,0);
type[nlocal] = atoi(values[1]);
if (type[nlocal] <= 0 || type[nlocal] > atom->ntypes)
error->one("Invalid atom type in Atoms section of data file");
x[nlocal][0] = coord[0];
x[nlocal][1] = coord[1];
x[nlocal][2] = coord[2];
image[nlocal] = imagetmp;
mask[nlocal] = 1;
// each sub-style parses sub-style specific values
int m = 5;
for (int k = 0; k < nstyles; k++)
m += styles[k]->data_atom_hybrid(nlocal,&values[m]);
atom->nlocal++;
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
unpack one line from Velocities section of data file unpack one line from Velocities section of data file
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void AtomVecHybrid::data_vel(int m, char *line, int ihybrid) void AtomVecHybrid::data_vel(int m, char **values)
{ {
styles[ihybrid]->data_vel(m,line,0); v[m][0] = atof(values[0]);
} v[m][1] = atof(values[1]);
v[m][2] = atof(values[2]);
/* ---------------------------------------------------------------------- // each sub-style parses sub-style specific values
set data file parameters for ihybrid sub-style
------------------------------------------------------------------------- */
void AtomVecHybrid::data_params(int ihybrid) int n = 3;
{ for (int k = 0; k < nstyles; k++)
size_data_atom = styles[ihybrid]->size_data_atom; n += styles[k]->data_vel_hybrid(m,&values[n]);
size_data_vel = styles[ihybrid]->size_data_vel;
xcol_data = styles[ihybrid]->xcol_data;
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
@ -476,8 +526,6 @@ void AtomVecHybrid::data_params(int ihybrid)
int AtomVecHybrid::memory_usage() int AtomVecHybrid::memory_usage()
{ {
int bytes = 0; int bytes = 0;
for (int m = 0; m < nstyles; m++) for (int k = 0; k < nstyles; k++) bytes += styles[k]->memory_usage();
bytes += styles[m]->memory_usage();
if (atom->memcheck("hybrid")) bytes += nmax * sizeof(int);
return bytes; return bytes;
} }

View File

@ -27,7 +27,7 @@ class AtomVecHybrid : public AtomVec {
AtomVecHybrid(class LAMMPS *, int, char **); AtomVecHybrid(class LAMMPS *, int, char **);
~AtomVecHybrid(); ~AtomVecHybrid();
void grow(int); void grow(int);
void reset_ptrs(); void reset_special();
void copy(int, int); void copy(int, int);
int pack_comm(int, int *, double *, int, int *); int pack_comm(int, int *, double *, int, int *);
void unpack_comm(int, int, double *); void unpack_comm(int, int, double *);
@ -38,19 +38,17 @@ class AtomVecHybrid : public AtomVec {
int pack_exchange(int, double *); int pack_exchange(int, double *);
int unpack_exchange(double *); int unpack_exchange(double *);
int size_restart(); int size_restart();
int size_restart_one(int) {return 0;}
int pack_restart(int, double *); int pack_restart(int, double *);
int unpack_restart(double *); int unpack_restart(double *);
void create_atom(int, double *, int); void create_atom(int, double *);
void data_atom(double *, int, char **, int); void data_atom(double *, int, char **);
void data_vel(int, char *, int); int data_atom_hybrid(int, char **) {return 0;}
void data_params(int); void data_vel(int, char **);
int memory_usage(); int memory_usage();
private: private:
int *tag,*type,*mask,*image; int *tag,*type,*mask,*image;
double **x,**v,**f; double **x,**v,**f;
int *hybrid;
}; };
} }

View File

@ -11,6 +11,10 @@
See the README file in the top-level LAMMPS directory. See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
/* ----------------------------------------------------------------------
Contributing author (triclinic) : Pieter in 't Veld (SNL)
------------------------------------------------------------------------- */
#include "math.h" #include "math.h"
#include "string.h" #include "string.h"
#include "stdio.h" #include "stdio.h"

View File

@ -60,7 +60,7 @@ void ComputeCentroAtom::init()
for (int i = 0; i < modify->ncompute; i++) for (int i = 0; i < modify->ncompute; i++)
if (strcmp(modify->compute[i]->style,"centro/atom") == 0) count++; if (strcmp(modify->compute[i]->style,"centro/atom") == 0) count++;
if (count > 1 && comm->me == 0) if (count > 1 && comm->me == 0)
error->warning("More than one compute centro/atom defined"); error->warning("More than one compute centro/atom");
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */

View File

@ -60,7 +60,7 @@ void ComputeCoordAtom::init()
for (int i = 0; i < modify->ncompute; i++) for (int i = 0; i < modify->ncompute; i++)
if (strcmp(modify->compute[i]->style,"coord/atom") == 0) count++; if (strcmp(modify->compute[i]->style,"coord/atom") == 0) count++;
if (count > 1 && comm->me == 0) if (count > 1 && comm->me == 0)
error->warning("More than one compute coord/atom defined"); error->warning("More than one compute coord/atom");
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */

View File

@ -65,7 +65,7 @@ void ComputeEpairAtom::init()
for (int i = 0; i < modify->ncompute; i++) for (int i = 0; i < modify->ncompute; i++)
if (strcmp(modify->compute[i]->style,"epair/atom") == 0) count++; if (strcmp(modify->compute[i]->style,"epair/atom") == 0) count++;
if (count > 1 && comm->me == 0) if (count > 1 && comm->me == 0)
error->warning("More than one compute epair/atom defined"); error->warning("More than one compute epair/atom");
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */

View File

@ -58,7 +58,7 @@ void ComputeEtotalAtom::init()
for (int i = 0; i < modify->ncompute; i++) for (int i = 0; i < modify->ncompute; i++)
if (strcmp(modify->compute[i]->style,"etotal/atom") == 0) count++; if (strcmp(modify->compute[i]->style,"etotal/atom") == 0) count++;
if (count > 1 && comm->me == 0) if (count > 1 && comm->me == 0)
error->warning("More than one compute etotal/atom defined"); error->warning("More than one compute etotal/atom");
// set epair Compute used by this compute // set epair Compute used by this compute

View File

@ -51,7 +51,7 @@ void ComputeKEAtom::init()
for (int i = 0; i < modify->ncompute; i++) for (int i = 0; i < modify->ncompute; i++)
if (strcmp(modify->compute[i]->style,"ke/atom") == 0) count++; if (strcmp(modify->compute[i]->style,"ke/atom") == 0) count++;
if (count > 1 && comm->me == 0) if (count > 1 && comm->me == 0)
error->warning("More than one compute ke/atom defined"); error->warning("More than one compute ke/atom");
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */

View File

@ -58,6 +58,8 @@ ComputePressure::ComputePressure(LAMMPS *lmp, int narg, char **arg) :
pressflag = 1; pressflag = 1;
vector = new double[6]; vector = new double[6];
nvirial = 0;
vptr = NULL;
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -66,6 +68,7 @@ ComputePressure::~ComputePressure()
{ {
delete [] id_pre; delete [] id_pre;
delete [] vector; delete [] vector;
delete [] vptr;
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -81,57 +84,41 @@ void ComputePressure::init()
if (icompute < 0) error->all("Could not find compute pressure temp ID"); if (icompute < 0) error->all("Could not find compute pressure temp ID");
temperature = modify->compute[icompute]; temperature = modify->compute[icompute];
// set flags/ptrs for all contributions to virial // detect contributions to virial
// vptr points to all virial[6] contributions
pairflag = bondflag = angleflag = dihedralflag = improperflag = 0;
delete [] vptr;
nvirial = 0;
vptr = NULL;
if (force->pair) nvirial++;
if (atom->molecular && force->bond) nvirial++;
if (atom->molecular && force->angle) nvirial++;
if (atom->molecular && force->dihedral) nvirial++;
if (atom->molecular && force->improper) nvirial++;
for (int i = 0; i < modify->nfix; i++)
if (modify->fix[i]->virial_flag) nvirial++;
if (nvirial) {
vptr = new double*[nvirial];
nvirial = 0;
if (force->pair) vptr[nvirial++] = force->pair->virial;
if (force->bond) vptr[nvirial++] = force->bond->virial;
if (force->angle) vptr[nvirial++] = force->angle->virial;
if (force->dihedral) vptr[nvirial++] = force->dihedral->virial;
if (force->improper) vptr[nvirial++] = force->improper->virial;
for (int i = 0; i < modify->nfix; i++)
if (modify->fix[i]->virial_flag)
vptr[nvirial++] = modify->fix[i]->virial;
}
// flag Kspace contribution separately, since not summed across procs
kspaceflag = 0; kspaceflag = 0;
shakeflag = bodyflag = rigidflag = poemsflag = 0;
if (force->pair) {
pairflag = 1;
pair_virial = force->pair->virial;
}
if (atom->molecular) {
if (force->bond) {
bondflag = 1;
bond_virial = force->bond->virial;
}
if (force->angle) {
angleflag = 1;
angle_virial = force->angle->virial;
}
if (force->dihedral) {
dihedralflag = 1;
dihedral_virial = force->dihedral->virial;
}
if (force->improper) {
improperflag = 1;
improper_virial = force->improper->virial;
}
}
if (force->kspace) { if (force->kspace) {
kspaceflag = 1; kspaceflag = 1;
kspace_virial = force->kspace->virial; kspace_virial = force->kspace->virial;
} }
for (int i = 0; i < modify->nfix; i++) {
if (strcmp(modify->fix[i]->style,"shake") == 0) {
shakeflag = 1;
shake_virial = modify->fix[i]->virial;
}
if (strcmp(modify->fix[i]->style,"rigid") == 0 ||
strcmp(modify->fix[i]->style,"poems") == 0) {
bodyflag = 1;
if (strcmp(modify->fix[i]->style,"rigid") == 0) {
rigidflag = 1;
rigid_virial = modify->fix[i]->virial;
} else {
poemsflag = 1;
poems_virial = modify->fix[i]->virial;
}
}
}
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
@ -166,32 +153,16 @@ void ComputePressure::compute_vector()
void ComputePressure::virial_compute(int n) void ComputePressure::virial_compute(int n)
{ {
int i; int i,j;
double v[6]; double v[6],*vcomponent;
for (i = 0; i < n; i++) v[i] = 0.0; for (i = 0; i < n; i++) v[i] = 0.0;
// sum contributions to virial from various forces and fixes // sum contributions to virial from forces and fixes
if (pairflag) for (j = 0; j < nvirial; j++) {
for (i = 0; i < n; i++) v[i] += pair_virial[i]; vcomponent = vptr[j];
for (i = 0; i < n; i++) v[i] += vcomponent[i];
if (atom->molecular) {
if (bondflag)
for (i = 0; i < n; i++) v[i] += bond_virial[i];
if (angleflag)
for (i = 0; i < n; i++) v[i] += angle_virial[i];
if (dihedralflag)
for (i = 0; i < n; i++) v[i] += dihedral_virial[i];
if (improperflag)
for (i = 0; i < n; i++) v[i] += improper_virial[i];
if (shakeflag)
for (i = 0; i < n; i++) v[i] += shake_virial[i];
}
if (bodyflag) {
if (rigidflag) for (i = 0; i < n; i++) v[i] += rigid_virial[i];
if (poemsflag) for (i = 0; i < n; i++) v[i] += poems_virial[i];
} }
// sum virial across procs // sum virial across procs

View File

@ -28,11 +28,10 @@ class ComputePressure : public Compute {
private: private:
double boltz,nktv2p,inv_volume; double boltz,nktv2p,inv_volume;
double *pair_virial,*bond_virial,*angle_virial; int nvirial;
double *dihedral_virial,*improper_virial,*kspace_virial; double **vptr;
double *shake_virial,*rigid_virial,*poems_virial; int kspaceflag;
int pairflag,bondflag,angleflag,dihedralflag,improperflag,kspaceflag; double *kspace_virial;
int shakeflag,bodyflag,rigidflag,poemsflag;
Compute *temperature; Compute *temperature;
double virial[6]; double virial[6];

View File

@ -15,7 +15,6 @@
#include "compute_rotate_dipole.h" #include "compute_rotate_dipole.h"
#include "atom.h" #include "atom.h"
#include "force.h" #include "force.h"
#include "pair.h"
#include "group.h" #include "group.h"
#include "error.h" #include "error.h"
@ -31,8 +30,8 @@ ComputeRotateDipole::ComputeRotateDipole(LAMMPS *lmp, int narg, char **arg) :
{ {
if (narg != 3) error->all("Illegal compute rotate/dipole command"); if (narg != 3) error->all("Illegal compute rotate/dipole command");
if (atom->check_style("dipole") == 0) if (atom->dipole == NULL || atom->omega == NULL)
error->all("Must use atom style dipole with compute rotate/dipole"); error->all("Compute rotate/dipole requires atom attributes dipole, omega");
scalar_flag = 1; scalar_flag = 1;
extensive = 1; extensive = 1;
@ -53,23 +52,16 @@ void ComputeRotateDipole::init()
{ {
delete [] inertia; delete [] inertia;
inertia = new double[atom->ntypes+1]; inertia = new double[atom->ntypes+1];
double *mass = atom->mass; double *mass = atom->mass;
double **shape = atom->shape;
// insure use of dipole pair_style
// set sigma to Pair's sigma
Pair *pair = force->pair_match("dipole");
if (pair == NULL)
error->all("Pair style is incompatible with compute rotate/dipole");
double **sigma;
pair->extract_dipole(&sigma);
if (force->dimension == 3) if (force->dimension == 3)
for (int i = 1; i <= atom->ntypes; i++) for (int i = 1; i <= atom->ntypes; i++)
inertia[i] = INERTIA3D * mass[i] * 0.25*sigma[i][i]*sigma[i][i]; inertia[i] = INERTIA3D * mass[i] * 0.25*shape[i][0]*shape[i][0];
else else
for (int i = 1; i <= atom->ntypes; i++) for (int i = 1; i <= atom->ntypes; i++)
inertia[i] = INERTIA2D * mass[i] * 0.25*sigma[i][i]*sigma[i][i]; inertia[i] = INERTIA2D * mass[i] * 0.25*shape[i][0]*shape[i][0];
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */

View File

@ -30,8 +30,9 @@ ComputeRotateGran::ComputeRotateGran(LAMMPS *lmp, int narg, char **arg) :
{ {
if (narg != 3) error->all("Illegal compute rotate/gran command"); if (narg != 3) error->all("Illegal compute rotate/gran command");
if (atom->check_style("granular") == 0) if (atom->radius == NULL || atom->rmass == NULL || atom->omega == NULL)
error->all("Must use atom style granular with compute rotate/gran"); error->all("Compute rotate/gran requires atom attributes "
"radius, rmass, omega");
scalar_flag = 1; scalar_flag = 1;
extensive = 1; extensive = 1;

View File

@ -62,7 +62,7 @@ void ComputeStressAtom::init()
for (int i = 0; i < modify->ncompute; i++) for (int i = 0; i < modify->ncompute; i++)
if (strcmp(modify->compute[i]->style,"stress/atom") == 0) count++; if (strcmp(modify->compute[i]->style,"stress/atom") == 0) count++;
if (count > 1 && comm->me == 0) if (count > 1 && comm->me == 0)
error->warning("More than one compute stress/atom defined"); error->warning("More than one compute stress/atom");
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */

View File

@ -139,7 +139,7 @@ void ComputeTempRamp::recount()
double ComputeTempRamp::compute_scalar() double ComputeTempRamp::compute_scalar()
{ {
double fraction,vramp,vtmp[3]; double fraction,vramp,vthermal[3];
double **x = atom->x; double **x = atom->x;
double **v = atom->v; double **v = atom->v;
@ -156,15 +156,16 @@ double ComputeTempRamp::compute_scalar()
fraction = MAX(fraction,0.0); fraction = MAX(fraction,0.0);
fraction = MIN(fraction,1.0); fraction = MIN(fraction,1.0);
vramp = v_lo + fraction*(v_hi - v_lo); vramp = v_lo + fraction*(v_hi - v_lo);
vtmp[0] = v[i][0]; vthermal[0] = v[i][0];
vtmp[1] = v[i][1]; vthermal[1] = v[i][1];
vtmp[2] = v[i][2]; vthermal[2] = v[i][2];
vtmp[v_dim] -= vramp; vthermal[v_dim] -= vramp;
if (mass) if (mass)
t += (vtmp[0]*vtmp[0] + vtmp[1]*vtmp[1] + vtmp[2]*vtmp[2]) * t += (vthermal[0]*vthermal[0] + vthermal[1]*vthermal[1] +
mass[type[i]]; vthermal[2]*vthermal[2]) * mass[type[i]];
else else
t += (vtmp[0]*vtmp[0] + vtmp[1]*vtmp[1] + vtmp[2]*vtmp[2]) * rmass[i]; t += (vthermal[0]*vthermal[0] + vthermal[1]*vthermal[1] +
vthermal[2]*vthermal[2]) * rmass[i];
} }
MPI_Allreduce(&t,&scalar,1,MPI_DOUBLE,MPI_SUM,world); MPI_Allreduce(&t,&scalar,1,MPI_DOUBLE,MPI_SUM,world);
@ -178,7 +179,7 @@ double ComputeTempRamp::compute_scalar()
void ComputeTempRamp::compute_vector() void ComputeTempRamp::compute_vector()
{ {
int i; int i;
double fraction,vramp,vtmp[3]; double fraction,vramp,vthermal[3];
double **x = atom->x; double **x = atom->x;
double **v = atom->v; double **v = atom->v;
@ -197,19 +198,19 @@ void ComputeTempRamp::compute_vector()
fraction = MAX(fraction,0.0); fraction = MAX(fraction,0.0);
fraction = MIN(fraction,1.0); fraction = MIN(fraction,1.0);
vramp = v_lo + fraction*(v_hi - v_lo); vramp = v_lo + fraction*(v_hi - v_lo);
vtmp[0] = v[i][0]; vthermal[0] = v[i][0];
vtmp[1] = v[i][1]; vthermal[1] = v[i][1];
vtmp[2] = v[i][2]; vthermal[2] = v[i][2];
vtmp[v_dim] -= vramp; vthermal[v_dim] -= vramp;
if (mass) massone = mass[type[i]]; if (mass) massone = mass[type[i]];
else massone = rmass[i]; else massone = rmass[i];
t[0] += massone * vtmp[0]*vtmp[0]; t[0] += massone * vthermal[0]*vthermal[0];
t[1] += massone * vtmp[1]*vtmp[1]; t[1] += massone * vthermal[1]*vthermal[1];
t[2] += massone * vtmp[2]*vtmp[2]; t[2] += massone * vthermal[2]*vthermal[2];
t[3] += massone * vtmp[0]*vtmp[1]; t[3] += massone * vthermal[0]*vthermal[1];
t[4] += massone * vtmp[0]*vtmp[2]; t[4] += massone * vthermal[0]*vthermal[2];
t[5] += massone * vtmp[1]*vtmp[2]; t[5] += massone * vthermal[1]*vthermal[2];
} }
MPI_Allreduce(t,vector,6,MPI_DOUBLE,MPI_SUM,world); MPI_Allreduce(t,vector,6,MPI_DOUBLE,MPI_SUM,world);

View File

@ -29,10 +29,8 @@ ComputeTempRegion::ComputeTempRegion(LAMMPS *lmp, int narg, char **arg) :
{ {
if (narg != 4) error->all("Illegal compute temp/region command"); if (narg != 4) error->all("Illegal compute temp/region command");
for (iregion = 0; iregion < domain->nregion; iregion++) iregion = domain->find_region(arg[3]);
if (strcmp(arg[3],domain->regions[iregion]->id) == 0) break; if (iregion == -1) error->all("Temperature region ID does not exist");
if (iregion == domain->nregion)
error->all("Temperature region ID does not exist");
scalar_flag = vector_flag = 1; scalar_flag = vector_flag = 1;
size_vector = 6; size_vector = 6;

View File

@ -17,7 +17,6 @@
#include "create_atoms.h" #include "create_atoms.h"
#include "atom.h" #include "atom.h"
#include "atom_vec.h" #include "atom_vec.h"
#include "atom_vec_hybrid.h"
#include "comm.h" #include "comm.h"
#include "domain.h" #include "domain.h"
#include "lattice.h" #include "lattice.h"
@ -30,6 +29,8 @@ using namespace LAMMPS_NS;
#define BIG 1.0e30 #define BIG 1.0e30
#define EPSILON 1.0e-6 #define EPSILON 1.0e-6
enum{BOX,REGION,SINGLE};
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
CreateAtoms::CreateAtoms(LAMMPS *lmp) : Pointers(lmp) {} CreateAtoms::CreateAtoms(LAMMPS *lmp) : Pointers(lmp) {}
@ -40,36 +41,48 @@ void CreateAtoms::command(int narg, char **arg)
{ {
if (domain->box_exist == 0) if (domain->box_exist == 0)
error->all("Create_atoms command before simulation box is defined"); error->all("Create_atoms command before simulation box is defined");
if (domain->lattice == NULL)
error->all("Cannot create atoms with undefined lattice");
// parse arguments // parse arguments
int nbasis = domain->lattice->nbasis; if (narg < 2) error->all("Illegal create_atoms command");
int *basistype = new int[nbasis]; itype = atoi(arg[0]);
if (narg < 1) error->all("Illegal create_atoms command");
int itype = atoi(arg[0]);
if (itype <= 0 || itype > atom->ntypes) if (itype <= 0 || itype > atom->ntypes)
error->all("Invalid atom type in create_atoms command"); error->all("Invalid atom type in create_atoms command");
for (int i = 0; i < nbasis; i++) basistype[i] = itype;
int regionflag = -1; int iarg;
int nhybrid = 0; if (strcmp(arg[1],"box") == 0) {
style = BOX;
iarg = 2;
} else if (strcmp(arg[1],"region") == 0) {
style = REGION;
if (narg < 3) error->all("Illegal create_atoms command");
int iregion = domain->find_region(arg[2]);
if (iregion == -1) error->all("Create_atoms region ID does not exist");
iarg = 3;;
} else if (strcmp(arg[1],"single") == 0) {
style = SINGLE;
if (narg < 5) error->all("Illegal create_atoms command");
xone[0] = atof(arg[2]);
xone[1] = atof(arg[3]);
xone[2] = atof(arg[4]);
iarg = 5;
} else error->all("Illegal create_atoms command");
// process optional keywords
int scaleflag = 1;
if (domain->lattice) {
nbasis = domain->lattice->nbasis;
basistype = new int[nbasis];
for (int i = 0; i < nbasis; i++) basistype[i] = itype;
}
int iarg = 1;
while (iarg < narg) { while (iarg < narg) {
if (strcmp(arg[iarg],"region") == 0) { if (strcmp(arg[iarg],"basis") == 0) {
if (iarg+2 > narg) error->all("Illegal create_atoms command");
int iregion;
for (iregion = 0; iregion < domain->nregion; iregion++)
if (strcmp(arg[iarg+1],domain->regions[iregion]->id) == 0) break;
if (iregion == domain->nregion)
error->all("Create_atoms region ID does not exist");
regionflag = iregion;
iarg += 2;
} else if (strcmp(arg[iarg],"basis") == 0) {
if (iarg+3 > narg) error->all("Illegal create_atoms command"); if (iarg+3 > narg) error->all("Illegal create_atoms command");
if (domain->lattice == NULL)
error->all("Cannot create atoms with undefined lattice");
int ibasis = atoi(arg[iarg+1]); int ibasis = atoi(arg[iarg+1]);
itype = atoi(arg[iarg+2]); itype = atoi(arg[iarg+2]);
if (ibasis <= 0 || ibasis > nbasis || if (ibasis <= 0 || ibasis > nbasis ||
@ -77,19 +90,121 @@ void CreateAtoms::command(int narg, char **arg)
error->all("Illegal create_atoms command"); error->all("Illegal create_atoms command");
basistype[ibasis-1] = itype; basistype[ibasis-1] = itype;
iarg += 3; iarg += 3;
} else if (strcmp(arg[iarg],"hybrid") == 0) { } else if (strcmp(arg[iarg],"units") == 0) {
if (iarg+3 > narg) error->all("Illegal create_atoms command"); if (iarg+2 > narg) error->all("Illegal create_atoms command");
AtomVecHybrid *avec_hybrid = (AtomVecHybrid *) atom->avec; if (strcmp(arg[iarg+1],"box") == 0) scaleflag = 0;
int ihybrid; else if (strcmp(arg[iarg+1],"lattice") == 0) scaleflag = 1;
for (ihybrid = 0; ihybrid < avec_hybrid->nstyles; ihybrid++) else error->all("Illegal create_atoms command");
if (strcmp(avec_hybrid->keywords[ihybrid],arg[iarg+1]) == 0) break; iarg += 2;
if (ihybrid == avec_hybrid->nstyles)
error->all("Create atoms hybrid sub-style does not exist");
nhybrid = ihybrid;
iarg += 3;
} else error->all("Illegal create_atoms command"); } else error->all("Illegal create_atoms command");
} }
// demand lattice be defined
// else setup scaling for single atom
// could use domain->lattice->lattice2box() to do conversion of
// lattice to box, but not consistent with other uses of units=lattice
// triclinic remapping occurs in add_single()
if (style == BOX || style == REGION) {
if (domain->lattice == NULL)
error->all("Cannot create atoms with undefined lattice");
} else if (scaleflag == 1) {
if (domain->lattice == NULL)
error->all("Cannot create atoms with undefined lattice");
xone[0] *= domain->lattice->xlattice;
xone[1] *= domain->lattice->ylattice;
xone[2] *= domain->lattice->zlattice;
}
// add atoms
double natoms_previous = atom->natoms;
int nlocal_previous = atom->nlocal;
if (style == SINGLE) add_single();
else add_many();
// clean up
if (domain->lattice) delete [] basistype;
// new total # of atoms
double rlocal = atom->nlocal;
MPI_Allreduce(&rlocal,&atom->natoms,1,MPI_DOUBLE,MPI_SUM,world);
// print status
if (comm->me == 0) {
if (screen)
fprintf(screen,"Created %.15g atoms\n",atom->natoms-natoms_previous);
if (logfile)
fprintf(logfile,"Created %.15g atoms\n",atom->natoms-natoms_previous);
}
// reset simulation now that more atoms are defined
// add tags for newly created atoms if possible
// if global map exists, reset it
// if a molecular system, set nspecial to 0 for new atoms
if (atom->natoms > MAXATOMS) atom->tag_enable = 0;
if (atom->natoms <= MAXATOMS) atom->tag_extend();
if (atom->map_style) {
atom->map_init();
atom->map_set();
}
if (atom->molecular) {
int **nspecial = atom->nspecial;
for (int i = nlocal_previous; i < atom->nlocal; i++) {
nspecial[i][0] = 0;
nspecial[i][1] = 0;
nspecial[i][2] = 0;
}
}
}
/* ----------------------------------------------------------------------
add single atom with coords at xone if it's in my sub-box
if triclinic, xone is in lamda coords
------------------------------------------------------------------------- */
void CreateAtoms::add_single()
{
double sublo[3],subhi[3];
if (domain->triclinic == 0) {
sublo[0] = domain->sublo[0]; subhi[0] = domain->subhi[0];
sublo[1] = domain->sublo[1]; subhi[1] = domain->subhi[1];
sublo[2] = domain->sublo[2]; subhi[2] = domain->subhi[2];
} else {
sublo[0] = domain->sublo_lamda[0]; subhi[0] = domain->subhi_lamda[0];
sublo[1] = domain->sublo_lamda[1]; subhi[1] = domain->subhi_lamda[1];
sublo[2] = domain->sublo_lamda[2]; subhi[2] = domain->subhi_lamda[2];
}
// if triclinic, convert to lamda coords (0-1)
double lamda[3],*coord;
if (domain->triclinic) {
domain->x2lamda(xone,lamda);
coord = lamda;
} else coord = xone;
// if atom is in my subbox, create it
if (coord[0] >= sublo[0] && coord[0] < subhi[0] &&
coord[1] >= sublo[1] && coord[1] < subhi[1] &&
coord[2] >= sublo[2] && coord[2] < subhi[2])
atom->avec->create_atom(itype,xone);
}
/* ----------------------------------------------------------------------
add many atoms by looping over lattice
------------------------------------------------------------------------- */
void CreateAtoms::add_many()
{
// convert 8 corners of my subdomain from box coords to lattice coords // convert 8 corners of my subdomain from box coords to lattice coords
// for orthogonal, use corner pts of my subbox // for orthogonal, use corner pts of my subbox
// for triclinic, use bounding box of my subbox // for triclinic, use bounding box of my subbox
@ -176,12 +291,9 @@ void CreateAtoms::command(int narg, char **arg)
// iterate on 3d periodic lattice using loop bounds // iterate on 3d periodic lattice using loop bounds
// invoke add_atom for nbasis atoms in each unit cell // invoke add_atom for nbasis atoms in each unit cell
// converts lattice coords to box coords // convert lattice coords to box coords
// add atom if it meets all criteria // add atom if it meets all criteria
double natoms_previous = atom->natoms;
int nlocal_previous = atom->nlocal;
double **basis = domain->lattice->basis; double **basis = domain->lattice->basis;
double x[3],lamda[3]; double x[3],lamda[3];
double *coord; double *coord;
@ -202,8 +314,8 @@ void CreateAtoms::command(int narg, char **arg)
// if a region was specified, test if atom is in it // if a region was specified, test if atom is in it
if (regionflag >= 0) if (style == REGION)
if (!domain->regions[regionflag]->match(x[0],x[1],x[2])) continue; if (!domain->regions[iregion]->match(x[0],x[1],x[2])) continue;
// test if atom is in my subbox // test if atom is in my subbox
@ -218,45 +330,6 @@ void CreateAtoms::command(int narg, char **arg)
// add the atom to my list of atoms // add the atom to my list of atoms
atom->avec->create_atom(basistype[m],x,nhybrid); atom->avec->create_atom(basistype[m],x);
} }
// clean up
delete [] basistype;
// new total # of atoms
double rlocal = atom->nlocal;
MPI_Allreduce(&rlocal,&atom->natoms,1,MPI_DOUBLE,MPI_SUM,world);
// print status
if (comm->me == 0) {
if (screen)
fprintf(screen,"Created %.15g atoms\n",atom->natoms-natoms_previous);
if (logfile)
fprintf(logfile,"Created %.15g atoms\n",atom->natoms-natoms_previous);
}
// reset simulation now that more atoms are defined
// add tags for newly created atoms if possible
// if global map exists, reset it
// if a molecular system, set nspecial to 0 for new atoms
if (atom->natoms > MAXATOMS) atom->tag_enable = 0;
if (atom->natoms <= MAXATOMS) atom->tag_extend();
if (atom->map_style) {
atom->map_init();
atom->map_set();
}
if (atom->molecular) {
int **nspecial = atom->nspecial;
for (i = nlocal_previous; i < atom->nlocal; i++) {
nspecial[i][0] = 0;
nspecial[i][1] = 0;
nspecial[i][2] = 0;
}
}
} }

View File

@ -22,6 +22,14 @@ class CreateAtoms : protected Pointers {
public: public:
CreateAtoms(class LAMMPS *); CreateAtoms(class LAMMPS *);
void command(int, char **); void command(int, char **);
private:
int itype,style,iregion,nbasis;
int *basistype;
double xone[3];
void add_single();
void add_many();
}; };
} }

View File

@ -42,14 +42,10 @@ void CreateBox::command(int narg, char **arg)
domain->box_exist = 1; domain->box_exist = 1;
// find region ID // region check
int iregion;
for (iregion = 0; iregion < domain->nregion; iregion++)
if (strcmp(arg[1],domain->regions[iregion]->id) == 0) break;
if (iregion == domain->nregion)
error->all("Create_box region ID does not exist");
int iregion = domain->find_region(arg[1]);
if (iregion == -1) error->all("Create_box region ID does not exist");
if (domain->regions[iregion]->interior == 0) if (domain->regions[iregion]->interior == 0)
error->all("Create_box region must be of type inside"); error->all("Create_box region must be of type inside");

View File

@ -143,11 +143,8 @@ void DeleteAtoms::delete_region(int narg, char **arg, int *list)
{ {
if (narg != 2) error->all("Illegal delete_atoms command"); if (narg != 2) error->all("Illegal delete_atoms command");
int iregion; int iregion = domain->find_region(arg[1]);
for (iregion = 0; iregion < domain->nregion; iregion++) if (iregion == -1) error->all("Could not find delete_atoms region ID");
if (strcmp(arg[1],domain->regions[iregion]->id) == 0) break;
if (iregion == domain->nregion)
error->all("Could not find delete_atoms region ID");
double **x = atom->x; double **x = atom->x;
int nlocal = atom->nlocal; int nlocal = atom->nlocal;

View File

@ -20,12 +20,12 @@
#include "lattice.h" #include "lattice.h"
#include "comm.h" #include "comm.h"
#include "group.h" #include "group.h"
#include "random_park.h"
#include "error.h" #include "error.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
#define MOVE 1 enum{MOVE,RAMP,RANDOM};
#define RAMP 2
#define MIN(a,b) ((a) < (b) ? (a) : (b)) #define MIN(a,b) ((a) < (b) ? (a) : (b))
#define MAX(a,b) ((a) > (b) ? (a) : (b)) #define MAX(a,b) ((a) > (b) ? (a) : (b))
@ -62,6 +62,7 @@ void DisplaceAtoms::command(int narg, char **arg)
int style; int style;
if (strcmp(arg[1],"move") == 0) style = MOVE; if (strcmp(arg[1],"move") == 0) style = MOVE;
else if (strcmp(arg[1],"ramp") == 0) style = RAMP; else if (strcmp(arg[1],"ramp") == 0) style = RAMP;
else if (strcmp(arg[1],"random") == 0) style = RANDOM;
else error->all("Illegal displace_atoms command"); else error->all("Illegal displace_atoms command");
// set option defaults // set option defaults
@ -72,6 +73,7 @@ void DisplaceAtoms::command(int narg, char **arg)
if (style == MOVE) options(narg-5,&arg[5]); if (style == MOVE) options(narg-5,&arg[5]);
else if (style == RAMP) options(narg-8,&arg[8]); else if (style == RAMP) options(narg-8,&arg[8]);
else if (style == RANDOM) options(narg-6,&arg[6]);
// setup scaling // setup scaling
@ -86,14 +88,13 @@ void DisplaceAtoms::command(int narg, char **arg)
} }
else xscale = yscale = zscale = 1.0; else xscale = yscale = zscale = 1.0;
// move atoms by specified 3-vector distance // move atoms by 3-vector
if (style == MOVE) { if (style == MOVE) {
double delx,dely,delz; double delx = xscale*atof(arg[2]);
delx = xscale*atof(arg[2]); double dely = yscale*atof(arg[3]);
dely = yscale*atof(arg[3]); double delz = zscale*atof(arg[4]);
delz = zscale*atof(arg[4]);
double **x = atom->x; double **x = atom->x;
int *mask = atom->mask; int *mask = atom->mask;
@ -165,6 +166,33 @@ void DisplaceAtoms::command(int narg, char **arg)
} }
} }
// move atoms randomly
if (style == RANDOM) {
RanPark *random = new RanPark(lmp,1);
double dx = xscale*atof(arg[2]);
double dy = yscale*atof(arg[3]);
double dz = zscale*atof(arg[4]);
int seed = atoi(arg[5]);
double **x = atom->x;
int *mask = atom->mask;
int nlocal = atom->nlocal;
int j;
for (i = 0; i < nlocal; i++) {
if (mask[i] & groupbit) {
random->reset(seed,x[i]);
x[i][0] += dx * 2.0*(random->uniform()-0.5);
x[i][1] += dy * 2.0*(random->uniform()-0.5);
x[i][2] += dz * 2.0*(random->uniform()-0.5);
}
}
delete random;
}
// move atoms back inside simulation box and to new processors // move atoms back inside simulation box and to new processors
// use remap() instead of pbc() in case atoms moved a long distance // use remap() instead of pbc() in case atoms moved a long distance
// use irregular() instead of exchange() in case atoms moved a long distance // use irregular() instead of exchange() in case atoms moved a long distance

View File

@ -26,6 +26,7 @@
#include "update.h" #include "update.h"
#include "modify.h" #include "modify.h"
#include "fix.h" #include "fix.h"
#include "fix_deform.h"
#include "region.h" #include "region.h"
#include "lattice.h" #include "lattice.h"
#include "comm.h" #include "comm.h"
@ -44,6 +45,8 @@ using namespace LAMMPS_NS;
#define MIN(a,b) ((a) < (b) ? (a) : (b)) #define MIN(a,b) ((a) < (b) ? (a) : (b))
#define MAX(a,b) ((a) > (b) ? (a) : (b)) #define MAX(a,b) ((a) > (b) ? (a) : (b))
enum{NO_REMAP,X_REMAP,V_REMAP}; // same as fix_deform.cpp
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
default is periodic default is periodic
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
@ -67,6 +70,12 @@ Domain::Domain(LAMMPS *lmp) : Pointers(lmp)
boxhi[0] = boxhi[1] = boxhi[2] = 0.5; boxhi[0] = boxhi[1] = boxhi[2] = 0.5;
xy = xz = yz = 0.0; xy = xz = yz = 0.0;
h[3] = h[4] = h[5] = 0.0;
h_inv[3] = h_inv[4] = h_inv[5] = 0.0;
h_rate[0] = h_rate[1] = h_rate[2] =
h_rate[3] = h_rate[4] = h_rate[5] = 0.0;
h_ratelo[0] = h_ratelo[1] = h_ratelo[2] = 0.0;
prd_lamda[0] = prd_lamda[1] = prd_lamda[2] = 1.0; prd_lamda[0] = prd_lamda[1] = prd_lamda[2] = 1.0;
boxlo_lamda[0] = boxlo_lamda[1] = boxlo_lamda[2] = 0.0; boxlo_lamda[0] = boxlo_lamda[1] = boxlo_lamda[2] = 0.0;
boxhi_lamda[0] = boxhi_lamda[1] = boxhi_lamda[2] = 1.0; boxhi_lamda[0] = boxhi_lamda[1] = boxhi_lamda[2] = 1.0;
@ -96,6 +105,18 @@ void Domain::init()
if (nonperiodic == 2) box_change = 1; if (nonperiodic == 2) box_change = 1;
for (int i = 0; i < modify->nfix; i++) for (int i = 0; i < modify->nfix; i++)
if (modify->fix[i]->box_change) box_change = 1; if (modify->fix[i]->box_change) box_change = 1;
// check for fix deform
deform_flag = deform_remap = 0;
for (int i = 0; i < modify->nfix; i++)
if (strcmp(modify->fix[i]->style,"deform") == 0) {
deform_flag = 1;
if (((FixDeform *) modify->fix[i])->remapflag == V_REMAP) {
deform_remap = 1;
deform_groupbit = modify->fix[i]->groupbit;
} else deform_remap = 0;
}
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
@ -120,11 +141,11 @@ void Domain::set_initial_box()
if (yz != 0.0 && (!yperiodic || !zperiodic)) if (yz != 0.0 && (!yperiodic || !zperiodic))
error->all("Triclinic box must be periodic in skewed dimensions"); error->all("Triclinic box must be periodic in skewed dimensions");
if (fabs(xy/(boxhi[1]-boxlo[1])) > 0.5) if (fabs(xy/(boxhi[0]-boxlo[0])) > 0.5)
error->all("Triclinic box skew is too large"); error->all("Triclinic box skew is too large");
if (fabs(xz/(boxhi[2]-boxlo[2])) > 0.5) if (fabs(xz/(boxhi[0]-boxlo[0])) > 0.5)
error->all("Triclinic box skew is too large"); error->all("Triclinic box skew is too large");
if (fabs(yz/(boxhi[2]-boxlo[2])) > 0.5) if (fabs(yz/(boxhi[1]-boxlo[1])) > 0.5)
error->all("Triclinic box skew is too large"); error->all("Triclinic box skew is too large");
} }
@ -157,21 +178,21 @@ void Domain::set_global_box()
prd[1] = yprd = boxhi[1] - boxlo[1]; prd[1] = yprd = boxhi[1] - boxlo[1];
prd[2] = zprd = boxhi[2] - boxlo[2]; prd[2] = zprd = boxhi[2] - boxlo[2];
h[0] = xprd;
h[1] = yprd;
h[2] = zprd;
h_inv[0] = 1.0/h[0];
h_inv[1] = 1.0/h[1];
h_inv[2] = 1.0/h[2];
xprd_half = 0.5*xprd; xprd_half = 0.5*xprd;
yprd_half = 0.5*yprd; yprd_half = 0.5*yprd;
zprd_half = 0.5*zprd; zprd_half = 0.5*zprd;
if (triclinic) { if (triclinic) {
h[0] = xprd;
h[1] = yprd;
h[2] = zprd;
h[3] = yz; h[3] = yz;
h[4] = xz; h[4] = xz;
h[5] = xy; h[5] = xy;
h_inv[0] = 1.0/h[0];
h_inv[1] = 1.0/h[1];
h_inv[2] = 1.0/h[2];
h_inv[3] = -h[3] / (h[1]*h[2]); h_inv[3] = -h[3] / (h[1]*h[2]);
h_inv[4] = (h[3]*h[5] - h[1]*h[4]) / (h[0]*h[1]*h[2]); h_inv[4] = (h[3]*h[5] - h[1]*h[4]) / (h[0]*h[1]*h[2]);
h_inv[5] = -h[5] / (h[0]*h[1]); h_inv[5] = -h[5] / (h[0]*h[1]);
@ -318,6 +339,7 @@ void Domain::reset_box()
called every reneighboring and by other commands that change atoms called every reneighboring and by other commands that change atoms
resulting coord must satisfy lo <= coord < hi resulting coord must satisfy lo <= coord < hi
MAX is important since coord - prd < lo can happen when coord = hi MAX is important since coord - prd < lo can happen when coord = hi
if fix deform, remap velocity of fix group atoms by box edge velocities
for triclinic, atoms must be in lamda coords (0-1) before pbc is called for triclinic, atoms must be in lamda coords (0-1) before pbc is called
image = 10 bits for each dimension image = 10 bits for each dimension
increment/decrement in wrap-around fashion increment/decrement in wrap-around fashion
@ -329,6 +351,8 @@ void Domain::pbc()
double *lo,*hi,*period; double *lo,*hi,*period;
int nlocal = atom->nlocal; int nlocal = atom->nlocal;
double **x = atom->x; double **x = atom->x;
double **v = atom->v;
int *mask = atom->mask;
int *image = atom->image; int *image = atom->image;
if (triclinic == 0) { if (triclinic == 0) {
@ -345,6 +369,7 @@ void Domain::pbc()
if (xperiodic) { if (xperiodic) {
if (x[i][0] < lo[0]) { if (x[i][0] < lo[0]) {
x[i][0] += period[0]; x[i][0] += period[0];
if (deform_remap && mask[i] & deform_groupbit) v[i][0] += h_rate[0];
idim = image[i] & 1023; idim = image[i] & 1023;
otherdims = image[i] ^ idim; otherdims = image[i] ^ idim;
idim--; idim--;
@ -354,6 +379,7 @@ void Domain::pbc()
if (x[i][0] >= hi[0]) { if (x[i][0] >= hi[0]) {
x[i][0] -= period[0]; x[i][0] -= period[0];
x[i][0] = MAX(x[i][0],lo[0]); x[i][0] = MAX(x[i][0],lo[0]);
if (deform_remap && mask[i] & deform_groupbit) v[i][0] -= h_rate[0];
idim = image[i] & 1023; idim = image[i] & 1023;
otherdims = image[i] ^ idim; otherdims = image[i] ^ idim;
idim++; idim++;
@ -365,6 +391,10 @@ void Domain::pbc()
if (yperiodic) { if (yperiodic) {
if (x[i][1] < lo[1]) { if (x[i][1] < lo[1]) {
x[i][1] += period[1]; x[i][1] += period[1];
if (deform_remap && mask[i] & deform_groupbit) {
v[i][0] += h_rate[5];
v[i][1] += h_rate[1];
}
idim = (image[i] >> 10) & 1023; idim = (image[i] >> 10) & 1023;
otherdims = image[i] ^ (idim << 10); otherdims = image[i] ^ (idim << 10);
idim--; idim--;
@ -374,6 +404,10 @@ void Domain::pbc()
if (x[i][1] >= hi[1]) { if (x[i][1] >= hi[1]) {
x[i][1] -= period[1]; x[i][1] -= period[1];
x[i][1] = MAX(x[i][1],lo[1]); x[i][1] = MAX(x[i][1],lo[1]);
if (deform_remap && mask[i] & deform_groupbit) {
v[i][0] -= h_rate[5];
v[i][1] -= h_rate[1];
}
idim = (image[i] >> 10) & 1023; idim = (image[i] >> 10) & 1023;
otherdims = image[i] ^ (idim << 10); otherdims = image[i] ^ (idim << 10);
idim++; idim++;
@ -385,6 +419,11 @@ void Domain::pbc()
if (zperiodic) { if (zperiodic) {
if (x[i][2] < lo[2]) { if (x[i][2] < lo[2]) {
x[i][2] += period[2]; x[i][2] += period[2];
if (deform_remap && mask[i] & deform_groupbit) {
v[i][0] += h_rate[4];
v[i][1] += h_rate[3];
v[i][2] += h_rate[2];
}
idim = image[i] >> 20; idim = image[i] >> 20;
otherdims = image[i] ^ (idim << 20); otherdims = image[i] ^ (idim << 20);
idim--; idim--;
@ -394,6 +433,11 @@ void Domain::pbc()
if (x[i][2] >= hi[2]) { if (x[i][2] >= hi[2]) {
x[i][2] -= period[2]; x[i][2] -= period[2];
x[i][2] = MAX(x[i][2],lo[2]); x[i][2] = MAX(x[i][2],lo[2]);
if (deform_remap && mask[i] & deform_groupbit) {
v[i][0] -= h_rate[4];
v[i][1] -= h_rate[3];
v[i][2] -= h_rate[2];
}
idim = image[i] >> 20; idim = image[i] >> 20;
otherdims = image[i] ^ (idim << 20); otherdims = image[i] ^ (idim << 20);
idim++; idim++;
@ -533,7 +577,7 @@ void Domain::minimum_image(double *delta)
adjust image accordingly adjust image accordingly
resulting coord must satisfy lo <= coord < hi resulting coord must satisfy lo <= coord < hi
MAX is important since coord - prd < lo can happen when coord = hi MAX is important since coord - prd < lo can happen when coord = hi
for triclinic, convert atom to lamda coords (0-1) before doing remap for triclinic, atom is converted to lamda coords (0-1) before doing remap
image = 10 bits for each dimension image = 10 bits for each dimension
increment/decrement in wrap-around fashion increment/decrement in wrap-around fashion
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */

View File

@ -67,8 +67,12 @@ class Domain : protected Pointers {
// triclinic box // triclinic box
double xy,xz,yz; // 3 tilt factors double xy,xz,yz; // 3 tilt factors
double h[6],h_inv[6]; // shape matrix in Voigt notation double h[6],h_inv[6]; // shape matrix in Voigt notation
double h_rate[6],h_ratelo[3]; // rate of box size/shape change
int box_change; // 1 if box bounds ever change, 0 if fixed int box_change; // 1 if box bounds ever change, 0 if fixed
int deform_flag; // 1 if fix deform exist, else 0
int deform_remap; // 1 if fix deform remaps v, else 0
int deform_groupbit; // atom group to perform v remap for
class Lattice *lattice; // user-defined lattice class Lattice *lattice; // user-defined lattice

View File

@ -31,7 +31,8 @@ using namespace LAMMPS_NS;
enum{TAG,MOL,TYPE,X,Y,Z,XS,YS,ZS,XU,YU,ZU,IX,IY,IZ, enum{TAG,MOL,TYPE,X,Y,Z,XS,YS,ZS,XU,YU,ZU,IX,IY,IZ,
VX,VY,VZ,FX,FY,FZ, VX,VY,VZ,FX,FY,FZ,
Q,MUX,MUY,MUZ,TQX,TQY,TQZ, Q,MUX,MUY,MUZ,
QUATW,QUATI,QUATJ,QUATK,TQX,TQY,TQZ,
EPAIR,KE,ETOTAL,CENTRO,SXX,SYY,SZZ,SXY,SXZ,SYZ, EPAIR,KE,ETOTAL,CENTRO,SXX,SYY,SZZ,SXY,SXZ,SYZ,
COMPUTE}; COMPUTE};
enum{LT,LE,GT,GE,EQ,NEQ}; enum{LT,LE,GT,GE,EQ,NEQ};
@ -405,6 +406,18 @@ int DumpCustom::count()
} else if (thresh_array[ithresh] == MUZ) { } else if (thresh_array[ithresh] == MUZ) {
ptr = &atom->mu[0][2]; ptr = &atom->mu[0][2];
nstride = 3; nstride = 3;
} else if (thresh_array[ithresh] == QUATW) {
ptr = &atom->quat[0][0];
nstride = 4;
} else if (thresh_array[ithresh] == QUATI) {
ptr = &atom->quat[0][1];
nstride = 4;
} else if (thresh_array[ithresh] == QUATJ) {
ptr = &atom->quat[0][2];
nstride = 4;
} else if (thresh_array[ithresh] == QUATK) {
ptr = &atom->quat[0][3];
nstride = 4;
} else if (thresh_array[ithresh] == TQX) { } else if (thresh_array[ithresh] == TQX) {
ptr = &atom->torque[0][0]; ptr = &atom->torque[0][0];
nstride = 3; nstride = 3;
@ -455,27 +468,29 @@ int DumpCustom::count()
} }
} }
// unselect atoms that don't meet threshhold criterion
value = thresh_value[ithresh]; value = thresh_value[ithresh];
if (thresh_op[ithresh] == GE) { if (thresh_op[ithresh] == LT) {
for (i = 0; i < nlocal; i++, ptr += nstride) for (i = 0; i < nlocal; i++, ptr += nstride)
if (choose[i] && *ptr >= value) { if (choose[i] && *ptr >= value) {
choose[i] = 0; choose[i] = 0;
nmine--; nmine--;
} }
} else if (thresh_op[ithresh] == GT) { } else if (thresh_op[ithresh] == LE) {
for (i = 0; i < nlocal; i++, ptr += nstride) for (i = 0; i < nlocal; i++, ptr += nstride)
if (choose[i] && *ptr > value) { if (choose[i] && *ptr > value) {
choose[i] = 0; choose[i] = 0;
nmine--; nmine--;
} }
} else if (thresh_op[ithresh] == LE) { } else if (thresh_op[ithresh] == GT) {
for (i = 0; i < nlocal; i++, ptr += nstride) for (i = 0; i < nlocal; i++, ptr += nstride)
if (choose[i] && *ptr <= value) { if (choose[i] && *ptr <= value) {
choose[i] = 0; choose[i] = 0;
nmine--; nmine--;
} }
} else if (thresh_op[ithresh] == LT) { } else if (thresh_op[ithresh] == GE) {
for (i = 0; i < nlocal; i++, ptr += nstride) for (i = 0; i < nlocal; i++, ptr += nstride)
if (choose[i] && *ptr < value) { if (choose[i] && *ptr < value) {
choose[i] = 0; choose[i] = 0;
@ -483,13 +498,13 @@ int DumpCustom::count()
} }
} else if (thresh_op[ithresh] == EQ) { } else if (thresh_op[ithresh] == EQ) {
for (i = 0; i < nlocal; i++, ptr += nstride) for (i = 0; i < nlocal; i++, ptr += nstride)
if (choose[i] && *ptr == value) { if (choose[i] && *ptr != value) {
choose[i] = 0; choose[i] = 0;
nmine--; nmine--;
} }
} else if (thresh_op[ithresh] == NEQ) { } else if (thresh_op[ithresh] == NEQ) {
for (i = 0; i < nlocal; i++, ptr += nstride) for (i = 0; i < nlocal; i++, ptr += nstride)
if (choose[i] && *ptr != value) { if (choose[i] && *ptr == value) {
choose[i] = 0; choose[i] = 0;
nmine--; nmine--;
} }
@ -645,6 +660,27 @@ void DumpCustom::parse_fields(int narg, char **arg)
error->all("Dumping an atom quantity that isn't allocated"); error->all("Dumping an atom quantity that isn't allocated");
pack_choice[i] = &DumpCustom::pack_muz; pack_choice[i] = &DumpCustom::pack_muz;
vtype[i] = DOUBLE; vtype[i] = DOUBLE;
} else if (strcmp(arg[iarg],"quatw") == 0) {
if (atom->quat == NULL)
error->all("Dumping an atom quantity that isn't allocated");
pack_choice[i] = &DumpCustom::pack_quatw;
vtype[i] = DOUBLE;
} else if (strcmp(arg[iarg],"quati") == 0) {
if (atom->quat == NULL)
error->all("Dumping an atom quantity that isn't allocated");
pack_choice[i] = &DumpCustom::pack_quati;
vtype[i] = DOUBLE;
} else if (strcmp(arg[iarg],"quatj") == 0) {
if (atom->quat == NULL)
error->all("Dumping an atom quantity that isn't allocated");
pack_choice[i] = &DumpCustom::pack_quatj;
vtype[i] = DOUBLE;
} else if (strcmp(arg[iarg],"quatk") == 0) {
if (atom->quat == NULL)
error->all("Dumping an atom quantity that isn't allocated");
pack_choice[i] = &DumpCustom::pack_quatk;
vtype[i] = DOUBLE;
} else if (strcmp(arg[iarg],"tqx") == 0) { } else if (strcmp(arg[iarg],"tqx") == 0) {
if (atom->torque == NULL) if (atom->torque == NULL)
error->all("Dumping an atom quantity that isn't allocated"); error->all("Dumping an atom quantity that isn't allocated");
@ -825,10 +861,8 @@ int DumpCustom::modify_param(int narg, char **arg)
if (narg < 2) error->all("Illegal dump_modify command"); if (narg < 2) error->all("Illegal dump_modify command");
if (strcmp(arg[1],"none") == 0) iregion = -1; if (strcmp(arg[1],"none") == 0) iregion = -1;
else { else {
for (iregion = 0; iregion < domain->nregion; iregion++) iregion = domain->find_region(arg[1]);
if (strcmp(arg[1],domain->regions[iregion]->id) == 0) break; if (iregion == -1) error->all("Dump_modify region ID does not exist");
if (iregion == domain->nregion)
error->all("Dump_modify region ID does not exist");
} }
return 2; return 2;
@ -896,6 +930,10 @@ int DumpCustom::modify_param(int narg, char **arg)
else if (strcmp(arg[1],"mux") == 0) thresh_array[nthresh] = MUX; else if (strcmp(arg[1],"mux") == 0) thresh_array[nthresh] = MUX;
else if (strcmp(arg[1],"muy") == 0) thresh_array[nthresh] = MUY; else if (strcmp(arg[1],"muy") == 0) thresh_array[nthresh] = MUY;
else if (strcmp(arg[1],"muz") == 0) thresh_array[nthresh] = MUZ; else if (strcmp(arg[1],"muz") == 0) thresh_array[nthresh] = MUZ;
else if (strcmp(arg[1],"quatw") == 0) thresh_array[nthresh] = QUATW;
else if (strcmp(arg[1],"quati") == 0) thresh_array[nthresh] = QUATI;
else if (strcmp(arg[1],"quatj") == 0) thresh_array[nthresh] = QUATJ;
else if (strcmp(arg[1],"quatk") == 0) thresh_array[nthresh] = QUATK;
else if (strcmp(arg[1],"tqx") == 0) thresh_array[nthresh] = TQX; else if (strcmp(arg[1],"tqx") == 0) thresh_array[nthresh] = TQX;
else if (strcmp(arg[1],"tqy") == 0) thresh_array[nthresh] = TQY; else if (strcmp(arg[1],"tqy") == 0) thresh_array[nthresh] = TQY;
else if (strcmp(arg[1],"tqz") == 0) thresh_array[nthresh] = TQZ; else if (strcmp(arg[1],"tqz") == 0) thresh_array[nthresh] = TQZ;
@ -1013,12 +1051,12 @@ int DumpCustom::modify_param(int narg, char **arg)
// set operation type of threshhold // set operation type of threshhold
if (strcmp(arg[2],">=") == 0) thresh_op[nthresh] = LT; if (strcmp(arg[2],"<") == 0) thresh_op[nthresh] = LT;
else if (strcmp(arg[2],">") == 0) thresh_op[nthresh] = LE; else if (strcmp(arg[2],"<=") == 0) thresh_op[nthresh] = LE;
else if (strcmp(arg[2],"<=") == 0) thresh_op[nthresh] = GT; else if (strcmp(arg[2],">") == 0) thresh_op[nthresh] = GT;
else if (strcmp(arg[2],"<") == 0) thresh_op[nthresh] = GE; else if (strcmp(arg[2],">=") == 0) thresh_op[nthresh] = GE;
else if (strcmp(arg[2],"=") == 0) thresh_op[nthresh] = NEQ; else if (strcmp(arg[2],"==") == 0) thresh_op[nthresh] = EQ;
else if (strcmp(arg[2],"<>") == 0) thresh_op[nthresh] = EQ; else if (strcmp(arg[2],"!=") == 0) thresh_op[nthresh] = NEQ;
else error->all("Invalid dump_modify threshhold operator"); else error->all("Invalid dump_modify threshhold operator");
// set threshhold value // set threshhold value
@ -1441,6 +1479,62 @@ void DumpCustom::pack_muz(int n)
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
void DumpCustom::pack_quatw(int n)
{
double **quat = atom->quat;
int nlocal = atom->nlocal;
for (int i = 0; i < nlocal; i++)
if (choose[i]) {
buf[n] = quat[i][0];
n += size_one;
}
}
/* ---------------------------------------------------------------------- */
void DumpCustom::pack_quati(int n)
{
double **quat = atom->quat;
int nlocal = atom->nlocal;
for (int i = 0; i < nlocal; i++)
if (choose[i]) {
buf[n] = quat[i][1];
n += size_one;
}
}
/* ---------------------------------------------------------------------- */
void DumpCustom::pack_quatj(int n)
{
double **quat = atom->quat;
int nlocal = atom->nlocal;
for (int i = 0; i < nlocal; i++)
if (choose[i]) {
buf[n] = quat[i][2];
n += size_one;
}
}
/* ---------------------------------------------------------------------- */
void DumpCustom::pack_quatk(int n)
{
double **quat = atom->quat;
int nlocal = atom->nlocal;
for (int i = 0; i < nlocal; i++)
if (choose[i]) {
buf[n] = quat[i][3];
n += size_one;
}
}
/* ---------------------------------------------------------------------- */
void DumpCustom::pack_tqx(int n) void DumpCustom::pack_tqx(int n)
{ {
double **torque = atom->torque; double **torque = atom->torque;

View File

@ -107,6 +107,10 @@ class DumpCustom : public Dump {
void pack_mux(int); void pack_mux(int);
void pack_muy(int); void pack_muy(int);
void pack_muz(int); void pack_muz(int);
void pack_quatw(int);
void pack_quati(int);
void pack_quatj(int);
void pack_quatk(int);
void pack_tqx(int); void pack_tqx(int);
void pack_tqy(int); void pack_tqy(int);
void pack_tqz(int); void pack_tqz(int);

View File

@ -39,6 +39,8 @@ Fix::Fix(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp)
box_change = 0; box_change = 0;
thermo_energy = 0; thermo_energy = 0;
pressure_every = 0; pressure_every = 0;
rigid_flag = 0;
virial_flag = 0;
comm_forward = comm_reverse = 0; comm_forward = comm_reverse = 0;
neigh_half_once = neigh_half_every = 0; neigh_half_once = neigh_half_every = 0;

View File

@ -31,6 +31,8 @@ class Fix : protected Pointers {
int thermo_energy; // 1 if ThEng enabled via fix_modify, 0 if not int thermo_energy; // 1 if ThEng enabled via fix_modify, 0 if not
int nevery; // how often to call an end_of_step fix int nevery; // how often to call an end_of_step fix
int pressure_every; // how often fix needs virial computed int pressure_every; // how often fix needs virial computed
int rigid_flag; // 1 if Fix integrates rigid bodies, 0 if not
int virial_flag; // 1 if Fix contributes to virial, 0 if not
int comm_forward; // size of forward communication (0 if none) int comm_forward; // size of forward communication (0 if none)
int comm_reverse; // size of reverse communication (0 if none) int comm_reverse; // size of reverse communication (0 if none)

View File

@ -280,7 +280,7 @@ void FixDeposit::pre_exchange()
newcoord[0] >= sublo[0] && newcoord[0] < subhi[0]) flag = 1; newcoord[0] >= sublo[0] && newcoord[0] < subhi[0]) flag = 1;
if (flag) { if (flag) {
atom->avec->create_atom(ntype,coord,0); atom->avec->create_atom(ntype,coord);
int m = atom->nlocal - 1; int m = atom->nlocal - 1;
atom->type[m] = ntype; atom->type[m] = ntype;
atom->mask[m] = 1 | groupbit; atom->mask[m] = 1 | groupbit;
@ -329,10 +329,8 @@ void FixDeposit::options(int narg, char **arg)
while (iarg < narg) { while (iarg < narg) {
if (strcmp(arg[iarg],"region") == 0) { if (strcmp(arg[iarg],"region") == 0) {
if (iarg+2 > narg) error->all("Illegal fix deposit command"); if (iarg+2 > narg) error->all("Illegal fix deposit command");
for (iregion = 0; iregion < domain->nregion; iregion++) iregion = domain->find_region(arg[iarg+1]);
if (strcmp(arg[iarg+1],domain->regions[iregion]->id) == 0) break; if (iregion == -1) error->all("Fix deposit region ID does not exist");
if (iregion == domain->nregion)
error->all("Fix deposit region ID does not exist");
iarg += 2; iarg += 2;
} else if (strcmp(arg[iarg],"global") == 0) { } else if (strcmp(arg[iarg],"global") == 0) {
if (iarg+3 > narg) error->all("Illegal fix deposit command"); if (iarg+3 > narg) error->all("Illegal fix deposit command");

View File

@ -31,24 +31,18 @@ FixGravity::FixGravity(LAMMPS *lmp, int narg, char **arg) :
if (strcmp(arg[3],"chute") == 0) { if (strcmp(arg[3],"chute") == 0) {
if (narg != 5) error->all("Illegal fix gravity command"); if (narg != 5) error->all("Illegal fix gravity command");
if (atom->check_style("granular") == 0)
error->all("Must use fix gravity chute with atom style granular");
dynamic = 0; dynamic = 0;
granular = 1; granular = 1;
phi = 0.0; phi = 0.0;
theta = 180.0 - atof(arg[4]); theta = 180.0 - atof(arg[4]);
} else if (strcmp(arg[3],"spherical") == 0) { } else if (strcmp(arg[3],"spherical") == 0) {
if (narg != 6) error->all("Illegal fix gravity command"); if (narg != 6) error->all("Illegal fix gravity command");
if (atom->check_style("granular") == 0)
error->all("Must use fix gravity spherical with atom style granular");
dynamic = 0; dynamic = 0;
granular = 1; granular = 1;
phi = atof(arg[4]); phi = atof(arg[4]);
theta = atof(arg[5]); theta = atof(arg[5]);
} else if (strcmp(arg[3],"gradient") == 0) { } else if (strcmp(arg[3],"gradient") == 0) {
if (narg != 8) error->all("Illegal fix gravity command"); if (narg != 8) error->all("Illegal fix gravity command");
if (atom->check_style("granular") == 0)
error->all("Must use fix gravity gradient with atom style granular");
dynamic = 1; dynamic = 1;
granular = 1; granular = 1;
phi = atof(arg[4]); phi = atof(arg[4]);
@ -57,8 +51,6 @@ FixGravity::FixGravity(LAMMPS *lmp, int narg, char **arg) :
thetagrad = atof(arg[7]); thetagrad = atof(arg[7]);
} else if (strcmp(arg[3],"vector") == 0) { } else if (strcmp(arg[3],"vector") == 0) {
if (narg != 8) error->all("Illegal fix gravity command"); if (narg != 8) error->all("Illegal fix gravity command");
if (atom->check_style("granular") != 0)
error->all("Cannot use fix gravity vector with atom style granular");
dynamic = 0; dynamic = 0;
granular = 0; granular = 0;
magnitude = atof(arg[4]); magnitude = atof(arg[4]);
@ -130,14 +122,7 @@ void FixGravity::post_force(int vflag)
int nlocal = atom->nlocal; int nlocal = atom->nlocal;
double massone; double massone;
if (granular) { if (mass) {
for (int i = 0; i < nlocal; i++)
if (mask[i] & groupbit) {
f[i][0] += rmass[i]*xgrav;
f[i][1] += rmass[i]*ygrav;
f[i][2] += rmass[i]*zgrav;
}
} else {
for (int i = 0; i < nlocal; i++) for (int i = 0; i < nlocal; i++)
if (mask[i] & groupbit) { if (mask[i] & groupbit) {
massone = mass[type[i]]; massone = mass[type[i]];
@ -145,5 +130,12 @@ void FixGravity::post_force(int vflag)
f[i][1] += massone*ygrav; f[i][1] += massone*ygrav;
f[i][2] += massone*zgrav; f[i][2] += massone*zgrav;
} }
} else {
for (int i = 0; i < nlocal; i++)
if (mask[i] & groupbit) {
f[i][0] += rmass[i]*xgrav;
f[i][1] += rmass[i]*ygrav;
f[i][2] += rmass[i]*zgrav;
}
} }
} }

View File

@ -77,10 +77,8 @@ FixLangevin::FixLangevin(LAMMPS *lmp, int narg, char **arg) :
ratio[itype] = scale; ratio[itype] = scale;
iarg += 3; iarg += 3;
} else if (strcmp(arg[iarg],"region") == 0) { } else if (strcmp(arg[iarg],"region") == 0) {
for (iregion = 0; iregion < domain->nregion; iregion++) iregion = domain->find_region(arg[iarg+1]);
if (strcmp(arg[iarg+1],domain->regions[iregion]->id) == 0) break; if (iregion == -1) error->all("Fix langevin region ID does not exist");
if (iregion == domain->nregion)
error->all("Fix langevin region ID does not exist");
iarg += 2; iarg += 2;
} else error->all("Illegal fix langevin command"); } else error->all("Illegal fix langevin command");
} }

View File

@ -129,7 +129,7 @@ void FixMSD::init()
int count = 0; int count = 0;
for (int i = 0; i < modify->nfix; i++) for (int i = 0; i < modify->nfix; i++)
if (strcmp(modify->fix[i]->style,"msd") == 0) count++; if (strcmp(modify->fix[i]->style,"msd") == 0) count++;
if (count > 1 && me == 0) error->warning("More than one msd fix"); if (count > 1 && me == 0) error->warning("More than one fix msd");
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */

View File

@ -263,10 +263,6 @@ void FixNPH::init()
} }
nkt = atom->natoms * boltz * t_initial; nkt = atom->natoms * boltz * t_initial;
double mass = 0.0;
for (int i = 0; i < atom->nlocal; i++) mass += atom->mass[atom->type[i]];
MPI_Allreduce(&mass,&total_mass,1,MPI_DOUBLE,MPI_SUM,world);
if (force->kspace) kspace_flag = 1; if (force->kspace) kspace_flag = 1;
else kspace_flag = 0; else kspace_flag = 0;
@ -275,7 +271,7 @@ void FixNPH::init()
step_respa = ((Respa *) update->integrate)->step; step_respa = ((Respa *) update->integrate)->step;
} }
// detect if any fix rigid exist so rigid bodies move when box is dilated // detect if any rigid fixes exist so rigid bodies move when box is dilated
// rfix[] = indices to each fix rigid // rfix[] = indices to each fix rigid
delete [] rfix; delete [] rfix;
@ -283,14 +279,12 @@ void FixNPH::init()
rfix = NULL; rfix = NULL;
for (int i = 0; i < modify->nfix; i++) for (int i = 0; i < modify->nfix; i++)
if (strcmp(modify->fix[i]->style,"rigid") == 0 || if (modify->fix[i]->rigid_flag) nrigid++;
strcmp(modify->fix[i]->style,"poems") == 0) nrigid++;
if (nrigid) { if (nrigid) {
rfix = new int[nrigid]; rfix = new int[nrigid];
nrigid = 0; nrigid = 0;
for (int i = 0; i < modify->nfix; i++) for (int i = 0; i < modify->nfix; i++)
if (strcmp(modify->fix[i]->style,"rigid") == 0 || if (modify->fix[i]->rigid_flag) rfix[nrigid++] = i;
strcmp(modify->fix[i]->style,"poems") == 0) rfix[nrigid++] = i;
} }
} }

View File

@ -37,7 +37,7 @@ class FixNPH : public Fix {
private: private:
double dtv,dtf,dthalf; double dtv,dtf,dthalf;
double boltz,nktv2p; double boltz,nktv2p;
double total_mass,vol0,nkt; double vol0,nkt;
int press_couple,dilate_partial; int press_couple,dilate_partial;
int p_flag[3]; // 1 if control P on this dim, 0 if not int p_flag[3]; // 1 if control P on this dim, 0 if not

View File

@ -162,7 +162,8 @@ FixNPT::FixNPT(LAMMPS *lmp, int narg, char **arg) :
char **newarg = new char*[3]; char **newarg = new char*[3];
newarg[0] = id_temp; newarg[0] = id_temp;
newarg[1] = "all"; newarg[1] = "all";
newarg[2] = "temp"; if (strcmp(style,"npt") == 0) newarg[2] = "temp";
else if (strcmp(style,"npt/asphere") == 0) newarg[2] = "temp/asphere";
modify->add_compute(3,newarg); modify->add_compute(3,newarg);
delete [] newarg; delete [] newarg;
tflag = 1; tflag = 1;
@ -251,6 +252,7 @@ void FixNPT::init()
// set timesteps and frequencies // set timesteps and frequencies
dtv = update->dt; dtv = update->dt;
dtq = 0.5 * update->dt;
dtf = 0.5 * update->dt * force->ftm2v; dtf = 0.5 * update->dt * force->ftm2v;
dthalf = 0.5 * update->dt; dthalf = 0.5 * update->dt;
@ -262,10 +264,6 @@ void FixNPT::init()
nktv2p = force->nktv2p; nktv2p = force->nktv2p;
vol0 = domain->xprd * domain->yprd * domain->zprd; vol0 = domain->xprd * domain->yprd * domain->zprd;
double mass = 0.0;
for (int i = 0; i < atom->nlocal; i++) mass += atom->mass[atom->type[i]];
MPI_Allreduce(&mass,&total_mass,1,MPI_DOUBLE,MPI_SUM,world);
if (force->kspace) kspace_flag = 1; if (force->kspace) kspace_flag = 1;
else kspace_flag = 0; else kspace_flag = 0;
@ -274,7 +272,7 @@ void FixNPT::init()
step_respa = ((Respa *) update->integrate)->step; step_respa = ((Respa *) update->integrate)->step;
} }
// detect if any fix rigid exist so rigid bodies move when box is dilated // detect if any rigid fixes exist so rigid bodies move when box is dilated
// rfix[] = indices to each fix rigid // rfix[] = indices to each fix rigid
delete [] rfix; delete [] rfix;
@ -282,14 +280,12 @@ void FixNPT::init()
rfix = NULL; rfix = NULL;
for (int i = 0; i < modify->nfix; i++) for (int i = 0; i < modify->nfix; i++)
if (strcmp(modify->fix[i]->style,"rigid") == 0 || if (modify->fix[i]->rigid_flag) nrigid++;
strcmp(modify->fix[i]->style,"poems") == 0) nrigid++;
if (nrigid) { if (nrigid) {
rfix = new int[nrigid]; rfix = new int[nrigid];
nrigid = 0; nrigid = 0;
for (int i = 0; i < modify->nfix; i++) for (int i = 0; i < modify->nfix; i++)
if (strcmp(modify->fix[i]->style,"rigid") == 0 || if (modify->fix[i]->rigid_flag) rfix[nrigid++] = i;
strcmp(modify->fix[i]->style,"poems") == 0) rfix[nrigid++] = i;
} }
} }

View File

@ -21,12 +21,12 @@ namespace LAMMPS_NS {
class FixNPT : public Fix { class FixNPT : public Fix {
public: public:
FixNPT(class LAMMPS *, int, char **); FixNPT(class LAMMPS *, int, char **);
~FixNPT(); virtual ~FixNPT();
int setmask(); int setmask();
void init(); virtual void init();
void setup(); void setup();
void initial_integrate(); virtual void initial_integrate();
void final_integrate(); virtual void final_integrate();
void initial_integrate_respa(int, int); void initial_integrate_respa(int, int);
void final_integrate_respa(int); void final_integrate_respa(int);
double thermo(int); double thermo(int);
@ -34,10 +34,10 @@ class FixNPT : public Fix {
void restart(char *); void restart(char *);
int modify_param(int, char **); int modify_param(int, char **);
private: protected:
double dtv,dtf,dthalf; double dtv,dtq,dtf,dthalf;
double boltz,nktv2p; double boltz,nktv2p;
double total_mass,vol0; double vol0;
double t_start,t_stop; double t_start,t_stop;
double t_current,t_target; double t_current,t_target;

View File

@ -69,7 +69,9 @@ FixNVT::FixNVT(LAMMPS *lmp, int narg, char **arg) :
char **newarg = new char*[3]; char **newarg = new char*[3];
newarg[0] = id_temp; newarg[0] = id_temp;
newarg[1] = group->names[igroup]; newarg[1] = group->names[igroup];
newarg[2] = "temp"; if (strcmp(style,"nvt") == 0) newarg[2] = "temp";
else if (strcmp(style,"nvt/asphere") == 0) newarg[2] = "temp/asphere";
else if (strcmp(style,"nvt/deform") == 0) newarg[2] = "temp/deform";
modify->add_compute(3,newarg); modify->add_compute(3,newarg);
delete [] newarg; delete [] newarg;
tflag = 1; tflag = 1;
@ -245,29 +247,16 @@ void FixNVT::initial_integrate_respa(int ilevel, int flag)
eta_dot *= drag_factor; eta_dot *= drag_factor;
eta += dtv*eta_dot; eta += dtv*eta_dot;
factor = exp(-dthalf*eta_dot); factor = exp(-dthalf*eta_dot);
} else factor = 1.0;
// update v of only atoms in NVT group // update v of only atoms in NVT group
for (int i = 0; i < nlocal; i++) { for (int i = 0; i < nlocal; i++) {
if (mask[i] & groupbit) { if (mask[i] & groupbit) {
dtfm = dtf / mass[type[i]]; dtfm = dtf / mass[type[i]];
v[i][0] = v[i][0]*factor + dtfm*f[i][0]; v[i][0] = v[i][0]*factor + dtfm*f[i][0];
v[i][1] = v[i][1]*factor + dtfm*f[i][1]; v[i][1] = v[i][1]*factor + dtfm*f[i][1];
v[i][2] = v[i][2]*factor + dtfm*f[i][2]; v[i][2] = v[i][2]*factor + dtfm*f[i][2];
}
}
} else {
// update v of only atoms in NVT group
for (int i = 0; i < nlocal; i++) {
if (mask[i] & groupbit) {
dtfm = dtf / mass[type[i]];
v[i][0] += dtfm*f[i][0];
v[i][1] += dtfm*f[i][1];
v[i][2] += dtfm*f[i][2];
}
} }
} }

View File

@ -21,13 +21,13 @@ namespace LAMMPS_NS {
class FixNVT : public Fix { class FixNVT : public Fix {
public: public:
FixNVT(class LAMMPS *, int, char **); FixNVT(class LAMMPS *, int, char **);
~FixNVT(); virtual ~FixNVT();
int setmask(); int setmask();
void init(); virtual void init();
void setup(); void setup();
void initial_integrate(); virtual void initial_integrate();
void final_integrate(); virtual void final_integrate();
void initial_integrate_respa(int,int); virtual void initial_integrate_respa(int,int);
void final_integrate_respa(int); void final_integrate_respa(int);
double thermo(int); double thermo(int);
void write_restart(FILE *); void write_restart(FILE *);
@ -35,7 +35,7 @@ class FixNVT : public Fix {
int modify_param(int, char **); int modify_param(int, char **);
void reset_target(double); void reset_target(double);
private: protected:
double t_start,t_stop; double t_start,t_stop;
double t_current,t_target; double t_current,t_target;
double t_freq,drag,drag_factor; double t_freq,drag,drag_factor;

View File

@ -43,6 +43,9 @@ FixRigid::FixRigid(LAMMPS *lmp, int narg, char **arg) :
{ {
int i,ibody; int i,ibody;
rigid_flag = 1;
virial_flag = 1;
// perform initial allocation of atom-based arrays // perform initial allocation of atom-based arrays
// register with Atom class // register with Atom class
@ -269,7 +272,7 @@ void FixRigid::init()
int count = 0; int count = 0;
for (int i = 0; i < modify->nfix; i++) for (int i = 0; i < modify->nfix; i++)
if (strcmp(modify->fix[i]->style,"rigid") == 0) count++; if (strcmp(modify->fix[i]->style,"rigid") == 0) count++;
if (count > 1 && comm->me == 0) error->warning("More than one rigid fix"); if (count > 1 && comm->me == 0) error->warning("More than one fix rigid");
// error if npt,nph fix comes before rigid fix // error if npt,nph fix comes before rigid fix

View File

@ -43,6 +43,7 @@ using namespace LAMMPS_NS;
FixShake::FixShake(LAMMPS *lmp, int narg, char **arg) : FixShake::FixShake(LAMMPS *lmp, int narg, char **arg) :
Fix(lmp, narg, arg) Fix(lmp, narg, arg)
{ {
virial_flag = 1;
MPI_Comm_rank(world,&me); MPI_Comm_rank(world,&me);
MPI_Comm_size(world,&nprocs); MPI_Comm_size(world,&nprocs);
@ -275,7 +276,7 @@ void FixShake::init()
int count = 0; int count = 0;
for (i = 0; i < modify->nfix; i++) for (i = 0; i < modify->nfix; i++)
if (strcmp(modify->fix[i]->style,"shake") == 0) count++; if (strcmp(modify->fix[i]->style,"shake") == 0) count++;
if (count > 1) error->all("More than one shake fix"); if (count > 1) error->all("More than one fix shake");
// cannot use with minimization since SHAKE turns off bonds // cannot use with minimization since SHAKE turns off bonds
// that should contribute to potential energy // that should contribute to potential energy

View File

@ -49,9 +49,8 @@ FixTempRescale::FixTempRescale(LAMMPS *lmp, int narg, char **arg) :
int iarg = 8; int iarg = 8;
while (iarg < narg) { while (iarg < narg) {
if (strcmp(arg[iarg],"region") == 0) { if (strcmp(arg[iarg],"region") == 0) {
for (iregion = 0; iregion < domain->nregion; iregion++) iregion = domain->find_region(arg[iarg+1]);
if (strcmp(arg[iarg+1],domain->regions[iregion]->id) == 0) break; if (iregion == -1)
if (iregion == domain->nregion)
error->all("Fix temp/rescale region ID does not exist"); error->all("Fix temp/rescale region ID does not exist");
iarg += 2; iarg += 2;
} else error->all("Illegal fix temp/rescale command"); } else error->all("Illegal fix temp/rescale command");

View File

@ -19,7 +19,6 @@
#include "group.h" #include "group.h"
#include "domain.h" #include "domain.h"
#include "atom.h" #include "atom.h"
#include "atom_vec_hybrid.h"
#include "force.h" #include "force.h"
#include "region.h" #include "region.h"
#include "memory.h" #include "memory.h"
@ -29,15 +28,8 @@ using namespace LAMMPS_NS;
#define MAX_GROUP 32 #define MAX_GROUP 32
#define TYPE 1 enum{TYPE,MOLECULE,ID};
#define MOLECULE 2 enum{LT,LE,GT,GE,EQ,NEQ,BETWEEN};
#define ID 3
#define LESS_THAN 1
#define GREATER_THAN 2
#define LESS_EQUAL 3
#define GREATER_EQUAL 4
#define BETWEEN 5
#define BIG 1.0e20 #define BIG 1.0e20
@ -111,45 +103,19 @@ void Group::assign(int narg, char **arg)
int bit = bitmask[igroup]; int bit = bitmask[igroup];
// style = region // style = region
// add to group if atom is in region
if (strcmp(arg[1],"region") == 0) { if (strcmp(arg[1],"region") == 0) {
if (narg != 3) error->all("Illegal group command"); if (narg != 3) error->all("Illegal group command");
int iregion; int iregion = domain->find_region(arg[2]);
for (iregion = 0; iregion < domain->nregion; iregion++) if (iregion == -1) error->all("Group region ID does not exist");
if (strcmp(arg[2],domain->regions[iregion]->id) == 0) break;
if (iregion == domain->nregion)
error->all("Group region ID does not exist");
// add to group if atom is in region
for (i = 0; i < nlocal; i++) for (i = 0; i < nlocal; i++)
if (domain->regions[iregion]->match(x[i][0],x[i][1],x[i][2])) if (domain->regions[iregion]->match(x[i][0],x[i][1],x[i][2]))
mask[i] |= bit; mask[i] |= bit;
// style = hybrid
} else if (strcmp(arg[1],"hybrid") == 0) {
if (narg != 3) error->all("Illegal group command");
if (strcmp(atom->atom_style,"hybrid") != 0)
error->all("Group hybrid command requires atom style hybrid");
AtomVecHybrid *avec_hybrid = (AtomVecHybrid *) atom->avec;
int ihybrid;
for (ihybrid = 0; ihybrid < avec_hybrid->nstyles; ihybrid++)
if (strcmp(avec_hybrid->keywords[ihybrid],arg[2]) == 0) break;
if (ihybrid == avec_hybrid->nstyles)
error->all("Group hybrid sub-style does not exist");
// add to group if atom matches hybrid sub-style
int *hybrid = atom->hybrid;
for (i = 0; i < nlocal; i++)
if (hybrid[i] == ihybrid) mask[i] |= bit;
// style = logical condition // style = logical condition
} else if (narg >= 3 && } else if (narg >= 3 &&
@ -165,10 +131,12 @@ void Group::assign(int narg, char **arg)
else if (strcmp(arg[1],"id") == 0) category = ID; else if (strcmp(arg[1],"id") == 0) category = ID;
else error->all("Illegal group command"); else error->all("Illegal group command");
if (strcmp(arg[2],"<") == 0) condition = LESS_THAN; if (strcmp(arg[2],"<") == 0) condition = LT;
else if (strcmp(arg[2],">") == 0) condition = GREATER_THAN; else if (strcmp(arg[2],"<=") == 0) condition = LE;
else if (strcmp(arg[2],"<=") == 0) condition = LESS_EQUAL; else if (strcmp(arg[2],">") == 0) condition = GT;
else if (strcmp(arg[2],">=") == 0) condition = GREATER_EQUAL; else if (strcmp(arg[2],">=") == 0) condition = GE;
else if (strcmp(arg[2],"==") == 0) condition = EQ;
else if (strcmp(arg[2],"!=") == 0) condition = NEQ;
else if (strcmp(arg[2],"<>") == 0) condition = BETWEEN; else if (strcmp(arg[2],"<>") == 0) condition = BETWEEN;
else error->all("Illegal group command"); else error->all("Illegal group command");
@ -187,14 +155,18 @@ void Group::assign(int narg, char **arg)
// add to group if meets condition // add to group if meets condition
if (condition == LESS_THAN) { if (condition == LT) {
for (i = 0; i < nlocal; i++) if (attribute[i] < bound1) mask[i] |= bit; for (i = 0; i < nlocal; i++) if (attribute[i] < bound1) mask[i] |= bit;
} else if (condition == GREATER_THAN) { } else if (condition == LE) {
for (i = 0; i < nlocal; i++) if (attribute[i] > bound1) mask[i] |= bit;
} else if (condition == LESS_EQUAL) {
for (i = 0; i < nlocal; i++) if (attribute[i] <= bound1) mask[i] |= bit; for (i = 0; i < nlocal; i++) if (attribute[i] <= bound1) mask[i] |= bit;
} else if (condition == GREATER_EQUAL) { } else if (condition == GT) {
for (i = 0; i < nlocal; i++) if (attribute[i] > bound1) mask[i] |= bit;
} else if (condition == GE) {
for (i = 0; i < nlocal; i++) if (attribute[i] >= bound1) mask[i] |= bit; for (i = 0; i < nlocal; i++) if (attribute[i] >= bound1) mask[i] |= bit;
} else if (condition == EQ) {
for (i = 0; i < nlocal; i++) if (attribute[i] == bound1) mask[i] |= bit;
} else if (condition == NEQ) {
for (i = 0; i < nlocal; i++) if (attribute[i] != bound1) mask[i] |= bit;
} else if (condition == BETWEEN) { } else if (condition == BETWEEN) {
for (i = 0; i < nlocal; i++) for (i = 0; i < nlocal; i++)
if (attribute[i] >= bound1 && attribute[i] <= bound2) mask[i] |= bit; if (attribute[i] >= bound1 && attribute[i] <= bound2) mask[i] |= bit;
@ -542,9 +514,9 @@ void Group::bounds(int igroup, double *minmax)
MPI_Allreduce(extent,minmax,6,MPI_DOUBLE,MPI_MAX,world); MPI_Allreduce(extent,minmax,6,MPI_DOUBLE,MPI_MAX,world);
extent[0] = -extent[0]; minmax[0] = -minmax[0];
extent[2] = -extent[2]; minmax[2] = -minmax[2];
extent[4] = -extent[4]; minmax[4] = -minmax[4];
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------

View File

@ -196,7 +196,7 @@ void Input::file()
process all input from filename process all input from filename
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void Input::file(char *filename) void Input::file(const char *filename)
{ {
// error if another nested file still open // error if another nested file still open
// if single open file is not stdin, close it // if single open file is not stdin, close it
@ -223,7 +223,7 @@ void Input::file(char *filename)
return command name to caller return command name to caller
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
char *Input::one(char *single) char *Input::one(const char *single)
{ {
strcpy(line,single); strcpy(line,single);
@ -417,7 +417,6 @@ int Input::execute_command()
else if (!strcmp(command,"dipole")) dipole(); else if (!strcmp(command,"dipole")) dipole();
else if (!strcmp(command,"dump")) dump(); else if (!strcmp(command,"dump")) dump();
else if (!strcmp(command,"dump_modify")) dump_modify(); else if (!strcmp(command,"dump_modify")) dump_modify();
// else if (!strcmp(command,"ellipsoid")) ellipsoid();
else if (!strcmp(command,"fix")) fix(); else if (!strcmp(command,"fix")) fix();
else if (!strcmp(command,"fix_modify")) fix_modify(); else if (!strcmp(command,"fix_modify")) fix_modify();
else if (!strcmp(command,"group")) group_command(); else if (!strcmp(command,"group")) group_command();
@ -441,6 +440,7 @@ int Input::execute_command()
else if (!strcmp(command,"reset_timestep")) reset_timestep(); else if (!strcmp(command,"reset_timestep")) reset_timestep();
else if (!strcmp(command,"restart")) restart(); else if (!strcmp(command,"restart")) restart();
else if (!strcmp(command,"run_style")) run_style(); else if (!strcmp(command,"run_style")) run_style();
else if (!strcmp(command,"shape")) shape();
else if (!strcmp(command,"special_bonds")) special_bonds(); else if (!strcmp(command,"special_bonds")) special_bonds();
else if (!strcmp(command,"thermo")) thermo(); else if (!strcmp(command,"thermo")) thermo();
else if (!strcmp(command,"thermo_modify")) thermo_modify(); else if (!strcmp(command,"thermo_modify")) thermo_modify();
@ -824,18 +824,6 @@ void Input::dump_modify()
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
/*
void Input::ellipsoid()
{
if (narg != 4) error->all("Illegal ellipsoid command");
if (domain->box_exist == 0)
error->all("Ellipsoid command before simulation box is defined");
atom->set_radii3(narg,arg);
}
*/
/* ---------------------------------------------------------------------- */
void Input::fix() void Input::fix()
{ {
modify->add_fix(narg,arg); modify->add_fix(narg,arg);
@ -1067,6 +1055,16 @@ void Input::run_style()
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
void Input::shape()
{
if (narg != 4) error->all("Illegal shape command");
if (domain->box_exist == 0)
error->all("Shape command before simulation box is defined");
atom->set_shape(narg,arg);
}
/* ---------------------------------------------------------------------- */
void Input::special_bonds() void Input::special_bonds()
{ {
// store 1-3,1-4 values before change // store 1-3,1-4 values before change

View File

@ -29,8 +29,8 @@ class Input : protected Pointers {
Input(class LAMMPS *, int, char **); Input(class LAMMPS *, int, char **);
~Input(); ~Input();
void file(); // process all input void file(); // process all input
void file(char *); // process an input script void file(const char *); // process an input script
char *one(char *); // process a single command char *one(const char *); // process a single command
void substitute(char *, int); // substitute for variables in a string void substitute(char *, int); // substitute for variables in a string
private: private:
@ -78,7 +78,6 @@ class Input : protected Pointers {
void dipole(); void dipole();
void dump(); void dump();
void dump_modify(); void dump_modify();
// void ellipsoid();
void fix(); void fix();
void fix_modify(); void fix_modify();
void group_command(); void group_command();
@ -102,6 +101,7 @@ class Input : protected Pointers {
void reset_timestep(); void reset_timestep();
void restart(); void restart();
void run_style(); void run_style();
void shape();
void special_bonds(); void special_bonds();
void thermo(); void thermo();
void thermo_modify(); void thermo_modify();

View File

@ -131,8 +131,7 @@ double **Memory::grow_2d_double_array(double **array,
if (array == NULL) return create_2d_double_array(n1,n2,name); if (array == NULL) return create_2d_double_array(n1,n2,name);
double *data = (double *) srealloc(array[0],n1*n2*sizeof(double),name); double *data = (double *) srealloc(array[0],n1*n2*sizeof(double),name);
sfree(array); array = (double **) srealloc(array,n1*sizeof(double *),name);
array = (double **) smalloc(n1*sizeof(double *),name);
int n = 0; int n = 0;
for (int i = 0; i < n1; i++) { for (int i = 0; i < n1; i++) {
@ -194,8 +193,7 @@ int **Memory::grow_2d_int_array(int **array, int n1, int n2, char *name)
if (array == NULL) return create_2d_int_array(n1,n2,name); if (array == NULL) return create_2d_int_array(n1,n2,name);
int *data = (int *) srealloc(array[0],n1*n2*sizeof(int),name); int *data = (int *) srealloc(array[0],n1*n2*sizeof(int),name);
sfree(array); array = (int **) srealloc(array,n1*sizeof(int *),name);
array = (int **) smalloc(n1*sizeof(int *),name);
int n = 0; int n = 0;
for (int i = 0; i < n1; i++) { for (int i = 0; i < n1; i++) {
@ -285,10 +283,8 @@ double ***Memory::grow_3d_double_array(double ***array,
if (array == NULL) return create_3d_double_array(n1,n2,n3,name); if (array == NULL) return create_3d_double_array(n1,n2,n3,name);
double *data = (double *) srealloc(array[0][0],n1*n2*n3*sizeof(double),name); double *data = (double *) srealloc(array[0][0],n1*n2*n3*sizeof(double),name);
sfree(array[0]); double **plane = (double **) srealloc(array[0],n1*n2*sizeof(double *),name);
double **plane = (double **) smalloc(n1*n2*sizeof(double *),name); array = (double ***) srealloc(array,n1*sizeof(double **),name);
sfree(array);
array = (double ***) smalloc(n1*sizeof(double **),name);
int n = 0; int n = 0;
for (i = 0; i < n1; i++) { for (i = 0; i < n1; i++) {

View File

@ -11,6 +11,10 @@
See the README file in the top-level LAMMPS directory. See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
/* ----------------------------------------------------------------------
Contributing author (triclinic and multi-neigh) : Pieter in 't Veld (SNL)
------------------------------------------------------------------------- */
#include "mpi.h" #include "mpi.h"
#include "math.h" #include "math.h"
#include "stdlib.h" #include "stdlib.h"
@ -508,7 +512,7 @@ void Neighbor::init()
// set ptrs to half/full/multi/triclinic build & stencil functions // set ptrs to half/full/multi/triclinic build & stencil functions
if (half) { if (half) {
if (atom->radius) { if (fix_history) {
if (style == NSQ) { if (style == NSQ) {
if (force->newton_pair == 0) if (force->newton_pair == 0)
half_build = &Neighbor::granular_nsq_no_newton; half_build = &Neighbor::granular_nsq_no_newton;

View File

@ -45,8 +45,23 @@ using namespace LAMMPS_NS;
Output::Output(LAMMPS *lmp) : Pointers(lmp) Output::Output(LAMMPS *lmp) : Pointers(lmp)
{ {
thermo = NULL; // create 2 default computes for temp and pressure
char **newarg = new char*[1];
char **newarg = new char*[4];
newarg[0] = "thermo_temp";
newarg[1] = "all";
newarg[2] = "temp";
modify->add_compute(3,newarg);
newarg[0] = "thermo_pressure";
newarg[1] = "all";
newarg[2] = "pressure";
newarg[3] = "thermo_temp";
modify->add_compute(4,newarg);
delete [] newarg;
// create default Thermo class
newarg = new char*[1];
newarg[0] = "one"; newarg[0] = "one";
thermo = new Thermo(lmp,1,newarg); thermo = new Thermo(lmp,1,newarg);
delete [] newarg; delete [] newarg;

Some files were not shown because too many files have changed in this diff Show More