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

This commit is contained in:
sjplimp
2007-06-22 16:59:17 +00:00
parent 988a4479e8
commit cea0208207
42 changed files with 245 additions and 194 deletions

View File

@ -48,14 +48,6 @@ AtomVecEllipsoid::AtomVecEllipsoid(LAMMPS *lmp, int narg, char **arg) :
atom->angmom_flag = atom->torque_flag = atom->quat_flag = 1; atom->angmom_flag = atom->torque_flag = atom->quat_flag = 1;
} }
/* ---------------------------------------------------------------------- */
void AtomVecEllipsoid::init()
{
if (force->dimension == 2)
error->all("Cannot use atom style ellipsoid for 2d simulation");
}
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
grow atom arrays grow atom arrays
n = 0 grows arrays by DELTA n = 0 grows arrays by DELTA

View File

@ -22,7 +22,6 @@ class AtomVecEllipsoid : public AtomVec {
public: public:
AtomVecEllipsoid(class LAMMPS *, int, char **); AtomVecEllipsoid(class LAMMPS *, int, char **);
virtual ~AtomVecEllipsoid() {} virtual ~AtomVecEllipsoid() {}
void init();
void grow(int); void grow(int);
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 *);

View File

@ -20,6 +20,7 @@
#include "math_extra.h" #include "math_extra.h"
#include "atom.h" #include "atom.h"
#include "force.h" #include "force.h"
#include "domain.h"
#include "modify.h" #include "modify.h"
#include "fix.h" #include "fix.h"
#include "group.h" #include "group.h"
@ -73,7 +74,7 @@ void ComputeTempAsphere::init()
void ComputeTempAsphere::recount() void ComputeTempAsphere::recount()
{ {
double natoms = group->count(igroup); double natoms = group->count(igroup);
dof = force->dimension * natoms; dof = domain->dimension * natoms;
dof -= extra_dof + fix_dof; dof -= extra_dof + fix_dof;
// add rotational degrees of freedom // add rotational degrees of freedom

View File

@ -15,6 +15,7 @@
#include "compute_temp_dipole.h" #include "compute_temp_dipole.h"
#include "atom.h" #include "atom.h"
#include "force.h" #include "force.h"
#include "domain.h"
#include "group.h" #include "group.h"
#include "modify.h" #include "modify.h"
#include "fix.h" #include "fix.h"
@ -76,7 +77,7 @@ void ComputeTempDipole::init()
void ComputeTempDipole::recount() void ComputeTempDipole::recount()
{ {
double natoms = group->count(igroup); double natoms = group->count(igroup);
dof = 2.0 * force->dimension * natoms; dof = 2.0 * domain->dimension * natoms;
dof -= extra_dof + fix_dof; dof -= extra_dof + fix_dof;
if (dof > 0) tfactor = force->mvv2e / (dof * force->boltz); if (dof > 0) tfactor = force->mvv2e / (dof * force->boltz);
else tfactor = 0.0; else tfactor = 0.0;

View File

@ -40,7 +40,7 @@ AtomVecGranular::AtomVecGranular(LAMMPS *lmp, int narg, char **arg) :
xcol_data = 5; xcol_data = 5;
atom->radius_flag = atom->density_flag = atom->rmass_flag = 1; atom->radius_flag = atom->density_flag = atom->rmass_flag = 1;
atom->xphi_flag = atom->omega_flag = atom->torque_flag = 1; atom->xorient_flag = atom->omega_flag = atom->torque_flag = 1;
PI = 4.0*atan(1.0); PI = 4.0*atan(1.0);
} }
@ -76,8 +76,8 @@ void AtomVecGranular::grow(int n)
rmass = atom->rmass = (double *) rmass = atom->rmass = (double *)
memory->srealloc(atom->rmass,nmax*sizeof(double),"atom:rmass"); memory->srealloc(atom->rmass,nmax*sizeof(double),"atom:rmass");
xphi = atom->xphi = xorient = atom->xorient =
memory->grow_2d_double_array(atom->xphi,nmax,3,"atom:xphi"); memory->grow_2d_double_array(atom->xorient,nmax,3,"atom:xorient");
omega = atom->omega = omega = atom->omega =
memory->grow_2d_double_array(atom->omega,nmax,3,"atom:omega"); memory->grow_2d_double_array(atom->omega,nmax,3,"atom:omega");
torque = atom->torque = torque = atom->torque =
@ -106,9 +106,9 @@ void AtomVecGranular::copy(int i, int j)
radius[j] = radius[i]; radius[j] = radius[i];
density[j] = density[i]; density[j] = density[i];
rmass[j] = rmass[i]; rmass[j] = rmass[i];
xphi[j][0] = xphi[i][0]; xorient[j][0] = xorient[i][0];
xphi[j][1] = xphi[i][1]; xorient[j][1] = xorient[i][1];
xphi[j][2] = xphi[i][2]; xorient[j][2] = xorient[i][2];
omega[j][0] = omega[i][0]; omega[j][0] = omega[i][0];
omega[j][1] = omega[i][1]; omega[j][1] = omega[i][1];
omega[j][2] = omega[i][2]; omega[j][2] = omega[i][2];
@ -407,9 +407,9 @@ int AtomVecGranular::pack_exchange(int i, double *buf)
buf[m++] = radius[i]; buf[m++] = radius[i];
buf[m++] = density[i]; buf[m++] = density[i];
buf[m++] = rmass[i]; buf[m++] = rmass[i];
buf[m++] = xphi[i][0]; buf[m++] = xorient[i][0];
buf[m++] = xphi[i][1]; buf[m++] = xorient[i][1];
buf[m++] = xphi[i][2]; buf[m++] = xorient[i][2];
buf[m++] = omega[i][0]; buf[m++] = omega[i][0];
buf[m++] = omega[i][1]; buf[m++] = omega[i][1];
buf[m++] = omega[i][2]; buf[m++] = omega[i][2];
@ -444,9 +444,9 @@ int AtomVecGranular::unpack_exchange(double *buf)
radius[nlocal] = buf[m++]; radius[nlocal] = buf[m++];
density[nlocal] = buf[m++]; density[nlocal] = buf[m++];
rmass[nlocal] = buf[m++]; rmass[nlocal] = buf[m++];
xphi[nlocal][0] = buf[m++]; xorient[nlocal][0] = buf[m++];
xphi[nlocal][1] = buf[m++]; xorient[nlocal][1] = buf[m++];
xphi[nlocal][2] = buf[m++]; xorient[nlocal][2] = buf[m++];
omega[nlocal][0] = buf[m++]; omega[nlocal][0] = buf[m++];
omega[nlocal][1] = buf[m++]; omega[nlocal][1] = buf[m++];
omega[nlocal][2] = buf[m++]; omega[nlocal][2] = buf[m++];
@ -502,9 +502,9 @@ int AtomVecGranular::pack_restart(int i, double *buf)
buf[m++] = radius[i]; buf[m++] = radius[i];
buf[m++] = density[i]; buf[m++] = density[i];
buf[m++] = xphi[i][0]; buf[m++] = xorient[i][0];
buf[m++] = xphi[i][1]; buf[m++] = xorient[i][1];
buf[m++] = xphi[i][2]; buf[m++] = xorient[i][2];
buf[m++] = omega[i][0]; buf[m++] = omega[i][0];
buf[m++] = omega[i][1]; buf[m++] = omega[i][1];
buf[m++] = omega[i][2]; buf[m++] = omega[i][2];
@ -546,15 +546,15 @@ int AtomVecGranular::unpack_restart(double *buf)
radius[nlocal] = buf[m++]; radius[nlocal] = buf[m++];
density[nlocal] = buf[m++]; density[nlocal] = buf[m++];
if (force->dimension == 3) if (domain->dimension == 3)
rmass[nlocal] = 4.0*PI/3.0 * rmass[nlocal] = 4.0*PI/3.0 *
radius[nlocal]*radius[nlocal]*radius[nlocal] * density[nlocal]; radius[nlocal]*radius[nlocal]*radius[nlocal] * density[nlocal];
else else
rmass[nlocal] = PI * radius[nlocal]*radius[nlocal] * density[nlocal]; rmass[nlocal] = PI * radius[nlocal]*radius[nlocal] * density[nlocal];
xphi[nlocal][0] = buf[m++]; xorient[nlocal][0] = buf[m++];
xphi[nlocal][1] = buf[m++]; xorient[nlocal][1] = buf[m++];
xphi[nlocal][2] = buf[m++]; xorient[nlocal][2] = buf[m++];
omega[nlocal][0] = buf[m++]; omega[nlocal][0] = buf[m++];
omega[nlocal][1] = buf[m++]; omega[nlocal][1] = buf[m++];
omega[nlocal][2] = buf[m++]; omega[nlocal][2] = buf[m++];
@ -592,14 +592,14 @@ void AtomVecGranular::create_atom(int itype, double *coord)
radius[nlocal] = 0.5; radius[nlocal] = 0.5;
density[nlocal] = 1.0; density[nlocal] = 1.0;
if (force->dimension == 3) if (domain->dimension == 3)
rmass[nlocal] = 4.0*PI/3.0 * rmass[nlocal] = 4.0*PI/3.0 *
radius[nlocal]*radius[nlocal]*radius[nlocal] * density[nlocal]; radius[nlocal]*radius[nlocal]*radius[nlocal] * density[nlocal];
else else
rmass[nlocal] = PI * radius[nlocal]*radius[nlocal] * density[nlocal]; rmass[nlocal] = PI * radius[nlocal]*radius[nlocal] * density[nlocal];
xphi[nlocal][0] = 0.0; xorient[nlocal][0] = 0.0;
xphi[nlocal][1] = 0.0; xorient[nlocal][1] = 0.0;
xphi[nlocal][2] = 0.0; xorient[nlocal][2] = 0.0;
omega[nlocal][0] = 0.0; omega[nlocal][0] = 0.0;
omega[nlocal][1] = 0.0; omega[nlocal][1] = 0.0;
omega[nlocal][2] = 0.0; omega[nlocal][2] = 0.0;
@ -627,7 +627,7 @@ void AtomVecGranular::data_atom(double *coord, int imagetmp, char **values)
radius[nlocal] = 0.5 * atof(values[2]); radius[nlocal] = 0.5 * atof(values[2]);
density[nlocal] = atof(values[3]); density[nlocal] = atof(values[3]);
if (force->dimension == 3) if (domain->dimension == 3)
rmass[nlocal] = 4.0*PI/3.0 * rmass[nlocal] = 4.0*PI/3.0 *
radius[nlocal]*radius[nlocal]*radius[nlocal] * density[nlocal]; radius[nlocal]*radius[nlocal]*radius[nlocal] * density[nlocal];
else else
@ -643,9 +643,9 @@ void AtomVecGranular::data_atom(double *coord, int imagetmp, char **values)
v[nlocal][0] = 0.0; v[nlocal][0] = 0.0;
v[nlocal][1] = 0.0; v[nlocal][1] = 0.0;
v[nlocal][2] = 0.0; v[nlocal][2] = 0.0;
xphi[nlocal][0] = 0.0; xorient[nlocal][0] = 1.0;
xphi[nlocal][1] = 0.0; xorient[nlocal][1] = 0.0;
xphi[nlocal][2] = 0.0; xorient[nlocal][2] = 0.0;
omega[nlocal][0] = 0.0; omega[nlocal][0] = 0.0;
omega[nlocal][1] = 0.0; omega[nlocal][1] = 0.0;
omega[nlocal][2] = 0.0; omega[nlocal][2] = 0.0;
@ -662,7 +662,7 @@ int AtomVecGranular::data_atom_hybrid(int nlocal, char **values)
{ {
radius[nlocal] = 0.5 * atof(values[0]); radius[nlocal] = 0.5 * atof(values[0]);
density[nlocal] = atof(values[1]); density[nlocal] = atof(values[1]);
if (force->dimension == 3) if (domain->dimension == 3)
rmass[nlocal] = 4.0*PI/3.0 * rmass[nlocal] = 4.0*PI/3.0 *
radius[nlocal]*radius[nlocal]*radius[nlocal] * density[nlocal]; radius[nlocal]*radius[nlocal]*radius[nlocal] * density[nlocal];
else else
@ -671,9 +671,9 @@ int AtomVecGranular::data_atom_hybrid(int nlocal, char **values)
v[nlocal][0] = 0.0; v[nlocal][0] = 0.0;
v[nlocal][1] = 0.0; v[nlocal][1] = 0.0;
v[nlocal][2] = 0.0; v[nlocal][2] = 0.0;
xphi[nlocal][0] = 0.0; xorient[nlocal][0] = 1.0;
xphi[nlocal][1] = 0.0; xorient[nlocal][1] = 0.0;
xphi[nlocal][2] = 0.0; xorient[nlocal][2] = 0.0;
omega[nlocal][0] = 0.0; omega[nlocal][0] = 0.0;
omega[nlocal][1] = 0.0; omega[nlocal][1] = 0.0;
omega[nlocal][2] = 0.0; omega[nlocal][2] = 0.0;
@ -726,7 +726,7 @@ int AtomVecGranular::memory_usage()
if (atom->memcheck("radius")) bytes += nmax * sizeof(double); if (atom->memcheck("radius")) bytes += nmax * sizeof(double);
if (atom->memcheck("density")) bytes += nmax * sizeof(double); if (atom->memcheck("density")) bytes += nmax * sizeof(double);
if (atom->memcheck("rmass")) bytes += nmax * sizeof(double); if (atom->memcheck("rmass")) bytes += nmax * sizeof(double);
if (atom->memcheck("xphi")) bytes += nmax*3 * sizeof(double); if (atom->memcheck("xorient")) bytes += nmax*3 * sizeof(double);
if (atom->memcheck("omega")) bytes += nmax*3 * sizeof(double); if (atom->memcheck("omega")) bytes += nmax*3 * sizeof(double);
if (atom->memcheck("torque")) bytes += nmax*3 * sizeof(double); if (atom->memcheck("torque")) bytes += nmax*3 * sizeof(double);

View File

@ -53,7 +53,7 @@ class AtomVecGranular : public AtomVec {
int *tag,*type,*mask,*image; int *tag,*type,*mask,*image;
double **x,**v,**f; double **x,**v,**f;
double *radius,*density,*rmass; double *radius,*density,*rmass;
double **xphi,**omega,**torque; double **xorient,**omega,**torque;
}; };
} }

View File

@ -17,6 +17,7 @@
#include "atom.h" #include "atom.h"
#include "update.h" #include "update.h"
#include "force.h" #include "force.h"
#include "domain.h"
#include "error.h" #include "error.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -33,9 +34,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->xphi_flag || !atom->omega_flag || !atom->torque_flag) if (!atom->xorient_flag || !atom->omega_flag || !atom->torque_flag)
error->all("Fix nve/gran requires atom attributes " error->all("Fix nve/gran requires atom attributes "
"xphi, omega, torque"); "xorient, omega, torque");
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -54,8 +55,8 @@ void FixNVEGran::init()
{ {
dtv = update->dt; dtv = update->dt;
dtf = 0.5 * update->dt * force->ftm2v; dtf = 0.5 * update->dt * force->ftm2v;
if (force->dimension == 3) dtfphi = dtf / INERTIA3D; if (domain->dimension == 3) dtfrotate = dtf / INERTIA3D;
else dtfphi = dtf / INERTIA2D; else dtfrotate = dtf / INERTIA2D;
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -67,7 +68,7 @@ void FixNVEGran::initial_integrate()
double **x = atom->x; double **x = atom->x;
double **v = atom->v; double **v = atom->v;
double **f = atom->f; double **f = atom->f;
double **xphi = atom->xphi; double **xorient = atom->xorient;
double **omega = atom->omega; double **omega = atom->omega;
double **torque = atom->torque; double **torque = atom->torque;
double *rmass = atom->rmass; double *rmass = atom->rmass;
@ -85,13 +86,13 @@ void FixNVEGran::initial_integrate()
x[i][1] += dtv * v[i][1]; x[i][1] += dtv * v[i][1];
x[i][2] += dtv * v[i][2]; x[i][2] += dtv * v[i][2];
dtfm = dtfphi / (radius[i]*radius[i]*rmass[i]); dtfm = dtfrotate / (radius[i]*radius[i]*rmass[i]);
omega[i][0] += dtfm * torque[i][0]; omega[i][0] += dtfm * torque[i][0];
omega[i][1] += dtfm * torque[i][1]; omega[i][1] += dtfm * torque[i][1];
omega[i][2] += dtfm * torque[i][2]; omega[i][2] += dtfm * torque[i][2];
xphi[i][0] += dtv * omega[i][0]; xorient[i][0] += dtv * omega[i][0];
xphi[i][1] += dtv * omega[i][1]; xorient[i][1] += dtv * omega[i][1];
xphi[i][2] += dtv * omega[i][2]; xorient[i][2] += dtv * omega[i][2];
} }
} }
} }
@ -118,7 +119,7 @@ void FixNVEGran::final_integrate()
v[i][1] += dtfm * f[i][1]; v[i][1] += dtfm * f[i][1];
v[i][2] += dtfm * f[i][2]; v[i][2] += dtfm * f[i][2];
dtfm = dtfphi / (radius[i]*radius[i]*rmass[i]); dtfm = dtfrotate / (radius[i]*radius[i]*rmass[i]);
omega[i][0] += dtfm * torque[i][0]; omega[i][0] += dtfm * torque[i][0];
omega[i][1] += dtfm * torque[i][1]; omega[i][1] += dtfm * torque[i][1];
omega[i][2] += dtfm * torque[i][2]; omega[i][2] += dtfm * torque[i][2];

