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

This commit is contained in:
sjplimp
2011-04-13 21:40:14 +00:00
parent e45fbd89d1
commit 819524ebd6
71 changed files with 1167 additions and 2718 deletions

View File

@ -35,40 +35,16 @@ ComputeERotateSphere::ComputeERotateSphere(LAMMPS *lmp, int narg, char **arg) :
scalar_flag = 1;
extscalar = 1;
// error checks
// error check
if (!atom->omega_flag)
error->all("Compute erotate/sphere requires atom attribute omega");
if (!atom->radius_flag && !atom->avec->shape_type)
error->all("Compute erotate/sphere requires atom attribute "
"radius or shape");
if (!atom->sphere_flag)
error->all("Compute erotate/sphere requires atom style sphere");
}
/* ---------------------------------------------------------------------- */
void ComputeERotateSphere::init()
{
int i,itype;
// if shape used, check that all particles are spherical
// point particles are allowed
if (atom->radius == NULL) {
double **shape = atom->shape;
int *type = atom->type;
int *mask = atom->mask;
int nlocal = atom->nlocal;
for (i = 0; i < nlocal; i++)
if (mask[i] & groupbit) {
itype = type[i];
if (shape[itype][0] != shape[itype][1] ||
shape[itype][0] != shape[itype][2])
error->one("Compute erotate/sphere requires "
"spherical particle shapes");
}
}
pfactor = 0.5 * force->mvv2e * INERTIA;
}
@ -76,59 +52,22 @@ void ComputeERotateSphere::init()
double ComputeERotateSphere::compute_scalar()
{
int i,itype;
invoked_scalar = update->ntimestep;
double **omega = atom->omega;
double *radius = atom->radius;
double *rmass = atom->rmass;
double *mass = atom->mass;
double **shape = atom->shape;
int *mask = atom->mask;
int *type = atom->type;
int nlocal = atom->nlocal;
// sum rotational energy for each particle
// point particles will not contribute due to radius or shape = 0
// point particles will not contribute due to radius = 0
double erotate = 0.0;
if (radius) {
if (rmass) {
for (i = 0; i < nlocal; i++)
if (mask[i] & groupbit)
erotate += (omega[i][0]*omega[i][0] + omega[i][1]*omega[i][1] +
omega[i][2]*omega[i][2]) * radius[i]*radius[i]*rmass[i];
} else {
for (i = 0; i < nlocal; i++)
if (mask[i] & groupbit) {
itype = type[i];
erotate += (omega[i][0]*omega[i][0] + omega[i][1]*omega[i][1] +
omega[i][2]*omega[i][2]) *
radius[i]*radius[i]*mass[itype];
}
}
} else {
if (rmass) {
for (i = 0; i < nlocal; i++)
if (mask[i] & groupbit) {
itype = type[i];
erotate += (omega[i][0]*omega[i][0] + omega[i][1]*omega[i][1] +
omega[i][2]*omega[i][2]) *
shape[itype][0]*shape[itype][0]*rmass[i];
}
} else {
for (i = 0; i < nlocal; i++)
if (mask[i] & groupbit) {
itype = type[i];
erotate += (omega[i][0]*omega[i][0] + omega[i][1]*omega[i][1] +
omega[i][2]*omega[i][2]) *
shape[itype][0]*shape[itype][0]*mass[itype];
}
}
}
for (int i = 0; i < nlocal; i++)
if (mask[i] & groupbit)
erotate += (omega[i][0]*omega[i][0] + omega[i][1]*omega[i][1] +
omega[i][2]*omega[i][2]) * radius[i]*radius[i]*rmass[i];
MPI_Allreduce(&erotate,&scalar,1,MPI_DOUBLE,MPI_SUM,world);
scalar *= pfactor;