From 021986ab2bb8d546b60b000c119e6c3a011ca64c Mon Sep 17 00:00:00 2001 From: sjplimp Date: Wed, 20 Aug 2008 15:23:21 +0000 Subject: [PATCH] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@2078 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- src/set.cpp | 33 +++++++++++++++++++++++++++++++-- src/set.h | 1 + 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/set.cpp b/src/set.cpp index caf28a8e5f..c725ca833a 100644 --- a/src/set.cpp +++ b/src/set.cpp @@ -35,7 +35,7 @@ enum{ATOM,GROUP,REGION}; enum{TYPE,TYPE_FRACTION,MOLECULE, X,Y,Z,VX,VY,VZ,CHARGE, DIPOLE,DIPOLE_RANDOM,QUAT,QUAT_RANDOM, - DIAMETER,DENSITY,VOLUME, + DIAMETER,DENSITY,VOLUME,IMAGE, BOND,ANGLE,DIHEDRAL,IMPROPER}; /* ---------------------------------------------------------------------- */ @@ -196,6 +196,23 @@ void Set::command(int narg, char **arg) error->all("Cannot set this attribute for this atom style"); set(VOLUME); iarg += 2; + } else if (strcmp(arg[iarg],"image") == 0) { + if (iarg+4 > narg) error->all("Illegal set command"); + ximageflag = yimageflag = zimageflag = 0; + if (strcmp(arg[iarg+1],"NULL") != 0 && domain->xperiodic) { + ximageflag = 1; + ximage = atoi(arg[iarg+1]); + } + if (strcmp(arg[iarg+2],"NULL") != 0 && domain->yperiodic) { + yimageflag = 1; + yimage = atoi(arg[iarg+2]); + } + if (strcmp(arg[iarg+3],"NULL") != 0 && domain->zperiodic) { + zimageflag = 1; + zimage = atoi(arg[iarg+3]); + } + set(IMAGE); + iarg += 4; } else if (strcmp(arg[iarg],"bond") == 0) { if (iarg+2 > narg) error->all("Illegal set command"); ivalue = atoi(arg[iarg+1]); @@ -354,7 +371,19 @@ void Set::set(int keyword) } else if (keyword == VOLUME) atom->vfrac[i] = dvalue; - else if (keyword == DIPOLE) { + // reset any or all of 3 image flags + + else if (keyword == IMAGE) { + int xbox = (atom->image[i] & 1023) - 512; + int ybox = (atom->image[i] >> 10 & 1023) - 512; + int zbox = (atom->image[i] >> 20) - 512; + if (ximageflag) xbox = ximage; + if (yimageflag) ybox = yimage; + if (zimageflag) zbox = zimage; + atom->image[i] = ((zbox + 512 & 1023) << 20) | + ((ybox + 512 & 1023) << 10) | (xbox + 512 & 1023); + + } else if (keyword == DIPOLE) { if (atom->dipole[atom->type[i]] > 0.0) { double **mu = atom->mu; mu[i][0] = xvalue; diff --git a/src/set.h b/src/set.h index d39dfe1428..e4d3313b3b 100644 --- a/src/set.h +++ b/src/set.h @@ -27,6 +27,7 @@ class Set : protected Pointers { char *id; int *select; int style,ivalue,newtype,count; + int ximage,yimage,zimage,ximageflag,yimageflag,zimageflag; double dvalue,xvalue,yvalue,zvalue,wvalue,fraction; double PI;