View File

@ -27,7 +27,7 @@ class FixNVEGran : public Fix {
void final_integrate(); void final_integrate();
private: private:
double dtv,dtf,dtfphi; double dtv,dtf,dtfrotate;
}; };
} }

View File

@ -94,7 +94,7 @@ FixPour::FixPour(LAMMPS *lmp, int narg, char **arg) :
rate = atof(arg[iarg+1]); rate = atof(arg[iarg+1]);
iarg += 2; iarg += 2;
} else if (strcmp(arg[iarg],"vel") == 0) { } else if (strcmp(arg[iarg],"vel") == 0) {
if (force->dimension == 3) { if (domain->dimension == 3) {
if (iarg+6 > narg) error->all("Illegal fix pour command"); if (iarg+6 > narg) error->all("Illegal fix pour command");
vxlo = atof(arg[iarg+1]); vxlo = atof(arg[iarg+1]);
vxhi = atof(arg[iarg+2]); vxhi = atof(arg[iarg+2]);
@ -150,7 +150,7 @@ FixPour::FixPour(LAMMPS *lmp, int narg, char **arg) :
error->all("Insertion region extends outside simulation box"); error->all("Insertion region extends outside simulation box");
} else error->all("Must use a block or cylinder region with fix pour"); } else error->all("Must use a block or cylinder region with fix pour");
if (region_style == 2 && force->dimension == 2) if (region_style == 2 && domain->dimension == 2)
error->all("Must use a block region with fix pour for 2d simulations"); error->all("Must use a block region with fix pour for 2d simulations");
// random number generator, same for all procs // random number generator, same for all procs
@ -171,7 +171,7 @@ FixPour::FixPour(LAMMPS *lmp, int narg, char **arg) :
double v_relative,delta; double v_relative,delta;
double g = 1.0; double g = 1.0;
if (force->dimension == 3) { if (domain->dimension == 3) {
v_relative = vz - rate; v_relative = vz - rate;
delta = v_relative + sqrt(v_relative*v_relative + 2.0*g*(zhi-zlo)) / g; delta = v_relative + sqrt(v_relative*v_relative + 2.0*g*(zhi-zlo)) / g;
} else { } else {
@ -192,7 +192,7 @@ FixPour::FixPour(LAMMPS *lmp, int narg, char **arg) :
// in 3d, insure dy >= 1, for quasi-2d simulations // in 3d, insure dy >= 1, for quasi-2d simulations
double volume,volume_one; double volume,volume_one;
if (force->dimension == 3) { if (domain->dimension == 3) {
if (region_style == 1) { if (region_style == 1) {
double dy = yhi - ylo; double dy = yhi - ylo;
if (dy < 1.0) dy = 1.0; if (dy < 1.0) dy = 1.0;
@ -261,7 +261,7 @@ void FixPour::init()
double ygrav = sin(degree2rad * theta) * sin(degree2rad * phi); double ygrav = sin(degree2rad * theta) * sin(degree2rad * phi);
double zgrav = cos(degree2rad * theta); double zgrav = cos(degree2rad * theta);
if (force->dimension == 3) { if (domain->dimension == 3) {
if (fabs(xgrav) > EPSILON || fabs(ygrav) > EPSILON || if (fabs(xgrav) > EPSILON || fabs(ygrav) > EPSILON ||
fabs(zgrav+1.0) > EPSILON) fabs(zgrav+1.0) > EPSILON)
error->all("Gravity must point in -z to use with fix pour in 3d"); error->all("Gravity must point in -z to use with fix pour in 3d");
@ -299,7 +299,7 @@ void FixPour::pre_exchange()
// lo/hi current = z (or y) bounds of insertion region this timestep // lo/hi current = z (or y) bounds of insertion region this timestep
if (force->dimension == 3) { if (domain->dimension == 3) {
lo_current = zlo + (update->ntimestep - nfirst) * update->dt * rate; lo_current = zlo + (update->ntimestep - nfirst) * update->dt * rate;
hi_current = zhi + (update->ntimestep - nfirst) * update->dt * rate; hi_current = zhi + (update->ntimestep - nfirst) * update->dt * rate;
} else { } else {
@ -430,7 +430,7 @@ void FixPour::pre_exchange()
coord[2] = xnear[i][2]; coord[2] = xnear[i][2];
radtmp = xnear[i][3]; radtmp = xnear[i][3];
denstmp = density_lo + random->uniform() * (density_hi-density_lo); denstmp = density_lo + random->uniform() * (density_hi-density_lo);
if (force->dimension == 3) { if (domain->dimension == 3) {
vxtmp = vxlo + random->uniform() * (vxhi-vxlo); vxtmp = vxlo + random->uniform() * (vxhi-vxlo);
vytmp = vylo + random->uniform() * (vyhi-vylo); vytmp = vylo + random->uniform() * (vyhi-vylo);
vztmp = vz - sqrt(2.0*g*(hi_current-coord[2])); vztmp = vz - sqrt(2.0*g*(hi_current-coord[2]));
@ -444,11 +444,11 @@ void FixPour::pre_exchange()
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]) flag = 1; coord[2] >= sublo[2] && coord[2] < subhi[2]) flag = 1;
else if (force->dimension == 3 && coord[2] >= domain->boxhi[2] && else if (domain->dimension == 3 && coord[2] >= domain->boxhi[2] &&
comm->myloc[2] == comm->procgrid[2]-1 && comm->myloc[2] == comm->procgrid[2]-1 &&
coord[0] >= sublo[0] && coord[0] < subhi[0] && coord[0] >= sublo[0] && coord[0] < subhi[0] &&
coord[1] >= sublo[1] && coord[1] < subhi[1]) flag = 1; coord[1] >= sublo[1] && coord[1] < subhi[1]) flag = 1;
else if (force->dimension == 2 && coord[1] >= domain->boxhi[1] && else if (domain->dimension == 2 && coord[1] >= domain->boxhi[1] &&
comm->myloc[1] == comm->procgrid[1]-1 && comm->myloc[1] == comm->procgrid[1]-1 &&
coord[0] >= sublo[0] && coord[0] < subhi[0]) flag = 1; coord[0] >= sublo[0] && coord[0] < subhi[0]) flag = 1;
@ -458,7 +458,7 @@ void FixPour::pre_exchange()
atom->type[m] = ntype; atom->type[m] = ntype;
atom->radius[m] = radtmp; atom->radius[m] = radtmp;
atom->density[m] = denstmp; atom->density[m] = denstmp;
if (force->dimension == 3) if (domain->dimension == 3)
atom->rmass[m] = 4.0*PI/3.0 * radtmp*radtmp*radtmp * denstmp; atom->rmass[m] = 4.0*PI/3.0 * radtmp*radtmp*radtmp * denstmp;
else else
atom->rmass[m] = PI * radtmp*radtmp * denstmp; atom->rmass[m] = PI * radtmp*radtmp * denstmp;
@ -505,7 +505,7 @@ int FixPour::overlap(int i)
double delta = radius_hi + atom->radius[i]; double delta = radius_hi + atom->radius[i];
double **x = atom->x; double **x = atom->x;
if (force->dimension == 3) { if (domain->dimension == 3) {
if (region_style == 1) { if (region_style == 1) {
if (x[i][0] < xlo-delta || x[i][0] > xhi+delta || if (x[i][0] < xlo-delta || x[i][0] > xhi+delta ||
x[i][1] < ylo-delta || x[i][1] > yhi+delta || x[i][1] < ylo-delta || x[i][1] > yhi+delta ||
@ -530,7 +530,7 @@ int FixPour::overlap(int i)
void FixPour::xyz_random(double h, double *coord) void FixPour::xyz_random(double h, double *coord)
{ {
if (force->dimension == 3) { if (domain->dimension == 3) {
if (region_style == 1) { if (region_style == 1) {
coord[0] = xlo + random->uniform() * (xhi-xlo); coord[0] = xlo + random->uniform() * (xhi-xlo);
coord[1] = ylo + random->uniform() * (yhi-ylo); coord[1] = ylo + random->uniform() * (yhi-ylo);

View File

@ -81,7 +81,7 @@ void Ewald::init()
// error check // error check
if (domain->triclinic) error->all("Cannot use Ewald with triclinic box"); if (domain->triclinic) error->all("Cannot use Ewald with triclinic box");
if (force->dimension == 2) error->all("Cannot use Ewald with 2d simulation"); if (domain->dimension == 2) error->all("Cannot use Ewald with 2d simulation");
if (!atom->q_flag) error->all("Kspace style requires atom attribute q"); if (!atom->q_flag) error->all("Kspace style requires atom attribute q");

View File

@ -107,7 +107,7 @@ void PPPM::init()
if (domain->triclinic) if (domain->triclinic)
error->all("Cannot (yet) use PPPM with triclinic box"); error->all("Cannot (yet) use PPPM with triclinic box");
if (force->dimension == 2) error->all("Cannot use PPPM with 2d simulation"); if (domain->dimension == 2) error->all("Cannot use PPPM with 2d simulation");
if (!atom->q_flag) error->all("Kspace style requires atom attribute q"); if (!atom->q_flag) error->all("Kspace style requires atom attribute q");

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 = quat = omega = angmom = torque = NULL; xorient = quat = omega = angmom = torque = NULL;
radius = density = rmass = vfrac = NULL; radius = density = rmass = vfrac = NULL;
maxspecial = 1; maxspecial = 1;
@ -87,7 +87,7 @@ Atom::Atom(LAMMPS *lmp) : Pointers(lmp)
molecule_flag = 0; molecule_flag = 0;
q_flag = mu_flag = 0; q_flag = mu_flag = 0;
xphi_flag = quat_flag = omega_flag = angmom_flag = torque_flag = 0; xorient_flag = quat_flag = omega_flag = angmom_flag = torque_flag = 0;
radius_flag = density_flag = rmass_flag = vfrac_flag = 0; radius_flag = density_flag = rmass_flag = vfrac_flag = 0;
// ntype-length arrays // ntype-length arrays
@ -150,7 +150,7 @@ 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(xorient);
memory->destroy_2d_double_array(quat); 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(angmom);

View File

@ -43,7 +43,7 @@ class Atom : protected Pointers {
int *molecule; int *molecule;
double *q,**mu; double *q,**mu;
double **xphi,**quat,**omega,**angmom,**torque; double **xorient,**quat,**omega,**angmom,**torque;
double *radius,*density,*rmass,*vfrac; double *radius,*density,*rmass,*vfrac;
int maxspecial; int maxspecial;
@ -70,7 +70,7 @@ class Atom : protected Pointers {
int molecule_flag; int molecule_flag;
int q_flag,mu_flag; int q_flag,mu_flag;
int xphi_flag,quat_flag,omega_flag,angmom_flag,torque_flag; int xorient_flag,quat_flag,omega_flag,angmom_flag,torque_flag;
int radius_flag,density_flag,rmass_flag,vfrac_flag; int radius_flag,density_flag,rmass_flag,vfrac_flag;
// extra peratom info in restart file destined for fix & diag // extra peratom info in restart file destined for fix & diag

View File

@ -166,7 +166,7 @@ void Comm::set_procs()
if (procgrid[0]*procgrid[1]*procgrid[2] != nprocs) if (procgrid[0]*procgrid[1]*procgrid[2] != nprocs)
error->all("Bad grid of processors"); error->all("Bad grid of processors");
if (force->dimension == 2 && procgrid[2] != 1) if (domain->dimension == 2 && procgrid[2] != 1)
error->all("Proc grid in z != 1 for 2d simulation"); error->all("Proc grid in z != 1 for 2d simulation");
if (grid2proc) memory->destroy_3d_int_array(grid2proc); if (grid2proc) memory->destroy_3d_int_array(grid2proc);
@ -272,7 +272,7 @@ void Comm::setup()
need[0] = static_cast<int> (cutghost[0] * procgrid[0] / prd[0]) + 1; need[0] = static_cast<int> (cutghost[0] * procgrid[0] / prd[0]) + 1;
need[1] = static_cast<int> (cutghost[1] * procgrid[1] / prd[1]) + 1; need[1] = static_cast<int> (cutghost[1] * procgrid[1] / prd[1]) + 1;
need[2] = static_cast<int> (cutghost[2] * procgrid[2] / prd[2]) + 1; need[2] = static_cast<int> (cutghost[2] * procgrid[2] / prd[2]) + 1;
if (force->dimension == 2) need[2] = 0; if (domain->dimension == 2) need[2] = 0;
// if non-periodic, do not communicate further than procgrid-1 away // if non-periodic, do not communicate further than procgrid-1 away
// this enables very large cutoffs in non-periodic systems // this enables very large cutoffs in non-periodic systems
@ -1300,7 +1300,7 @@ void Comm::procs2box()
while (ipy <= nremain) { while (ipy <= nremain) {
if (nremain % ipy == 0) { if (nremain % ipy == 0) {
ipz = nremain/ipy; ipz = nremain/ipy;
if (force->dimension == 3 || ipz == 1) { if (domain->dimension == 3 || ipz == 1) {
surf = area[0]/ipx/ipy + area[1]/ipx/ipz + area[2]/ipy/ipz; surf = area[0]/ipx/ipy + area[1]/ipx/ipz + area[2]/ipy/ipz;
if (surf < bestsurf) { if (surf < bestsurf) {
bestsurf = surf; bestsurf = surf;

View File

@ -14,7 +14,7 @@
#include "mpi.h" #include "mpi.h"
#include "compute_rotate_dipole.h" #include "compute_rotate_dipole.h"
#include "atom.h" #include "atom.h"
#include "force.h" #include "domain.h"
#include "group.h" #include "group.h"
#include "error.h" #include "error.h"
@ -56,7 +56,7 @@ void ComputeRotateDipole::init()
double *mass = atom->mass; double *mass = atom->mass;
double **shape = atom->shape; double **shape = atom->shape;
if (force->dimension == 3) if (domain->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*shape[i][0]*shape[i][0]; inertia[i] = INERTIA3D * mass[i] * 0.25*shape[i][0]*shape[i][0];
else else

View File

@ -15,6 +15,7 @@
#include "compute_rotate_gran.h" #include "compute_rotate_gran.h"
#include "atom.h" #include "atom.h"
#include "force.h" #include "force.h"
#include "domain.h"
#include "group.h" #include "group.h"
#include "error.h" #include "error.h"
@ -42,7 +43,7 @@ ComputeRotateGran::ComputeRotateGran(LAMMPS *lmp, int narg, char **arg) :
void ComputeRotateGran::init() void ComputeRotateGran::init()
{ {
if (force->dimension == 3) pfactor = 0.5 * force->mvv2e * INERTIA3D; if (domain->dimension == 3) pfactor = 0.5 * force->mvv2e * INERTIA3D;
else pfactor = 0.5 * force->mvv2e * INERTIA2D; else pfactor = 0.5 * force->mvv2e * INERTIA2D;
} }

View File

@ -15,6 +15,7 @@
#include "compute_temp.h" #include "compute_temp.h"
#include "atom.h" #include "atom.h"
#include "force.h" #include "force.h"
#include "domain.h"
#include "modify.h" #include "modify.h"
#include "fix.h" #include "fix.h"
#include "group.h" #include "group.h"
@ -59,7 +60,7 @@ void ComputeTemp::init()
void ComputeTemp::recount() void ComputeTemp::recount()
{ {
double natoms = group->count(igroup); double natoms = group->count(igroup);
dof = force->dimension * natoms; dof = domain->dimension * natoms;
dof -= extra_dof + fix_dof; dof -= extra_dof + fix_dof;
if (dof > 0) tfactor = force->mvv2e / (dof * force->boltz); if (dof > 0) tfactor = force->mvv2e / (dof * force->boltz);
else tfactor = 0.0; else tfactor = 0.0;

View File

@ -83,7 +83,7 @@ void ComputeTempDeform::init()
void ComputeTempDeform::recount() void ComputeTempDeform::recount()
{ {
double natoms = group->count(igroup); double natoms = group->count(igroup);
dof = force->dimension * natoms; dof = domain->dimension * natoms;
dof -= extra_dof + fix_dof; dof -= extra_dof + fix_dof;
if (dof > 0) tfactor = force->mvv2e / (dof * force->boltz); if (dof > 0) tfactor = force->mvv2e / (dof * force->boltz);
else tfactor = 0.0; else tfactor = 0.0;

View File

@ -129,7 +129,7 @@ void ComputeTempRamp::init()
void ComputeTempRamp::recount() void ComputeTempRamp::recount()
{ {
double natoms = group->count(igroup); double natoms = group->count(igroup);
dof = force->dimension * natoms; dof = domain->dimension * natoms;
dof -= extra_dof + fix_dof; dof -= extra_dof + fix_dof;
if (dof > 0) tfactor = force->mvv2e / (dof * force->boltz); if (dof > 0) tfactor = force->mvv2e / (dof * force->boltz);
else tfactor = 0.0; else tfactor = 0.0;

View File

@ -90,7 +90,7 @@ double ComputeTempRegion::compute_scalar()
tarray[0] = count; tarray[0] = count;
tarray[1] = t; tarray[1] = t;
MPI_Allreduce(tarray,tarray_all,2,MPI_DOUBLE,MPI_SUM,world); MPI_Allreduce(tarray,tarray_all,2,MPI_DOUBLE,MPI_SUM,world);
dof = force->dimension * tarray_all[0] - extra_dof; dof = domain->dimension * tarray_all[0] - extra_dof;
if (dof > 0) scalar = force->mvv2e * tarray_all[1] / (dof * force->boltz); if (dof > 0) scalar = force->mvv2e * tarray_all[1] / (dof * force->boltz);
else scalar = 0.0; else scalar = 0.0;
return scalar; return scalar;

View File

@ -37,7 +37,7 @@ void CreateBox::command(int narg, char **arg)
if (domain->box_exist) if (domain->box_exist)
error->all("Cannot create_box after simulation box is defined"); error->all("Cannot create_box after simulation box is defined");
if (force->dimension == 2 && domain->zperiodic == 0) if (domain->dimension == 2 && domain->zperiodic == 0)
error->all("Cannot run 2d simulation with nonperiodic Z dimension"); error->all("Cannot run 2d simulation with nonperiodic Z dimension");
domain->box_exist = 1; domain->box_exist = 1;

View File

@ -55,6 +55,7 @@ Domain::Domain(LAMMPS *lmp) : Pointers(lmp)
{ {
box_exist = 0; box_exist = 0;
dimension = 3;
nonperiodic = 0; nonperiodic = 0;
xperiodic = yperiodic = zperiodic = 1; xperiodic = yperiodic = zperiodic = 1;
periodicity[0] = xperiodic; periodicity[0] = xperiodic;
@ -132,7 +133,7 @@ void Domain::set_initial_box()
error->one("Box bounds are invalid"); error->one("Box bounds are invalid");
if (triclinic) { if (triclinic) {
if (force->dimension == 2 && (xz != 0.0 || yz != 0.0)) if (domain->dimension == 2 && (xz != 0.0 || yz != 0.0))
error->all("Cannot skew triclinic box in z for 2d simulation"); error->all("Cannot skew triclinic box in z for 2d simulation");
if (xy != 0.0 && (!xperiodic || !yperiodic)) if (xy != 0.0 && (!xperiodic || !yperiodic))
error->all("Triclinic box must be periodic in skewed dimensions"); error->all("Triclinic box must be periodic in skewed dimensions");

View File

@ -21,7 +21,7 @@ namespace LAMMPS_NS {
class Domain : protected Pointers { class Domain : protected Pointers {
public: public:
int box_exist; // 0 = not yet created, 1 = exists int box_exist; // 0 = not yet created, 1 = exists
int dimension; // 2 = 2d, 3 = 3d
int nonperiodic; // 0 = periodic in all 3 dims int nonperiodic; // 0 = periodic in all 3 dims
// 1 = periodic or fixed in all 6 // 1 = periodic or fixed in all 6
// 2 = shrink-wrap in any of 6 // 2 = shrink-wrap in any of 6

View File

@ -570,7 +570,7 @@ void DumpCustom::parse_fields(int narg, char **arg)
pack_choice[i] = &DumpCustom::pack_tag; pack_choice[i] = &DumpCustom::pack_tag;
vtype[i] = INT; vtype[i] = INT;
} else if (strcmp(arg[iarg],"mol") == 0) { } else if (strcmp(arg[iarg],"mol") == 0) {
if (atom->molecule == NULL) if (!atom->molecule_flag)
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_molecule; pack_choice[i] = &DumpCustom::pack_molecule;
vtype[i] = INT; vtype[i] = INT;
@ -641,58 +641,58 @@ void DumpCustom::parse_fields(int narg, char **arg)
vtype[i] = DOUBLE; vtype[i] = DOUBLE;
} else if (strcmp(arg[iarg],"q") == 0) { } else if (strcmp(arg[iarg],"q") == 0) {
if (atom->q == NULL) if (!atom->q_flag)
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_q; pack_choice[i] = &DumpCustom::pack_q;
vtype[i] = DOUBLE; vtype[i] = DOUBLE;
} else if (strcmp(arg[iarg],"mux") == 0) { } else if (strcmp(arg[iarg],"mux") == 0) {
if (atom->mu == NULL) if (!atom->mu_flag)
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_mux; pack_choice[i] = &DumpCustom::pack_mux;
vtype[i] = DOUBLE; vtype[i] = DOUBLE;
} else if (strcmp(arg[iarg],"muy") == 0) { } else if (strcmp(arg[iarg],"muy") == 0) {
if (atom->mu == NULL) if (!atom->mu_flag)
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_muy; pack_choice[i] = &DumpCustom::pack_muy;
vtype[i] = DOUBLE; vtype[i] = DOUBLE;
} else if (strcmp(arg[iarg],"muz") == 0) { } else if (strcmp(arg[iarg],"muz") == 0) {
if (atom->mu == NULL) if (!atom->mu_flag)
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) { } else if (strcmp(arg[iarg],"quatw") == 0) {
if (atom->quat == NULL) if (!atom->quat_flag)
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_quatw; pack_choice[i] = &DumpCustom::pack_quatw;
vtype[i] = DOUBLE; vtype[i] = DOUBLE;
} else if (strcmp(arg[iarg],"quati") == 0) { } else if (strcmp(arg[iarg],"quati") == 0) {
if (atom->quat == NULL) if (!atom->quat_flag)
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_quati; pack_choice[i] = &DumpCustom::pack_quati;
vtype[i] = DOUBLE; vtype[i] = DOUBLE;
} else if (strcmp(arg[iarg],"quatj") == 0) { } else if (strcmp(arg[iarg],"quatj") == 0) {
if (atom->quat == NULL) if (!atom->quat_flag)
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_quatj; pack_choice[i] = &DumpCustom::pack_quatj;
vtype[i] = DOUBLE; vtype[i] = DOUBLE;
} else if (strcmp(arg[iarg],"quatk") == 0) { } else if (strcmp(arg[iarg],"quatk") == 0) {
if (atom->quat == NULL) if (!atom->quat_flag)
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_quatk; pack_choice[i] = &DumpCustom::pack_quatk;
vtype[i] = DOUBLE; vtype[i] = DOUBLE;
} else if (strcmp(arg[iarg],"tqx") == 0) { } else if (strcmp(arg[iarg],"tqx") == 0) {
if (atom->torque == NULL) if (!atom->torque_flag)
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_tqx; pack_choice[i] = &DumpCustom::pack_tqx;
vtype[i] = DOUBLE; vtype[i] = DOUBLE;
} else if (strcmp(arg[iarg],"tqy") == 0) { } else if (strcmp(arg[iarg],"tqy") == 0) {
if (atom->torque == NULL) if (!atom->torque_flag)
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_tqy; pack_choice[i] = &DumpCustom::pack_tqy;
vtype[i] = DOUBLE; vtype[i] = DOUBLE;
} else if (strcmp(arg[iarg],"tqz") == 0) { } else if (strcmp(arg[iarg],"tqz") == 0) {
if (atom->torque == NULL) if (!atom->torque_flag)
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_tqz; pack_choice[i] = &DumpCustom::pack_tqz;
vtype[i] = DOUBLE; vtype[i] = DOUBLE;

View File

@ -162,20 +162,24 @@ FixDeform::FixDeform(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg)
if (set[5].style && (domain->xperiodic == 0 || domain->yperiodic == 0)) if (set[5].style && (domain->xperiodic == 0 || domain->yperiodic == 0))
error->all("Cannot fix deform on a non-periodic boundary"); error->all("Cannot fix deform on a non-periodic boundary");
// setup scaling // apply scaling to FINAL,DELTA,VEL since they have distance/vel units
if (scaleflag && domain->lattice == NULL) int flag = 0;
for (int i = 0; i < 6; i++)
if (set[i].style == FINAL || set[i].style == DELTA ||
set[i].style == VEL) flag = 1;
if (flag && scaleflag && domain->lattice == NULL)
error->all("Use of fix deform with undefined lattice"); error->all("Use of fix deform with undefined lattice");
if (scaleflag) { if (flag && scaleflag) {
xscale = domain->lattice->xlattice; xscale = domain->lattice->xlattice;
yscale = domain->lattice->ylattice; yscale = domain->lattice->ylattice;
zscale = domain->lattice->zlattice; zscale = domain->lattice->zlattice;
} }
else xscale = yscale = zscale = 1.0; else xscale = yscale = zscale = 1.0;
// apply scaling to input parameters with dist/vel units // for 3,4,5 scaling is in 1st dimension, e.g. x for xz
// for 3,4,5 scale is in 1st dimension, e.g. x for xz
double map[6]; double map[6];
map[0] = xscale; map[1] = yscale; map[2] = zscale; map[0] = xscale; map[1] = yscale; map[2] = zscale;

View File

@ -88,7 +88,7 @@ FixDeposit::FixDeposit(LAMMPS *lmp, int narg, char **arg) :
// apply scaling to all input parameters with dist/vel units // apply scaling to all input parameters with dist/vel units
if (force->dimension == 2) { if (domain->dimension == 2) {
lo *= yscale; lo *= yscale;
hi *= yscale; hi *= yscale;
rate *= yscale; rate *= yscale;
@ -191,7 +191,7 @@ void FixDeposit::pre_exchange()
// adjust vertical coord by offset // adjust vertical coord by offset
if (force->dimension == 2) coord[1] += offset; if (domain->dimension == 2) coord[1] += offset;
else coord[2] += offset; else coord[2] += offset;
// if global, reset vertical coord to be lo-hi above highest atom // if global, reset vertical coord to be lo-hi above highest atom
@ -202,7 +202,7 @@ void FixDeposit::pre_exchange()
int dim; int dim;
double max,maxall,delx,dely,delz,rsq; double max,maxall,delx,dely,delz,rsq;
if (force->dimension == 2) { if (domain->dimension == 2) {
dim = 1; dim = 1;
max = domain->boxlo[1]; max = domain->boxlo[1];
} else { } else {
@ -218,7 +218,7 @@ void FixDeposit::pre_exchange()
dely = coord[1] - x[i][1]; dely = coord[1] - x[i][1];
delz = 0.0; delz = 0.0;
domain->minimum_image(delx,dely,delz); domain->minimum_image(delx,dely,delz);
if (force->dimension == 2) rsq = delx*delx; if (domain->dimension == 2) rsq = delx*delx;
else rsq = delx*delx + dely*dely; else rsq = delx*delx + dely*dely;
if (rsq > deltasq) continue; if (rsq > deltasq) continue;
} }
@ -226,7 +226,7 @@ void FixDeposit::pre_exchange()
} }
MPI_Allreduce(&max,&maxall,1,MPI_DOUBLE,MPI_MAX,world); MPI_Allreduce(&max,&maxall,1,MPI_DOUBLE,MPI_MAX,world);
if (force->dimension == 2) if (domain->dimension == 2)
coord[1] = maxall + lo + random->uniform()*(hi-lo); coord[1] = maxall + lo + random->uniform()*(hi-lo);
else else
coord[2] = maxall + lo + random->uniform()*(hi-lo); coord[2] = maxall + lo + random->uniform()*(hi-lo);
@ -271,11 +271,11 @@ void FixDeposit::pre_exchange()
if (newcoord[0] >= sublo[0] && newcoord[0] < subhi[0] && if (newcoord[0] >= sublo[0] && newcoord[0] < subhi[0] &&
newcoord[1] >= sublo[1] && newcoord[1] < subhi[1] && newcoord[1] >= sublo[1] && newcoord[1] < subhi[1] &&
newcoord[2] >= sublo[2] && newcoord[2] < subhi[2]) flag = 1; newcoord[2] >= sublo[2] && newcoord[2] < subhi[2]) flag = 1;
else if (force->dimension == 3 && newcoord[2] >= domain->boxhi[2] && else if (domain->dimension == 3 && newcoord[2] >= domain->boxhi[2] &&
comm->myloc[2] == comm->procgrid[2]-1 && comm->myloc[2] == comm->procgrid[2]-1 &&
newcoord[0] >= sublo[0] && newcoord[0] < subhi[0] && newcoord[0] >= sublo[0] && newcoord[0] < subhi[0] &&
newcoord[1] >= sublo[1] && newcoord[1] < subhi[1]) flag = 1; newcoord[1] >= sublo[1] && newcoord[1] < subhi[1]) flag = 1;
else if (force->dimension == 2 && newcoord[1] >= domain->boxhi[1] && else if (domain->dimension == 2 && newcoord[1] >= domain->boxhi[1] &&
comm->myloc[1] == comm->procgrid[1]-1 && comm->myloc[1] == comm->procgrid[1]-1 &&
newcoord[0] >= sublo[0] && newcoord[0] < subhi[0]) flag = 1; newcoord[0] >= sublo[0] && newcoord[0] < subhi[0]) flag = 1;

View File

@ -67,9 +67,7 @@ void FixEnforce2D::min_setup()
void FixEnforce2D::post_force(int vflag) void FixEnforce2D::post_force(int vflag)
{ {
double **v = atom->v; double **v = atom->v;
double **omega = atom->omega;
double **f = atom->f; double **f = atom->f;
double **torque = atom->torque;
int *mask = atom->mask; int *mask = atom->mask;
int nlocal = atom->nlocal; int nlocal = atom->nlocal;
@ -79,9 +77,10 @@ void FixEnforce2D::post_force(int vflag)
f[i][2] = 0.0; f[i][2] = 0.0;
} }
// for omega/torque systems, zero xy rotation // for systems with omega/angmom/torque, zero x and y components
if (omega) { if (atom->omega_flag) {
double **omega = atom->omega;
for (int i = 0; i < nlocal; i++) for (int i = 0; i < nlocal; i++)
if (mask[i] & groupbit) { if (mask[i] & groupbit) {
omega[i][0] = 0.0; omega[i][0] = 0.0;
@ -89,7 +88,17 @@ void FixEnforce2D::post_force(int vflag)
} }
} }
if (torque) { if (atom->angmom_flag) {
double **angmom = atom->angmom;
for (int i = 0; i < nlocal; i++)
if (mask[i] & groupbit) {
angmom[i][0] = 0.0;
angmom[i][1] = 0.0;
}
}
if (atom->torque_flag) {
double **torque = atom->torque;
for (int i = 0; i < nlocal; i++) for (int i = 0; i < nlocal; i++)
if (mask[i] & groupbit) { if (mask[i] & groupbit) {
torque[i][0] = 0.0; torque[i][0] = 0.0;

View File

@ -71,7 +71,7 @@ FixNVT::FixNVT(LAMMPS *lmp, int narg, char **arg) :
newarg[1] = group->names[igroup]; newarg[1] = group->names[igroup];
if (strcmp(style,"nvt") == 0) 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/asphere") == 0) newarg[2] = "temp/asphere";
else if (strcmp(style,"nvt/deform") == 0) newarg[2] = "temp/deform"; else if (strcmp(style,"nvt/sllod") == 0) newarg[2] = "temp/deform";
modify->add_compute(3,newarg); modify->add_compute(3,newarg);
delete [] newarg; delete [] newarg;
tflag = 1; tflag = 1;

View File

@ -51,7 +51,6 @@ using namespace LAMMPS_NS;
Force::Force(LAMMPS *lmp) : Pointers(lmp) Force::Force(LAMMPS *lmp) : Pointers(lmp)
{ {
dimension = 3;
newton = newton_pair = newton_bond = 1; newton = newton_pair = newton_bond = 1;
special_lj[1] = special_lj[2] = special_lj[3] = 0.0; special_lj[1] = special_lj[2] = special_lj[3] = 0.0;

View File

@ -29,7 +29,6 @@ class Force : protected Pointers {
double dielectric; // dielectric constant double dielectric; // dielectric constant
double qqrd2e; // q^2/r to energy w/ dielectric constant double qqrd2e; // q^2/r to energy w/ dielectric constant
int dimension; // 2 = 2d, 3 = 3d
int newton,newton_pair,newton_bond; // Newton's 3rd law settings int newton,newton_pair,newton_bond; // Newton's 3rd law settings
class Pair *pair; class Pair *pair;

View File

@ -795,7 +795,7 @@ void Input::dimension()
if (narg != 1) error->all("Illegal dimension command"); if (narg != 1) error->all("Illegal dimension command");
if (domain->box_exist) if (domain->box_exist)
error->all("Dimension command after simulation box is defined"); error->all("Dimension command after simulation box is defined");
force->dimension = atoi(arg[0]); domain->dimension = atoi(arg[0]);
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */

View File

@ -16,7 +16,7 @@
#include "stdlib.h" #include "stdlib.h"
#include "lattice.h" #include "lattice.h"
#include "update.h" #include "update.h"
#include "force.h" #include "domain.h"
#include "comm.h" #include "comm.h"
#include "memory.h" #include "memory.h"
#include "error.h" #include "error.h"
@ -59,7 +59,7 @@ Lattice::Lattice(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp)
// check that lattice matches dimension // check that lattice matches dimension
// style CUSTOM can be either 2d or 3d // style CUSTOM can be either 2d or 3d
int dimension = force->dimension; int dimension = domain->dimension;
if (dimension == 2) { if (dimension == 2) {
if (style == SC || style == BCC || style == FCC || style == DIAMOND) if (style == SC || style == BCC || style == FCC || style == DIAMOND)
error->all("Lattice style incompatible with simulation dimension"); error->all("Lattice style incompatible with simulation dimension");

View File

@ -520,19 +520,19 @@ void Neighbor::init()
} else if (style == BIN) { } else if (style == BIN) {
if (force->newton_pair == 0) { if (force->newton_pair == 0) {
half_build = &Neighbor::granular_bin_no_newton; half_build = &Neighbor::granular_bin_no_newton;
if (force->dimension == 3) if (domain->dimension == 3)
half_stencil = &Neighbor::stencil_half_3d_no_newton; half_stencil = &Neighbor::stencil_half_3d_no_newton;
else else
half_stencil = &Neighbor::stencil_half_2d_no_newton; half_stencil = &Neighbor::stencil_half_2d_no_newton;
} else if (triclinic) { } else if (triclinic) {
half_build = &Neighbor::granular_bin_newton_tri; half_build = &Neighbor::granular_bin_newton_tri;
if (force->dimension == 3) if (domain->dimension == 3)
half_stencil = &Neighbor::stencil_half_3d_newton_tri; half_stencil = &Neighbor::stencil_half_3d_newton_tri;
else else
half_stencil = &Neighbor::stencil_half_2d_newton_tri; half_stencil = &Neighbor::stencil_half_2d_newton_tri;
} else { } else {
half_build = &Neighbor::granular_bin_newton; half_build = &Neighbor::granular_bin_newton;
if (force->dimension == 3) if (domain->dimension == 3)
half_stencil = &Neighbor::stencil_half_3d_newton; half_stencil = &Neighbor::stencil_half_3d_newton;
else else
half_stencil = &Neighbor::stencil_half_2d_newton; half_stencil = &Neighbor::stencil_half_2d_newton;
@ -547,19 +547,19 @@ void Neighbor::init()
} else if (style == BIN) { } else if (style == BIN) {
if (force->newton_pair == 0) { if (force->newton_pair == 0) {
half_build = &Neighbor::respa_bin_no_newton; half_build = &Neighbor::respa_bin_no_newton;
if (force->dimension == 3) if (domain->dimension == 3)
half_stencil = &Neighbor::stencil_half_3d_no_newton; half_stencil = &Neighbor::stencil_half_3d_no_newton;
else else
half_stencil = &Neighbor::stencil_half_2d_no_newton; half_stencil = &Neighbor::stencil_half_2d_no_newton;
} else if (triclinic) { } else if (triclinic) {
half_build = &Neighbor::respa_bin_newton_tri; half_build = &Neighbor::respa_bin_newton_tri;
if (force->dimension == 3) if (domain->dimension == 3)
half_stencil = &Neighbor::stencil_half_3d_newton_tri; half_stencil = &Neighbor::stencil_half_3d_newton_tri;
else else
half_stencil = &Neighbor::stencil_half_2d_newton_tri; half_stencil = &Neighbor::stencil_half_2d_newton_tri;
} else { } else {
half_build = &Neighbor::respa_bin_newton; half_build = &Neighbor::respa_bin_newton;
if (force->dimension == 3) if (domain->dimension == 3)
half_stencil = &Neighbor::stencil_half_3d_newton; half_stencil = &Neighbor::stencil_half_3d_newton;
else else
half_stencil = &Neighbor::stencil_half_2d_newton; half_stencil = &Neighbor::stencil_half_2d_newton;
@ -582,7 +582,7 @@ void Neighbor::init()
half_stencil = &Neighbor::stencil_none; half_stencil = &Neighbor::stencil_none;
} else { } else {
half_build = &Neighbor::half_bin_no_newton; half_build = &Neighbor::half_bin_no_newton;
if (force->dimension == 3) if (domain->dimension == 3)
half_stencil = &Neighbor::stencil_half_3d_no_newton; half_stencil = &Neighbor::stencil_half_3d_no_newton;
else else
half_stencil = &Neighbor::stencil_half_2d_no_newton; half_stencil = &Neighbor::stencil_half_2d_no_newton;
@ -593,13 +593,13 @@ void Neighbor::init()
half_stencil = &Neighbor::stencil_none; half_stencil = &Neighbor::stencil_none;
} else if (triclinic) { } else if (triclinic) {
half_build = &Neighbor::half_bin_newton_tri; half_build = &Neighbor::half_bin_newton_tri;
if (force->dimension == 3) if (domain->dimension == 3)
half_stencil = &Neighbor::stencil_half_3d_newton_tri; half_stencil = &Neighbor::stencil_half_3d_newton_tri;
else else
half_stencil = &Neighbor::stencil_half_2d_newton_tri; half_stencil = &Neighbor::stencil_half_2d_newton_tri;
} else { } else {
half_build = &Neighbor::half_bin_newton; half_build = &Neighbor::half_bin_newton;
if (force->dimension == 3) if (domain->dimension == 3)
half_stencil = &Neighbor::stencil_half_3d_newton; half_stencil = &Neighbor::stencil_half_3d_newton;
else else
half_stencil = &Neighbor::stencil_half_2d_newton; half_stencil = &Neighbor::stencil_half_2d_newton;
@ -612,7 +612,7 @@ void Neighbor::init()
half_stencil = &Neighbor::stencil_none; half_stencil = &Neighbor::stencil_none;
} else { } else {
half_build = &Neighbor::half_bin_no_newton_multi; half_build = &Neighbor::half_bin_no_newton_multi;
if (force->dimension == 3) if (domain->dimension == 3)
half_stencil = &Neighbor::stencil_half_3d_no_newton_multi; half_stencil = &Neighbor::stencil_half_3d_no_newton_multi;
else else
half_stencil = &Neighbor::stencil_half_2d_no_newton_multi; half_stencil = &Neighbor::stencil_half_2d_no_newton_multi;
@ -623,13 +623,13 @@ void Neighbor::init()
half_stencil = &Neighbor::stencil_none; half_stencil = &Neighbor::stencil_none;
} else if (triclinic) { } else if (triclinic) {
half_build = &Neighbor::half_bin_newton_multi_tri; half_build = &Neighbor::half_bin_newton_multi_tri;
if (force->dimension == 3) if (domain->dimension == 3)
half_stencil = &Neighbor::stencil_half_3d_newton_multi_tri; half_stencil = &Neighbor::stencil_half_3d_newton_multi_tri;
else else
half_stencil = &Neighbor::stencil_half_2d_newton_multi_tri; half_stencil = &Neighbor::stencil_half_2d_newton_multi_tri;
} else { } else {
half_build = &Neighbor::half_bin_newton_multi; half_build = &Neighbor::half_bin_newton_multi;
if (force->dimension == 3) if (domain->dimension == 3)
half_stencil = &Neighbor::stencil_half_3d_newton_multi; half_stencil = &Neighbor::stencil_half_3d_newton_multi;
else else
half_stencil = &Neighbor::stencil_half_2d_newton_multi; half_stencil = &Neighbor::stencil_half_2d_newton_multi;
@ -644,13 +644,13 @@ void Neighbor::init()
if (style == NSQ) full_build = &Neighbor::full_nsq; if (style == NSQ) full_build = &Neighbor::full_nsq;
else if (style == BIN) { else if (style == BIN) {
full_build = &Neighbor::full_bin; full_build = &Neighbor::full_bin;
if (force->dimension == 3) if (domain->dimension == 3)
full_stencil = &Neighbor::stencil_full_3d; full_stencil = &Neighbor::stencil_full_3d;
else else
full_stencil = &Neighbor::stencil_full_2d; full_stencil = &Neighbor::stencil_full_2d;
} else { } else {
full_build = &Neighbor::full_bin_multi; full_build = &Neighbor::full_bin_multi;
if (force->dimension == 3) if (domain->dimension == 3)
full_stencil = &Neighbor::stencil_full_3d_multi; full_stencil = &Neighbor::stencil_full_3d_multi;
else else
full_stencil = &Neighbor::stencil_full_2d_multi; full_stencil = &Neighbor::stencil_full_2d_multi;
@ -1001,7 +1001,7 @@ void Neighbor::setup_bins()
nbinx = static_cast<int> (bbox[0]*binsizeinv); nbinx = static_cast<int> (bbox[0]*binsizeinv);
nbiny = static_cast<int> (bbox[1]*binsizeinv); nbiny = static_cast<int> (bbox[1]*binsizeinv);
if (force->dimension == 3) if (domain->dimension == 3)
nbinz = static_cast<int> (bbox[2]*binsizeinv); nbinz = static_cast<int> (bbox[2]*binsizeinv);
else nbinz = 1; else nbinz = 1;

View File

@ -117,7 +117,7 @@ void Pair::init()
if (offset_flag && tail_flag) if (offset_flag && tail_flag)
error->all("Cannot have both pair_modify shift and tail set to yes"); error->all("Cannot have both pair_modify shift and tail set to yes");
if (tail_flag && force->dimension == 2) if (tail_flag && domain->dimension == 2)
error->all("Cannot use pair tail corrections with 2d simulations"); error->all("Cannot use pair tail corrections with 2d simulations");
if (tail_flag && domain->nonperiodic && comm->me == 0) if (tail_flag && domain->nonperiodic && comm->me == 0)
error->warning("Using pair tail corrections with nonperiodic system"); error->warning("Using pair tail corrections with nonperiodic system");

View File

@ -71,7 +71,7 @@ void ReadData::command(int narg, char **arg)
if (domain->box_exist) if (domain->box_exist)
error->all("Cannot read_data after simulation box is defined"); error->all("Cannot read_data after simulation box is defined");
if (force->dimension == 2 && domain->zperiodic == 0) if (domain->dimension == 2 && domain->zperiodic == 0)
error->all("Cannot run 2d simulation with nonperiodic Z dimension"); error->all("Cannot run 2d simulation with nonperiodic Z dimension");
// scan data file to determine max topology needed per atom // scan data file to determine max topology needed per atom

View File

@ -378,10 +378,10 @@ void ReadRestart::header()
} else if (flag == DIMENSION) { } else if (flag == DIMENSION) {
int dimension = read_int(); int dimension = read_int();
if (dimension != force->dimension && me == 0) if (dimension != domain->dimension && me == 0)
error->warning("Resetting dimension to restart file value"); error->warning("Resetting dimension to restart file value");
force->dimension = dimension; domain->dimension = dimension;
if (force->dimension == 2 && domain->zperiodic == 0) if (domain->dimension == 2 && domain->zperiodic == 0)
error->all("Cannot run 2d simulation with nonperiodic Z dimension"); error->all("Cannot run 2d simulation with nonperiodic Z dimension");
// read nprocs_file from restart file, warn if different // read nprocs_file from restart file, warn if different

View File

@ -62,7 +62,7 @@ void Replicate::command(int narg, char **arg)
// error and warning checks // error and warning checks
if (nx <= 0 || ny <= 0 || nz <= 0) error->all("Illegal replicate command"); if (nx <= 0 || ny <= 0 || nz <= 0) error->all("Illegal replicate command");
if (force->dimension == 2 && nz != 1) if (domain->dimension == 2 && nz != 1)
error->all("Cannot replicate 2d simulation in z dimension"); error->all("Cannot replicate 2d simulation in z dimension");
if ((nx > 1 && domain->xperiodic == 0) || if ((nx > 1 && domain->xperiodic == 0) ||
(ny > 1 && domain->yperiodic == 0) || (ny > 1 && domain->yperiodic == 0) ||

View File

@ -26,6 +26,7 @@
#include "force.h" #include "force.h"
#include "pair.h" #include "pair.h"
#include "random_park.h" #include "random_park.h"
#include "math_extra.h"
#include "error.h" #include "error.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -94,7 +95,7 @@ void Set::command(int narg, char **arg)
} else if (strcmp(arg[iarg],"mol") == 0) { } else if (strcmp(arg[iarg],"mol") == 0) {
if (iarg+2 > narg) error->all("Illegal set command"); if (iarg+2 > narg) error->all("Illegal set command");
ivalue = atoi(arg[iarg+1]); ivalue = atoi(arg[iarg+1]);
if (atom->molecule == NULL) if (!atom->molecule_flag)
error->all("Cannot set this attribute for this atom style"); error->all("Cannot set this attribute for this atom style");
set(MOLECULE); set(MOLECULE);
iarg += 2; iarg += 2;
@ -131,7 +132,7 @@ void Set::command(int narg, char **arg)
} else if (strcmp(arg[iarg],"charge") == 0) { } else if (strcmp(arg[iarg],"charge") == 0) {
if (iarg+2 > narg) error->all("Illegal set command"); if (iarg+2 > narg) error->all("Illegal set command");
dvalue = atof(arg[iarg+1]); dvalue = atof(arg[iarg+1]);
if (atom->q == NULL) if (!atom->q_flag)
error->all("Cannot set this attribute for this atom style"); error->all("Cannot set this attribute for this atom style");
set(CHARGE); set(CHARGE);
iarg += 2; iarg += 2;
@ -140,31 +141,32 @@ void Set::command(int narg, char **arg)
xvalue = atof(arg[iarg+1]); xvalue = atof(arg[iarg+1]);
yvalue = atof(arg[iarg+2]); yvalue = atof(arg[iarg+2]);
zvalue = atof(arg[iarg+3]); zvalue = atof(arg[iarg+3]);
if (atom->mu == NULL || atom->dipole == NULL) if (!atom->mu_flag || atom->dipole == NULL)
error->all("Cannot set this attribute for this atom style"); error->all("Cannot set this attribute for this atom style");
set(DIPOLE); set(DIPOLE);
iarg += 4; iarg += 4;
} else if (strcmp(arg[iarg],"dipole/random") == 0) { } else if (strcmp(arg[iarg],"dipole/random") == 0) {
if (iarg+2 > narg) error->all("Illegal set command"); if (iarg+2 > narg) error->all("Illegal set command");
ivalue = atoi(arg[iarg+1]); ivalue = atoi(arg[iarg+1]);
if (atom->mu == NULL || atom->shape == NULL) if (!atom->mu_flag || atom->shape == NULL)
error->all("Cannot set this attribute for this atom style"); error->all("Cannot set this attribute for this atom style");
if (ivalue <= 0) error->all("Invalid random number seed in set command"); if (ivalue <= 0) error->all("Invalid random number seed in set command");
setrandom(DIPOLE_RANDOM); setrandom(DIPOLE_RANDOM);
iarg += 2; iarg += 2;
} else if (strcmp(arg[iarg],"quat") == 0) { } else if (strcmp(arg[iarg],"quat") == 0) {
if (iarg+4 > narg) error->all("Illegal set command"); if (iarg+5 > narg) error->all("Illegal set command");
xvalue = atof(arg[iarg+1]); xvalue = atof(arg[iarg+1]);
yvalue = atof(arg[iarg+2]); yvalue = atof(arg[iarg+2]);
zvalue = atof(arg[iarg+3]); zvalue = atof(arg[iarg+3]);
if (atom->quat == NULL) wvalue = atof(arg[iarg+4]);
if (!atom->quat_flag)
error->all("Cannot set this attribute for this atom style"); error->all("Cannot set this attribute for this atom style");
set(QUAT); set(QUAT);
iarg += 4; iarg += 5;
} else if (strcmp(arg[iarg],"quat/random") == 0) { } else if (strcmp(arg[iarg],"quat/random") == 0) {
if (iarg+2 > narg) error->all("Illegal set command"); if (iarg+2 > narg) error->all("Illegal set command");
ivalue = atoi(arg[iarg+1]); ivalue = atoi(arg[iarg+1]);
if (atom->quat == NULL) if (!atom->quat_flag)
error->all("Cannot set this attribute for this atom style"); error->all("Cannot set this attribute for this atom style");
if (ivalue <= 0) error->all("Invalid random number seed in set command"); if (ivalue <= 0) error->all("Invalid random number seed in set command");
setrandom(QUAT_RANDOM); setrandom(QUAT_RANDOM);
@ -305,11 +307,15 @@ void Set::set(int keyword)
} }
} else if (keyword == QUAT) { } else if (keyword == QUAT) {
// need to set orientation correctly and normalize quat double PI = 4.0*atan(1.0);
double theta2 = 0.5 * PI * wvalue/180.0;
double sintheta2 = sin(theta2);
double **quat = atom->quat; double **quat = atom->quat;
quat[i][0] = xvalue; quat[i][0] = cos(theta2);
quat[i][1] = yvalue; quat[i][1] = xvalue * sintheta2;
quat[i][2] = zvalue; quat[i][2] = yvalue * sintheta2;
quat[i][3] = zvalue * sintheta2;
MathExtra::normalize4(quat[i]);
} }
count++; count++;
} }
@ -345,55 +351,90 @@ void Set::setrandom(int keyword)
count++; count++;
} }
// set dipole moments to random orientations // set dipole moments to random orientations in 3d or 2d
// dipole length is determined by dipole type array // dipole length is determined by dipole type array
} else if (keyword == DIPOLE) { } else if (keyword == DIPOLE_RANDOM) {
int *type = atom->type; int *type = atom->type;
double *dipole = atom->dipole; double *dipole = atom->dipole;
double **mu = atom->mu; double **mu = atom->mu;
int nlocal = atom->nlocal; int nlocal = atom->nlocal;
double msq,scale; double msq,scale;
for (i = 0; i < nlocal; i++)
if (select[i]) { if (domain->dimension == 3) {
if (dipole[type[i]] > 0.0) { for (i = 0; i < nlocal; i++)
random->reset(seed,x[i]); if (select[i]) {
mu[i][0] = random->uniform() - 0.5; if (dipole[type[i]] > 0.0) {
mu[i][1] = random->uniform() - 0.5; random->reset(seed,x[i]);
mu[i][2] = random->uniform() - 0.5; mu[i][0] = random->uniform() - 0.5;
msq = mu[i][0]*mu[i][0] + mu[i][1]*mu[i][1] + mu[i][2]*mu[i][2]; mu[i][1] = random->uniform() - 0.5;
scale = dipole[type[i]]/sqrt(msq); mu[i][2] = random->uniform() - 0.5;
mu[i][0] *= scale; msq = mu[i][0]*mu[i][0] + mu[i][1]*mu[i][1] + mu[i][2]*mu[i][2];
mu[i][1] *= scale; scale = dipole[type[i]]/sqrt(msq);
mu[i][2] *= scale; mu[i][0] *= scale;
count++; mu[i][1] *= scale;
mu[i][2] *= scale;
count++;
}
} }
}
// set quaternions to random orientations } else {
for (i = 0; i < nlocal; i++)
if (select[i]) {
if (dipole[type[i]] > 0.0) {
random->reset(seed,x[i]);
mu[i][0] = random->uniform() - 0.5;
mu[i][1] = random->uniform() - 0.5;
mu[i][2] = 0.0;
msq = mu[i][0]*mu[i][0] + mu[i][1]*mu[i][1];
scale = dipole[type[i]]/sqrt(msq);
mu[i][0] *= scale;
mu[i][1] *= scale;
count++;
}
}
}
} else if (keyword == QUAT) { // set quaternions to random orientations in 3d or 2d
// no need to normalize quats since creations algorithms already do
} else if (keyword == QUAT_RANDOM) {
double **quat = atom->quat; double **quat = atom->quat;
int nlocal = atom->nlocal; int nlocal = atom->nlocal;
double s,t1,t2,theta1,theta2; if (domain->dimension == 3) {
double PI = 4.0*atan(1.0); double s,t1,t2,theta1,theta2;
double PI = 4.0*atan(1.0);
for (i = 0; i < nlocal; i++)
if (select[i]) {
random->reset(seed,x[i]);
s = random->uniform();
t1 = sqrt(1.0-s);
t2 = sqrt(s);
theta1 = 2.0*PI*random->uniform();
theta2 = 2.0*PI*random->uniform();
quat[i][0] = cos(theta2)*t2;
quat[i][1] = sin(theta1)*t1;
quat[i][2] = cos(theta1)*t1;
quat[i][3] = sin(theta2)*t2;
count++;
}
for (i = 0; i < nlocal; i++) } else {
if (select[i]) { double theta2;
random->reset(seed,x[i]); double PI = 4.0*atan(1.0);
s = random->uniform(); for (i = 0; i < nlocal; i++)
t1 = sqrt(1.0-s); if (select[i]) {
t2 = sqrt(s); random->reset(seed,x[i]);
theta1 = 2.0*PI*random->uniform(); theta2 = PI*random->uniform();
theta2 = 2.0*PI*random->uniform(); quat[i][0] = cos(theta2);
quat[i][0] = cos(theta2)*t2; quat[i][1] = 0.0;
quat[i][1] = sin(theta1)*t1; quat[i][2] = 0.0;
quat[i][2] = cos(theta1)*t1; quat[i][3] = sin(theta2);
quat[i][3] = sin(theta2)*t2; count++;
count++; }
} }
} }
delete random; delete random;

View File

@ -27,7 +27,7 @@ class Set : protected Pointers {
char *id; char *id;
int *select; int *select;
int style,ivalue,newtype,count; int style,ivalue,newtype,count;
double dvalue,xvalue,yvalue,zvalue,fraction; double dvalue,xvalue,yvalue,zvalue,wvalue,fraction;
void selection(int); void selection(int);
void set(int); void set(int);

View File

@ -154,6 +154,7 @@ DumpStyle(xyz,DumpXYZ)
#include "fix_nve.h" #include "fix_nve.h"
#include "fix_nve_noforce.h" #include "fix_nve_noforce.h"
#include "fix_nvt.h" #include "fix_nvt.h"
#include "fix_nvt_sllod.h"
#include "fix_plane_force.h" #include "fix_plane_force.h"
#include "fix_print.h" #include "fix_print.h"
#include "fix_orient_fcc.h" #include "fix_orient_fcc.h"
@ -201,6 +202,7 @@ FixStyle(npt,FixNPT)
FixStyle(nve,FixNVE) FixStyle(nve,FixNVE)
FixStyle(nve,FixNVENoforce) FixStyle(nve,FixNVENoforce)
FixStyle(nvt,FixNVT) FixStyle(nvt,FixNVT)
FixStyle(nvt/sllod,FixNVTSlodd)
FixStyle(orient/fcc,FixOrientFCC) FixStyle(orient/fcc,FixOrientFCC)
FixStyle(print,FixPrint) FixStyle(print,FixPrint)
FixStyle(planeforce,FixPlaneForce) FixStyle(planeforce,FixPlaneForce)

View File

@ -176,7 +176,7 @@ void Velocity::create(int narg, char **arg)
int *mask = atom->mask; int *mask = atom->mask;
double *mass = atom->mass; double *mass = atom->mass;
double *rmass = atom->rmass; double *rmass = atom->rmass;
int dimension = force->dimension; int dimension = domain->dimension;
int m; int m;
double vx,vy,vz,factor; double vx,vy,vz,factor;
@ -360,7 +360,7 @@ void Velocity::set(int narg, char **arg)
double **v = atom->v; double **v = atom->v;
int *mask = atom->mask; int *mask = atom->mask;
int nlocal = atom->nlocal; int nlocal = atom->nlocal;
int dimension = force->dimension; int dimension = domain->dimension;
for (int i = 0; i < nlocal; i++) { for (int i = 0; i < nlocal; i++) {
if (mask[i] & groupbit) { if (mask[i] & groupbit) {
@ -427,7 +427,7 @@ void Velocity::ramp(int narg, char **arg)
else if (strcmp(arg[0],"vz") == 0) v_dim = 2; else if (strcmp(arg[0],"vz") == 0) v_dim = 2;
else error->all("Illegal velocity command"); else error->all("Illegal velocity command");
if (v_dim == 2 && force->dimension == 2) if (v_dim == 2 && domain->dimension == 2)
error->all("Velocity ramp in z for a 2d problem"); error->all("Velocity ramp in z for a 2d problem");
double v_lo,v_hi; double v_lo,v_hi;

View File

@ -242,7 +242,7 @@ void WriteRestart::header()
write_char(VERSION,universe->version); write_char(VERSION,universe->version);
write_char(UNITS,update->unit_style); write_char(UNITS,update->unit_style);
write_int(NTIMESTEP,update->ntimestep); write_int(NTIMESTEP,update->ntimestep);
write_int(DIMENSION,force->dimension); write_int(DIMENSION,domain->dimension);
write_int(NPROCS,nprocs); write_int(NPROCS,nprocs);
write_int(PROCGRID_0,comm->procgrid[0]); write_int(PROCGRID_0,comm->procgrid[0]);
write_int(PROCGRID_1,comm->procgrid[1]); write_int(PROCGRID_1,comm->procgrid[1]);