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

This commit is contained in:
sjplimp 2011-05-30 15:46:44 +00:00
parent 575de169b9
commit 405d127522
6 changed files with 124 additions and 56 deletions

View File

@ -136,6 +136,11 @@ ComputePropertyAtom::ComputePropertyAtom(LAMMPS *lmp, int narg, char **arg) :
error->all("Compute property/atom for "
"atom property that isn't allocated");
pack_choice[i] = &ComputePropertyAtom::pack_radius;
} else if (strcmp(arg[iarg],"diameter") == 0) {
if (!atom->radius_flag)
error->all("Compute property/atom for "
"atom property that isn't allocated");
pack_choice[i] = &ComputePropertyAtom::pack_diameter;
} else if (strcmp(arg[iarg],"omegax") == 0) {
if (!atom->omega_flag)
error->all("Compute property/atom for "
@ -882,6 +887,21 @@ void ComputePropertyAtom::pack_radius(int n)
/* ---------------------------------------------------------------------- */
void ComputePropertyAtom::pack_diameter(int n)
{
double *radius = atom->radius;
int *mask = atom->mask;
int nlocal = atom->nlocal;
for (int i = 0; i < nlocal; i++) {
if (mask[i] & groupbit) buf[n] = 2.0*radius[i];
else buf[n] = 0.0;
n += nvalues;
}
}
/* ---------------------------------------------------------------------- */
void ComputePropertyAtom::pack_omegax(int n)
{
double **omega = atom->omega;

View File

@ -79,6 +79,8 @@ class ComputePropertyAtom : public Compute {
void pack_muz(int);
void pack_mu(int);
void pack_radius(int);
void pack_diameter(int);
void pack_omegax(int);
void pack_omegay(int);
void pack_omegaz(int);

View File

@ -47,7 +47,8 @@ DumpCFG::DumpCFG(LAMMPS *lmp, int narg, char **arg) :
(strcmp(arg[8],"ys") != 0 && strcmp(arg[8],"ysu") != 0) ||
(strcmp(arg[9],"zs") != 0 && strcmp(arg[9],"zsu") != 0)
)
error->all("Dump cfg arguments must start with 'id type xs ys zs' or 'id type xsu ysu zsu'");
error->all("Dump cfg arguments must start with "
"'id type xs ys zs' or 'id type xsu ysu zsu'");
if (strcmp(arg[7],"xs") == 0)
if (strcmp(arg[8],"ysu") == 0 || strcmp(arg[9],"zsu") == 0)
@ -57,9 +58,6 @@ DumpCFG::DumpCFG(LAMMPS *lmp, int narg, char **arg) :
error->all("Dump cfg arguments can not mix xs|ys|zs with xsu|ysu|zsu");
else unwrapflag = 1;
ntypes = atom->ntypes;
typenames = NULL;
// arrays for data rearrangement
rbuf = NULL;
@ -108,11 +106,6 @@ DumpCFG::DumpCFG(LAMMPS *lmp, int narg, char **arg) :
DumpCFG::~DumpCFG()
{
if (typenames) {
for (int i = 1; i <= ntypes; i++) delete [] typenames[i];
delete [] typenames;
}
if (rbuf) memory->destroy(rbuf);
if (auxname) {
@ -127,16 +120,6 @@ void DumpCFG::init_style()
{
if (multifile == 0) error->all("Dump cfg requires one snapshot per file");
if (typenames == NULL) {
typenames = new char*[ntypes+1];
for (int itype = 1; itype <= ntypes; itype++) {
typenames[itype] = new char[3];
strcpy(typenames[itype],"C");
}
if (comm->me == 0)
error->warning("All element names have been set to 'C' for dump cfg");
}
// setup format strings
delete [] format;
@ -148,6 +131,16 @@ void DumpCFG::init_style()
format = new char[n];
strcpy(format,str);
// default for element names = C
if (typenames == NULL) {
typenames = new char*[ntypes+1];
for (int itype = 1; itype <= ntypes; itype++) {
typenames[itype] = new char[2];
strcpy(typenames[itype],"C");
}
}
// tokenize the format string and add space at end of each format element
char *ptr;
@ -319,29 +312,3 @@ void DumpCFG::write_data(int n, double *mybuf)
nlines = 0;
}
}
/* ---------------------------------------------------------------------- */
int DumpCFG::modify_param2(int narg, char **arg)
{
if (strcmp(arg[0],"element") == 0) {
if (narg != ntypes+1)
error->all("Dump modify element names do not match atom types");
if (typenames) {
for (int i = 1; i <= ntypes; i++) delete [] typenames[i];
delete [] typenames;
typenames = NULL;
}
typenames = new char*[ntypes+1];
for (int itype = 1; itype <= ntypes; itype++) {
typenames[itype] = new char[3];
if (strlen(arg[itype]) >= 3)
error->all("Illegal chemical element names");
strcpy(typenames[itype],arg[itype]);
}
return ntypes+1;
} else return 0;
}

View File

@ -30,8 +30,6 @@ class DumpCFG : public DumpCustom {
~DumpCFG();
private:
int ntypes; // # of atom types
char **typenames; // array of element names for each type
char **auxname; // name strings of auxiliary properties
int nchosen; // # of lines to be written on a writing proc
int nlines; // # of lines transferred from buf to rbuf
@ -41,8 +39,6 @@ class DumpCFG : public DumpCustom {
void init_style();
void write_header(bigint);
void write_data(int, double *);
int modify_param2(int, char **);
};
}

View File

@ -32,18 +32,19 @@
using namespace LAMMPS_NS;
// customize by adding keyword
// same list as in compute_property.cpp, also customize that command
// also customize compute_atom_property.cpp
enum{ID,MOL,TYPE,MASS,
enum{ID,MOL,TYPE,ELEMENT,MASS,
X,Y,Z,XS,YS,ZS,XSTRI,YSTRI,ZSTRI,XU,YU,ZU,XUTRI,YUTRI,ZUTRI,
XSU,YSU,ZSU,XSUTRI,YSUTRI,ZSUTRI,
IX,IY,IZ,
VX,VY,VZ,FX,FY,FZ,
Q,MUX,MUY,MUZ,MU,RADIUS,OMEGAX,OMEGAY,OMEGAZ,ANGMOMX,ANGMOMY,ANGMOMZ,
Q,MUX,MUY,MUZ,MU,RADIUS,DIAMETER,
OMEGAX,OMEGAY,OMEGAZ,ANGMOMX,ANGMOMY,ANGMOMZ,
TQX,TQY,TQZ,SPIN,ERADIUS,ERVEL,ERFORCE,
COMPUTE,FIX,VARIABLE};
enum{LT,LE,GT,GE,EQ,NEQ};
enum{INT,DOUBLE};
enum{INT,DOUBLE,STRING};
#define INVOKED_PERATOM 8
@ -97,6 +98,11 @@ DumpCustom::DumpCustom(LAMMPS *lmp, int narg, char **arg) :
choose = NULL;
dchoose = NULL;
// element names
ntypes = atom->ntypes;
typenames = NULL;
// setup format strings
vformat = new char*[size_one];
@ -106,7 +112,8 @@ DumpCustom::DumpCustom(LAMMPS *lmp, int narg, char **arg) :
for (int i = 0; i < size_one; i++) {
if (vtype[i] == INT) format_default = strcat(format_default,"%d ");
else format_default = strcat(format_default,"%g ");
else if (vtype[i] == DOUBLE) format_default = strcat(format_default,"%g ");
else if (vtype[i] == STRING) strcat(format_default,"%s ");
vformat[i] = NULL;
}
@ -153,6 +160,11 @@ DumpCustom::~DumpCustom()
memory->destroy(choose);
memory->destroy(dchoose);
if (typenames) {
for (int i = 1; i <= ntypes; i++) delete [] typenames[i];
delete [] typenames;
}
for (int i = 0; i < size_one; i++) delete [] vformat[i];
delete [] vformat;
@ -172,6 +184,16 @@ void DumpCustom::init_style()
format = new char[n];
strcpy(format,str);
// default for element names = C
if (typenames == NULL) {
typenames = new char*[ntypes+1];
for (int itype = 1; itype <= ntypes; itype++) {
typenames[itype] = new char[2];
strcpy(typenames[itype],"C");
}
}
// tokenize the format string and add space at end of each format element
char *ptr;
@ -429,6 +451,11 @@ int DumpCustom::count()
for (i = 0; i < nlocal; i++) dchoose[i] = type[i];
ptr = dchoose;
nstride = 1;
} else if (thresh_array[ithresh] == ELEMENT) {
int *type = atom->type;
for (i = 0; i < nlocal; i++) dchoose[i] = type[i];
ptr = dchoose;
nstride = 1;
} else if (thresh_array[ithresh] == MASS) {
if (atom->rmass) {
ptr = atom->rmass;
@ -581,7 +608,8 @@ int DumpCustom::count()
double boxylo = domain->boxlo[1];
double invyprd = 1.0/domain->yprd;
for (i = 0; i < nlocal; i++)
dchoose[i] = (x[i][1] - boxylo) * invyprd + (image[i] >> 10 & 1023) - 512;
dchoose[i] =
(x[i][1] - boxylo) * invyprd + (image[i] >> 10 & 1023) - 512;
ptr = dchoose;
nstride = 1;
@ -698,6 +726,13 @@ int DumpCustom::count()
error->all("Threshhold for an atom property that isn't allocated");
ptr = atom->radius;
nstride = 1;
} else if (thresh_array[ithresh] == DIAMETER) {
if (!atom->radius_flag)
error->all("Threshhold for an atom property that isn't allocated");
double *radius = atom->radius;
for (i = 0; i < nlocal; i++) dchoose[i] = 2.0*radius[i];
ptr = dchoose;
nstride = 1;
} else if (thresh_array[ithresh] == OMEGAX) {
if (!atom->omega_flag)
error->all("Threshhold for an atom property that isn't allocated");
@ -880,7 +915,9 @@ void DumpCustom::write_text(int n, double *mybuf)
for (i = 0; i < n; i++) {
for (j = 0; j < size_one; j++) {
if (vtype[j] == INT) fprintf(fp,vformat[j],static_cast<int> (mybuf[m]));
else fprintf(fp,vformat[j],mybuf[m]);
else if (vtype[j] == DOUBLE) fprintf(fp,vformat[j],mybuf[m]);
else if (vtype[j] == STRING)
fprintf(fp,vformat[j],typenames[(int) mybuf[m]]);
m++;
}
fprintf(fp,"\n");
@ -908,6 +945,9 @@ void DumpCustom::parse_fields(int narg, char **arg)
} else if (strcmp(arg[iarg],"type") == 0) {
pack_choice[i] = &DumpCustom::pack_type;
vtype[i] = INT;
} else if (strcmp(arg[iarg],"element") == 0) {
pack_choice[i] = &DumpCustom::pack_type;
vtype[i] = STRING;
} else if (strcmp(arg[iarg],"mass") == 0) {
pack_choice[i] = &DumpCustom::pack_mass;
vtype[i] = DOUBLE;
@ -1017,6 +1057,11 @@ void DumpCustom::parse_fields(int narg, char **arg)
error->all("Dumping an atom property that isn't allocated");
pack_choice[i] = &DumpCustom::pack_radius;
vtype[i] = DOUBLE;
} else if (strcmp(arg[iarg],"diameter") == 0) {
if (!atom->radius_flag)
error->all("Dumping an atom property that isn't allocated");
pack_choice[i] = &DumpCustom::pack_diameter;
vtype[i] = DOUBLE;
} else if (strcmp(arg[iarg],"omegax") == 0) {
if (!atom->omega_flag)
error->all("Dumping an atom property that isn't allocated");
@ -1271,6 +1316,24 @@ int DumpCustom::modify_param(int narg, char **arg)
}
return 2;
} else if (strcmp(arg[0],"element") == 0) {
if (narg != ntypes+1)
error->all("Dump modify element names do not match atom types");
if (typenames) {
for (int i = 1; i <= ntypes; i++) delete [] typenames[i];
delete [] typenames;
typenames = NULL;
}
typenames = new char*[ntypes+1];
for (int itype = 1; itype <= ntypes; itype++) {
int n = strlen(arg[itype]) + 1;
typenames[itype] = new char[n];
strcpy(typenames[itype],arg[itype]);
}
return ntypes+1;
} else if (strcmp(arg[0],"thresh") == 0) {
if (narg < 2) error->all("Illegal dump_modify command");
if (strcmp(arg[1],"none") == 0) {
@ -1362,6 +1425,7 @@ int DumpCustom::modify_param(int narg, char **arg)
else if (strcmp(arg[1],"mu") == 0) thresh_array[nthresh] = MU;
else if (strcmp(arg[1],"radius") == 0) thresh_array[nthresh] = RADIUS;
else if (strcmp(arg[1],"diameter") == 0) thresh_array[nthresh] = DIAMETER;
else if (strcmp(arg[1],"omegax") == 0) thresh_array[nthresh] = OMEGAX;
else if (strcmp(arg[1],"omegay") == 0) thresh_array[nthresh] = OMEGAY;
else if (strcmp(arg[1],"omegaz") == 0) thresh_array[nthresh] = OMEGAZ;
@ -2236,6 +2300,20 @@ void DumpCustom::pack_radius(int n)
/* ---------------------------------------------------------------------- */
void DumpCustom::pack_diameter(int n)
{
double *radius = atom->radius;
int nlocal = atom->nlocal;
for (int i = 0; i < nlocal; i++)
if (choose[i]) {
buf[n] = 2.0*radius[i];
n += size_one;
}
}
/* ---------------------------------------------------------------------- */
void DumpCustom::pack_omegax(int n)
{
double **omega = atom->omega;

View File

@ -67,6 +67,9 @@ class DumpCustom : public Dump {
int *variable; // list of indices for the Variables
double **vbuf; // local storage for variable evaluation
int ntypes; // # of atom types
char **typenames; // array of element names for each type
// private methods
virtual void init_style();
@ -142,6 +145,8 @@ class DumpCustom : public Dump {
void pack_muz(int);
void pack_mu(int);
void pack_radius(int);
void pack_diameter(int);
void pack_omegax(int);
void pack_omegay(int);
void pack_omegaz(int);