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

This commit is contained in:
sjplimp
2013-04-06 23:08:09 +00:00
parent 022e3c1c57
commit afac9a0f14
12 changed files with 371 additions and 55 deletions

View File

@ -19,6 +19,7 @@
#include "domain.h"
#include "modify.h"
#include "fix.h"
#include "fix_store.h"
#include "error.h"
using namespace LAMMPS_NS;
@ -49,28 +50,57 @@ ComputeMSD::ComputeMSD(LAMMPS *lmp, int narg, char **arg) :
} else error->all(FLERR,"Illegal compute msd command");
}
// create a new fix store/state style with or without com keyword
// id = compute-ID + store_state, fix group = compute group
// create a new fix STORE style
// id = compute-ID + COMPUTE_STORE, fix group = compute group
int n = strlen(id) + strlen("_store_state") + 1;
int n = strlen(id) + strlen("_COMPUTE_STORE") + 1;
id_fix = new char[n];
strcpy(id_fix,id);
strcat(id_fix,"_store_state");
strcat(id_fix,"_COMPUTE_STORE");
char **newarg = new char*[9];
char **newarg = new char*[5];
newarg[0] = id_fix;
newarg[1] = group->names[igroup];
newarg[2] = (char *) "store/state";
newarg[3] = (char *) "0";
newarg[4] = (char *) "xu";
newarg[5] = (char *) "yu";
newarg[6] = (char *) "zu";
newarg[7] = (char *) "com";
newarg[8] = (char *) "yes";
if (comflag) modify->add_fix(9,newarg);
else modify->add_fix(7,newarg);
newarg[2] = (char *) "STORE";
newarg[3] = (char *) "1";
newarg[4] = (char *) "3";
modify->add_fix(5,newarg);
fix = (FixStore *) modify->fix[modify->nfix-1];
delete [] newarg;
// calculate xu,yu,zu for fix store array
// skip if reset from restart file
if (fix->restart_reset) fix->restart_reset = 0;
else {
double **xoriginal = fix->astore;
double **x = atom->x;
int *mask = atom->mask;
tagint *image = atom->image;
int nlocal = atom->nlocal;
for (int i = 0; i < nlocal; i++)
if (mask[i] & groupbit) domain->unmap(x[i],image[i],xoriginal[i]);
else xoriginal[i][0] = xoriginal[i][1] = xoriginal[i][2] = 0.0;
// adjust for COM if requested
if (comflag) {
double cm[3];
masstotal = group->mass(igroup);
group->xcm(igroup,masstotal,cm);
for (int i = 0; i < nlocal; i++)
if (mask[i] & groupbit) {
xoriginal[i][0] -= cm[0];
xoriginal[i][1] -= cm[1];
xoriginal[i][2] -= cm[2];
}
}
}
// displacement vector
vector = new double[4];
}
@ -94,7 +124,7 @@ void ComputeMSD::init()
int ifix = modify->find_fix(id_fix);
if (ifix < 0) error->all(FLERR,"Could not find compute msd fix ID");
fix = modify->fix[ifix];
fix = (FixStore *) modify->fix[ifix];
// nmsd = # of atoms in group
@ -129,7 +159,7 @@ void ComputeMSD::compute_vector()
// relative to center of mass if comflag is set
// for triclinic, need to unwrap current atom coord via h matrix
double **xoriginal = fix->array_atom;
double **xoriginal = fix->astore;
double **x = atom->x;
int *mask = atom->mask;