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

This commit is contained in:
sjplimp
2011-04-15 22:25:19 +00:00
parent 74c219743e
commit 8ff0659bae
62 changed files with 1016 additions and 822 deletions

View File

@ -30,6 +30,7 @@
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
#define DELTA 10000 #define DELTA 10000
#define DELTA_BONUS 10000
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -41,17 +42,27 @@ AtomVecEllipsoid::AtomVecEllipsoid(LAMMPS *lmp, int narg, char **arg) :
comm_x_only = comm_f_only = 0; comm_x_only = comm_f_only = 0;
size_forward = 7; size_forward = 7;
size_reverse = 6; size_reverse = 6;
size_border = 13; size_border = 14;
size_velocity = 6; size_velocity = 6;
size_data_atom = 13; size_data_atom = 7;
size_data_vel = 7; size_data_vel = 7;
xcol_data = 7; size_data_bonus = 8;
xcol_data = 5;
atom->ellipsoid_flag = 1; atom->ellipsoid_flag = 1;
atom->shape_flag = atom->rmass_flag = atom->quat_flag = atom->rmass_flag = atom->angmom_flag = atom->torque_flag = 1;
atom->angmom_flag = atom->torque_flag = 1;
PI = 4.0*atan(1.0); PI = 4.0*atan(1.0);
nlocal_bonus = nghost_bonus = nmax_bonus = 0;
bonus = NULL;
}
/* ---------------------------------------------------------------------- */
AtomVecEllipsoid::~AtomVecEllipsoid()
{
memory->sfree(bonus);
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
@ -76,11 +87,10 @@ void AtomVecEllipsoid::grow(int n)
v = memory->grow(atom->v,nmax,3,"atom:v"); v = memory->grow(atom->v,nmax,3,"atom:v");
f = memory->grow(atom->f,nmax,3,"atom:f"); f = memory->grow(atom->f,nmax,3,"atom:f");
shape = memory->grow(atom->shape,nmax,3,"atom:shape");
rmass = memory->grow(atom->rmass,nmax,"atom:rmass"); rmass = memory->grow(atom->rmass,nmax,"atom:rmass");
quat = memory->grow(atom->quat,nmax,4,"atom:quat");
angmom = memory->grow(atom->angmom,nmax,3,"atom:angmom"); angmom = memory->grow(atom->angmom,nmax,3,"atom:angmom");
torque = memory->grow(atom->torque,nmax,3,"atom:torque"); torque = memory->grow(atom->torque,nmax,3,"atom:torque");
ellipsoid = memory->grow(atom->ellipsoid,nmax,"atom:ellipsoid");
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++)
@ -96,13 +106,29 @@ void AtomVecEllipsoid::grow_reset()
tag = atom->tag; type = atom->type; tag = atom->tag; type = atom->type;
mask = atom->mask; image = atom->image; mask = atom->mask; image = atom->image;
x = atom->x; v = atom->v; f = atom->f; x = atom->x; v = atom->v; f = atom->f;
shape = atom->shape; rmass = atom->rmass; rmass = atom->rmass; angmom = atom->angmom; torque = atom->torque;
quat = atom->quat; angmom = atom->angmom; torque = atom->torque;
} }
/* ---------------------------------------------------------------------- */ /* ----------------------------------------------------------------------
grow Bonus data for style-specific atom data
------------------------------------------------------------------------- */
void AtomVecEllipsoid::copy(int i, int j) void AtomVecEllipsoid::grow_bonus()
{
nmax_bonus += DELTA_BONUS;
if (nmax_bonus < 0 || nmax_bonus > MAXSMALLINT)
error->one("Per-processor system is too big");
bonus = (Bonus *) memory->srealloc(bonus,nmax_bonus*sizeof(Bonus),
"atom:bonus");
}
/* ----------------------------------------------------------------------
copy atom I info to atom J
if delflag and atom J has style-specific data, then delete it
------------------------------------------------------------------------- */
void AtomVecEllipsoid::copy(int i, int j, int delflag)
{ {
tag[j] = tag[i]; tag[j] = tag[i];
type[j] = type[i]; type[j] = type[i];
@ -115,23 +141,90 @@ void AtomVecEllipsoid::copy(int i, int j)
v[j][1] = v[i][1]; v[j][1] = v[i][1];
v[j][2] = v[i][2]; v[j][2] = v[i][2];
shape[j][0] = shape[i][0];
shape[j][1] = shape[i][1];
shape[j][2] = shape[i][2];
rmass[j] = rmass[i]; rmass[j] = rmass[i];
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][0] = angmom[i][0];
angmom[j][1] = angmom[i][1]; angmom[j][1] = angmom[i][1];
angmom[j][2] = angmom[i][2]; angmom[j][2] = angmom[i][2];
if (delflag && ellipsoid[j] >= 0) {
copy_bonus(nlocal_bonus-1,ellipsoid[j]);
nlocal_bonus--;
}
ellipsoid[j] = ellipsoid[i];
if (ellipsoid[j] >= 0) bonus[ellipsoid[j]].ilocal = j;
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]]->copy_arrays(i,j); modify->fix[atom->extra_grow[iextra]]->copy_arrays(i,j);
} }
/* ----------------------------------------------------------------------
copy Bonus for I to J, effectively deleting the J entry
insure index pointers between per-atom and bonus data are updated
------------------------------------------------------------------------- */
void AtomVecEllipsoid::copy_bonus(int i, int j)
{
double *ishape = bonus[i].shape;
double *iquat = bonus[i].quat;
double *jshape = bonus[j].shape;
double *jquat = bonus[j].quat;
jshape[0] = ishape[0];
jshape[1] = ishape[1];
jshape[2] = ishape[2];
jquat[0] = iquat[0];
jquat[1] = iquat[1];
jquat[2] = iquat[2];
jquat[3] = iquat[3];
int m = bonus[i].ilocal;
bonus[j].ilocal = m;
ellipsoid[m] = j;
}
/* ----------------------------------------------------------------------
set shape values in Bonus data for particle I
this may create or delete entry in Bonus data
------------------------------------------------------------------------- */
void AtomVecEllipsoid::set_bonus(int i,
double shapex, double shapey, double shapez)
{
if (ellipsoid[i] < 0) {
if (shapex == 0.0 && shapey == 0.0 && shapez == 0.0) return;
if (nlocal_bonus == nmax_bonus) grow_bonus();
double *shape = bonus[nlocal_bonus].shape;
double *quat = bonus[nlocal_bonus].quat;
shape[0] = shapex;
shape[1] = shapey;
shape[2] = shapez;
quat[0] = 1.0;
quat[1] = 0.0;
quat[2] = 0.0;
quat[3] = 0.0;
bonus[nlocal_bonus].ilocal = i;
ellipsoid[i] = nlocal_bonus++;
} else if (shapex == 0.0 && shapey == 0.0 && shapez == 0.0) {
copy_bonus(nlocal_bonus-1,ellipsoid[i]);
nlocal_bonus--;
ellipsoid[i] = -1;
} else {
double *shape = bonus[ellipsoid[i]].shape;
shape[0] = shapex;
shape[1] = shapey;
shape[2] = shapez;
}
}
/* ----------------------------------------------------------------------
clear ghost info in Bonus data
called before ghosts are recommunicated in comm and irregular
------------------------------------------------------------------------- */
void AtomVecEllipsoid::clear_bonus()
{
nghost_bonus = 0;
}
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
int AtomVecEllipsoid::pack_comm(int n, int *list, double *buf, int AtomVecEllipsoid::pack_comm(int n, int *list, double *buf,
@ -139,6 +232,7 @@ int AtomVecEllipsoid::pack_comm(int n, int *list, double *buf,
{ {
int i,j,m; int i,j,m;
double dx,dy,dz; double dx,dy,dz;
double *quat;
m = 0; m = 0;
if (pbc_flag == 0) { if (pbc_flag == 0) {
@ -147,10 +241,13 @@ int AtomVecEllipsoid::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];
buf[m++] = quat[j][0]; if (ellipsoid[j] >= 0) {
buf[m++] = quat[j][1]; quat = bonus[ellipsoid[j]].quat;
buf[m++] = quat[j][2]; buf[m++] = quat[0];
buf[m++] = quat[j][3]; buf[m++] = quat[1];
buf[m++] = quat[2];
buf[m++] = quat[3];
}
} }
} else { } else {
if (domain->triclinic == 0) { if (domain->triclinic == 0) {
@ -167,10 +264,13 @@ int AtomVecEllipsoid::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;
buf[m++] = quat[j][0]; if (ellipsoid[j] >= 0) {
buf[m++] = quat[j][1]; quat = bonus[ellipsoid[j]].quat;
buf[m++] = quat[j][2]; buf[m++] = quat[0];
buf[m++] = quat[j][3]; buf[m++] = quat[1];
buf[m++] = quat[2];
buf[m++] = quat[3];
}
} }
} }
return m; return m;
@ -183,6 +283,7 @@ int AtomVecEllipsoid::pack_comm_vel(int n, int *list, double *buf,
{ {
int i,j,m; int i,j,m;
double dx,dy,dz,dvx,dvy,dvz; double dx,dy,dz,dvx,dvy,dvz;
double *quat;
m = 0; m = 0;
if (pbc_flag == 0) { if (pbc_flag == 0) {
@ -191,10 +292,13 @@ int AtomVecEllipsoid::pack_comm_vel(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];
buf[m++] = quat[j][0]; if (ellipsoid[j] >= 0) {
buf[m++] = quat[j][1]; quat = bonus[ellipsoid[j]].quat;
buf[m++] = quat[j][2]; buf[m++] = quat[0];
buf[m++] = quat[j][3]; buf[m++] = quat[1];
buf[m++] = quat[2];
buf[m++] = quat[3];
}
buf[m++] = v[j][0]; buf[m++] = v[j][0];
buf[m++] = v[j][1]; buf[m++] = v[j][1];
buf[m++] = v[j][2]; buf[m++] = v[j][2];
@ -218,10 +322,13 @@ int AtomVecEllipsoid::pack_comm_vel(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;
buf[m++] = quat[j][0]; if (ellipsoid[j] >= 0) {
buf[m++] = quat[j][1]; quat = bonus[ellipsoid[j]].quat;
buf[m++] = quat[j][2]; buf[m++] = quat[0];
buf[m++] = quat[j][3]; buf[m++] = quat[1];
buf[m++] = quat[2];
buf[m++] = quat[3];
}
buf[m++] = v[j][0]; buf[m++] = v[j][0];
buf[m++] = v[j][1]; buf[m++] = v[j][1];
buf[m++] = v[j][2]; buf[m++] = v[j][2];
@ -238,10 +345,13 @@ int AtomVecEllipsoid::pack_comm_vel(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;
buf[m++] = quat[j][0]; if (ellipsoid[j] >= 0) {
buf[m++] = quat[j][1]; quat = bonus[ellipsoid[j]].quat;
buf[m++] = quat[j][2]; buf[m++] = quat[0];
buf[m++] = quat[j][3]; buf[m++] = quat[1];
buf[m++] = quat[2];
buf[m++] = quat[3];
}
if (mask[i] & deform_groupbit) { if (mask[i] & deform_groupbit) {
buf[m++] = v[j][0] + dvx; buf[m++] = v[j][0] + dvx;
buf[m++] = v[j][1] + dvy; buf[m++] = v[j][1] + dvy;
@ -265,14 +375,18 @@ int AtomVecEllipsoid::pack_comm_vel(int n, int *list, double *buf,
int AtomVecEllipsoid::pack_comm_hybrid(int n, int *list, double *buf) int AtomVecEllipsoid::pack_comm_hybrid(int n, int *list, double *buf)
{ {
int i,j,m; int i,j,m;
double *quat;
m = 0; m = 0;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
j = list[i]; j = list[i];
buf[m++] = quat[i][0]; if (ellipsoid[j] >= 0) {
buf[m++] = quat[i][1]; quat = bonus[ellipsoid[j]].quat;
buf[m++] = quat[i][2]; buf[m++] = quat[0];
buf[m++] = quat[i][3]; buf[m++] = quat[1];
buf[m++] = quat[2];
buf[m++] = quat[3];
}
} }
return m; return m;
} }
@ -282,6 +396,7 @@ int AtomVecEllipsoid::pack_comm_hybrid(int n, int *list, double *buf)
void AtomVecEllipsoid::unpack_comm(int n, int first, double *buf) void AtomVecEllipsoid::unpack_comm(int n, int first, double *buf)
{ {
int i,m,last; int i,m,last;
double *quat;
m = 0; m = 0;
last = first + n; last = first + n;
@ -289,10 +404,13 @@ void AtomVecEllipsoid::unpack_comm(int n, int first, double *buf)
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++];
quat[i][0] = buf[m++]; if (ellipsoid[i] >= 0) {
quat[i][1] = buf[m++]; quat = bonus[ellipsoid[i]].quat;
quat[i][2] = buf[m++]; quat[0] = buf[m++];
quat[i][3] = buf[m++]; quat[1] = buf[m++];
quat[2] = buf[m++];
quat[3] = buf[m++];
}
} }
} }
@ -301,6 +419,7 @@ void AtomVecEllipsoid::unpack_comm(int n, int first, double *buf)
void AtomVecEllipsoid::unpack_comm_vel(int n, int first, double *buf) void AtomVecEllipsoid::unpack_comm_vel(int n, int first, double *buf)
{ {
int i,m,last; int i,m,last;
double *quat;
m = 0; m = 0;
last = first + n; last = first + n;
@ -308,10 +427,13 @@ void AtomVecEllipsoid::unpack_comm_vel(int n, int first, double *buf)
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++];
quat[i][0] = buf[m++]; if (ellipsoid[i] >= 0) {
quat[i][1] = buf[m++]; quat = bonus[ellipsoid[i]].quat;
quat[i][2] = buf[m++]; quat[0] = buf[m++];
quat[i][3] = buf[m++]; quat[1] = buf[m++];
quat[2] = buf[m++];
quat[3] = buf[m++];
}
v[i][0] = buf[m++]; v[i][0] = buf[m++];
v[i][1] = buf[m++]; v[i][1] = buf[m++];
v[i][2] = buf[m++]; v[i][2] = buf[m++];
@ -326,14 +448,18 @@ void AtomVecEllipsoid::unpack_comm_vel(int n, int first, double *buf)
int AtomVecEllipsoid::unpack_comm_hybrid(int n, int first, double *buf) int AtomVecEllipsoid::unpack_comm_hybrid(int n, int first, double *buf)
{ {
int i,m,last; int i,m,last;
double *quat;
m = 0; m = 0;
last = first + n; last = first + n;
for (i = first; i < last; i++) { for (i = first; i < last; i++) {
quat[i][0] = buf[m++]; if (ellipsoid[i] >= 0) {
quat[i][1] = buf[m++]; quat = bonus[ellipsoid[i]].quat;
quat[i][2] = buf[m++]; quat[0] = buf[m++];
quat[i][3] = buf[m++]; quat[1] = buf[m++];
quat[2] = buf[m++];
quat[3] = buf[m++];
}
} }
return m; return m;
} }
@ -414,6 +540,7 @@ int AtomVecEllipsoid::pack_border(int n, int *list, double *buf,
{ {
int i,j,m; int i,j,m;
double dx,dy,dz; double dx,dy,dz;
double *shape,*quat;
m = 0; m = 0;
if (pbc_flag == 0) { if (pbc_flag == 0) {
@ -425,13 +552,19 @@ int AtomVecEllipsoid::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++] = shape[j][0]; if (ellipsoid[j] < 0) buf[m++] = 0;
buf[m++] = shape[j][1]; else {
buf[m++] = shape[j][2]; buf[m++] = 1;
buf[m++] = quat[j][0]; shape = bonus[ellipsoid[j]].shape;
buf[m++] = quat[j][1]; quat = bonus[ellipsoid[j]].quat;
buf[m++] = quat[j][2]; buf[m++] = shape[0];
buf[m++] = quat[j][3]; buf[m++] = shape[1];
buf[m++] = shape[2];
buf[m++] = quat[0];
buf[m++] = quat[1];
buf[m++] = quat[2];
buf[m++] = quat[3];
}
} }
} else { } else {
if (domain->triclinic == 0) { if (domain->triclinic == 0) {
@ -451,13 +584,19 @@ int AtomVecEllipsoid::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++] = shape[j][0]; if (ellipsoid[j] < 0) buf[m++] = 0;
buf[m++] = shape[j][1]; else {
buf[m++] = shape[j][2]; buf[m++] = 1;
buf[m++] = quat[j][0]; shape = bonus[ellipsoid[j]].shape;
buf[m++] = quat[j][1]; quat = bonus[ellipsoid[j]].quat;
buf[m++] = quat[j][2]; buf[m++] = shape[0];
buf[m++] = quat[j][3]; buf[m++] = shape[1];
buf[m++] = shape[2];
buf[m++] = quat[0];
buf[m++] = quat[1];
buf[m++] = quat[2];
buf[m++] = quat[3];
}
} }
} }
return m; return m;
@ -470,6 +609,7 @@ int AtomVecEllipsoid::pack_border_vel(int n, int *list, double *buf,
{ {
int i,j,m; int i,j,m;
double dx,dy,dz,dvx,dvy,dvz; double dx,dy,dz,dvx,dvy,dvz;
double *shape,*quat;
m = 0; m = 0;
if (pbc_flag == 0) { if (pbc_flag == 0) {
@ -481,13 +621,19 @@ int AtomVecEllipsoid::pack_border_vel(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++] = shape[j][0]; if (ellipsoid[j] < 0) buf[m++] = 0;
buf[m++] = shape[j][1]; else {
buf[m++] = shape[j][2]; buf[m++] = 1;
buf[m++] = quat[j][0]; shape = bonus[ellipsoid[j]].shape;
buf[m++] = quat[j][1]; quat = bonus[ellipsoid[j]].quat;
buf[m++] = quat[j][2]; buf[m++] = shape[0];
buf[m++] = quat[j][3]; buf[m++] = shape[1];
buf[m++] = shape[2];
buf[m++] = quat[0];
buf[m++] = quat[1];
buf[m++] = quat[2];
buf[m++] = quat[3];
}
buf[m++] = v[j][0]; buf[m++] = v[j][0];
buf[m++] = v[j][1]; buf[m++] = v[j][1];
buf[m++] = v[j][2]; buf[m++] = v[j][2];
@ -514,13 +660,18 @@ int AtomVecEllipsoid::pack_border_vel(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++] = shape[j][0]; if (ellipsoid[j] < 0) buf[m++] = 0;
buf[m++] = shape[j][1]; else {
buf[m++] = shape[j][2]; buf[m++] = 1;
buf[m++] = quat[j][0]; quat = bonus[ellipsoid[j]].quat;
buf[m++] = quat[j][1]; buf[m++] = shape[0];
buf[m++] = quat[j][2]; buf[m++] = shape[1];
buf[m++] = quat[j][3]; buf[m++] = shape[2];
buf[m++] = quat[0];
buf[m++] = quat[1];
buf[m++] = quat[2];
buf[m++] = quat[3];
}
buf[m++] = v[j][0]; buf[m++] = v[j][0];
buf[m++] = v[j][1]; buf[m++] = v[j][1];
buf[m++] = v[j][2]; buf[m++] = v[j][2];
@ -540,13 +691,19 @@ int AtomVecEllipsoid::pack_border_vel(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++] = shape[j][0]; if (ellipsoid[j] < 0) buf[m++] = 0;
buf[m++] = shape[j][1]; else {
buf[m++] = shape[j][2]; buf[m++] = 1;
buf[m++] = quat[j][0]; shape = bonus[ellipsoid[j]].shape;
buf[m++] = quat[j][1]; quat = bonus[ellipsoid[j]].quat;
buf[m++] = quat[j][2]; buf[m++] = shape[0];
buf[m++] = quat[j][3]; buf[m++] = shape[1];
buf[m++] = shape[2];
buf[m++] = quat[0];
buf[m++] = quat[1];
buf[m++] = quat[2];
buf[m++] = quat[3];
}
if (mask[i] & deform_groupbit) { if (mask[i] & deform_groupbit) {
buf[m++] = v[j][0] + dvx; buf[m++] = v[j][0] + dvx;
buf[m++] = v[j][1] + dvy; buf[m++] = v[j][1] + dvy;
@ -570,17 +727,24 @@ int AtomVecEllipsoid::pack_border_vel(int n, int *list, double *buf,
int AtomVecEllipsoid::pack_border_hybrid(int n, int *list, double *buf) int AtomVecEllipsoid::pack_border_hybrid(int n, int *list, double *buf)
{ {
int i,j,m; int i,j,m;
double *shape,*quat;
m = 0; m = 0;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
j = list[i]; j = list[i];
buf[m++] = shape[j][0]; if (ellipsoid[j] < 0) buf[m++] = 0;
buf[m++] = shape[j][1]; else {
buf[m++] = shape[j][2]; buf[m++] = 1;
buf[m++] = quat[j][0]; shape = bonus[ellipsoid[j]].shape;
buf[m++] = quat[j][1]; quat = bonus[ellipsoid[j]].quat;
buf[m++] = quat[j][2]; buf[m++] = shape[0];
buf[m++] = quat[j][3]; buf[m++] = shape[1];
buf[m++] = shape[2];
buf[m++] = quat[0];
buf[m++] = quat[1];
buf[m++] = quat[2];
buf[m++] = quat[3];
}
} }
return m; return m;
} }
@ -589,7 +753,8 @@ int AtomVecEllipsoid::pack_border_hybrid(int n, int *list, double *buf)
void AtomVecEllipsoid::unpack_border(int n, int first, double *buf) void AtomVecEllipsoid::unpack_border(int n, int first, double *buf)
{ {
int i,m,last; int i,j,m,last;
double *shape,*quat;
m = 0; m = 0;
last = first + n; last = first + n;
@ -601,13 +766,24 @@ void AtomVecEllipsoid::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++]);
shape[i][0] = buf[m++]; ellipsoid[i] = static_cast<int> (buf[m++]);
shape[i][1] = buf[m++]; if (ellipsoid[i] < 0) ellipsoid[i] = 0;
shape[i][2] = buf[m++]; else {
quat[i][0] = buf[m++]; j = nlocal_bonus + nghost_bonus;
quat[i][1] = buf[m++]; if (j == nmax_bonus) grow_bonus();
quat[i][2] = buf[m++]; shape = bonus[j].shape;
quat[i][3] = buf[m++]; quat = bonus[j].quat;
shape[0] = buf[m++];
shape[1] = buf[m++];
shape[2] = buf[m++];
quat[0] = buf[m++];
quat[1] = buf[m++];
quat[2] = buf[m++];
quat[3] = buf[m++];
bonus[j].ilocal = i;
ellipsoid[i] = j;
nghost_bonus++;
}
} }
} }
@ -615,7 +791,8 @@ void AtomVecEllipsoid::unpack_border(int n, int first, double *buf)
void AtomVecEllipsoid::unpack_border_vel(int n, int first, double *buf) void AtomVecEllipsoid::unpack_border_vel(int n, int first, double *buf)
{ {
int i,m,last; int i,j,m,last;
double *shape,*quat;
m = 0; m = 0;
last = first + n; last = first + n;
@ -627,13 +804,24 @@ void AtomVecEllipsoid::unpack_border_vel(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++]);
shape[i][0] = buf[m++]; ellipsoid[i] = static_cast<int> (buf[m++]);
shape[i][1] = buf[m++]; if (ellipsoid[i] < 0) ellipsoid[i] = 0;
shape[i][2] = buf[m++]; else {
quat[i][0] = buf[m++]; j = nlocal_bonus + nghost_bonus;
quat[i][1] = buf[m++]; if (j == nmax_bonus) grow_bonus();
quat[i][2] = buf[m++]; shape = bonus[j].shape;
quat[i][3] = buf[m++]; quat = bonus[j].quat;
shape[0] = buf[m++];
shape[1] = buf[m++];
shape[2] = buf[m++];
quat[0] = buf[m++];
quat[1] = buf[m++];
quat[2] = buf[m++];
quat[3] = buf[m++];
bonus[j].ilocal = i;
ellipsoid[i] = j;
nghost_bonus++;
}
v[i][0] = buf[m++]; v[i][0] = buf[m++];
v[i][1] = buf[m++]; v[i][1] = buf[m++];
v[i][2] = buf[m++]; v[i][2] = buf[m++];
@ -647,18 +835,30 @@ void AtomVecEllipsoid::unpack_border_vel(int n, int first, double *buf)
int AtomVecEllipsoid::unpack_border_hybrid(int n, int first, double *buf) int AtomVecEllipsoid::unpack_border_hybrid(int n, int first, double *buf)
{ {
int i,m,last; int i,j,m,last;
double *shape,*quat;
m = 0; m = 0;
last = first + n; last = first + n;
for (i = first; i < last; i++) { for (i = first; i < last; i++) {
shape[i][0] = buf[m++]; ellipsoid[i] = static_cast<int> (buf[m++]);
shape[i][1] = buf[m++]; if (ellipsoid[i] < 0) ellipsoid[i] = 0;
shape[i][2] = buf[m++]; else {
quat[i][0] = buf[m++]; j = nlocal_bonus + nghost_bonus;
quat[i][1] = buf[m++]; if (j == nmax_bonus) grow_bonus();
quat[i][2] = buf[m++]; shape = bonus[j].shape;
quat[i][3] = buf[m++]; quat = bonus[j].quat;
shape[0] = buf[m++];
shape[1] = buf[m++];
shape[2] = buf[m++];
quat[0] = buf[m++];
quat[1] = buf[m++];
quat[2] = buf[m++];
quat[3] = buf[m++];
bonus[j].ilocal = i;
ellipsoid[i] = j;
nghost_bonus++;
}
} }
return m; return m;
} }
@ -682,18 +882,24 @@ int AtomVecEllipsoid::pack_exchange(int i, double *buf)
buf[m++] = mask[i]; buf[m++] = mask[i];
buf[m++] = image[i]; buf[m++] = image[i];
buf[m++] = shape[i][0];
buf[m++] = shape[i][1];
buf[m++] = shape[i][2];
buf[m++] = rmass[i]; buf[m++] = rmass[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][0];
buf[m++] = angmom[i][1]; buf[m++] = angmom[i][1];
buf[m++] = angmom[i][2]; buf[m++] = angmom[i][2];
if (ellipsoid[i] < 0) buf[m++] = 0;
else {
buf[m++] = 1;
int j = ellipsoid[i];
buf[m++] = bonus[j].shape[0];
buf[m++] = bonus[j].shape[1];
buf[m++] = bonus[j].shape[2];
buf[m++] = bonus[j].quat[0];
buf[m++] = bonus[j].quat[1];
buf[m++] = bonus[j].quat[2];
buf[m++] = bonus[j].quat[3];
}
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++)
m += modify->fix[atom->extra_grow[iextra]]->pack_exchange(i,&buf[m]); m += modify->fix[atom->extra_grow[iextra]]->pack_exchange(i,&buf[m]);
@ -721,18 +927,27 @@ int AtomVecEllipsoid::unpack_exchange(double *buf)
mask[nlocal] = static_cast<int> (buf[m++]); mask[nlocal] = static_cast<int> (buf[m++]);
image[nlocal] = static_cast<int> (buf[m++]); image[nlocal] = static_cast<int> (buf[m++]);
shape[nlocal][0] = buf[m++];
shape[nlocal][1] = buf[m++];
shape[nlocal][2] = buf[m++];
rmass[nlocal] = buf[m++]; rmass[nlocal] = 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][0] = buf[m++];
angmom[nlocal][1] = buf[m++]; angmom[nlocal][1] = buf[m++];
angmom[nlocal][2] = buf[m++]; angmom[nlocal][2] = buf[m++];
ellipsoid[nlocal] = static_cast<int> (buf[m++]);
if (ellipsoid[nlocal]) {
if (nlocal_bonus == nmax_bonus) grow_bonus();
double *shape = bonus[nlocal_bonus].shape;
double *quat = bonus[nlocal_bonus].quat;
shape[0] = buf[m++];
shape[1] = buf[m++];
shape[2] = buf[m++];
quat[0] = buf[m++];
quat[1] = buf[m++];
quat[2] = buf[m++];
quat[3] = buf[m++];
bonus[nlocal_bonus].ilocal = nlocal;
ellipsoid[nlocal] = nlocal_bonus++;
}
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++)
m += modify->fix[atom->extra_grow[iextra]]-> m += modify->fix[atom->extra_grow[iextra]]->
@ -751,8 +966,11 @@ int AtomVecEllipsoid::size_restart()
{ {
int i; int i;
int n = 0;
int nlocal = atom->nlocal; int nlocal = atom->nlocal;
int n = 22 * nlocal; for (i = 0; i < nlocal; i++)
if (ellipsoid[i] >= 0) n += 23;
else n += 16;
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++)
@ -763,7 +981,7 @@ int AtomVecEllipsoid::size_restart()
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
pack atom I's data for restart file including extra quantities pack atom I's data for restart file including Bonus data
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
molecular types may be negative, but write as positive molecular types may be negative, but write as positive
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
@ -782,18 +1000,24 @@ int AtomVecEllipsoid::pack_restart(int i, double *buf)
buf[m++] = v[i][1]; buf[m++] = v[i][1];
buf[m++] = v[i][2]; buf[m++] = v[i][2];
buf[m++] = shape[i][0];
buf[m++] = shape[i][1];
buf[m++] = shape[i][2];
buf[m++] = rmass[i]; buf[m++] = rmass[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][0];
buf[m++] = angmom[i][1]; buf[m++] = angmom[i][1];
buf[m++] = angmom[i][2]; buf[m++] = angmom[i][2];
if (ellipsoid[i] < 0) buf[m++] = 0;
else {
buf[m++] = 1;
int j = ellipsoid[i];
buf[m++] = bonus[j].shape[0];
buf[m++] = bonus[j].shape[1];
buf[m++] = bonus[j].shape[2];
buf[m++] = bonus[j].quat[0];
buf[m++] = bonus[j].quat[1];
buf[m++] = bonus[j].quat[2];
buf[m++] = bonus[j].quat[3];
}
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++)
m += modify->fix[atom->extra_restart[iextra]]->pack_restart(i,&buf[m]); m += modify->fix[atom->extra_restart[iextra]]->pack_restart(i,&buf[m]);
@ -803,7 +1027,7 @@ int AtomVecEllipsoid::pack_restart(int i, double *buf)
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
unpack data for one atom from restart file including extra quantities unpack data for one atom from restart file including Bonus data
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
int AtomVecEllipsoid::unpack_restart(double *buf) int AtomVecEllipsoid::unpack_restart(double *buf)
@ -827,18 +1051,27 @@ int AtomVecEllipsoid::unpack_restart(double *buf)
v[nlocal][1] = buf[m++]; v[nlocal][1] = buf[m++];
v[nlocal][2] = buf[m++]; v[nlocal][2] = buf[m++];
shape[nlocal][0] = buf[m++];
shape[nlocal][1] = buf[m++];
shape[nlocal][2] = buf[m++];
rmass[nlocal] = buf[m++]; rmass[nlocal] = 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][0] = buf[m++];
angmom[nlocal][1] = buf[m++]; angmom[nlocal][1] = buf[m++];
angmom[nlocal][2] = buf[m++]; angmom[nlocal][2] = buf[m++];
ellipsoid[nlocal] = static_cast<int> (buf[m++]);
if (ellipsoid[nlocal]) {
if (nlocal_bonus == nmax_bonus) grow_bonus();
double *shape = bonus[nlocal_bonus].shape;
double *quat = bonus[nlocal_bonus].quat;
shape[0] = buf[m++];
shape[1] = buf[m++];
shape[2] = buf[m++];
quat[0] = buf[m++];
quat[1] = buf[m++];
quat[2] = buf[m++];
quat[3] = buf[m++];
bonus[nlocal_bonus].ilocal = nlocal;
ellipsoid[nlocal] = nlocal_bonus++;
}
double **extra = atom->extra; double **extra = atom->extra;
if (atom->nextra_store) { if (atom->nextra_store) {
int size = static_cast<int> (buf[0]) - m; int size = static_cast<int> (buf[0]) - m;
@ -870,16 +1103,7 @@ void AtomVecEllipsoid::create_atom(int itype, double *coord)
v[nlocal][1] = 0.0; v[nlocal][1] = 0.0;
v[nlocal][2] = 0.0; v[nlocal][2] = 0.0;
shape[nlocal][0] = 0.5; ellipsoid[nlocal] = -1;
shape[nlocal][1] = 0.5;
shape[nlocal][2] = 0.5;
rmass[nlocal] = 4.0*PI/3.0 *
shape[nlocal][0]*shape[nlocal][1]*shape[nlocal][2];
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][0] = 0.0;
angmom[nlocal][1] = 0.0; angmom[nlocal][1] = 0.0;
angmom[nlocal][2] = 0.0; angmom[nlocal][2] = 0.0;
@ -905,38 +1129,19 @@ void AtomVecEllipsoid::data_atom(double *coord, int imagetmp, char **values)
if (type[nlocal] <= 0 || type[nlocal] > atom->ntypes) if (type[nlocal] <= 0 || type[nlocal] > atom->ntypes)
error->one("Invalid atom type in Atoms section of data file"); error->one("Invalid atom type in Atoms section of data file");
shape[nlocal][0] = 0.5 * atof(values[2]); ellipsoid[nlocal] = atoi(values[2]);
shape[nlocal][1] = 0.5 * atof(values[3]); if (ellipsoid[nlocal] == 0) ellipsoid[nlocal] = -1;
shape[nlocal][2] = 0.5 * atof(values[4]); else if (ellipsoid[nlocal] == 1) ellipsoid[nlocal] = 0;
if (shape[nlocal][0] < 0.0 || shape[nlocal][1] < 0.0 || else error->one("Invalid atom type in Atoms section of data file");
shape[nlocal][2] < 0.0)
error->one("Invalid shape in Atoms section of data file");
if (shape[nlocal][0] > 0.0 || shape[nlocal][1] > 0.0 ||
shape[nlocal][2] > 0.0) {
if (shape[nlocal][0] == 0.0 || shape[nlocal][1] == 0.0 ||
shape[nlocal][2] == 0.0)
error->one("Invalid shape in Atoms section of data file");
}
double density = atof(values[5]); rmass[nlocal] = atof(values[3]);
if (density <= 0.0) if (rmass[nlocal] <= 0.0)
error->one("Invalid density in Atoms section of data file"); error->one("Invalid density in Atoms section of data file");
if (shape[nlocal][0] == 0.0) rmass[nlocal] = density;
else
rmass[nlocal] = 4.0*PI/3.0 *
shape[nlocal][0]*shape[nlocal][1]*shape[nlocal][2] * density;
x[nlocal][0] = coord[0]; x[nlocal][0] = coord[0];
x[nlocal][1] = coord[1]; x[nlocal][1] = coord[1];
x[nlocal][2] = coord[2]; x[nlocal][2] = coord[2];
quat[nlocal][0] = atof(values[9]);
quat[nlocal][1] = atof(values[10]);
quat[nlocal][2] = atof(values[11]);
quat[nlocal][3] = atof(values[12]);
MathExtra::normalize4(quat[nlocal]);
image[nlocal] = imagetmp; image[nlocal] = imagetmp;
mask[nlocal] = 1; mask[nlocal] = 1;
@ -957,35 +1162,50 @@ void AtomVecEllipsoid::data_atom(double *coord, int imagetmp, char **values)
int AtomVecEllipsoid::data_atom_hybrid(int nlocal, char **values) int AtomVecEllipsoid::data_atom_hybrid(int nlocal, char **values)
{ {
shape[nlocal][0] = 0.5 * atof(values[0]); ellipsoid[nlocal] = atoi(values[0]);
shape[nlocal][1] = 0.5 * atof(values[1]); if (ellipsoid[nlocal] == 0) ellipsoid[nlocal] = -1;
shape[nlocal][2] = 0.5 * atof(values[2]); else if (ellipsoid[nlocal] == 1) ellipsoid[nlocal] = 0;
if (shape[nlocal][0] < 0.0 || shape[nlocal][1] < 0.0 || else error->one("Invalid atom type in Atoms section of data file");
shape[nlocal][2] < 0.0)
error->one("Invalid shape in Atoms section of data file");
if (shape[nlocal][0] > 0.0 || shape[nlocal][1] > 0.0 ||
shape[nlocal][2] > 0.0) {
if (shape[nlocal][0] == 0.0 || shape[nlocal][1] == 0.0 ||
shape[nlocal][2] == 0.0)
error->one("Invalid shape in Atoms section of data file");
}
double density = atof(values[3]); rmass[nlocal] = atof(values[1]);
if (density <= 0.0) if (rmass[nlocal] <= 0.0)
error->one("Invalid density in Atoms section of data file"); error->one("Invalid density in Atoms section of data file");
if (shape[nlocal][0] == 0.0) rmass[nlocal] = density; return 2;
else }
rmass[nlocal] = 4.0*PI/3.0 *
shape[nlocal][0]*shape[nlocal][1]*shape[nlocal][2] * density;
quat[nlocal][0] = atof(values[4]); /* ----------------------------------------------------------------------
quat[nlocal][1] = atof(values[5]); unpack one line from Ellipsoids section of data file
quat[nlocal][2] = atof(values[6]); ------------------------------------------------------------------------- */
quat[nlocal][3] = atof(values[7]);
MathExtra::normalize4(quat[nlocal]);
return 8; void AtomVecEllipsoid::data_atom_bonus(int m, char **values)
{
if (ellipsoid[m])
error->one("Assigning ellipsoid parameters to non-ellipsoid atom");
if (nlocal_bonus == nmax_bonus) grow_bonus();
double *shape = bonus[nlocal_bonus].shape;
double *quat = bonus[nlocal_bonus].quat;
shape[0] = 0.5 * atof(values[0]);
shape[1] = 0.5 * atof(values[1]);
shape[2] = 0.5 * atof(values[2]);
if (shape[0] <= 0.0 || shape[1] <= 0.0 || shape[2] <= 0.0)
error->one("Invalid shape in Ellipsoids section of data file");
quat[0] = atof(values[3]);
quat[1] = atof(values[4]);
quat[2] = atof(values[5]);
quat[3] = atof(values[6]);
MathExtra::normalize4(quat);
// reset ellipsoid mass
// previously stored density in rmass
rmass[m] *= 4.0*PI/3.0 * shape[0]*shape[1]*shape[2];
bonus[nlocal_bonus].ilocal = m;
ellipsoid[m] = nlocal_bonus++;
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
@ -1030,11 +1250,11 @@ bigint AtomVecEllipsoid::memory_usage()
if (atom->memcheck("v")) bytes += memory->usage(v,nmax,3); if (atom->memcheck("v")) bytes += memory->usage(v,nmax,3);
if (atom->memcheck("f")) bytes += memory->usage(f,nmax,3); if (atom->memcheck("f")) bytes += memory->usage(f,nmax,3);
if (atom->memcheck("shape")) bytes += memory->usage(shape,nmax,3);
if (atom->memcheck("rmass")) bytes += memory->usage(rmass,nmax); if (atom->memcheck("rmass")) bytes += memory->usage(rmass,nmax);
if (atom->memcheck("quat")) bytes += memory->usage(quat,nmax,4);
if (atom->memcheck("angmom")) bytes += memory->usage(angmom,nmax,3); if (atom->memcheck("angmom")) bytes += memory->usage(angmom,nmax,3);
if (atom->memcheck("torque")) bytes += memory->usage(torque,nmax,3); if (atom->memcheck("torque")) bytes += memory->usage(torque,nmax,3);
bytes += nmax_bonus*sizeof(Bonus);
return bytes; return bytes;
} }

View File

@ -26,11 +26,18 @@ namespace LAMMPS_NS {
class AtomVecEllipsoid : public AtomVec { class AtomVecEllipsoid : public AtomVec {
public: public:
struct Bonus {
double shape[3];
double quat[4];
int ilocal;
};
struct Bonus *bonus;
AtomVecEllipsoid(class LAMMPS *, int, char **); AtomVecEllipsoid(class LAMMPS *, int, char **);
virtual ~AtomVecEllipsoid() {} virtual ~AtomVecEllipsoid();
void grow(int); void grow(int);
void grow_reset(); void grow_reset();
void copy(int, int); void copy(int, int, int);
int pack_comm(int, int *, double *, int, int *); int pack_comm(int, int *, double *, int, int *);
int pack_comm_vel(int, int *, double *, int, int *); int pack_comm_vel(int, int *, double *, int, int *);
int pack_comm_hybrid(int, int *, double *); int pack_comm_hybrid(int, int *, double *);
@ -59,12 +66,23 @@ class AtomVecEllipsoid : public AtomVec {
int data_vel_hybrid(int, char **); int data_vel_hybrid(int, char **);
bigint memory_usage(); bigint memory_usage();
// manipulate Bonus data structure for extra atom info
void grow_bonus();
void copy_bonus(int, int);
void set_bonus(int, double, double, double);
void clear_bonus();
void data_atom_bonus(int, char **);
private: private:
double PI; double PI;
int *tag,*type,*mask,*image; int *tag,*type,*mask,*image;
double **x,**v,**f; double **x,**v,**f;
double **shape,*density,*rmass; double *density,*rmass;
double **angmom,**torque,**quat; double **angmom,**torque;
int *ellipsoid;
int nlocal_bonus,nghost_bonus,nmax_bonus;
}; };
} }

View File

@ -15,7 +15,7 @@
#include "compute_erotate_asphere.h" #include "compute_erotate_asphere.h"
#include "math_extra.h" #include "math_extra.h"
#include "atom.h" #include "atom.h"
#include "atom_vec.h" #include "atom_vec_ellipsoid.h"
#include "update.h" #include "update.h"
#include "force.h" #include "force.h"
#include "memory.h" #include "memory.h"
@ -36,7 +36,8 @@ ComputeERotateAsphere(LAMMPS *lmp, int narg, char **arg) :
// error check // error check
if (!atom->ellipsoid_flag) avec = (AtomVecEllipsoid *) atom->style_match("ellipsoid");
if (!avec)
error->all("Compute erotate/asphere requires atom style ellipsoid"); error->all("Compute erotate/asphere requires atom style ellipsoid");
} }
@ -47,13 +48,13 @@ void ComputeERotateAsphere::init()
// check that all particles are finite-size // check that all particles are finite-size
// no point particles allowed, spherical is OK // no point particles allowed, spherical is OK
double **shape = atom->shape; int *ellipsoid = atom->ellipsoid;
int *mask = atom->mask; int *mask = atom->mask;
int nlocal = atom->nlocal; int nlocal = atom->nlocal;
for (int i = 0; i < nlocal; i++) for (int i = 0; i < nlocal; i++)
if (mask[i] & groupbit) if (mask[i] & groupbit)
if (shape[i][0] == 0.0) if (ellipsoid[i] < 0)
error->one("Compute erotate/asphere requires extended particles"); error->one("Compute erotate/asphere requires extended particles");
pfactor = 0.5 * force->mvv2e; pfactor = 0.5 * force->mvv2e;
@ -65,9 +66,9 @@ double ComputeERotateAsphere::compute_scalar()
{ {
invoked_scalar = update->ntimestep; invoked_scalar = update->ntimestep;
double **quat = atom->quat; AtomVecEllipsoid::Bonus *bonus = avec->bonus;
int *ellipsoid = atom->ellipsoid;
double **angmom = atom->angmom; double **angmom = atom->angmom;
double **shape = atom->shape;
double *rmass = atom->rmass; double *rmass = atom->rmass;
int *mask = atom->mask; int *mask = atom->mask;
int nlocal = atom->nlocal; int nlocal = atom->nlocal;
@ -75,6 +76,7 @@ double ComputeERotateAsphere::compute_scalar()
// sum rotational energy for each particle // sum rotational energy for each particle
// no point particles since divide by inertia // no point particles since divide by inertia
double *shape,*quat;
double wbody[3],inertia[3]; double wbody[3],inertia[3];
double rot[3][3]; double rot[3][3];
double erotate = 0.0; double erotate = 0.0;
@ -82,18 +84,18 @@ double ComputeERotateAsphere::compute_scalar()
for (int i = 0; i < nlocal; i++) for (int i = 0; i < nlocal; i++)
if (mask[i] & groupbit) { if (mask[i] & groupbit) {
shape = bonus[ellipsoid[i]].shape;
quat = bonus[ellipsoid[i]].quat;
// principal moments of inertia // principal moments of inertia
inertia[0] = rmass[i] * inertia[0] = rmass[i] * (shape[1]*shape[1]+shape[2]*shape[2]) / 5.0;
(shape[i][1]*shape[i][1]+shape[i][2]*shape[i][2]) / 5.0; inertia[1] = rmass[i] * (shape[0]*shape[0]+shape[2]*shape[2]) / 5.0;
inertia[1] = rmass[i] * inertia[2] = rmass[i] * (shape[0]*shape[0]+shape[1]*shape[1]) / 5.0;
(shape[i][0]*shape[i][0]+shape[i][2]*shape[i][2]) / 5.0;
inertia[2] = rmass[i] *
(shape[i][0]*shape[i][0]+shape[i][1]*shape[i][1]) / 5.0;
// wbody = angular velocity in body frame // wbody = angular velocity in body frame
MathExtra::quat_to_mat(quat[i],rot); MathExtra::quat_to_mat(quat,rot);
MathExtra::transpose_times_column3(rot,angmom[i],wbody); MathExtra::transpose_times_column3(rot,angmom[i],wbody);
wbody[0] /= inertia[0]; wbody[0] /= inertia[0];
wbody[1] /= inertia[1]; wbody[1] /= inertia[1];

View File

@ -32,6 +32,7 @@ class ComputeERotateAsphere : public Compute {
private: private:
double pfactor; double pfactor;
class AtomVecEllipsoid *avec;
}; };
} }

View File

@ -19,7 +19,7 @@
#include "compute_temp_asphere.h" #include "compute_temp_asphere.h"
#include "math_extra.h" #include "math_extra.h"
#include "atom.h" #include "atom.h"
#include "atom_vec.h" #include "atom_vec_ellipsoid.h"
#include "update.h" #include "update.h"
#include "force.h" #include "force.h"
#include "domain.h" #include "domain.h"
@ -56,9 +56,10 @@ ComputeTempAsphere::ComputeTempAsphere(LAMMPS *lmp, int narg, char **arg) :
vector = new double[6]; vector = new double[6];
// error checks // error check
if (!atom->ellipsoid_flag) avec = (AtomVecEllipsoid *) atom->style_match("ellipsoid");
if (!avec)
error->all("Compute temp/asphere requires atom style ellipsoid"); error->all("Compute temp/asphere requires atom style ellipsoid");
} }
@ -77,13 +78,13 @@ void ComputeTempAsphere::init()
// check that all particles are finite-size // check that all particles are finite-size
// no point particles allowed, spherical is OK // no point particles allowed, spherical is OK
double **shape = atom->shape; int *ellipsoid = atom->ellipsoid;
int *mask = atom->mask; int *mask = atom->mask;
int nlocal = atom->nlocal; int nlocal = atom->nlocal;
for (int i = 0; i < nlocal; i++) for (int i = 0; i < nlocal; i++)
if (mask[i] & groupbit) if (mask[i] & groupbit)
if (shape[i][0] == 0.0) if (ellipsoid[i] < 0)
error->one("Compute temp/asphere requires extended particles"); error->one("Compute temp/asphere requires extended particles");
if (tempbias) { if (tempbias) {
@ -151,14 +152,15 @@ double ComputeTempAsphere::compute_scalar()
tbias->remove_bias_all(); tbias->remove_bias_all();
} }
AtomVecEllipsoid::Bonus *bonus = avec->bonus;
int *ellipsoid = atom->ellipsoid;
double **v = atom->v; double **v = atom->v;
double **quat = atom->quat;
double **angmom = atom->angmom; double **angmom = atom->angmom;
double **shape = atom->shape;
double *rmass = atom->rmass; double *rmass = atom->rmass;
int *mask = atom->mask; int *mask = atom->mask;
int nlocal = atom->nlocal; int nlocal = atom->nlocal;
double *shape,*quat;
double wbody[3],inertia[3]; double wbody[3],inertia[3];
double rot[3][3]; double rot[3][3];
double t = 0.0; double t = 0.0;
@ -169,20 +171,20 @@ double ComputeTempAsphere::compute_scalar()
for (int i = 0; i < nlocal; i++) for (int i = 0; i < nlocal; i++)
if (mask[i] & groupbit) { if (mask[i] & groupbit) {
shape = bonus[ellipsoid[i]].shape;
quat = bonus[ellipsoid[i]].quat;
t += (v[i][0]*v[i][0] + v[i][1]*v[i][1] + v[i][2]*v[i][2]) * rmass[i]; t += (v[i][0]*v[i][0] + v[i][1]*v[i][1] + v[i][2]*v[i][2]) * rmass[i];
// principal moments of inertia // principal moments of inertia
inertia[0] = rmass[i] * inertia[0] = rmass[i] * (shape[1]*shape[1]+shape[2]*shape[2]) / 5.0;
(shape[i][1]*shape[i][1]+shape[i][2]*shape[i][2]) / 5.0; inertia[1] = rmass[i] * (shape[0]*shape[0]+shape[2]*shape[2]) / 5.0;
inertia[1] = rmass[i] * inertia[2] = rmass[i] * (shape[0]*shape[0]+shape[1]*shape[1]) / 5.0;
(shape[i][0]*shape[i][0]+shape[i][2]*shape[i][2]) / 5.0;
inertia[2] = rmass[i] *
(shape[i][0]*shape[i][0]+shape[i][1]*shape[i][1]) / 5.0;
// wbody = angular velocity in body frame // wbody = angular velocity in body frame
MathExtra::quat_to_mat(quat[i],rot); MathExtra::quat_to_mat(quat,rot);
MathExtra::transpose_times_column3(rot,angmom[i],wbody); MathExtra::transpose_times_column3(rot,angmom[i],wbody);
wbody[0] /= inertia[0]; wbody[0] /= inertia[0];
wbody[1] /= inertia[1]; wbody[1] /= inertia[1];
@ -213,14 +215,15 @@ void ComputeTempAsphere::compute_vector()
tbias->remove_bias_all(); tbias->remove_bias_all();
} }
AtomVecEllipsoid::Bonus *bonus = avec->bonus;
int *ellipsoid = atom->ellipsoid;
double **v = atom->v; double **v = atom->v;
double **quat = atom->quat;
double **angmom = atom->angmom; double **angmom = atom->angmom;
double **shape = atom->shape;
double *rmass = atom->rmass; double *rmass = atom->rmass;
int *mask = atom->mask; int *mask = atom->mask;
int nlocal = atom->nlocal; int nlocal = atom->nlocal;
double *shape,*quat;
double wbody[3],inertia[3]; double wbody[3],inertia[3];
double rot[3][3]; double rot[3][3];
double massone,t[6]; double massone,t[6];
@ -229,6 +232,9 @@ void ComputeTempAsphere::compute_vector()
for (i = 0; i < nlocal; i++) for (i = 0; i < nlocal; i++)
if (mask[i] & groupbit) { if (mask[i] & groupbit) {
shape = bonus[ellipsoid[i]].shape;
quat = bonus[ellipsoid[i]].quat;
// translational kinetic energy // translational kinetic energy
massone = rmass[i]; massone = rmass[i];
@ -241,16 +247,13 @@ void ComputeTempAsphere::compute_vector()
// principal moments of inertia // principal moments of inertia
inertia[0] = rmass[i] * inertia[0] = rmass[i] * (shape[1]*shape[1]+shape[2]*shape[2]) / 5.0;
(shape[i][1]*shape[i][1]+shape[i][2]*shape[i][2]) / 5.0; inertia[1] = rmass[i] * (shape[0]*shape[0]+shape[2]*shape[2]) / 5.0;
inertia[1] = rmass[i] * inertia[2] = rmass[i] * (shape[0]*shape[0]+shape[1]*shape[1]) / 5.0;
(shape[i][0]*shape[i][0]+shape[i][2]*shape[i][2]) / 5.0;
inertia[2] = rmass[i] *
(shape[i][0]*shape[i][0]+shape[i][1]*shape[i][1]) / 5.0;
// wbody = angular velocity in body frame // wbody = angular velocity in body frame
MathExtra::quat_to_mat(quat[i],rot); MathExtra::quat_to_mat(quat,rot);
MathExtra::transpose_times_column3(rot,angmom[i],wbody); MathExtra::transpose_times_column3(rot,angmom[i],wbody);
wbody[0] /= inertia[0]; wbody[0] /= inertia[0];
wbody[1] /= inertia[1]; wbody[1] /= inertia[1];

View File

@ -39,7 +39,8 @@ class ComputeTempAsphere : public Compute {
int fix_dof; int fix_dof;
double tfactor; double tfactor;
char *id_bias; char *id_bias;
Compute *tbias; // ptr to additional bias compute class Compute *tbias; // ptr to additional bias compute
class AtomVecEllipsoid *avec;
void dof_compute(); void dof_compute();
}; };

View File

@ -21,7 +21,7 @@
#include "math_extra.h" #include "math_extra.h"
#include "fix_nh_asphere.h" #include "fix_nh_asphere.h"
#include "atom.h" #include "atom.h"
#include "atom_vec.h" #include "atom_vec_ellipsoid.h"
#include "group.h" #include "group.h"
#include "memory.h" #include "memory.h"
#include "error.h" #include "error.h"
@ -33,8 +33,9 @@ using namespace LAMMPS_NS;
FixNHAsphere::FixNHAsphere(LAMMPS *lmp, int narg, char **arg) : FixNHAsphere::FixNHAsphere(LAMMPS *lmp, int narg, char **arg) :
FixNH(lmp, narg, arg) FixNH(lmp, narg, arg)
{ {
if (!atom->ellipsoid_flag) avec = (AtomVecEllipsoid *) atom->style_match("ellipsoid");
error->all("Fix nvt/nph/npt asphere requires atom style ellipsoid"); if (!avec)
error->all("Compute nvt/nph/npt asphere requires atom style ellipsoid");
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -44,13 +45,13 @@ void FixNHAsphere::init()
// check that all particles are finite-size // check that all particles are finite-size
// no point particles allowed, spherical is OK // no point particles allowed, spherical is OK
double **shape = atom->shape; int *ellipsoid = atom->ellipsoid;
int *mask = atom->mask; int *mask = atom->mask;
int nlocal = atom->nlocal; int nlocal = atom->nlocal;
for (int i = 0; i < nlocal; i++) for (int i = 0; i < nlocal; i++)
if (mask[i] & groupbit) if (mask[i] & groupbit)
if (shape[i][0] == 0.0) if (ellipsoid[i] < 0)
error->one("Fix nvt/nph/npt asphere requires extended particles"); error->one("Fix nvt/nph/npt asphere requires extended particles");
FixNH::init(); FixNH::init();
@ -170,9 +171,9 @@ void FixNHAsphere::nve_x()
FixNH::nve_x(); FixNH::nve_x();
double **quat = atom->quat; AtomVecEllipsoid::Bonus *bonus = avec->bonus;
int *ellipsoid = atom->ellipsoid;
double **angmom = atom->angmom; double **angmom = atom->angmom;
double **shape = atom->shape;
double *rmass = atom->rmass; double *rmass = atom->rmass;
int *mask = atom->mask; int *mask = atom->mask;
int nlocal = atom->nlocal; int nlocal = atom->nlocal;
@ -186,18 +187,19 @@ void FixNHAsphere::nve_x()
// returns new normalized quaternion // returns new normalized quaternion
// principal moments of inertia // principal moments of inertia
double *shape,*quat;
double inertia[3]; double inertia[3];
for (int i = 0; i < nlocal; i++) for (int i = 0; i < nlocal; i++)
if (mask[i] & groupbit) { if (mask[i] & groupbit) {
inertia[0] = rmass[i] * shape = bonus[ellipsoid[i]].shape;
(shape[i][1]*shape[i][1]+shape[i][2]*shape[i][2]) / 5.0; quat = bonus[ellipsoid[i]].quat;
inertia[1] = rmass[i] *
(shape[i][0]*shape[i][0]+shape[i][2]*shape[i][2]) / 5.0;
inertia[2] = rmass[i] *
(shape[i][0]*shape[i][0]+shape[i][1]*shape[i][1]) / 5.0;
richardson(quat[i],angmom[i],inertia); inertia[0] = rmass[i] * (shape[1]*shape[1]+shape[2]*shape[2]) / 5.0;
inertia[1] = rmass[i] * (shape[0]*shape[0]+shape[2]*shape[2]) / 5.0;
inertia[2] = rmass[i] * (shape[0]*shape[0]+shape[1]*shape[1]) / 5.0;
richardson(quat,angmom[i],inertia);
} }
} }

View File

@ -27,6 +27,7 @@ class FixNHAsphere : public FixNH {
protected: protected:
double dtq; double dtq;
double **inertia; double **inertia;
class AtomVecEllipsoid *avec;
void richardson(double *, double *, double *); void richardson(double *, double *, double *);
void omega_from_mq(double *, double *, double *, double *); void omega_from_mq(double *, double *, double *, double *);

View File

@ -21,7 +21,7 @@
#include "fix_nve_asphere.h" #include "fix_nve_asphere.h"
#include "math_extra.h" #include "math_extra.h"
#include "atom.h" #include "atom.h"
#include "atom_vec.h" #include "atom_vec_ellipsoid.h"
#include "force.h" #include "force.h"
#include "update.h" #include "update.h"
#include "memory.h" #include "memory.h"
@ -34,10 +34,9 @@ using namespace LAMMPS_NS;
FixNVEAsphere::FixNVEAsphere(LAMMPS *lmp, int narg, char **arg) : FixNVEAsphere::FixNVEAsphere(LAMMPS *lmp, int narg, char **arg) :
FixNVE(lmp, narg, arg) FixNVE(lmp, narg, arg)
{ {
// error checks avec = (AtomVecEllipsoid *) atom->style_match("ellipsoid");
if (!avec)
if (!atom->ellipsoid_flag) error->all("Compute nve/asphere requires atom style ellipsoid");
error->all("Fix nve/asphere requires atom style ellipsoid");
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -47,13 +46,13 @@ void FixNVEAsphere::init()
// check that all particles are finite-size // check that all particles are finite-size
// no point particles allowed, spherical is OK // no point particles allowed, spherical is OK
double **shape = atom->shape; int *ellipsoid = atom->ellipsoid;
int *mask = atom->mask; int *mask = atom->mask;
int nlocal = atom->nlocal; int nlocal = atom->nlocal;
for (int i = 0; i < nlocal; i++) for (int i = 0; i < nlocal; i++)
if (mask[i] & groupbit) if (mask[i] & groupbit)
if (shape[i][0] == 0.0) if (ellipsoid[i] < 0)
error->one("Fix nve/asphere requires extended particles"); error->one("Fix nve/asphere requires extended particles");
FixNVE::init(); FixNVE::init();
@ -65,14 +64,15 @@ void FixNVEAsphere::initial_integrate(int vflag)
{ {
double dtfm; double dtfm;
double inertia[3]; double inertia[3];
double *shape,*quat;
AtomVecEllipsoid::Bonus *bonus = avec->bonus;
int *ellipsoid = atom->ellipsoid;
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 **quat = atom->quat;
double **angmom = atom->angmom; double **angmom = atom->angmom;
double **torque = atom->torque; double **torque = atom->torque;
double **shape = atom->shape;
double *rmass = atom->rmass; double *rmass = atom->rmass;
int *mask = atom->mask; int *mask = atom->mask;
int nlocal = atom->nlocal; int nlocal = atom->nlocal;
@ -102,14 +102,14 @@ void FixNVEAsphere::initial_integrate(int vflag)
// principal moments of inertia // principal moments of inertia
inertia[0] = rmass[i] * shape = bonus[ellipsoid[i]].shape;
(shape[i][1]*shape[i][1]+shape[i][2]*shape[i][2]) / 5.0; quat = bonus[ellipsoid[i]].quat;
inertia[1] = rmass[i] *
(shape[i][0]*shape[i][0]+shape[i][2]*shape[i][2]) / 5.0;
inertia[2] = rmass[i] *
(shape[i][0]*shape[i][0]+shape[i][1]*shape[i][1]) / 5.0;
richardson(quat[i],angmom[i],inertia); inertia[0] = rmass[i] * (shape[1]*shape[1]+shape[2]*shape[2]) / 5.0;
inertia[1] = rmass[i] * (shape[0]*shape[0]+shape[2]*shape[2]) / 5.0;
inertia[2] = rmass[i] * (shape[0]*shape[0]+shape[1]*shape[1]) / 5.0;
richardson(quat,angmom[i],inertia);
} }
} }

View File

@ -33,6 +33,7 @@ class FixNVEAsphere : public FixNVE {
private: private:
double dtq; double dtq;
class AtomVecEllipsoid *avec;
void richardson(double *, double *, double *); void richardson(double *, double *, double *);
void omega_from_mq(double *, double *, double *, double *); void omega_from_mq(double *, double *, double *, double *);

View File

@ -22,7 +22,7 @@
#include "pair_gayberne.h" #include "pair_gayberne.h"
#include "math_extra.h" #include "math_extra.h"
#include "atom.h" #include "atom.h"
#include "atom_vec.h" #include "atom_vec_ellipsoid.h"
#include "comm.h" #include "comm.h"
#include "force.h" #include "force.h"
#include "neighbor.h" #include "neighbor.h"
@ -42,6 +42,10 @@ enum{SPHERE_SPHERE,SPHERE_ELLIPSE,ELLIPSE_SPHERE,ELLIPSE_ELLIPSE};
PairGayBerne::PairGayBerne(LAMMPS *lmp) : Pair(lmp) PairGayBerne::PairGayBerne(LAMMPS *lmp) : Pair(lmp)
{ {
avec = (AtomVecEllipsoid *) atom->style_match("ellipsoid");
if (!avec)
error->all("Pair gayberne requires atom style ellipsoid");
single_enable = 0; single_enable = 0;
} }
@ -81,14 +85,16 @@ void PairGayBerne::compute(int eflag, int vflag)
double fforce[3],ttor[3],rtor[3],r12[3]; 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]; double a1[3][3],b1[3][3],g1[3][3],a2[3][3],b2[3][3],g2[3][3],temp[3][3];
int *ilist,*jlist,*numneigh,**firstneigh; int *ilist,*jlist,*numneigh,**firstneigh;
double *iquat,*jquat;
evdwl = 0.0; evdwl = 0.0;
if (eflag || vflag) ev_setup(eflag,vflag); if (eflag || vflag) ev_setup(eflag,vflag);
else evflag = vflag_fdotr = 0; else evflag = vflag_fdotr = 0;
AtomVecEllipsoid::Bonus *bonus = avec->bonus;
int *ellipsoid = atom->ellipsoid;
double **x = atom->x; double **x = atom->x;
double **f = atom->f; double **f = atom->f;
double **quat = atom->quat;
double **tor = atom->torque; double **tor = atom->torque;
int *type = atom->type; int *type = atom->type;
int nlocal = atom->nlocal; int nlocal = atom->nlocal;
@ -107,7 +113,8 @@ void PairGayBerne::compute(int eflag, int vflag)
itype = type[i]; itype = type[i];
if (form[itype][itype] == ELLIPSE_ELLIPSE) { if (form[itype][itype] == ELLIPSE_ELLIPSE) {
MathExtra::quat_to_mat_trans(quat[i],a1); iquat = bonus[ellipsoid[i]].quat;
MathExtra::quat_to_mat_trans(iquat,a1);
MathExtra::diag_times3(well[itype],a1,temp); MathExtra::diag_times3(well[itype],a1,temp);
MathExtra::transpose_times3(a1,temp,b1); MathExtra::transpose_times3(a1,temp,b1);
MathExtra::diag_times3(shape2[itype],a1,temp); MathExtra::diag_times3(shape2[itype],a1,temp);
@ -151,7 +158,8 @@ void PairGayBerne::compute(int eflag, int vflag)
break; break;
case SPHERE_ELLIPSE: case SPHERE_ELLIPSE:
MathExtra::quat_to_mat_trans(quat[j],a2); jquat = bonus[ellipsoid[j]].quat;
MathExtra::quat_to_mat_trans(jquat,a2);
MathExtra::diag_times3(well[jtype],a2,temp); MathExtra::diag_times3(well[jtype],a2,temp);
MathExtra::transpose_times3(a2,temp,b2); MathExtra::transpose_times3(a2,temp,b2);
MathExtra::diag_times3(shape2[jtype],a2,temp); MathExtra::diag_times3(shape2[jtype],a2,temp);
@ -166,7 +174,8 @@ void PairGayBerne::compute(int eflag, int vflag)
break; break;
default: default:
MathExtra::quat_to_mat_trans(quat[j],a2); jquat = bonus[ellipsoid[j]].quat;
MathExtra::quat_to_mat_trans(jquat,a2);
MathExtra::diag_times3(well[jtype],a2,temp); MathExtra::diag_times3(well[jtype],a2,temp);
MathExtra::transpose_times3(a2,temp,b2); MathExtra::transpose_times3(a2,temp,b2);
MathExtra::diag_times3(shape2[jtype],a2,temp); MathExtra::diag_times3(shape2[jtype],a2,temp);
@ -332,9 +341,6 @@ void PairGayBerne::coeff(int narg, char **arg)
void PairGayBerne::init_style() void PairGayBerne::init_style()
{ {
if (!atom->ellipsoid_flag)
error->all("Pair gayberne requires atom style ellipsoid");
int irequest = neighbor->request(this); int irequest = neighbor->request(this);
// per-type shape precalculations // per-type shape precalculations

View File

@ -53,6 +53,7 @@ class PairGayBerne : public Pair {
double **lj1,**lj2,**lj3,**lj4; double **lj1,**lj2,**lj3,**lj4;
double **offset; double **offset;
int *setwell; int *setwell;
class AtomVecEllipsoid *avec;
void allocate(); void allocate();
double gayberne_analytic(const int i, const int j, double a1[3][3], double gayberne_analytic(const int i, const int j, double a1[3][3],

View File

@ -22,7 +22,7 @@
#include "pair_resquared.h" #include "pair_resquared.h"
#include "math_extra.h" #include "math_extra.h"
#include "atom.h" #include "atom.h"
#include "atom_vec.h" #include "atom_vec_ellipsoid.h"
#include "comm.h" #include "comm.h"
#include "force.h" #include "force.h"
#include "neighbor.h" #include "neighbor.h"
@ -44,7 +44,12 @@ PairRESquared::PairRESquared(LAMMPS *lmp) : Pair(lmp),
b_alpha(45.0/56.0), b_alpha(45.0/56.0),
cr60(pow(60.0,1.0/3.0)) cr60(pow(60.0,1.0/3.0))
{ {
avec = (AtomVecEllipsoid *) atom->style_match("ellipsoid");
if (!avec)
error->all("Pair gayberne requires atom style ellipsoid");
single_enable = 0; single_enable = 0;
cr60 = pow(60.0,1.0/3.0); cr60 = pow(60.0,1.0/3.0);
b_alpha = 45.0/56.0; b_alpha = 45.0/56.0;
solv_f_a = 3.0/(16.0*atan(1.0)*-36.0); solv_f_a = 3.0/(16.0*atan(1.0)*-36.0);
@ -314,16 +319,12 @@ void PairRESquared::coeff(int narg, char **arg)
if (count == 0) error->all("Incorrect args for pair coefficients"); if (count == 0) error->all("Incorrect args for pair coefficients");
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
init specific to this pair style init specific to this pair style
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void PairRESquared::init_style() void PairRESquared::init_style()
{ {
if (!atom->ellipsoid_flag)
error->all("Pair resquared requires atom style ellipsoid");
int irequest = neighbor->request(this); int irequest = neighbor->request(this);
// per-type shape precalculations // per-type shape precalculations
@ -497,10 +498,12 @@ void PairRESquared::read_restart_settings(FILE *fp)
Precompute per-particle temporaries for RE-squared calculation Precompute per-particle temporaries for RE-squared calculation
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void PairRESquared::precompute_i(const int i,RE2Vars &ws) { void PairRESquared::precompute_i(const int i,RE2Vars &ws)
{
double aTs[3][3]; // A1'*S1^2 double aTs[3][3]; // A1'*S1^2
int *ellipsoid = atom->ellipsoid;
MathExtra::quat_to_mat_trans(atom->quat[i],ws.A); AtomVecEllipsoid::Bonus *bonus = avec->bonus;
MathExtra::quat_to_mat_trans(bonus[ellipsoid[i]].quat,ws.A);
MathExtra::transpose_times_diag3(ws.A,well[atom->type[i]],ws.aTe); MathExtra::transpose_times_diag3(ws.A,well[atom->type[i]],ws.aTe);
MathExtra::transpose_times_diag3(ws.A,shape2[atom->type[i]],aTs); MathExtra::transpose_times_diag3(ws.A,shape2[atom->type[i]],aTs);
MathExtra::diag_times3(shape2[atom->type[i]],ws.A,ws.sa); MathExtra::diag_times3(shape2[atom->type[i]],ws.A,ws.sa);

View File

@ -52,6 +52,7 @@ class PairRESquared : public Pair {
double **lj1,**lj2,**lj3,**lj4; double **lj1,**lj2,**lj3,**lj4;
double **offset; double **offset;
int *setwell; int *setwell;
class AtomVecEllipsoid *avec;
// per-particle temporaries for RE-squared calculation // per-particle temporaries for RE-squared calculation

View File

@ -89,9 +89,11 @@ void AtomVecDipole::grow_reset()
q = atom->q; mu = atom->mu; q = atom->q; mu = atom->mu;
} }
/* ---------------------------------------------------------------------- */ /* ----------------------------------------------------------------------
copy atom I info to atom J
------------------------------------------------------------------------- */
void AtomVecDipole::copy(int i, int j) void AtomVecDipole::copy(int i, int j, int delflag)
{ {
tag[j] = tag[i]; tag[j] = tag[i];
type[j] = type[i]; type[j] = type[i];

View File

@ -29,7 +29,7 @@ class AtomVecDipole : public AtomVec {
AtomVecDipole(class LAMMPS *, int, char **); AtomVecDipole(class LAMMPS *, int, char **);
void grow(int); void grow(int);
void grow_reset(); void grow_reset();
void copy(int, int); void copy(int, int, int);
int pack_comm(int, int *, double *, int, int *); int pack_comm(int, int *, double *, int, int *);
int pack_comm_vel(int, int *, double *, int, int *); int pack_comm_vel(int, int *, double *, int, int *);
int pack_comm_hybrid(int, int *, double *); int pack_comm_hybrid(int, int *, double *);

View File

@ -114,9 +114,11 @@ void AtomVecAngle::grow_reset()
angle_atom3 = atom->angle_atom3; angle_atom3 = atom->angle_atom3;
} }
/* ---------------------------------------------------------------------- */ /* ----------------------------------------------------------------------
copy atom I info to atom J
------------------------------------------------------------------------- */
void AtomVecAngle::copy(int i, int j) void AtomVecAngle::copy(int i, int j, int delflag)
{ {
int k; int k;

View File

@ -29,7 +29,7 @@ class AtomVecAngle : public AtomVec {
AtomVecAngle(class LAMMPS *, int, char **); AtomVecAngle(class LAMMPS *, int, char **);
void grow(int); void grow(int);
void grow_reset(); void grow_reset();
void copy(int, int); void copy(int, int, int);
int pack_comm(int, int *, double *, int, int *); int pack_comm(int, int *, double *, int, int *);
int pack_comm_vel(int, int *, double *, int, int *); int pack_comm_vel(int, int *, double *, int, int *);
void unpack_comm(int, int, double *); void unpack_comm(int, int, double *);

View File

@ -102,9 +102,11 @@ void AtomVecBond::grow_reset()
bond_atom = atom->bond_atom; bond_atom = atom->bond_atom;
} }
/* ---------------------------------------------------------------------- */ /* ----------------------------------------------------------------------
copy atom I info to atom J
------------------------------------------------------------------------- */
void AtomVecBond::copy(int i, int j) void AtomVecBond::copy(int i, int j, int delflag)
{ {
int k; int k;

View File

@ -29,7 +29,7 @@ class AtomVecBond : public AtomVec {
AtomVecBond(class LAMMPS *, int, char **); AtomVecBond(class LAMMPS *, int, char **);
void grow(int); void grow(int);
void grow_reset(); void grow_reset();
void copy(int, int); void copy(int, int, int);
int pack_comm(int, int *, double *, int, int *); int pack_comm(int, int *, double *, int, int *);
int pack_comm_vel(int, int *, double *, int, int *); int pack_comm_vel(int, int *, double *, int, int *);
void unpack_comm(int, int, double *); void unpack_comm(int, int, double *);

View File

@ -155,9 +155,11 @@ void AtomVecFull::grow_reset()
improper_atom3 = atom->improper_atom3; improper_atom4 = atom->improper_atom4; improper_atom3 = atom->improper_atom3; improper_atom4 = atom->improper_atom4;
} }
/* ---------------------------------------------------------------------- */ /* ----------------------------------------------------------------------
copy atom I info to atom J
------------------------------------------------------------------------- */
void AtomVecFull::copy(int i, int j) void AtomVecFull::copy(int i, int j, int delflag)
{ {
int k; int k;

View File

@ -29,7 +29,7 @@ class AtomVecFull : public AtomVec {
AtomVecFull(class LAMMPS *, int, char **); AtomVecFull(class LAMMPS *, int, char **);
void grow(int); void grow(int);
void grow_reset(); void grow_reset();
void copy(int, int); void copy(int, int, int);
int pack_comm(int, int *, double *, int, int *); int pack_comm(int, int *, double *, int, int *);
int pack_comm_vel(int, int *, double *, int, int *); int pack_comm_vel(int, int *, double *, int, int *);
void unpack_comm(int, int, double *); void unpack_comm(int, int, double *);

View File

@ -154,9 +154,11 @@ void AtomVecMolecular::grow_reset()
improper_atom3 = atom->improper_atom3; improper_atom4 = atom->improper_atom4; improper_atom3 = atom->improper_atom3; improper_atom4 = atom->improper_atom4;
} }
/* ---------------------------------------------------------------------- */ /* ----------------------------------------------------------------------
copy atom I info to atom J
------------------------------------------------------------------------- */
void AtomVecMolecular::copy(int i, int j) void AtomVecMolecular::copy(int i, int j, int delflag)
{ {
int k; int k;

View File

@ -29,7 +29,7 @@ class AtomVecMolecular : public AtomVec {
AtomVecMolecular(class LAMMPS *, int, char **); AtomVecMolecular(class LAMMPS *, int, char **);
void grow(int); void grow(int);
void grow_reset(); void grow_reset();
void copy(int, int); void copy(int, int, int);
int pack_comm(int, int *, double *, int, int *); int pack_comm(int, int *, double *, int, int *);
int pack_comm_vel(int, int *, double *, int, int *); int pack_comm_vel(int, int *, double *, int, int *);
void unpack_comm(int, int, double *); void unpack_comm(int, int, double *);

View File

@ -96,9 +96,11 @@ void AtomVecPeri::grow_reset()
s0 = atom->s0; x0 = atom->x0; s0 = atom->s0; x0 = atom->x0;
} }
/* ---------------------------------------------------------------------- */ /* ----------------------------------------------------------------------
copy atom I info to atom J
------------------------------------------------------------------------- */
void AtomVecPeri::copy(int i, int j) void AtomVecPeri::copy(int i, int j, int delflag)
{ {
tag[j] = tag[i]; tag[j] = tag[i];
type[j] = type[i]; type[j] = type[i];

View File

@ -29,7 +29,7 @@ class AtomVecPeri : public AtomVec {
AtomVecPeri(class LAMMPS *, int, char **); AtomVecPeri(class LAMMPS *, int, char **);
void grow(int); void grow(int);
void grow_reset(); void grow_reset();
void copy(int, int); void copy(int, int, int);
int pack_comm(int, int *, double *, int, int *); int pack_comm(int, int *, double *, int, int *);
int pack_comm_vel(int, int *, double *, int, int *); int pack_comm_vel(int, int *, double *, int, int *);
int pack_comm_hybrid(int, int *, double *); int pack_comm_hybrid(int, int *, double *);

View File

@ -423,12 +423,10 @@ void PairPeriLPS::init_style()
{ {
// error checks // error checks
if (!atom->peri_flag) error->all("Pair style peri requires atom style peri");
if (atom->map_style == 0) if (atom->map_style == 0)
error->all("Pair peri requires an atom map, see atom_modify"); error->all("Pair peri requires an atom map, see atom_modify");
if (atom->style_match("peri") == 0)
error->all("Pair style peri_lps requires atom style peri");
if (domain->lattice == NULL) if (domain->lattice == NULL)
error->all("Pair peri requires a lattice be defined"); error->all("Pair peri requires a lattice be defined");
if (domain->lattice->xlattice != domain->lattice->ylattice || if (domain->lattice->xlattice != domain->lattice->ylattice ||

View File

@ -360,12 +360,10 @@ void PairPeriPMB::init_style()
{ {
// error checks // error checks
if (!atom->peri_flag) error->all("Pair style peri requires atom style peri");
if (atom->map_style == 0) if (atom->map_style == 0)
error->all("Pair peri requires an atom map, see atom_modify"); error->all("Pair peri requires an atom map, see atom_modify");
if (atom->style_match("peri") == 0)
error->all("Pair style peri_pmb requires atom style peri");
if (domain->lattice == NULL) if (domain->lattice == NULL)
error->all("Pair peri requires a lattice be defined"); error->all("Pair peri requires a lattice be defined");
if (domain->lattice->xlattice != domain->lattice->ylattice || if (domain->lattice->xlattice != domain->lattice->ylattice ||

View File

@ -20,7 +20,7 @@
#include "stdlib.h" #include "stdlib.h"
#include "fix_srd.h" #include "fix_srd.h"
#include "atom.h" #include "atom.h"
#include "atom_vec.h" #include "atom_vec_ellipsoid.h"
#include "group.h" #include "group.h"
#include "update.h" #include "update.h"
#include "force.h" #include "force.h"
@ -233,6 +233,10 @@ FixSRD::FixSRD(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg)
srd_bin_temp = 0.0; srd_bin_temp = 0.0;
srd_bin_count = 0; srd_bin_count = 0;
// atom style pointers to particles that store extra info
avec_ellipsoid = (AtomVecEllipsoid *) atom->style_match("ellipsoid");
// fix parameters // fix parameters
if (collidestyle == SLIP) comm_reverse = 3; if (collidestyle == SLIP) comm_reverse = 3;
@ -288,12 +292,8 @@ void FixSRD::init()
if (force->newton_pair == 0) error->all("Fix srd requires newton pair on"); if (force->newton_pair == 0) error->all("Fix srd requires newton pair on");
if (bigexist && comm->ghost_velocity == 0) if (bigexist && comm->ghost_velocity == 0)
error->all("Fix srd requires ghost atoms store velocity"); error->all("Fix srd requires ghost atoms store velocity");
if (bigexist && !atom->sphere_flag && !atom->ellipsoid_flag)
error->all("Fix SRD requires atom style sphere or ellipsoid");
if (bigexist && collidestyle == NOSLIP && !atom->torque_flag) if (bigexist && collidestyle == NOSLIP && !atom->torque_flag)
error->all("Fix SRD no-slip requires atom attribute torque"); error->all("Fix SRD no-slip requires atom attribute torque");
if (initflag && update->dt != dt_big) if (initflag && update->dt != dt_big)
error->all("Cannot change timestep once fix srd is setup"); error->all("Cannot change timestep once fix srd is setup");
@ -2092,8 +2092,9 @@ void FixSRD::parameterize()
// big particle must either have radius > 0 or shape > 0 defined // big particle must either have radius > 0 or shape > 0 defined
// apply radfactor at end // apply radfactor at end
AtomVecEllipsoid::Bonus *ebonus = avec_ellipsoid->bonus;
double *radius = atom->radius; double *radius = atom->radius;
double **shape = atom->shape; int *ellipsoid = atom->ellipsoid;
int *mask = atom->mask; int *mask = atom->mask;
int nlocal = atom->nlocal; int nlocal = atom->nlocal;
@ -2106,15 +2107,15 @@ void FixSRD::parameterize()
if (radius && radius[i] > 0.0) { if (radius && radius[i] > 0.0) {
maxbigdiam = MAX(maxbigdiam,2.0*radius[i]); maxbigdiam = MAX(maxbigdiam,2.0*radius[i]);
minbigdiam = MIN(minbigdiam,2.0*radius[i]); minbigdiam = MIN(minbigdiam,2.0*radius[i]);
} else if (shape && shape[i][0] > 0.0) { } else if (ellipsoid && ellipsoid[i] >= 0) {
maxbigdiam = MAX(maxbigdiam,2.0*shape[i][0]); any_ellipsoids = 1;
maxbigdiam = MAX(maxbigdiam,2.0*shape[i][1]); double *shape = ebonus[ellipsoid[i]].shape;
maxbigdiam = MAX(maxbigdiam,2.0*shape[i][2]); maxbigdiam = MAX(maxbigdiam,2.0*shape[0]);
minbigdiam = MIN(minbigdiam,2.0*shape[i][0]); maxbigdiam = MAX(maxbigdiam,2.0*shape[1]);
minbigdiam = MIN(minbigdiam,2.0*shape[i][1]); maxbigdiam = MAX(maxbigdiam,2.0*shape[2]);
minbigdiam = MIN(minbigdiam,2.0*shape[i][2]); minbigdiam = MIN(minbigdiam,2.0*shape[0]);
if (shape[i][0] != shape[i][1] || shape[i][0] != shape[i][2]) minbigdiam = MIN(minbigdiam,2.0*shape[1]);
any_ellipsoids = 1; minbigdiam = MIN(minbigdiam,2.0*shape[2]);
} else } else
error->one("Big particle in fix srd cannot be point particle"); error->one("Big particle in fix srd cannot be point particle");
} }
@ -2171,8 +2172,6 @@ void FixSRD::parameterize()
temperature_srd = force->mvv2e * temperature_srd = force->mvv2e *
(lamda/dt_srd)*(lamda/dt_srd) * mass_srd/force->boltz; (lamda/dt_srd)*(lamda/dt_srd) * mass_srd/force->boltz;
printf("AAA %g %g\n",mass_srd,lamda);
// vmax = maximum velocity of an SRD particle // vmax = maximum velocity of an SRD particle
// dmax = maximum distance an SRD can move = 4*lamda = vmax * dt_srd // dmax = maximum distance an SRD can move = 4*lamda = vmax * dt_srd
@ -2191,16 +2190,20 @@ void FixSRD::parameterize()
if (mask[i] & biggroupbit) { if (mask[i] & biggroupbit) {
if (radius && radius[i] > 0.0) if (radius && radius[i] > 0.0)
volbig += 4.0/3.0*PI*radius[i]*radius[i]*radius[i]; volbig += 4.0/3.0*PI*radius[i]*radius[i]*radius[i];
else if (shape && shape[i][0] > 0.0) else if (ellipsoid && ellipsoid[i] >= 0) {
volbig += 4.0/3.0*PI * shape[i][0]*shape[i][1]*shape[i][2]; double *shape = ebonus[ellipsoid[i]].shape;
volbig += 4.0/3.0*PI * shape[0]*shape[1]*shape[2];
}
} }
} else { } else {
for (int i = 0; i < nlocal; i++) for (int i = 0; i < nlocal; i++)
if (mask[i] & biggroupbit) { if (mask[i] & biggroupbit) {
if (radius && radius[i] > 0.0) if (radius && radius[i] > 0.0)
volbig += PI*radius[i]*radius[i]; volbig += PI*radius[i]*radius[i];
else if (shape && shape[i][0] > 0.0) else if (ellipsoid && ellipsoid[i] >= 0) {
volbig += PI*shape[i][0]*shape[i][1]; double *shape = ebonus[ellipsoid[i]].shape;
volbig += PI*shape[0]*shape[1];
}
} }
} }
@ -2401,9 +2404,11 @@ void FixSRD::big_static()
{ {
int i; int i;
double rad,arad,brad,crad; double rad,arad,brad,crad;
double *shape;
AtomVecEllipsoid::Bonus *ebonus = avec_ellipsoid->bonus;
double *radius = atom->radius; double *radius = atom->radius;
double **shape = atom->shape; int *ellipsoid = atom->ellipsoid;
int *type = atom->type; int *type = atom->type;
double skinhalf = 0.5 * neighbor->skin; double skinhalf = 0.5 * neighbor->skin;
@ -2416,11 +2421,12 @@ void FixSRD::big_static()
biglist[k].radius = rad; biglist[k].radius = rad;
biglist[k].radsq = rad*rad; biglist[k].radsq = rad*rad;
biglist[k].cutbinsq = (rad+skinhalf) * (rad+skinhalf); biglist[k].cutbinsq = (rad+skinhalf) * (rad+skinhalf);
} else if (shape && shape[i][0] > 0.0) { } else if (ellipsoid && ellipsoid[i] >= 0) {
shape = ebonus[ellipsoid[i]].shape;
biglist[k].type = ELLIPSOID; biglist[k].type = ELLIPSOID;
arad = radfactor*shape[i][0]; arad = radfactor*shape[0];
brad = radfactor*shape[i][1]; brad = radfactor*shape[1];
crad = radfactor*shape[i][2]; crad = radfactor*shape[2];
biglist[k].aradsqinv = 1.0/(arad*arad); biglist[k].aradsqinv = 1.0/(arad*arad);
biglist[k].bradsqinv = 1.0/(brad*brad); biglist[k].bradsqinv = 1.0/(brad*brad);
biglist[k].cradsqinv = 1.0/(crad*crad); biglist[k].cradsqinv = 1.0/(crad*crad);
@ -2441,12 +2447,13 @@ void FixSRD::big_static()
void FixSRD::big_dynamic() void FixSRD::big_dynamic()
{ {
int i; int i;
double *shape,*quat;
AtomVecEllipsoid::Bonus *ebonus = avec_ellipsoid->bonus;
double **omega = atom->omega; double **omega = atom->omega;
double **angmom = atom->angmom; double **angmom = atom->angmom;
double **quat = atom->quat;
double **shape = atom->shape;
double *rmass = atom->rmass; double *rmass = atom->rmass;
int *ellipsoid = atom->ellipsoid;
for (int k = 0; k < nbig; k++) { for (int k = 0; k < nbig; k++) {
i = biglist[k].index; i = biglist[k].index;
@ -2463,9 +2470,11 @@ void FixSRD::big_dynamic()
// calculate ex,ey,ez and omega from quaternion and angmom // calculate ex,ey,ez and omega from quaternion and angmom
} else if (biglist[k].type == ELLIPSOID) { } else if (biglist[k].type == ELLIPSOID) {
exyz_from_q(quat[i],biglist[k].ex,biglist[k].ey,biglist[k].ez); shape = ebonus[ellipsoid[i]].shape;
quat = ebonus[ellipsoid[i]].quat;
exyz_from_q(quat,biglist[k].ex,biglist[k].ey,biglist[k].ez);
omega_from_mq(angmom[i],biglist[k].ex,biglist[k].ey,biglist[k].ez, omega_from_mq(angmom[i],biglist[k].ex,biglist[k].ey,biglist[k].ez,
rmass[i],shape[i],biglist[k].omega); rmass[i],shape,biglist[k].omega);
} }
} }
} }

View File

@ -63,6 +63,8 @@ class FixSRD : public Fix {
double **fwall; double **fwall;
double walltrigger; double walltrigger;
class AtomVecEllipsoid *avec_ellipsoid;
// for orthogonal box, these are in box units // for orthogonal box, these are in box units
// for triclinic box, these are in lamda units // for triclinic box, these are in lamda units

View File

@ -97,9 +97,11 @@ void AtomVecElectron::grow_reset()
eradius = atom->eradius; ervel = atom->ervel; erforce = atom->erforce; eradius = atom->eradius; ervel = atom->ervel; erforce = atom->erforce;
} }
/* ---------------------------------------------------------------------- */ /* ----------------------------------------------------------------------
copy atom I info to atom J
------------------------------------------------------------------------- */
void AtomVecElectron::copy(int i, int j) void AtomVecElectron::copy(int i, int j, int delflag)
{ {
tag[j] = tag[i]; tag[j] = tag[i];
type[j] = type[i]; type[j] = type[i];

View File

@ -30,7 +30,7 @@ class AtomVecElectron : public AtomVec {
~AtomVecElectron() {} ~AtomVecElectron() {}
void grow(int); void grow(int);
void grow_reset(); void grow_reset();
void copy(int, int); void copy(int, int, int);
int pack_comm(int, int *, double *, int, int *); int pack_comm(int, int *, double *, int, int *);
int pack_comm_vel(int, int *, double *, int, int *); int pack_comm_vel(int, int *, double *, int, int *);
int pack_comm_hybrid(int, int *, double *); int pack_comm_hybrid(int, int *, double *);

View File

@ -19,6 +19,7 @@
#include "atom.h" #include "atom.h"
#include "style_atom.h" #include "style_atom.h"
#include "atom_vec.h" #include "atom_vec.h"
#include "atom_vec_ellipsoid.h"
#include "comm.h" #include "comm.h"
#include "neighbor.h" #include "neighbor.h"
#include "force.h" #include "force.h"
@ -70,11 +71,11 @@ Atom::Atom(LAMMPS *lmp) : Pointers(lmp)
molecule = NULL; molecule = NULL;
q = NULL; q = NULL;
mu = NULL; mu = NULL;
quat = omega = angmom = torque = shape = NULL; omega = angmom = torque = NULL;
radius = rmass = NULL; radius = rmass = NULL;
vfrac = s0 = NULL; vfrac = s0 = NULL;
x0 = NULL; x0 = NULL;
ellipsoid = NULL;
spin = NULL; spin = NULL;
eradius = ervel = erforce = NULL; eradius = ervel = erforce = NULL;
@ -102,8 +103,7 @@ Atom::Atom(LAMMPS *lmp) : Pointers(lmp)
sphere_flag = ellipsoid_flag = peri_flag = electron_flag = 0; sphere_flag = ellipsoid_flag = peri_flag = electron_flag = 0;
molecule_flag = q_flag = mu_flag = 0; molecule_flag = q_flag = mu_flag = 0;
rmass_flag = radius_flag = omega_flag = torque_flag = 0; rmass_flag = radius_flag = omega_flag = torque_flag = angmom_flag = 0;
quat_flag = shape_flag = angmom_flag = 0;
vfrac_flag = spin_flag = eradius_flag = ervel_flag = erforce_flag = 0; vfrac_flag = spin_flag = eradius_flag = ervel_flag = erforce_flag = 0;
// ntype-length arrays // ntype-length arrays
@ -167,18 +167,15 @@ Atom::~Atom()
memory->destroy(q); memory->destroy(q);
memory->destroy(mu); memory->destroy(mu);
memory->destroy(quat);
memory->destroy(shape);
memory->destroy(omega); memory->destroy(omega);
memory->destroy(angmom); memory->destroy(angmom);
memory->destroy(torque); memory->destroy(torque);
memory->destroy(radius); memory->destroy(radius);
memory->destroy(rmass); memory->destroy(rmass);
memory->destroy(vfrac); memory->destroy(vfrac);
memory->destroy(s0); memory->destroy(s0);
memory->destroy(x0); memory->destroy(x0);
memory->destroy(ellipsoid);
memory->destroy(spin); memory->destroy(spin);
memory->destroy(eradius); memory->destroy(eradius);
memory->destroy(ervel); memory->destroy(ervel);
@ -256,8 +253,7 @@ void Atom::create_avec(const char *style, int narg, char **arg)
sphere_flag = ellipsoid_flag = peri_flag = electron_flag = 0; sphere_flag = ellipsoid_flag = peri_flag = electron_flag = 0;
molecule_flag = q_flag = mu_flag = 0; molecule_flag = q_flag = mu_flag = 0;
rmass_flag = radius_flag = omega_flag = torque_flag = 0; rmass_flag = radius_flag = omega_flag = torque_flag = angmom_flag = 0;
quat_flag = shape_flag = angmom_flag = 0;
vfrac_flag = spin_flag = eradius_flag = ervel_flag = erforce_flag = 0; vfrac_flag = spin_flag = eradius_flag = ervel_flag = erforce_flag = 0;
avec = new_avec(style,narg,arg); avec = new_avec(style,narg,arg);
@ -329,19 +325,20 @@ void Atom::setup()
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
return 1 if style matches atom style or hybrid sub-style return ptr to AtomVec class if matches style or to matching hybrid sub-class
else return 0 return NULL if no match
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
int Atom::style_match(const char *style) AtomVec *Atom::style_match(const char *style)
{ {
if (strcmp(atom_style,style) == 0) return 1; if (strcmp(atom_style,style) == 0) return avec;
else if (strcmp(atom_style,"hybrid") == 0) { else if (strcmp(atom_style,"hybrid") == 0) {
AtomVecHybrid *avec_hybrid = (AtomVecHybrid *) avec; AtomVecHybrid *avec_hybrid = (AtomVecHybrid *) avec;
for (int i = 0; i < avec_hybrid->nstyles; i++) for (int i = 0; i < avec_hybrid->nstyles; i++)
if (strcmp(avec_hybrid->keywords[i],style) == 0) return 1; if (strcmp(avec_hybrid->keywords[i],style) == 0)
return avec_hybrid->styles[i];
} }
return 0; return NULL;
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
@ -847,6 +844,53 @@ void Atom::data_vels(int n, char *buf)
delete [] values; delete [] values;
} }
/* ----------------------------------------------------------------------
unpack n lines from atom-style specific section of data file
check that atom IDs are > 0 and <= map_tag_max
call style-specific routine to parse line
------------------------------------------------------------------------- */
void Atom::data_bonus(int n, char *buf, AtomVec *avec_bonus)
{
int j,m,tagdata;
char *next;
next = strchr(buf,'\n');
*next = '\0';
int nwords = count_words(buf);
*next = '\n';
if (nwords != avec_bonus->size_data_bonus)
error->all("Incorrect bonus data format in data file");
char **values = new char*[nwords];
// loop over lines of bonus atom data
// tokenize the line into values
// if I own atom tag, unpack its values
for (int i = 0; i < n; i++) {
next = strchr(buf,'\n');
values[0] = strtok(buf," \t\n\r\f");
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 Bonus section of data file");
// ok to call child's data_atom_bonus() method thru parent avec_bonus,
// since data_bonus() was called with child ptr, and method is virtual
if ((m = map(tagdata)) >= 0) avec_bonus->data_atom_bonus(m,&values[1]);
buf = next + 1;
}
delete [] values;
}
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
check that atom IDs are > 0 and <= map_tag_max check that atom IDs are > 0 and <= map_tag_max
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
@ -1170,23 +1214,32 @@ int Atom::radius_consistency(int itype, double &rad)
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
check that shape of all particles of itype are the same check that shape of all particles of itype are the same
return 1 if true, else return 0 return 1 if true, else return 0
also return the radius value for that type also return the 3 shape params for itype
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
int Atom::shape_consistency(int itype, int Atom::shape_consistency(int itype,
double &shapex, double &shapey, double &shapez) double &shapex, double &shapey, double &shapez)
{ {
double one[3]; double zero[3] = {0.0, 0.0, 0.0};
one[0] = one[1] = one[2] = -1.0; double one[3] = {-1.0, -1.0, -1.0};
double *shape;
AtomVecEllipsoid *avec_ellipsoid =
(AtomVecEllipsoid *) style_match("ellipsoid");
AtomVecEllipsoid::Bonus *bonus = avec_ellipsoid->bonus;
int flag = 0; int flag = 0;
for (int i = 0; i < nlocal; i++) { for (int i = 0; i < nlocal; i++) {
if (type[i] != itype) continue; if (type[i] != itype) continue;
if (ellipsoid[i] < 0) shape = zero;
else shape = bonus[ellipsoid[i]].shape;
if (one[0] < 0.0) { if (one[0] < 0.0) {
one[0] = shape[i][0]; one[0] = shape[0];
one[1] = shape[i][1]; one[1] = shape[1];
one[2] = shape[i][2]; one[2] = shape[2];
} else if (one[0] != shape[i][0] || one[1] != shape[i][1] || } else if (one[0] != shape[0] || one[1] != shape[1] || one[2] != shape[2])
one[2] != shape[i][2]) flag = 1; flag = 1;
} }
int flagall; int flagall;
@ -1223,9 +1276,9 @@ void Atom::first_reorder()
for (int i = 0; i < nlocal; i++) { for (int i = 0; i < nlocal; i++) {
if (mask[i] & bitmask && i > nfirst) { if (mask[i] & bitmask && i > nfirst) {
avec->copy(i,nlocal); avec->copy(i,nlocal,0);
avec->copy(nfirst,i); avec->copy(nfirst,i,0);
avec->copy(nlocal,nfirst); avec->copy(nlocal,nfirst,0);
while (nfirst < nlocal && mask[nfirst] & bitmask) nfirst++; while (nfirst < nlocal && mask[nfirst] & bitmask) nfirst++;
} }
} }
@ -1310,13 +1363,13 @@ void Atom::sort()
for (i = 0; i < nlocal; i++) { for (i = 0; i < nlocal; i++) {
if (current[i] == permute[i]) continue; if (current[i] == permute[i]) continue;
avec->copy(i,nlocal); avec->copy(i,nlocal,0);
empty = i; empty = i;
while (permute[empty] != i) { while (permute[empty] != i) {
avec->copy(permute[empty],empty); avec->copy(permute[empty],empty,0);
empty = current[empty] = permute[empty]; empty = current[empty] = permute[empty];
} }
avec->copy(nlocal,empty); avec->copy(nlocal,empty,0);
current[empty] = permute[empty]; current[empty] = permute[empty];
} }

View File

@ -48,10 +48,10 @@ class Atom : protected Pointers {
int *molecule; int *molecule;
double *q,**mu; double *q,**mu;
double **quat,**omega,**angmom,**torque,**shape; double **omega,**angmom,**torque;
double *radius,*rmass,*vfrac,*s0; double *radius,*rmass,*vfrac,*s0;
double **x0; double **x0;
int *ellipsoid;
int *spin; int *spin;
double *eradius,*ervel,*erforce; double *eradius,*ervel,*erforce;
@ -81,8 +81,7 @@ class Atom : protected Pointers {
int sphere_flag,ellipsoid_flag,peri_flag,electron_flag; int sphere_flag,ellipsoid_flag,peri_flag,electron_flag;
int molecule_flag,q_flag,mu_flag; int molecule_flag,q_flag,mu_flag;
int rmass_flag,radius_flag,omega_flag,torque_flag; int rmass_flag,radius_flag,omega_flag,torque_flag,angmom_flag;
int quat_flag,shape_flag,angmom_flag;
int vfrac_flag,spin_flag,eradius_flag,ervel_flag,erforce_flag; int vfrac_flag,spin_flag,eradius_flag,ervel_flag,erforce_flag;
// extra peratom info in restart file destined for fix & diag // extra peratom info in restart file destined for fix & diag
@ -120,7 +119,7 @@ class Atom : protected Pointers {
void init(); void init();
void setup(); void setup();
int style_match(const char *); class AtomVec *style_match(const char *);
void modify_params(int, char **); void modify_params(int, char **);
void tag_extend(); void tag_extend();
int tag_consecutive(); int tag_consecutive();
@ -130,6 +129,8 @@ class Atom : protected Pointers {
void data_atoms(int, char *); void data_atoms(int, char *);
void data_vels(int, char *); void data_vels(int, char *);
void data_bonus(int, char *, class AtomVec *);
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 *);

View File

@ -25,6 +25,7 @@ AtomVec::AtomVec(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp)
nmax = 0; nmax = 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 = dipole_type = 0;
size_data_bonus = 0;
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------

View File

@ -35,6 +35,7 @@ class AtomVec : protected Pointers {
int size_velocity; // # of velocity based quantities int size_velocity; // # of velocity based quantities
int size_data_atom; // number of values in Atom line int size_data_atom; // number of values in Atom line
int size_data_vel; // number of values in Velocity line int size_data_vel; // number of values in Velocity line
int size_data_bonus; // number of values in Bonus line
int xcol_data; // column (1-N) where x is in Atom line int xcol_data; // column (1-N) where x is in Atom line
AtomVec(class LAMMPS *, int, char **); AtomVec(class LAMMPS *, int, char **);
@ -43,7 +44,8 @@ class AtomVec : protected Pointers {
virtual void grow(int) = 0; virtual void grow(int) = 0;
virtual void grow_reset() = 0; virtual void grow_reset() = 0;
virtual void copy(int, int) = 0; virtual void copy(int, int, int) = 0;
virtual void clear_bonus() {}
virtual int pack_comm(int, int *, double *, int, int *) = 0; virtual int pack_comm(int, int *, double *, int, int *) = 0;
virtual int pack_comm_vel(int, int *, double *, int, int *) = 0; virtual int pack_comm_vel(int, int *, double *, int, int *) = 0;
@ -73,6 +75,7 @@ class AtomVec : protected Pointers {
virtual void create_atom(int, double *) = 0; virtual void create_atom(int, double *) = 0;
virtual void data_atom(double *, int, char **) = 0; virtual void data_atom(double *, int, char **) = 0;
virtual void data_atom_bonus(int, char **) {}
virtual int data_atom_hybrid(int, char **) {return 0;} virtual int data_atom_hybrid(int, char **) {return 0;}
virtual void data_vel(int, char **); virtual void data_vel(int, char **);
virtual int data_vel_hybrid(int, char **) {return 0;} virtual int data_vel_hybrid(int, char **) {return 0;}

View File

@ -81,9 +81,11 @@ void AtomVecAtomic::grow_reset()
x = atom->x; v = atom->v; f = atom->f; x = atom->x; v = atom->v; f = atom->f;
} }
/* ---------------------------------------------------------------------- */ /* ----------------------------------------------------------------------
copy atom I info to atom J
------------------------------------------------------------------------- */
void AtomVecAtomic::copy(int i, int j) void AtomVecAtomic::copy(int i, int j, int delflag)
{ {
tag[j] = tag[i]; tag[j] = tag[i];
type[j] = type[i]; type[j] = type[i];

View File

@ -30,7 +30,7 @@ class AtomVecAtomic : public AtomVec {
~AtomVecAtomic() {} ~AtomVecAtomic() {}
void grow(int); void grow(int);
void grow_reset(); void grow_reset();
void copy(int, int); void copy(int, int, int);
int pack_comm(int, int *, double *, int, int *); int pack_comm(int, int *, double *, int, int *);
int pack_comm_vel(int, int *, double *, int, int *); int pack_comm_vel(int, int *, double *, int, int *);
void unpack_comm(int, int, double *); void unpack_comm(int, int, double *);

View File

@ -86,9 +86,11 @@ void AtomVecCharge::grow_reset()
q = atom->q; q = atom->q;
} }
/* ---------------------------------------------------------------------- */ /* ----------------------------------------------------------------------
copy atom I info to atom J
------------------------------------------------------------------------- */
void AtomVecCharge::copy(int i, int j) void AtomVecCharge::copy(int i, int j, int delflag)
{ {
tag[j] = tag[i]; tag[j] = tag[i];
type[j] = type[i]; type[j] = type[i];

View File

@ -29,7 +29,7 @@ class AtomVecCharge : public AtomVec {
AtomVecCharge(class LAMMPS *, int, char **); AtomVecCharge(class LAMMPS *, int, char **);
void grow(int); void grow(int);
void grow_reset(); void grow_reset();
void copy(int, int); void copy(int, int, int);
int pack_comm(int, int *, double *, int, int *); int pack_comm(int, int *, double *, int, int *);
int pack_comm_vel(int, int *, double *, int, int *); int pack_comm_vel(int, int *, double *, int, int *);
void unpack_comm(int, int, double *); void unpack_comm(int, int, double *);

View File

@ -157,14 +157,14 @@ void AtomVecHybrid::grow_reset()
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
copy array values for all sub-styles copy atom I info to atom J for all sub-styles
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void AtomVecHybrid::copy(int i, int j) void AtomVecHybrid::copy(int i, int j, int delflag)
{ {
int tmp = atom->nextra_grow; int tmp = atom->nextra_grow;
atom->nextra_grow = 0; atom->nextra_grow = 0;
for (int k = 0; k < nstyles; k++) styles[k]->copy(i,j); for (int k = 0; k < nstyles; k++) styles[k]->copy(i,j,delflag);
atom->nextra_grow = tmp; atom->nextra_grow = tmp;
if (atom->nextra_grow) if (atom->nextra_grow)
@ -174,6 +174,13 @@ void AtomVecHybrid::copy(int i, int j)
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
void AtomVecHybrid::clear_bonus()
{
for (int k = 0; k < nstyles; k++) styles[k]->clear_bonus();
}
/* ---------------------------------------------------------------------- */
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)
{ {

View File

@ -35,7 +35,8 @@ class AtomVecHybrid : public AtomVec {
void init(); void init();
void grow(int); void grow(int);
void grow_reset(); void grow_reset();
void copy(int, int); void copy(int, int, int);
void clear_bonus();
int pack_comm(int, int *, double *, int, int *); int pack_comm(int, int *, double *, int, int *);
int pack_comm_vel(int, int *, double *, int, int *); int pack_comm_vel(int, int *, double *, int, int *);
void unpack_comm(int, int, double *); void unpack_comm(int, int, double *);

View File

@ -121,9 +121,11 @@ void AtomVecSphere::grow_reset()
omega = atom->omega; torque = atom->torque; omega = atom->omega; torque = atom->torque;
} }
/* ---------------------------------------------------------------------- */ /* ----------------------------------------------------------------------
copy atom I info to atom J
------------------------------------------------------------------------- */
void AtomVecSphere::copy(int i, int j) void AtomVecSphere::copy(int i, int j, int delflag)
{ {
tag[j] = tag[i]; tag[j] = tag[i];
type[j] = type[i]; type[j] = type[i];

View File

@ -31,7 +31,7 @@ class AtomVecSphere : public AtomVec {
void init(); void init();
void grow(int); void grow(int);
void grow_reset(); void grow_reset();
void copy(int, int); void copy(int, int, int);
int pack_comm(int, int *, double *, int, int *); int pack_comm(int, int *, double *, int, int *);
int pack_comm_vel(int, int *, double *, int, int *); int pack_comm_vel(int, int *, double *, int, int *);
int pack_comm_hybrid(int, int *, double *); int pack_comm_hybrid(int, int *, double *);

View File

@ -566,7 +566,7 @@ void Comm::exchange()
if (x[i][dim] < lo || x[i][dim] >= hi) { if (x[i][dim] < lo || x[i][dim] >= hi) {
if (nsend > maxsend) grow_send(nsend,1); if (nsend > maxsend) grow_send(nsend,1);
nsend += avec->pack_exchange(i,&buf_send[nsend]); nsend += avec->pack_exchange(i,&buf_send[nsend]);
avec->copy(nlocal-1,i); avec->copy(nlocal-1,i,1);
nlocal--; nlocal--;
} else i++; } else i++;
} }
@ -643,9 +643,10 @@ void Comm::borders()
MPI_Status status; MPI_Status status;
AtomVec *avec = atom->avec; AtomVec *avec = atom->avec;
// clear old ghosts // clear old ghosts and any ghost bonus data internal to AtomVec
atom->nghost = 0; atom->nghost = 0;
atom->avec->clear_bonus();
// do swaps over all 3 dimensions // do swaps over all 3 dimensions

View File

@ -14,6 +14,7 @@
#include "string.h" #include "string.h"
#include "compute_property_atom.h" #include "compute_property_atom.h"
#include "atom.h" #include "atom.h"
#include "atom_vec_ellipsoid.h"
#include "update.h" #include "update.h"
#include "domain.h" #include "domain.h"
#include "memory.h" #include "memory.h"
@ -167,39 +168,39 @@ ComputePropertyAtom::ComputePropertyAtom(LAMMPS *lmp, int narg, char **arg) :
pack_choice[i] = &ComputePropertyAtom::pack_angmomz; pack_choice[i] = &ComputePropertyAtom::pack_angmomz;
} else if (strcmp(arg[iarg],"shapex") == 0) { } else if (strcmp(arg[iarg],"shapex") == 0) {
if (!atom->shape_flag) avec = (AtomVecEllipsoid *) atom->style_match("ellipsoid");
error->all("Compute property/atom for " if (!avec) error->all("Compute property/atom for "
"atom property that isn't allocated"); "atom property that isn't allocated");
pack_choice[i] = &ComputePropertyAtom::pack_shapex; pack_choice[i] = &ComputePropertyAtom::pack_shapex;
} else if (strcmp(arg[iarg],"shapey") == 0) { } else if (strcmp(arg[iarg],"shapey") == 0) {
if (!atom->shape_flag) avec = (AtomVecEllipsoid *) atom->style_match("ellipsoid");
error->all("Compute property/atom for " if (!avec) error->all("Compute property/atom for "
"atom property that isn't allocated"); "atom property that isn't allocated");
pack_choice[i] = &ComputePropertyAtom::pack_shapey; pack_choice[i] = &ComputePropertyAtom::pack_shapey;
} else if (strcmp(arg[iarg],"shapez") == 0) { } else if (strcmp(arg[iarg],"shapez") == 0) {
if (!atom->shape_flag) avec = (AtomVecEllipsoid *) atom->style_match("ellipsoid");
error->all("Compute property/atom for " if (!avec) error->all("Compute property/atom for "
"atom property that isn't allocated"); "atom property that isn't allocated");
pack_choice[i] = &ComputePropertyAtom::pack_shapez; pack_choice[i] = &ComputePropertyAtom::pack_shapez;
} else if (strcmp(arg[iarg],"quatw") == 0) { } else if (strcmp(arg[iarg],"quatw") == 0) {
if (!atom->quat_flag) avec = (AtomVecEllipsoid *) atom->style_match("ellipsoid");
error->all("Compute property/atom for " if (!avec) error->all("Compute property/atom for "
"atom property that isn't allocated"); "atom property that isn't allocated");
pack_choice[i] = &ComputePropertyAtom::pack_quatw; pack_choice[i] = &ComputePropertyAtom::pack_quatw;
} else if (strcmp(arg[iarg],"quati") == 0) { } else if (strcmp(arg[iarg],"quati") == 0) {
if (!atom->quat_flag) avec = (AtomVecEllipsoid *) atom->style_match("ellipsoid");
error->all("Compute property/atom for " if (!avec) error->all("Compute property/atom for "
"atom property that isn't allocated"); "atom property that isn't allocated");
pack_choice[i] = &ComputePropertyAtom::pack_quati; pack_choice[i] = &ComputePropertyAtom::pack_quati;
} else if (strcmp(arg[iarg],"quatj") == 0) { } else if (strcmp(arg[iarg],"quatj") == 0) {
if (!atom->quat_flag) avec = (AtomVecEllipsoid *) atom->style_match("ellipsoid");
error->all("Compute property/atom for " if (!avec) error->all("Compute property/atom for "
"atom property that isn't allocated"); "atom property that isn't allocated");
pack_choice[i] = &ComputePropertyAtom::pack_quatj; pack_choice[i] = &ComputePropertyAtom::pack_quatj;
} else if (strcmp(arg[iarg],"quatk") == 0) { } else if (strcmp(arg[iarg],"quatk") == 0) {
if (!atom->quat_flag) avec = (AtomVecEllipsoid *) atom->style_match("ellipsoid");
error->all("Compute property/atom for " if (!avec) error->all("Compute property/atom for "
"atom property that isn't allocated"); "atom property that isn't allocated");
pack_choice[i] = &ComputePropertyAtom::pack_quatk; pack_choice[i] = &ComputePropertyAtom::pack_quatk;
} else if (strcmp(arg[iarg],"tqx") == 0) { } else if (strcmp(arg[iarg],"tqx") == 0) {
if (!atom->torque_flag) if (!atom->torque_flag)
@ -973,12 +974,14 @@ void ComputePropertyAtom::pack_angmomz(int n)
void ComputePropertyAtom::pack_shapex(int n) void ComputePropertyAtom::pack_shapex(int n)
{ {
double **shape = atom->shape; AtomVecEllipsoid::Bonus *bonus = avec->bonus;
int *ellipsoid = atom->ellipsoid;
int *mask = atom->mask; int *mask = atom->mask;
int nlocal = atom->nlocal; int nlocal = atom->nlocal;
for (int i = 0; i < nlocal; i++) { for (int i = 0; i < nlocal; i++) {
if (mask[i] & groupbit) buf[n] = shape[i][0]; if ((mask[i] & groupbit) && ellipsoid[i] >= 0)
buf[n] = bonus[ellipsoid[i]].shape[0];
else buf[n] = 0.0; else buf[n] = 0.0;
n += nvalues; n += nvalues;
} }
@ -988,12 +991,14 @@ void ComputePropertyAtom::pack_shapex(int n)
void ComputePropertyAtom::pack_shapey(int n) void ComputePropertyAtom::pack_shapey(int n)
{ {
double **shape = atom->shape; AtomVecEllipsoid::Bonus *bonus = avec->bonus;
int *ellipsoid = atom->ellipsoid;
int *mask = atom->mask; int *mask = atom->mask;
int nlocal = atom->nlocal; int nlocal = atom->nlocal;
for (int i = 0; i < nlocal; i++) { for (int i = 0; i < nlocal; i++) {
if (mask[i] & groupbit) buf[n] = shape[i][1]; if ((mask[i] & groupbit) && ellipsoid[i] >= 0)
buf[n] = bonus[ellipsoid[i]].shape[1];
else buf[n] = 0.0; else buf[n] = 0.0;
n += nvalues; n += nvalues;
} }
@ -1003,12 +1008,14 @@ void ComputePropertyAtom::pack_shapey(int n)
void ComputePropertyAtom::pack_shapez(int n) void ComputePropertyAtom::pack_shapez(int n)
{ {
double **shape = atom->shape; AtomVecEllipsoid::Bonus *bonus = avec->bonus;
int *ellipsoid = atom->ellipsoid;
int *mask = atom->mask; int *mask = atom->mask;
int nlocal = atom->nlocal; int nlocal = atom->nlocal;
for (int i = 0; i < nlocal; i++) { for (int i = 0; i < nlocal; i++) {
if (mask[i] & groupbit) buf[n] = shape[i][2]; if ((mask[i] & groupbit) && ellipsoid[i] >= 0)
buf[n] = bonus[ellipsoid[i]].shape[2];
else buf[n] = 0.0; else buf[n] = 0.0;
n += nvalues; n += nvalues;
} }
@ -1018,12 +1025,14 @@ void ComputePropertyAtom::pack_shapez(int n)
void ComputePropertyAtom::pack_quatw(int n) void ComputePropertyAtom::pack_quatw(int n)
{ {
double **quat = atom->quat; AtomVecEllipsoid::Bonus *bonus = avec->bonus;
int *ellipsoid = atom->ellipsoid;
int *mask = atom->mask; int *mask = atom->mask;
int nlocal = atom->nlocal; int nlocal = atom->nlocal;
for (int i = 0; i < nlocal; i++) { for (int i = 0; i < nlocal; i++) {
if (mask[i] & groupbit) buf[n] = quat[i][0]; if ((mask[i] & groupbit) && ellipsoid[i] >= 0)
buf[n] = bonus[ellipsoid[i]].quat[0];
else buf[n] = 0.0; else buf[n] = 0.0;
n += nvalues; n += nvalues;
} }
@ -1033,12 +1042,14 @@ void ComputePropertyAtom::pack_quatw(int n)
void ComputePropertyAtom::pack_quati(int n) void ComputePropertyAtom::pack_quati(int n)
{ {
double **quat = atom->quat; AtomVecEllipsoid::Bonus *bonus = avec->bonus;
int *ellipsoid = atom->ellipsoid;
int *mask = atom->mask; int *mask = atom->mask;
int nlocal = atom->nlocal; int nlocal = atom->nlocal;
for (int i = 0; i < nlocal; i++) { for (int i = 0; i < nlocal; i++) {
if (mask[i] & groupbit) buf[n] = quat[i][1]; if ((mask[i] & groupbit) && ellipsoid[i] >= 0)
buf[n] = bonus[ellipsoid[i]].quat[1];
else buf[n] = 0.0; else buf[n] = 0.0;
n += nvalues; n += nvalues;
} }
@ -1048,12 +1059,14 @@ void ComputePropertyAtom::pack_quati(int n)
void ComputePropertyAtom::pack_quatj(int n) void ComputePropertyAtom::pack_quatj(int n)
{ {
double **quat = atom->quat; AtomVecEllipsoid::Bonus *bonus = avec->bonus;
int *ellipsoid = atom->ellipsoid;
int *mask = atom->mask; int *mask = atom->mask;
int nlocal = atom->nlocal; int nlocal = atom->nlocal;
for (int i = 0; i < nlocal; i++) { for (int i = 0; i < nlocal; i++) {
if (mask[i] & groupbit) buf[n] = quat[i][2]; if ((mask[i] & groupbit) && ellipsoid[i] >= 0)
buf[n] = bonus[ellipsoid[i]].quat[2];
else buf[n] = 0.0; else buf[n] = 0.0;
n += nvalues; n += nvalues;
} }
@ -1063,12 +1076,14 @@ void ComputePropertyAtom::pack_quatj(int n)
void ComputePropertyAtom::pack_quatk(int n) void ComputePropertyAtom::pack_quatk(int n)
{ {
double **quat = atom->quat; AtomVecEllipsoid::Bonus *bonus = avec->bonus;
int *ellipsoid = atom->ellipsoid;
int *mask = atom->mask; int *mask = atom->mask;
int nlocal = atom->nlocal; int nlocal = atom->nlocal;
for (int i = 0; i < nlocal; i++) { for (int i = 0; i < nlocal; i++) {
if (mask[i] & groupbit) buf[n] = quat[i][3]; if ((mask[i] & groupbit) && ellipsoid[i] >= 0)
buf[n] = bonus[ellipsoid[i]].quat[3];
else buf[n] = 0.0; else buf[n] = 0.0;
n += nvalues; n += nvalues;
} }

View File

@ -38,6 +38,7 @@ class ComputePropertyAtom : public Compute {
double *vector; double *vector;
double **array; double **array;
double *buf; double *buf;
class AtomVecEllipsoid *avec;
typedef void (ComputePropertyAtom::*FnPtrPack)(int); typedef void (ComputePropertyAtom::*FnPtrPack)(int);
FnPtrPack *pack_choice; // ptrs to pack functions FnPtrPack *pack_choice; // ptrs to pack functions

View File

@ -69,7 +69,7 @@ void DeleteAtoms::command(int narg, char **arg)
int i = 0; int i = 0;
while (i < nlocal) { while (i < nlocal) {
if (dlist[i]) { if (dlist[i]) {
avec->copy(nlocal-1,i); avec->copy(nlocal-1,i,1);
dlist[i] = dlist[nlocal-1]; dlist[i] = dlist[nlocal-1];
nlocal--; nlocal--;
} else i++; } else i++;

View File

@ -191,7 +191,7 @@ void DumpCFG::write_header(bigint n)
// scale box dimension to sc lattice for C with sigma = 1.44 Angstroms // scale box dimension to sc lattice for C with sigma = 1.44 Angstroms
double scale; double scale;
if (atom->style_match("peri")) { if (atom->peri_flag) {
int nlocal = atom->nlocal; int nlocal = atom->nlocal;
double vone = 0.0; double vone = 0.0;
for (int i = 0; i < nlocal; i++) vone += atom->vfrac[i]; for (int i = 0; i < nlocal; i++) vone += atom->vfrac[i];

View File

@ -38,8 +38,7 @@ enum{ID,MOL,TYPE,MASS,
X,Y,Z,XS,YS,ZS,XSTRI,YSTRI,ZSTRI,XU,YU,ZU,XUTRI,YUTRI,ZUTRI,IX,IY,IZ, X,Y,Z,XS,YS,ZS,XSTRI,YSTRI,ZSTRI,XU,YU,ZU,XUTRI,YUTRI,ZUTRI,IX,IY,IZ,
VX,VY,VZ,FX,FY,FZ, VX,VY,VZ,FX,FY,FZ,
Q,MUX,MUY,MUZ,MU,RADIUS,OMEGAX,OMEGAY,OMEGAZ,ANGMOMX,ANGMOMY,ANGMOMZ, Q,MUX,MUY,MUZ,MU,RADIUS,OMEGAX,OMEGAY,OMEGAZ,ANGMOMX,ANGMOMY,ANGMOMZ,
SHAPEX,SHAPEY,SHAPEZ, TQX,TQY,TQZ,SPIN,ERADIUS,ERVEL,ERFORCE,
QUATW,QUATI,QUATJ,QUATK,TQX,TQY,TQZ,SPIN,ERADIUS,ERVEL,ERFORCE,
COMPUTE,FIX,VARIABLE}; COMPUTE,FIX,VARIABLE};
enum{LT,LE,GT,GE,EQ,NEQ}; enum{LT,LE,GT,GE,EQ,NEQ};
enum{INT,DOUBLE}; enum{INT,DOUBLE};
@ -663,42 +662,6 @@ int DumpCustom::count()
error->all("Threshhold for an atom property that isn't allocated"); error->all("Threshhold for an atom property that isn't allocated");
ptr = &atom->angmom[0][2]; ptr = &atom->angmom[0][2];
nstride = 3; nstride = 3;
} else if (thresh_array[ithresh] == SHAPEX) {
if (!atom->shape_flag)
error->all("Threshhold for an atom property that isn't allocated");
ptr = &atom->shape[0][0];
nstride = 3;
} else if (thresh_array[ithresh] == SHAPEY) {
if (!atom->shape_flag)
error->all("Threshhold for an atom property that isn't allocated");
ptr = &atom->shape[0][1];
nstride = 3;
} else if (thresh_array[ithresh] == SHAPEZ) {
if (!atom->shape_flag)
error->all("Threshhold for an atom property that isn't allocated");
ptr = &atom->shape[0][2];
nstride = 3;
} else if (thresh_array[ithresh] == QUATW) {
if (!atom->quat_flag)
error->all("Threshhold for an atom property that isn't allocated");
ptr = &atom->quat[0][0];
nstride = 4;
} else if (thresh_array[ithresh] == QUATI) {
if (!atom->quat_flag)
error->all("Threshhold for an atom property that isn't allocated");
ptr = &atom->quat[0][1];
nstride = 4;
} else if (thresh_array[ithresh] == QUATJ) {
if (!atom->quat_flag)
error->all("Threshhold for an atom property that isn't allocated");
ptr = &atom->quat[0][2];
nstride = 4;
} else if (thresh_array[ithresh] == QUATK) {
if (!atom->quat_flag)
error->all("Threshhold for an atom property that isn't allocated");
ptr = &atom->quat[0][3];
nstride = 4;
} else if (thresh_array[ithresh] == TQX) { } else if (thresh_array[ithresh] == TQX) {
if (!atom->torque_flag) if (!atom->torque_flag)
error->all("Threshhold for an atom property that isn't allocated"); error->all("Threshhold for an atom property that isn't allocated");
@ -1006,42 +969,6 @@ void DumpCustom::parse_fields(int narg, char **arg)
error->all("Dumping an atom property that isn't allocated"); error->all("Dumping an atom property that isn't allocated");
pack_choice[i] = &DumpCustom::pack_angmomz; pack_choice[i] = &DumpCustom::pack_angmomz;
vtype[i] = DOUBLE; vtype[i] = DOUBLE;
} else if (strcmp(arg[iarg],"shapex") == 0) {
if (!atom->shape_flag)
error->all("Dumping an atom property that isn't allocated");
pack_choice[i] = &DumpCustom::pack_shapex;
vtype[i] = DOUBLE;
} else if (strcmp(arg[iarg],"shapey") == 0) {
if (!atom->shape_flag)
error->all("Dumping an atom property that isn't allocated");
pack_choice[i] = &DumpCustom::pack_shapey;
vtype[i] = DOUBLE;
} else if (strcmp(arg[iarg],"shapez") == 0) {
if (!atom->shape_flag)
error->all("Dumping an atom property that isn't allocated");
pack_choice[i] = &DumpCustom::pack_shapez;
vtype[i] = DOUBLE;
} else if (strcmp(arg[iarg],"quatw") == 0) {
if (!atom->quat_flag)
error->all("Dumping an atom property that isn't allocated");
pack_choice[i] = &DumpCustom::pack_quatw;
vtype[i] = DOUBLE;
} else if (strcmp(arg[iarg],"quati") == 0) {
if (!atom->quat_flag)
error->all("Dumping an atom property that isn't allocated");
pack_choice[i] = &DumpCustom::pack_quati;
vtype[i] = DOUBLE;
} else if (strcmp(arg[iarg],"quatj") == 0) {
if (!atom->quat_flag)
error->all("Dumping an atom property that isn't allocated");
pack_choice[i] = &DumpCustom::pack_quatj;
vtype[i] = DOUBLE;
} else if (strcmp(arg[iarg],"quatk") == 0) {
if (!atom->quat_flag)
error->all("Dumping an atom property 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_flag) if (!atom->torque_flag)
error->all("Dumping an atom property that isn't allocated"); error->all("Dumping an atom property that isn't allocated");
@ -1350,14 +1277,6 @@ int DumpCustom::modify_param(int narg, char **arg)
else if (strcmp(arg[1],"angmomx") == 0) thresh_array[nthresh] = ANGMOMX; else if (strcmp(arg[1],"angmomx") == 0) thresh_array[nthresh] = ANGMOMX;
else if (strcmp(arg[1],"angmomy") == 0) thresh_array[nthresh] = ANGMOMY; else if (strcmp(arg[1],"angmomy") == 0) thresh_array[nthresh] = ANGMOMY;
else if (strcmp(arg[1],"angmomz") == 0) thresh_array[nthresh] = ANGMOMZ; else if (strcmp(arg[1],"angmomz") == 0) thresh_array[nthresh] = ANGMOMZ;
else if (strcmp(arg[1],"shapex") == 0) thresh_array[nthresh] = SHAPEX;
else if (strcmp(arg[1],"shapey") == 0) thresh_array[nthresh] = SHAPEY;
else if (strcmp(arg[1],"shapez") == 0) thresh_array[nthresh] = SHAPEZ;
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;
@ -2196,104 +2115,6 @@ void DumpCustom::pack_angmomz(int n)
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
void DumpCustom::pack_shapex(int n)
{
double **shape = atom->shape;
int nlocal = atom->nlocal;
for (int i = 0; i < nlocal; i++)
if (choose[i]) {
buf[n] = shape[i][0];
n += size_one;
}
}
/* ---------------------------------------------------------------------- */
void DumpCustom::pack_shapey(int n)
{
double **shape = atom->shape;
int nlocal = atom->nlocal;
for (int i = 0; i < nlocal; i++)
if (choose[i]) {
buf[n] = shape[i][1];
n += size_one;
}
}
/* ---------------------------------------------------------------------- */
void DumpCustom::pack_shapez(int n)
{
double **shape = atom->shape;
int nlocal = atom->nlocal;
for (int i = 0; i < nlocal; i++)
if (choose[i]) {
buf[n] = shape[i][2];
n += size_one;
}
}
/* ---------------------------------------------------------------------- */
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

@ -142,13 +142,6 @@ class DumpCustom : public Dump {
void pack_angmomx(int); void pack_angmomx(int);
void pack_angmomy(int); void pack_angmomy(int);
void pack_angmomz(int); void pack_angmomz(int);
void pack_shapex(int);
void pack_shapey(int);
void pack_shapez(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

@ -287,7 +287,7 @@ void FixEvaporate::pre_exchange()
for (i = nlocal-1; i >= 0; i--) { for (i = nlocal-1; i >= 0; i--) {
if (mark[i]) { if (mark[i]) {
avec->copy(atom->nlocal-1,i); avec->copy(atom->nlocal-1,i,1);
atom->nlocal--; atom->nlocal--;
} }
} }

View File

@ -181,7 +181,7 @@ FixMove::FixMove(LAMMPS *lmp, int narg, char **arg) :
if (atom->angmom_flag && comm->me == 0) if (atom->angmom_flag && comm->me == 0)
error->warning("Fix move does not update angular momentum"); error->warning("Fix move does not update angular momentum");
if (atom->quat_flag && comm->me == 0) if (atom->ellipsoid_flag && comm->me == 0)
error->warning("Fix move does not update quaternions"); error->warning("Fix move does not update quaternions");
// setup scaling and apply scaling factors to velocity & amplitude // setup scaling and apply scaling factors to velocity & amplitude

View File

@ -18,7 +18,7 @@
#include "fix_rigid.h" #include "fix_rigid.h"
#include "math_extra.h" #include "math_extra.h"
#include "atom.h" #include "atom.h"
#include "atom_vec.h" #include "atom_vec_ellipsoid.h"
#include "domain.h" #include "domain.h"
#include "update.h" #include "update.h"
#include "respa.h" #include "respa.h"
@ -361,6 +361,10 @@ FixRigid::FixRigid(LAMMPS *lmp, int narg, char **arg) :
ANGMOM = 64; ANGMOM = 64;
TORQUE = 128; TORQUE = 128;
// atom style pointers to particles that store extra info
avec_ellipsoid = (AtomVecEllipsoid *) atom->style_match("ellipsoid");
// print statistics // print statistics
int nsum = 0; int nsum = 0;
@ -466,20 +470,21 @@ void FixRigid::init()
extended = dorientflag = qorientflag = 0; extended = dorientflag = qorientflag = 0;
double **shape = atom->shape; AtomVecEllipsoid::Bonus *ebonus = avec_ellipsoid->bonus;
double **mu = atom->mu; double **mu = atom->mu;
double *radius = atom->radius; double *radius = atom->radius;
double *rmass = atom->rmass; double *rmass = atom->rmass;
double *mass = atom->mass; double *mass = atom->mass;
int *ellipsoid = atom->ellipsoid;
int *type = atom->type; int *type = atom->type;
int nlocal = atom->nlocal; int nlocal = atom->nlocal;
if (atom->radius_flag || atom->shape_flag) { if (atom->radius_flag || atom->ellipsoid_flag || atom->mu_flag) {
int flag = 0; int flag = 0;
for (i = 0; i < nlocal; i++) { for (i = 0; i < nlocal; i++) {
if (body[i] < 0) continue; if (body[i] < 0) continue;
if (radius && radius[i] > 0.0) flag = 1; if (radius && radius[i] > 0.0) flag = 1;
if (shape && shape[i][0] > 0.0) flag = 1; if (ellipsoid && ellipsoid[i] >= 0) flag = 1;
if (mu && mu[i][3] > 0.0) flag = 1; if (mu && mu[i][3] > 0.0) flag = 1;
} }
@ -492,7 +497,7 @@ void FixRigid::init()
if (extended) { if (extended) {
if (atom->mu_flag) dorientflag = 1; if (atom->mu_flag) dorientflag = 1;
if (atom->quat_flag) qorientflag = 1; if (atom->ellipsoid_flag) qorientflag = 1;
grow_arrays(atom->nmax); grow_arrays(atom->nmax);
for (i = 0; i < nlocal; i++) { for (i = 0; i < nlocal; i++) {
@ -505,7 +510,7 @@ void FixRigid::init()
eflags[i] |= INERTIA_SPHERE; eflags[i] |= INERTIA_SPHERE;
eflags[i] |= OMEGA; eflags[i] |= OMEGA;
eflags[i] |= TORQUE; eflags[i] |= TORQUE;
} else if (shape && shape[i][0] > 0.0) { } else if (ellipsoid && ellipsoid[i] >= 0) {
eflags[i] |= INERTIA_ELLIPSOID; eflags[i] |= INERTIA_ELLIPSOID;
eflags[i] |= ORIENT_QUAT; eflags[i] |= ORIENT_QUAT;
eflags[i] |= ANGMOM; eflags[i] |= ANGMOM;
@ -629,9 +634,7 @@ void FixRigid::init()
if (extended) { if (extended) {
double ex[3],ey[3],ez[3],idiag[3]; double ex[3],ey[3],ez[3],idiag[3];
double p[3][3],ptrans[3][3],ispace[3][3],itemp[3][3]; double p[3][3],ptrans[3][3],ispace[3][3],itemp[3][3];
double *shape,*quatatom;
double *radius = atom->radius;
double **shape = atom->shape;
for (i = 0; i < nlocal; i++) { for (i = 0; i < nlocal; i++) {
if (body[i] < 0) continue; if (body[i] < 0) continue;
@ -647,14 +650,13 @@ void FixRigid::init()
sum[ibody][2] += 0.4 * massone * radius[i]*radius[i]; sum[ibody][2] += 0.4 * massone * radius[i]*radius[i];
} }
if (eflags[i] & INERTIA_ELLIPSOID) { if (eflags[i] & INERTIA_ELLIPSOID) {
MathExtra::quat_to_mat(atom->quat[i],p); shape = ebonus[ellipsoid[i]].shape;
MathExtra::quat_to_mat_trans(atom->quat[i],ptrans); quatatom = ebonus[ellipsoid[i]].quat;
idiag[0] = 0.2*massone * MathExtra::quat_to_mat(quatatom,p);
(shape[i][1]*shape[i][1]+shape[itype][2]*shape[i][2]); MathExtra::quat_to_mat_trans(quatatom,ptrans);
idiag[1] = 0.2*massone * idiag[0] = 0.2*massone * (shape[1]*shape[1]+shape[2]*shape[2]);
(shape[i][0]*shape[i][0]+shape[i][2]*shape[i][2]); idiag[1] = 0.2*massone * (shape[0]*shape[0]+shape[2]*shape[2]);
idiag[2] = 0.2*massone * idiag[2] = 0.2*massone * (shape[0]*shape[0]+shape[1]*shape[1]);
(shape[i][0]*shape[i][0]+shape[i][1]*shape[i][1]);
MathExtra::diag_times3(idiag,ptrans,itemp); MathExtra::diag_times3(idiag,ptrans,itemp);
MathExtra::times3(p,itemp,ispace); MathExtra::times3(p,itemp,ispace);
sum[ibody][0] += ispace[0][0]; sum[ibody][0] += ispace[0][0];
@ -744,6 +746,7 @@ void FixRigid::init()
// for extended particles, set their orientation wrt to rigid body // for extended particles, set their orientation wrt to rigid body
double qc[4]; double qc[4];
double *quatatom;
for (i = 0; i < nlocal; i++) { for (i = 0; i < nlocal; i++) {
if (body[i] < 0) { if (body[i] < 0) {
@ -779,9 +782,6 @@ void FixRigid::init()
dz*ez_space[ibody][2]; dz*ez_space[ibody][2];
if (extended) { if (extended) {
double **mu = atom->mu;
int *type = atom->type;
if (eflags[i] & ORIENT_DIPOLE) { if (eflags[i] & ORIENT_DIPOLE) {
dorient[i][0] = mu[i][0]*ex_space[ibody][0] + dorient[i][0] = mu[i][0]*ex_space[ibody][0] +
mu[i][1]*ex_space[ibody][1] + mu[i][2]*ex_space[ibody][2]; mu[i][1]*ex_space[ibody][1] + mu[i][2]*ex_space[ibody][2];
@ -794,8 +794,9 @@ void FixRigid::init()
dorient[i][0] = dorient[i][1] = dorient[i][2] = 0.0; dorient[i][0] = dorient[i][1] = dorient[i][2] = 0.0;
if (eflags[i] & ORIENT_QUAT) { if (eflags[i] & ORIENT_QUAT) {
quatatom = ebonus[ellipsoid[i]].quat;
qconjugate(quat[ibody],qc); qconjugate(quat[ibody],qc);
quatquat(qc,atom->quat[i],qorient[i]); quatquat(qc,quatatom,qorient[i]);
qnormalize(qorient[i]); qnormalize(qorient[i]);
} else if (qorientflag) } else if (qorientflag)
qorient[i][0] = qorient[i][1] = qorient[i][2] = qorient[i][3] = 0.0; qorient[i][0] = qorient[i][1] = qorient[i][2] = qorient[i][3] = 0.0;
@ -831,9 +832,7 @@ void FixRigid::init()
if (extended) { if (extended) {
double ex[3],ey[3],ez[3],idiag[3]; double ex[3],ey[3],ez[3],idiag[3];
double p[3][3],ptrans[3][3],ispace[3][3],itemp[3][3]; double p[3][3],ptrans[3][3],ispace[3][3],itemp[3][3];
double *shape;
double *radius = atom->radius;
double **shape = atom->shape;
for (i = 0; i < nlocal; i++) { for (i = 0; i < nlocal; i++) {
if (body[i] < 0) continue; if (body[i] < 0) continue;
@ -849,14 +848,12 @@ void FixRigid::init()
sum[ibody][2] += 0.4 * massone * radius[i]*radius[i]; sum[ibody][2] += 0.4 * massone * radius[i]*radius[i];
} }
if (eflags[i] & INERTIA_ELLIPSOID) { if (eflags[i] & INERTIA_ELLIPSOID) {
shape = ebonus[ellipsoid[i]].shape;
MathExtra::quat_to_mat(qorient[i],p); MathExtra::quat_to_mat(qorient[i],p);
MathExtra::quat_to_mat_trans(qorient[i],ptrans); MathExtra::quat_to_mat_trans(qorient[i],ptrans);
idiag[0] = 0.2*massone * idiag[0] = 0.2*massone * (shape[1]*shape[1]+shape[2]*shape[2]);
(shape[i][1]*shape[i][1]+shape[i][2]*shape[i][2]); idiag[1] = 0.2*massone * (shape[0]*shape[0]+shape[2]*shape[2]);
idiag[1] = 0.2*massone * idiag[2] = 0.2*massone * (shape[0]*shape[0]+shape[1]*shape[1]);
(shape[i][0]*shape[i][0]+shape[i][2]*shape[i][2]);
idiag[2] = 0.2*massone *
(shape[i][0]*shape[i][0]+shape[i][1]*shape[i][1]);
MathExtra::diag_times3(idiag,ptrans,itemp); MathExtra::diag_times3(idiag,ptrans,itemp);
MathExtra::times3(p,itemp,ispace); MathExtra::times3(p,itemp,ispace);
sum[ibody][0] += ispace[0][0]; sum[ibody][0] += ispace[0][0];
@ -1934,10 +1931,13 @@ void FixRigid::set_xv()
// set orientation, omega, angmom of each extended particle // set orientation, omega, angmom of each extended particle
if (extended) { if (extended) {
double *shape,*quatatom;
AtomVecEllipsoid::Bonus *ebonus = avec_ellipsoid->bonus;
double **omega_one = atom->omega; double **omega_one = atom->omega;
double **angmom_one = atom->angmom; double **angmom_one = atom->angmom;
double **shape = atom->shape;
double **mu = atom->mu; double **mu = atom->mu;
int *ellipsoid = atom->ellipsoid;
for (int i = 0; i < nlocal; i++) { for (int i = 0; i < nlocal; i++) {
if (body[i] < 0) continue; if (body[i] < 0) continue;
@ -1949,8 +1949,9 @@ void FixRigid::set_xv()
MathExtra::snormalize3(mu[i][3],mu[i],mu[i]); MathExtra::snormalize3(mu[i][3],mu[i],mu[i]);
} }
if (eflags[i] & ORIENT_QUAT) { if (eflags[i] & ORIENT_QUAT) {
quatquat(quat[ibody],qorient[i],atom->quat[i]); quatatom = ebonus[ellipsoid[i]].quat;
qnormalize(atom->quat[i]); quatquat(quat[ibody],qorient[i],quatatom);
qnormalize(quatatom);
} }
if (eflags[i] & OMEGA) { if (eflags[i] & OMEGA) {
omega_one[i][0] = omega[ibody][0]; omega_one[i][0] = omega[ibody][0];
@ -1958,13 +1959,12 @@ void FixRigid::set_xv()
omega_one[i][2] = omega[ibody][2]; omega_one[i][2] = omega[ibody][2];
} }
if (eflags[i] & ANGMOM) { if (eflags[i] & ANGMOM) {
ione[0] = 0.2*rmass[i] * shape = ebonus[ellipsoid[i]].shape;
(shape[i][1]*shape[i][1] + shape[i][2]*shape[i][2]); quatatom = ebonus[ellipsoid[i]].quat;
ione[1] = 0.2*rmass[i] * ione[0] = 0.2*rmass[i] * (shape[1]*shape[1] + shape[2]*shape[2]);
(shape[i][0]*shape[i][0] + shape[i][2]*shape[i][2]); ione[1] = 0.2*rmass[i] * (shape[0]*shape[0] + shape[2]*shape[2]);
ione[2] = 0.2*rmass[i] * ione[2] = 0.2*rmass[i] * (shape[0]*shape[0] + shape[1]*shape[1]);
(shape[i][0]*shape[i][0] + shape[i][1]*shape[i][1]); exyz_from_q(quatatom,exone,eyone,ezone);
exyz_from_q(atom->quat[i],exone,eyone,ezone);
angmom_from_omega(omega[ibody],exone,eyone,ezone,ione,angmom_one[i]); angmom_from_omega(omega[ibody],exone,eyone,ezone,ione,angmom_one[i]);
} }
} }
@ -2073,9 +2073,12 @@ void FixRigid::set_v()
// set omega, angmom of each extended particle // set omega, angmom of each extended particle
if (extended) { if (extended) {
double *shape,*quatatom;
AtomVecEllipsoid::Bonus *ebonus = avec_ellipsoid->bonus;
double **omega_one = atom->omega; double **omega_one = atom->omega;
double **angmom_one = atom->angmom; double **angmom_one = atom->angmom;
double **shape = atom->shape; int *ellipsoid = atom->ellipsoid;
for (int i = 0; i < nlocal; i++) { for (int i = 0; i < nlocal; i++) {
if (body[i] < 0) continue; if (body[i] < 0) continue;
@ -2087,13 +2090,12 @@ void FixRigid::set_v()
omega_one[i][2] = omega[ibody][2]; omega_one[i][2] = omega[ibody][2];
} }
if (eflags[i] & ANGMOM) { if (eflags[i] & ANGMOM) {
ione[0] = 0.2*rmass[i] * shape = ebonus[ellipsoid[i]].shape;
(shape[i][1]*shape[i][1] + shape[i][2]*shape[i][2]); quatatom = ebonus[ellipsoid[i]].quat;
ione[1] = 0.2*rmass[i] * ione[0] = 0.2*rmass[i] * (shape[1]*shape[1] + shape[2]*shape[2]);
(shape[i][0]*shape[i][0] + shape[i][2]*shape[i][2]); ione[1] = 0.2*rmass[i] * (shape[0]*shape[0] + shape[2]*shape[2]);
ione[2] = 0.2*rmass[i] * ione[2] = 0.2*rmass[i] * (shape[0]*shape[0] + shape[1]*shape[1]);
(shape[i][0]*shape[i][0] + shape[i][1]*shape[i][1]); exyz_from_q(quatatom,exone,eyone,ezone);
exyz_from_q(atom->quat[i],exone,eyone,ezone);
angmom_from_omega(omega[ibody],exone,eyone,ezone,ione,angmom_one[i]); angmom_from_omega(omega[ibody],exone,eyone,ezone,ione,angmom_one[i]);
} }
} }

View File

@ -95,6 +95,8 @@ class FixRigid : public Fix {
double p_period,p_freq; double p_period,p_freq;
int p_chain; int p_chain;
class AtomVecEllipsoid *avec_ellipsoid;
// bitmasks for eflags // bitmasks for eflags
int INERTIA_POINT,INERTIA_SPHERE,INERTIA_ELLIPSOID; int INERTIA_POINT,INERTIA_SPHERE,INERTIA_ELLIPSOID;
int ORIENT_DIPOLE,ORIENT_QUAT; int ORIENT_DIPOLE,ORIENT_QUAT;

View File

@ -167,23 +167,6 @@ FixStoreState::FixStoreState(LAMMPS *lmp, int narg, char **arg) :
if (!atom->angmom_flag) if (!atom->angmom_flag)
error->all("Fix store/state for atom property that isn't allocated"); error->all("Fix store/state for atom property that isn't allocated");
pack_choice[nvalues++] = &FixStoreState::pack_angmomz; pack_choice[nvalues++] = &FixStoreState::pack_angmomz;
} else if (strcmp(arg[iarg],"quatw") == 0) {
if (!atom->quat_flag)
error->all("Fix store/state for atom property that isn't allocated");
pack_choice[nvalues++] = &FixStoreState::pack_quatw;
} else if (strcmp(arg[iarg],"quati") == 0) {
if (!atom->quat_flag)
error->all("Fix store/state for atom property that isn't allocated");
pack_choice[nvalues++] = &FixStoreState::pack_quati;
} else if (strcmp(arg[iarg],"quatj") == 0) {
if (!atom->quat_flag)
error->all("Fix store/state for atom property that isn't allocated");
pack_choice[nvalues++] = &FixStoreState::pack_quatj;
} else if (strcmp(arg[iarg],"quatk") == 0) {
if (!atom->quat_flag)
error->all("Fix store/state for atom property that isn't allocated");
pack_choice[nvalues++] = &FixStoreState::pack_quatk;
} else if (strcmp(arg[iarg],"tqx") == 0) { } else if (strcmp(arg[iarg],"tqx") == 0) {
if (!atom->torque_flag) if (!atom->torque_flag)
error->all("Fix store/state for atom property that isn't allocated"); error->all("Fix store/state for atom property that isn't allocated");
@ -1231,66 +1214,6 @@ void FixStoreState::pack_angmomz(int n)
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
void FixStoreState::pack_quatw(int n)
{
double **quat = atom->quat;
int *mask = atom->mask;
int nlocal = atom->nlocal;
for (int i = 0; i < nlocal; i++) {
if (mask[i] & groupbit) vbuf[n] = quat[i][0];
else vbuf[n] = 0.0;
n += nvalues;
}
}
/* ---------------------------------------------------------------------- */
void FixStoreState::pack_quati(int n)
{
double **quat = atom->quat;
int *mask = atom->mask;
int nlocal = atom->nlocal;
for (int i = 0; i < nlocal; i++) {
if (mask[i] & groupbit) vbuf[n] = quat[i][1];
else vbuf[n] = 0.0;
n += nvalues;
}
}
/* ---------------------------------------------------------------------- */
void FixStoreState::pack_quatj(int n)
{
double **quat = atom->quat;
int *mask = atom->mask;
int nlocal = atom->nlocal;
for (int i = 0; i < nlocal; i++) {
if (mask[i] & groupbit) vbuf[n] = quat[i][2];
else vbuf[n] = 0.0;
n += nvalues;
}
}
/* ---------------------------------------------------------------------- */
void FixStoreState::pack_quatk(int n)
{
double **quat = atom->quat;
int *mask = atom->mask;
int nlocal = atom->nlocal;
for (int i = 0; i < nlocal; i++) {
if (mask[i] & groupbit) vbuf[n] = quat[i][3];
else vbuf[n] = 0.0;
n += nvalues;
}
}
/* ---------------------------------------------------------------------- */
void FixStoreState::pack_tqx(int n) void FixStoreState::pack_tqx(int n)
{ {
double **torque = atom->torque; double **torque = atom->torque;

View File

@ -100,10 +100,6 @@ class FixStoreState : public Fix {
void pack_angmomx(int); void pack_angmomx(int);
void pack_angmomy(int); void pack_angmomy(int);
void pack_angmomz(int); void pack_angmomz(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

@ -147,7 +147,7 @@ Pair *Force::new_pair(const char *style)
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
return ptr to current pair class or hybrid sub-class return ptr to Pair class if matches word or to matching hybrid sub-class
if exact, then style name must be exact match to word if exact, then style name must be exact match to word
if not exact, style name must contain word if not exact, style name must contain word
return NULL if no match return NULL if no match

View File

@ -78,12 +78,13 @@ Irregular::~Irregular()
void Irregular::migrate_atoms() void Irregular::migrate_atoms()
{ {
// clear global->local map since atoms move to new procs // clear global->local map since atoms move to new procs
// zero out ghosts so map_set() at end will operate only on local atoms // clear old ghosts so map_set() at end will operate only on local atoms
// exchange() doesn't need to zero ghosts b/c borders() // exchange() doesn't need to clear ghosts b/c borders()
// is called right after and it zeroes ghosts and calls map_set() // is called right after and it clears ghosts and calls map_set()
if (map_style) atom->map_clear(); if (map_style) atom->map_clear();
atom->nghost = 0; atom->nghost = 0;
atom->avec->clear_bonus();
// subbox bounds for orthogonal or triclinic // subbox bounds for orthogonal or triclinic
@ -123,7 +124,7 @@ void Irregular::migrate_atoms()
sizes[nsendatom] = avec->pack_exchange(i,&buf_send[nsend]); sizes[nsendatom] = avec->pack_exchange(i,&buf_send[nsend]);
nsend += sizes[nsendatom]; nsend += sizes[nsendatom];
nsendatom++; nsendatom++;
avec->copy(nlocal-1,i); avec->copy(nlocal-1,i,1);
nlocal--; nlocal--;
} else i++; } else i++;
} else i++; } else i++;

View File

@ -19,6 +19,7 @@
#include "read_data.h" #include "read_data.h"
#include "atom.h" #include "atom.h"
#include "atom_vec.h" #include "atom_vec.h"
#include "atom_vec_ellipsoid.h"
#include "comm.h" #include "comm.h"
#include "update.h" #include "update.h"
#include "force.h" #include "force.h"
@ -39,7 +40,8 @@ using namespace LAMMPS_NS;
#define CHUNK 1024 #define CHUNK 1024
#define DELTA 4 // must be 2 or larger #define DELTA 4 // must be 2 or larger
#define NSECTIONS 22 // change when add to header::section_keywords // customize for new sections
#define NSECTIONS 23 // change when add to header::section_keywords
#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))
@ -54,6 +56,12 @@ ReadData::ReadData(LAMMPS *lmp) : Pointers(lmp)
buffer = new char[CHUNK*MAXLINE]; buffer = new char[CHUNK*MAXLINE];
narg = maxarg = 0; narg = maxarg = 0;
arg = NULL; arg = NULL;
// customize for new sections
// pointers to atom styles that store extra info
nellipsoids = 0;
avec_ellipsoid = (AtomVecEllipsoid *) atom->style_match("ellipsoid");
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -128,8 +136,8 @@ void ReadData::command(int narg, char **arg)
comm->set_procs(); comm->set_procs();
domain->set_local_box(); domain->set_local_box();
// customize for new sections
// read rest of file in free format // read rest of file in free format
// if add a section keyword, add to header::section_keywords and NSECTIONS
int atomflag = 0; int atomflag = 0;
@ -140,6 +148,12 @@ void ReadData::command(int narg, char **arg)
} else if (strcmp(keyword,"Velocities") == 0) { } else if (strcmp(keyword,"Velocities") == 0) {
if (atomflag == 0) error->all("Must read Atoms before Velocities"); if (atomflag == 0) error->all("Must read Atoms before Velocities");
velocities(); velocities();
} else if (strcmp(keyword,"Ellipsoids") == 0) {
if (!avec_ellipsoid)
error->all("Invalid data file section: Ellipsoids");
if (atomflag == 0) error->all("Must read Atoms before Ellipsoids");
ellipsoids();
} else if (strcmp(keyword,"Bonds") == 0) { } else if (strcmp(keyword,"Bonds") == 0) {
if (atom->avec->bonds_allow == 0) if (atom->avec->bonds_allow == 0)
error->all("Invalid data file section: Bonds"); error->all("Invalid data file section: Bonds");
@ -287,9 +301,12 @@ void ReadData::header(int flag)
int n; int n;
char *ptr; char *ptr;
// customize for new sections
char *section_keywords[NSECTIONS] = char *section_keywords[NSECTIONS] =
{"Atoms","Velocities","Bonds","Angles","Dihedrals","Impropers","Masses", {"Atoms","Velocities","Ellipsoids",
"Pair Coeffs","Bond Coeffs","Angle Coeffs", "Bonds","Angles","Dihedrals","Impropers",
"Masses","Pair Coeffs","Bond Coeffs","Angle Coeffs",
"Dihedral Coeffs","Improper Coeffs", "Dihedral Coeffs","Improper Coeffs",
"BondBond Coeffs","BondAngle Coeffs","MiddleBondTorsion Coeffs", "BondBond Coeffs","BondAngle Coeffs","MiddleBondTorsion Coeffs",
"EndBondTorsion Coeffs","AngleTorsion Coeffs", "EndBondTorsion Coeffs","AngleTorsion Coeffs",
@ -302,6 +319,8 @@ void ReadData::header(int flag)
if (eof == NULL) error->one("Unexpected end of data file"); if (eof == NULL) error->one("Unexpected end of data file");
} }
// customize for new header lines
while (1) { while (1) {
// read a line and bcast length if flag is set // read a line and bcast length if flag is set
@ -351,6 +370,12 @@ void ReadData::header(int flag)
else if (strstr(line,"extra bond per atom")) else if (strstr(line,"extra bond per atom"))
sscanf(line,"%d",&atom->extra_bond_per_atom); sscanf(line,"%d",&atom->extra_bond_per_atom);
else if (strstr(line,"ellipsoids")) {
if (!avec_ellipsoid)
error->all("No ellipsoids allowed with this atom style");
sscanf(line,BIGINT_FORMAT,&nellipsoids);
}
else if (strstr(line,"xlo xhi")) else if (strstr(line,"xlo xhi"))
sscanf(line,"%lg %lg",&domain->boxlo[0],&domain->boxhi[0]); sscanf(line,"%lg %lg",&domain->boxlo[0],&domain->boxhi[0]);
else if (strstr(line,"ylo yhi")) else if (strstr(line,"ylo yhi"))
@ -543,6 +568,57 @@ void ReadData::velocities()
} }
} }
/* ----------------------------------------------------------------------
read all ellipsoids
to find atoms, must build atom map if not a molecular system
------------------------------------------------------------------------- */
void ReadData::ellipsoids()
{
int i,m,nchunk;
int mapflag = 0;
if (atom->map_style == 0) {
mapflag = 1;
atom->map_style = 1;
atom->map_init();
atom->map_set();
}
bigint nread = 0;
bigint natoms = nellipsoids;
while (nread < natoms) {
if (natoms-nread > CHUNK) nchunk = CHUNK;
else nchunk = natoms-nread;
if (me == 0) {
char *eof;
m = 0;
for (i = 0; i < nchunk; i++) {
eof = fgets(&buffer[m],MAXLINE,fp);
if (eof == NULL) error->one("Unexpected end of data file");
m += strlen(&buffer[m]);
}
buffer[m++] = '\n';
}
MPI_Bcast(&m,1,MPI_INT,0,world);
MPI_Bcast(buffer,m,MPI_CHAR,0,world);
atom->data_bonus(nchunk,buffer,avec_ellipsoid);
nread += nchunk;
}
if (mapflag) {
atom->map_delete();
atom->map_style = 0;
}
if (me == 0) {
if (screen) fprintf(screen," " BIGINT_FORMAT " ellipsoids\n",natoms);
if (logfile) fprintf(logfile," " BIGINT_FORMAT " ellipsoids\n",natoms);
}
}
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
void ReadData::bonds() void ReadData::bonds()
@ -933,6 +1009,7 @@ void ReadData::scan(int &bond_per_atom, int &angle_per_atom,
int natoms = static_cast<int> (atom->natoms); int natoms = static_cast<int> (atom->natoms);
bond_per_atom = angle_per_atom = dihedral_per_atom = improper_per_atom = 0; bond_per_atom = angle_per_atom = dihedral_per_atom = improper_per_atom = 0;
// customize for new sections
// allocate topology counting vector // allocate topology counting vector
// initially, array length = 1 to natoms // initially, array length = 1 to natoms
// will grow via reallocate() if atom IDs > natoms // will grow via reallocate() if atom IDs > natoms
@ -947,32 +1024,33 @@ void ReadData::scan(int &bond_per_atom, int &angle_per_atom,
else if (strcmp(keyword,"Atoms") == 0) skip_lines(natoms); else if (strcmp(keyword,"Atoms") == 0) skip_lines(natoms);
else if (strcmp(keyword,"Velocities") == 0) skip_lines(natoms); else if (strcmp(keyword,"Velocities") == 0) skip_lines(natoms);
else if (strcmp(keyword,"Pair Coeffs") == 0) { else if (strcmp(keyword,"Ellipsoids") == 0) {
if (!avec_ellipsoid)
error->all("Invalid data file section: Ellipsoids");
skip_lines(nellipsoids);
} else if (strcmp(keyword,"Pair Coeffs") == 0) {
if (force->pair == NULL) if (force->pair == NULL)
error->all("Must define pair_style before Pair Coeffs"); error->all("Must define pair_style before Pair Coeffs");
skip_lines(atom->ntypes); skip_lines(atom->ntypes);
} else if (strcmp(keyword,"Bond Coeffs") == 0) { } else if (strcmp(keyword,"Bond Coeffs") == 0) {
if (atom->avec->bonds_allow == 0) if (atom->avec->bonds_allow == 0)
error->all("Invalid data file section: Bond Coeffs"); error->all("Invalid data file section: Bond Coeffs");
if (force->bond == NULL) if (force->bond == NULL)
error->all("Must define bond_style before Bond Coeffs"); error->all("Must define bond_style before Bond Coeffs");
skip_lines(atom->nbondtypes); skip_lines(atom->nbondtypes);
} else if (strcmp(keyword,"Angle Coeffs") == 0) { } else if (strcmp(keyword,"Angle Coeffs") == 0) {
if (atom->avec->angles_allow == 0) if (atom->avec->angles_allow == 0)
error->all("Invalid data file section: Angle Coeffs"); error->all("Invalid data file section: Angle Coeffs");
if (force->angle == NULL) if (force->angle == NULL)
error->all("Must define angle_style before Angle Coeffs"); error->all("Must define angle_style before Angle Coeffs");
skip_lines(atom->nangletypes); skip_lines(atom->nangletypes);
} else if (strcmp(keyword,"Dihedral Coeffs") == 0) { } else if (strcmp(keyword,"Dihedral Coeffs") == 0) {
skip_lines(atom->ndihedraltypes); skip_lines(atom->ndihedraltypes);
if (atom->avec->dihedrals_allow == 0) if (atom->avec->dihedrals_allow == 0)
error->all("Invalid data file section: Dihedral Coeffs"); error->all("Invalid data file section: Dihedral Coeffs");
if (force->dihedral == NULL) if (force->dihedral == NULL)
error->all("Must define dihedral_style before Dihedral Coeffs"); error->all("Must define dihedral_style before Dihedral Coeffs");
} else if (strcmp(keyword,"Improper Coeffs") == 0) { } else if (strcmp(keyword,"Improper Coeffs") == 0) {
if (atom->avec->impropers_allow == 0) if (atom->avec->impropers_allow == 0)
error->all("Invalid data file section: Improper Coeffs"); error->all("Invalid data file section: Improper Coeffs");
@ -986,49 +1064,42 @@ void ReadData::scan(int &bond_per_atom, int &angle_per_atom,
if (force->angle == NULL) if (force->angle == NULL)
error->all("Must define angle_style before BondBond Coeffs"); error->all("Must define angle_style before BondBond Coeffs");
skip_lines(atom->nangletypes); skip_lines(atom->nangletypes);
} else if (strcmp(keyword,"BondAngle Coeffs") == 0) { } else if (strcmp(keyword,"BondAngle Coeffs") == 0) {
if (atom->avec->angles_allow == 0) if (atom->avec->angles_allow == 0)
error->all("Invalid data file section: BondAngle Coeffs"); error->all("Invalid data file section: BondAngle Coeffs");
if (force->angle == NULL) if (force->angle == NULL)
error->all("Must define angle_style before BondAngle Coeffs"); error->all("Must define angle_style before BondAngle Coeffs");
skip_lines(atom->nangletypes); skip_lines(atom->nangletypes);
} else if (strcmp(keyword,"MiddleBondTorsion Coeffs") == 0) { } else if (strcmp(keyword,"MiddleBondTorsion Coeffs") == 0) {
if (atom->avec->dihedrals_allow == 0) if (atom->avec->dihedrals_allow == 0)
error->all("Invalid data file section: MiddleBondTorsion Coeffs"); error->all("Invalid data file section: MiddleBondTorsion Coeffs");
if (force->dihedral == NULL) if (force->dihedral == NULL)
error->all("Must define dihedral_style before MiddleBondTorsion Coeffs"); error->all("Must define dihedral_style before MiddleBondTorsion Coeffs");
skip_lines(atom->ndihedraltypes); skip_lines(atom->ndihedraltypes);
} else if (strcmp(keyword,"EndBondTorsion Coeffs") == 0) { } else if (strcmp(keyword,"EndBondTorsion Coeffs") == 0) {
if (atom->avec->dihedrals_allow == 0) if (atom->avec->dihedrals_allow == 0)
error->all("Invalid data file section: EndBondTorsion Coeffs"); error->all("Invalid data file section: EndBondTorsion Coeffs");
if (force->dihedral == NULL) if (force->dihedral == NULL)
error->all("Must define dihedral_style before EndBondTorsion Coeffs"); error->all("Must define dihedral_style before EndBondTorsion Coeffs");
skip_lines(atom->ndihedraltypes); skip_lines(atom->ndihedraltypes);
} else if (strcmp(keyword,"AngleTorsion Coeffs") == 0) { } else if (strcmp(keyword,"AngleTorsion Coeffs") == 0) {
if (atom->avec->dihedrals_allow == 0) if (atom->avec->dihedrals_allow == 0)
error->all("Invalid data file section: AngleTorsion Coeffs"); error->all("Invalid data file section: AngleTorsion Coeffs");
if (force->dihedral == NULL) if (force->dihedral == NULL)
error->all("Must define dihedral_style before AngleTorsion Coeffs"); error->all("Must define dihedral_style before AngleTorsion Coeffs");
skip_lines(atom->ndihedraltypes); skip_lines(atom->ndihedraltypes);
} else if (strcmp(keyword,"AngleAngleTorsion Coeffs") == 0) { } else if (strcmp(keyword,"AngleAngleTorsion Coeffs") == 0) {
if (atom->avec->dihedrals_allow == 0) if (atom->avec->dihedrals_allow == 0)
error->all("Invalid data file section: AngleAngleTorsion Coeffs"); error->all("Invalid data file section: AngleAngleTorsion Coeffs");
if (force->dihedral == NULL) if (force->dihedral == NULL)
error->all("Must define dihedral_style before AngleAngleTorsion Coeffs"); error->all("Must define dihedral_style before AngleAngleTorsion Coeffs");
skip_lines(atom->ndihedraltypes); skip_lines(atom->ndihedraltypes);
} else if (strcmp(keyword,"BondBond13 Coeffs") == 0) { } else if (strcmp(keyword,"BondBond13 Coeffs") == 0) {
if (atom->avec->dihedrals_allow == 0) if (atom->avec->dihedrals_allow == 0)
error->all("Invalid data file section: BondBond13 Coeffs"); error->all("Invalid data file section: BondBond13 Coeffs");
if (force->dihedral == NULL) if (force->dihedral == NULL)
error->all("Must define dihedral_style before BondBond13 Coeffs"); error->all("Must define dihedral_style before BondBond13 Coeffs");
skip_lines(atom->ndihedraltypes); skip_lines(atom->ndihedraltypes);
} else if (strcmp(keyword,"AngleAngle Coeffs") == 0) { } else if (strcmp(keyword,"AngleAngle Coeffs") == 0) {
if (atom->avec->impropers_allow == 0) if (atom->avec->impropers_allow == 0)
error->all("Invalid data file section: AngleAngle Coeffs"); error->all("Invalid data file section: AngleAngle Coeffs");

View File

@ -38,6 +38,9 @@ class ReadData : protected Pointers {
int narg,maxarg,compressed; int narg,maxarg,compressed;
char **arg; char **arg;
bigint nellipsoids;
class AtomVecEllipsoid *avec_ellipsoid;
void open(char *); void open(char *);
void scan(int &, int &, int &, int &); void scan(int &, int &, int &, int &);
int reallocate(int **, int, int); int reallocate(int **, int, int);
@ -48,14 +51,14 @@ class ReadData : protected Pointers {
void atoms(); void atoms();
void velocities(); void velocities();
void ellipsoids();
void bonds(); void bonds();
void angles(); void angles();
void dihedrals(); void dihedrals();
void impropers(); void impropers();
void mass(); void mass();
void dipole();
void paircoeffs(); void paircoeffs();
void bondcoeffs(); void bondcoeffs();
void anglecoeffs(int); void anglecoeffs(int);

View File

@ -18,6 +18,7 @@
#include "set.h" #include "set.h"
#include "atom.h" #include "atom.h"
#include "atom_vec.h" #include "atom_vec.h"
#include "atom_vec_ellipsoid.h"
#include "domain.h" #include "domain.h"
#include "region.h" #include "region.h"
#include "group.h" #include "group.h"
@ -142,7 +143,7 @@ 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->shape_flag) if (!atom->ellipsoid_flag)
error->all("Cannot set this attribute for this atom style"); error->all("Cannot set this attribute for this atom style");
if (xvalue < 0.0 || yvalue < 0.0 || zvalue < 0.0) if (xvalue < 0.0 || yvalue < 0.0 || zvalue < 0.0)
error->all("Invalid shape in set command"); error->all("Invalid shape in set command");
@ -177,14 +178,14 @@ void Set::command(int narg, char **arg)
yvalue = atof(arg[iarg+2]); yvalue = atof(arg[iarg+2]);
zvalue = atof(arg[iarg+3]); zvalue = atof(arg[iarg+3]);
wvalue = atof(arg[iarg+4]); wvalue = atof(arg[iarg+4]);
if (!atom->quat_flag) if (!atom->ellipsoid_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 += 5; 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_flag) if (!atom->ellipsoid_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);
@ -358,6 +359,9 @@ void Set::selection(int n)
void Set::set(int keyword) void Set::set(int keyword)
{ {
AtomVecEllipsoid *avec_ellipsoid =
(AtomVecEllipsoid *) atom->style_match("ellipsoid");
selection(atom->nlocal); selection(atom->nlocal);
int nlocal = atom->nlocal; int nlocal = atom->nlocal;
@ -376,25 +380,22 @@ void Set::set(int keyword)
// set shape // set shape
else if (keyword == SHAPE) { else if (keyword == SHAPE)
double **shape = atom->shape; avec_ellipsoid->set_bonus(i,0.5*xvalue,0.5*yvalue,0.5*zvalue);
shape[i][0] = 0.5 * xvalue;
shape[i][1] = 0.5 * yvalue;
shape[i][2] = 0.5 * zvalue;
// set rmass via density // set rmass via density
// if radius > 0.0, assume sphere // if radius > 0.0, assume sphere
// if shape > 0.0, assume ellipsoid // if shape > 0.0, assume ellipsoid
// else set rmass to density directly // else set rmass to density directly
} else if (keyword == DENSITY) { else if (keyword == DENSITY) {
if (atom->radius_flag && atom->radius[i] > 0.0) if (atom->radius_flag && atom->radius[i] > 0.0)
atom->rmass[i] = 4.0*PI/3.0 * atom->rmass[i] = 4.0*PI/3.0 *
atom->radius[i]*atom->radius[i]*atom->radius[i] * dvalue; atom->radius[i]*atom->radius[i]*atom->radius[i] * dvalue;
else if (atom->shape_flag && atom->shape[i][0] > 0.0) else if (atom->ellipsoid_flag && atom->ellipsoid[i] >= 0) {
atom->rmass[i] = 4.0*PI/3.0 * double *shape = avec_ellipsoid->bonus[atom->ellipsoid[i]].shape;
atom->shape[i][0]*atom->shape[i][1]*atom->shape[i][2] * dvalue; atom->rmass[i] = 4.0*PI/3.0 * shape[0]*shape[1]*shape[2] * dvalue;
else atom->rmass[i] = dvalue; } else atom->rmass[i] = dvalue;
// reset any or all of 3 image flags // reset any or all of 3 image flags
@ -421,15 +422,16 @@ void Set::set(int keyword)
// set quaternion orientation // set quaternion orientation
} else if (keyword == QUAT) { } else if (keyword == QUAT) {
double PI = 4.0*atan(1.0); if (atom->ellipsoid[i] < 0)
error->one("Cannot set quaternion for atom that is not an ellipsoid");
double *quat = avec_ellipsoid->bonus[atom->ellipsoid[i]].quat;
double theta2 = 0.5 * PI * wvalue/180.0; double theta2 = 0.5 * PI * wvalue/180.0;
double sintheta2 = sin(theta2); double sintheta2 = sin(theta2);
double **quat = atom->quat; quat[0] = cos(theta2);
quat[i][0] = cos(theta2); quat[1] = xvalue * sintheta2;
quat[i][1] = xvalue * sintheta2; quat[2] = yvalue * sintheta2;
quat[i][2] = yvalue * sintheta2; quat[3] = zvalue * sintheta2;
quat[i][3] = zvalue * sintheta2; MathExtra::normalize4(quat);
MathExtra::normalize4(quat[i]);
} }
count++; count++;
} }
@ -509,38 +511,48 @@ void Set::setrandom(int keyword)
// no need to normalize quats since creations algorithms already do // no need to normalize quats since creations algorithms already do
} else if (keyword == QUAT_RANDOM) { } else if (keyword == QUAT_RANDOM) {
double **quat = atom->quat; AtomVecEllipsoid *avec_ellipsoid =
(AtomVecEllipsoid *) atom->style_match("ellipsoid");
AtomVecEllipsoid::Bonus *bonus = avec_ellipsoid->bonus;
int *ellipsoid = atom->ellipsoid;
int nlocal = atom->nlocal; int nlocal = atom->nlocal;
double *quat;
if (domain->dimension == 3) { if (domain->dimension == 3) {
double s,t1,t2,theta1,theta2; double s,t1,t2,theta1,theta2;
double PI = 4.0*atan(1.0);
for (i = 0; i < nlocal; i++) for (i = 0; i < nlocal; i++)
if (select[i]) { if (select[i]) {
if (ellipsoid[i] < 0)
error->one("Cannot set quaternion for atom "
"that is not an ellipsoid");
quat = bonus[ellipsoid[i]].quat;
random->reset(seed,x[i]); random->reset(seed,x[i]);
s = random->uniform(); s = random->uniform();
t1 = sqrt(1.0-s); t1 = sqrt(1.0-s);
t2 = sqrt(s); t2 = sqrt(s);
theta1 = 2.0*PI*random->uniform(); theta1 = 2.0*PI*random->uniform();
theta2 = 2.0*PI*random->uniform(); theta2 = 2.0*PI*random->uniform();
quat[i][0] = cos(theta2)*t2; quat[0] = cos(theta2)*t2;
quat[i][1] = sin(theta1)*t1; quat[1] = sin(theta1)*t1;
quat[i][2] = cos(theta1)*t1; quat[2] = cos(theta1)*t1;
quat[i][3] = sin(theta2)*t2; quat[3] = sin(theta2)*t2;
count++; count++;
} }
} else { } else {
double theta2; double theta2;
double PI = 4.0*atan(1.0);
for (i = 0; i < nlocal; i++) for (i = 0; i < nlocal; i++)
if (select[i]) { if (select[i]) {
if (ellipsoid[i] < 0)
error->one("Cannot set quaternion for atom "
"that is not an ellipsoid");
quat = bonus[ellipsoid[i]].quat;
random->reset(seed,x[i]); random->reset(seed,x[i]);
theta2 = PI*random->uniform(); theta2 = PI*random->uniform();
quat[i][0] = cos(theta2); quat[0] = cos(theta2);
quat[i][1] = 0.0; quat[1] = 0.0;
quat[i][2] = 0.0; quat[2] = 0.0;
quat[i][3] = sin(theta2); quat[3] = sin(theta2);
count++; count++;
} }
} }