git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@8271 f3b2605a-c512-4ea7-a41b-209d697bcdaa
This commit is contained in:
@ -11,9 +11,12 @@
|
||||
See the README file in the top-level LAMMPS directory.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "math.h"
|
||||
#include "compute_gyration.h"
|
||||
#include "update.h"
|
||||
#include "atom.h"
|
||||
#include "group.h"
|
||||
#include "domain.h"
|
||||
#include "error.h"
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
@ -25,8 +28,19 @@ ComputeGyration::ComputeGyration(LAMMPS *lmp, int narg, char **arg) :
|
||||
{
|
||||
if (narg != 3) error->all(FLERR,"Illegal compute gyration command");
|
||||
|
||||
scalar_flag = 1;
|
||||
scalar_flag = vector_flag = 1;
|
||||
size_vector = 6;
|
||||
extscalar = 0;
|
||||
extvector = 0;
|
||||
|
||||
vector = new double[6];
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
ComputeGyration::~ComputeGyration()
|
||||
{
|
||||
delete [] vector;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
@ -47,3 +61,57 @@ double ComputeGyration::compute_scalar()
|
||||
scalar = group->gyration(igroup,masstotal,xcm);
|
||||
return scalar;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
compute the radius-of-gyration tensor of group of atoms
|
||||
around center-of-mass cm
|
||||
must unwrap atoms to compute Rg tensor correctly
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void ComputeGyration::compute_vector()
|
||||
{
|
||||
invoked_vector = update->ntimestep;
|
||||
|
||||
double masstotal;
|
||||
double xcm[3];
|
||||
group->xcm(igroup,masstotal,xcm);
|
||||
|
||||
double **x = atom->x;
|
||||
int *mask = atom->mask;
|
||||
int *type = atom->type;
|
||||
int *image = atom->image;
|
||||
double *mass = atom->mass;
|
||||
double *rmass = atom->rmass;
|
||||
int nlocal = atom->nlocal;
|
||||
|
||||
int xbox,ybox,zbox;
|
||||
double dx,dy,dz,massone;
|
||||
double xprd = domain->xprd;
|
||||
double yprd = domain->yprd;
|
||||
double zprd = domain->zprd;
|
||||
|
||||
double rg[6];
|
||||
rg[0] = rg[1] = rg[2] = rg[3] = rg[4] = rg[5] = 0.0;
|
||||
|
||||
for (int i = 0; i < nlocal; i++)
|
||||
if (mask[i] & groupbit) {
|
||||
xbox = (image[i] & 1023) - 512;
|
||||
ybox = (image[i] >> 10 & 1023) - 512;
|
||||
zbox = (image[i] >> 20) - 512;
|
||||
dx = (x[i][0] + xbox*xprd) - xcm[0];
|
||||
dy = (x[i][1] + ybox*yprd) - xcm[1];
|
||||
dz = (x[i][2] + zbox*zprd) - xcm[2];
|
||||
if (rmass) massone = rmass[i];
|
||||
else massone = mass[type[i]];
|
||||
rg[0] += dx*dx * massone;
|
||||
rg[1] += dy*dy * massone;
|
||||
rg[2] += dz*dz * massone;
|
||||
rg[3] += dx*dy * massone;
|
||||
rg[4] += dx*dz * massone;
|
||||
rg[5] += dy*dz * massone;
|
||||
}
|
||||
MPI_Allreduce(rg,vector,6,MPI_DOUBLE,MPI_SUM,world);
|
||||
|
||||
if (masstotal == 0.0) return;
|
||||
for (int i = 0; i < 6; i++) vector[i] = sqrt(vector[i]/masstotal);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user