git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@7003 f3b2605a-c512-4ea7-a41b-209d697bcdaa
This commit is contained in:
152
src/set.cpp
152
src/set.cpp
@ -52,10 +52,10 @@ Set::Set(LAMMPS *lmp) : Pointers(lmp)
|
||||
void Set::command(int narg, char **arg)
|
||||
{
|
||||
if (domain->box_exist == 0)
|
||||
error->all("Set command before simulation box is defined");
|
||||
error->all(FLERR,"Set command before simulation box is defined");
|
||||
if (atom->natoms == 0)
|
||||
error->all("Set command with no atoms existing");
|
||||
if (narg < 3) error->all("Illegal set command");
|
||||
error->all(FLERR,"Set command with no atoms existing");
|
||||
if (narg < 3) error->all(FLERR,"Illegal set command");
|
||||
|
||||
// style and ID info
|
||||
|
||||
@ -64,7 +64,7 @@ void Set::command(int narg, char **arg)
|
||||
else if (strcmp(arg[0],"type") == 0) style = TYPE_SELECT;
|
||||
else if (strcmp(arg[0],"group") == 0) style = GROUP_SELECT;
|
||||
else if (strcmp(arg[0],"region") == 0) style = REGION_SELECT;
|
||||
else error->all("Illegal set command");
|
||||
else error->all(FLERR,"Illegal set command");
|
||||
|
||||
int n = strlen(arg[1]) + 1;
|
||||
id = new char[n];
|
||||
@ -84,137 +84,137 @@ void Set::command(int narg, char **arg)
|
||||
origarg = iarg;
|
||||
|
||||
if (strcmp(arg[iarg],"type") == 0) {
|
||||
if (iarg+2 > narg) error->all("Illegal set command");
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal set command");
|
||||
ivalue = atoi(arg[iarg+1]);
|
||||
if (ivalue <= 0 || ivalue > atom->ntypes)
|
||||
error->all("Invalid value in set command");
|
||||
error->all(FLERR,"Invalid value in set command");
|
||||
set(TYPE);
|
||||
iarg += 2;
|
||||
} else if (strcmp(arg[iarg],"type/fraction") == 0) {
|
||||
if (iarg+4 > narg) error->all("Illegal set command");
|
||||
if (iarg+4 > narg) error->all(FLERR,"Illegal set command");
|
||||
newtype = atoi(arg[iarg+1]);
|
||||
fraction = atof(arg[iarg+2]);
|
||||
ivalue = atoi(arg[iarg+3]);
|
||||
if (newtype <= 0 || newtype > atom->ntypes)
|
||||
error->all("Invalid value in set command");
|
||||
error->all(FLERR,"Invalid value in set command");
|
||||
if (fraction < 0.0 || fraction > 1.0)
|
||||
error->all("Invalid value in set command");
|
||||
if (ivalue <= 0) error->all("Invalid random number seed in set command");
|
||||
error->all(FLERR,"Invalid value in set command");
|
||||
if (ivalue <= 0) error->all(FLERR,"Invalid random number seed in set command");
|
||||
setrandom(TYPE_FRACTION);
|
||||
iarg += 4;
|
||||
} else if (strcmp(arg[iarg],"mol") == 0) {
|
||||
if (iarg+2 > narg) error->all("Illegal set command");
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal set command");
|
||||
ivalue = atoi(arg[iarg+1]);
|
||||
if (!atom->molecule_flag)
|
||||
error->all("Cannot set this attribute for this atom style");
|
||||
error->all(FLERR,"Cannot set this attribute for this atom style");
|
||||
set(MOLECULE);
|
||||
iarg += 2;
|
||||
} else if (strcmp(arg[iarg],"x") == 0) {
|
||||
if (iarg+2 > narg) error->all("Illegal set command");
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal set command");
|
||||
dvalue = atof(arg[iarg+1]);
|
||||
set(X);
|
||||
iarg += 2;
|
||||
} else if (strcmp(arg[iarg],"y") == 0) {
|
||||
if (iarg+2 > narg) error->all("Illegal set command");
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal set command");
|
||||
dvalue = atof(arg[iarg+1]);
|
||||
set(Y);
|
||||
iarg += 2;
|
||||
} else if (strcmp(arg[iarg],"z") == 0) {
|
||||
if (iarg+2 > narg) error->all("Illegal set command");
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal set command");
|
||||
dvalue = atof(arg[iarg+1]);
|
||||
set(Z);
|
||||
iarg += 2;
|
||||
} else if (strcmp(arg[iarg],"charge") == 0) {
|
||||
if (iarg+2 > narg) error->all("Illegal set command");
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal set command");
|
||||
dvalue = atof(arg[iarg+1]);
|
||||
if (!atom->q_flag)
|
||||
error->all("Cannot set this attribute for this atom style");
|
||||
error->all(FLERR,"Cannot set this attribute for this atom style");
|
||||
set(CHARGE);
|
||||
iarg += 2;
|
||||
} else if (strcmp(arg[iarg],"mass") == 0) {
|
||||
if (iarg+2 > narg) error->all("Illegal set command");
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal set command");
|
||||
dvalue = atof(arg[iarg+1]);
|
||||
if (!atom->rmass_flag)
|
||||
error->all("Cannot set this attribute for this atom style");
|
||||
if (dvalue <= 0.0) error->all("Invalid mass in set command");
|
||||
error->all(FLERR,"Cannot set this attribute for this atom style");
|
||||
if (dvalue <= 0.0) error->all(FLERR,"Invalid mass in set command");
|
||||
set(MASS);
|
||||
iarg += 2;
|
||||
} else if (strcmp(arg[iarg],"shape") == 0) {
|
||||
if (iarg+4 > narg) error->all("Illegal set command");
|
||||
if (iarg+4 > narg) error->all(FLERR,"Illegal set command");
|
||||
xvalue = atof(arg[iarg+1]);
|
||||
yvalue = atof(arg[iarg+2]);
|
||||
zvalue = atof(arg[iarg+3]);
|
||||
if (!atom->ellipsoid_flag)
|
||||
error->all("Cannot set this attribute for this atom style");
|
||||
error->all(FLERR,"Cannot set this attribute for this atom style");
|
||||
if (xvalue < 0.0 || yvalue < 0.0 || zvalue < 0.0)
|
||||
error->all("Invalid shape in set command");
|
||||
error->all(FLERR,"Invalid shape in set command");
|
||||
if (xvalue > 0.0 || yvalue > 0.0 || zvalue > 0.0) {
|
||||
if (xvalue == 0.0 || yvalue == 0.0 || zvalue == 0.0)
|
||||
error->one("Invalid shape in set command");
|
||||
error->one(FLERR,"Invalid shape in set command");
|
||||
}
|
||||
set(SHAPE);
|
||||
iarg += 4;
|
||||
} else if (strcmp(arg[iarg],"dipole") == 0) {
|
||||
if (iarg+4 > narg) error->all("Illegal set command");
|
||||
if (iarg+4 > narg) error->all(FLERR,"Illegal set command");
|
||||
xvalue = atof(arg[iarg+1]);
|
||||
yvalue = atof(arg[iarg+2]);
|
||||
zvalue = atof(arg[iarg+3]);
|
||||
if (!atom->mu_flag)
|
||||
error->all("Cannot set this attribute for this atom style");
|
||||
error->all(FLERR,"Cannot set this attribute for this atom style");
|
||||
set(DIPOLE);
|
||||
iarg += 4;
|
||||
} else if (strcmp(arg[iarg],"dipole/random") == 0) {
|
||||
if (iarg+3 > narg) error->all("Illegal set command");
|
||||
if (iarg+3 > narg) error->all(FLERR,"Illegal set command");
|
||||
ivalue = atoi(arg[iarg+1]);
|
||||
dvalue = atof(arg[iarg+2]);
|
||||
if (!atom->mu_flag)
|
||||
error->all("Cannot set this attribute for this atom style");
|
||||
if (ivalue <= 0) error->all("Invalid random number seed in set command");
|
||||
if (dvalue <= 0.0) error->all("Invalid dipole length in set command");
|
||||
error->all(FLERR,"Cannot set this attribute for this atom style");
|
||||
if (ivalue <= 0) error->all(FLERR,"Invalid random number seed in set command");
|
||||
if (dvalue <= 0.0) error->all(FLERR,"Invalid dipole length in set command");
|
||||
setrandom(DIPOLE_RANDOM);
|
||||
iarg += 3;
|
||||
} else if (strcmp(arg[iarg],"quat") == 0) {
|
||||
if (iarg+5 > narg) error->all("Illegal set command");
|
||||
if (iarg+5 > narg) error->all(FLERR,"Illegal set command");
|
||||
xvalue = atof(arg[iarg+1]);
|
||||
yvalue = atof(arg[iarg+2]);
|
||||
zvalue = atof(arg[iarg+3]);
|
||||
wvalue = atof(arg[iarg+4]);
|
||||
if (!atom->ellipsoid_flag)
|
||||
error->all("Cannot set this attribute for this atom style");
|
||||
error->all(FLERR,"Cannot set this attribute for this atom style");
|
||||
set(QUAT);
|
||||
iarg += 5;
|
||||
} else if (strcmp(arg[iarg],"quat/random") == 0) {
|
||||
if (iarg+2 > narg) error->all("Illegal set command");
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal set command");
|
||||
ivalue = atoi(arg[iarg+1]);
|
||||
if (!atom->ellipsoid_flag)
|
||||
error->all("Cannot set this attribute for this atom style");
|
||||
if (ivalue <= 0) error->all("Invalid random number seed in set command");
|
||||
error->all(FLERR,"Cannot set this attribute for this atom style");
|
||||
if (ivalue <= 0) error->all(FLERR,"Invalid random number seed in set command");
|
||||
setrandom(QUAT_RANDOM);
|
||||
iarg += 2;
|
||||
} else if (strcmp(arg[iarg],"diameter") == 0) {
|
||||
if (iarg+2 > narg) error->all("Illegal set command");
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal set command");
|
||||
dvalue = atof(arg[iarg+1]);
|
||||
if (!atom->radius_flag)
|
||||
error->all("Cannot set this attribute for this atom style");
|
||||
if (dvalue < 0.0) error->all("Invalid diameter in set command");
|
||||
error->all(FLERR,"Cannot set this attribute for this atom style");
|
||||
if (dvalue < 0.0) error->all(FLERR,"Invalid diameter in set command");
|
||||
set(DIAMETER);
|
||||
iarg += 2;
|
||||
} else if (strcmp(arg[iarg],"density") == 0) {
|
||||
if (iarg+2 > narg) error->all("Illegal set command");
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal set command");
|
||||
dvalue = atof(arg[iarg+1]);
|
||||
if (!atom->rmass_flag)
|
||||
error->all("Cannot set this attribute for this atom style");
|
||||
error->all(FLERR,"Cannot set this attribute for this atom style");
|
||||
set(DENSITY);
|
||||
iarg += 2;
|
||||
} else if (strcmp(arg[iarg],"volume") == 0) {
|
||||
if (iarg+2 > narg) error->all("Illegal set command");
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal set command");
|
||||
dvalue = atof(arg[iarg+1]);
|
||||
if (!atom->vfrac_flag)
|
||||
error->all("Cannot set this attribute for this atom style");
|
||||
error->all(FLERR,"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");
|
||||
if (iarg+4 > narg) error->all(FLERR,"Illegal set command");
|
||||
ximageflag = yimageflag = zimageflag = 0;
|
||||
if (strcmp(arg[iarg+1],"NULL") != 0) {
|
||||
ximageflag = 1;
|
||||
@ -229,71 +229,71 @@ void Set::command(int narg, char **arg)
|
||||
zimage = atoi(arg[iarg+3]);
|
||||
}
|
||||
if (ximageflag && ximage && !domain->xperiodic)
|
||||
error->all("Cannot set non-zero image flag for non-periodic dimension");
|
||||
error->all(FLERR,"Cannot set non-zero image flag for non-periodic dimension");
|
||||
if (yimageflag && yimage && !domain->yperiodic)
|
||||
error->all("Cannot set non-zero image flag for non-periodic dimension");
|
||||
error->all(FLERR,"Cannot set non-zero image flag for non-periodic dimension");
|
||||
if (zimageflag && zimage && !domain->zperiodic)
|
||||
error->all("Cannot set non-zero image flag for non-periodic dimension");
|
||||
error->all(FLERR,"Cannot set non-zero image flag for non-periodic dimension");
|
||||
set(IMAGE);
|
||||
iarg += 4;
|
||||
} else if (strcmp(arg[iarg],"bond") == 0) {
|
||||
if (iarg+2 > narg) error->all("Illegal set command");
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal set command");
|
||||
ivalue = atoi(arg[iarg+1]);
|
||||
if (atom->avec->bonds_allow == 0)
|
||||
error->all("Cannot set this attribute for this atom style");
|
||||
error->all(FLERR,"Cannot set this attribute for this atom style");
|
||||
if (ivalue <= 0 || ivalue > atom->nbondtypes)
|
||||
error->all("Invalid value in set command");
|
||||
error->all(FLERR,"Invalid value in set command");
|
||||
topology(BOND);
|
||||
iarg += 2;
|
||||
} else if (strcmp(arg[iarg],"angle") == 0) {
|
||||
if (iarg+2 > narg) error->all("Illegal set command");
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal set command");
|
||||
ivalue = atoi(arg[iarg+1]);
|
||||
if (atom->avec->angles_allow == 0)
|
||||
error->all("Cannot set this attribute for this atom style");
|
||||
error->all(FLERR,"Cannot set this attribute for this atom style");
|
||||
if (ivalue <= 0 || ivalue > atom->nangletypes)
|
||||
error->all("Invalid value in set command");
|
||||
error->all(FLERR,"Invalid value in set command");
|
||||
topology(ANGLE);
|
||||
iarg += 2;
|
||||
} else if (strcmp(arg[iarg],"dihedral") == 0) {
|
||||
if (iarg+2 > narg) error->all("Illegal set command");
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal set command");
|
||||
ivalue = atoi(arg[iarg+1]);
|
||||
if (atom->avec->dihedrals_allow == 0)
|
||||
error->all("Cannot set this attribute for this atom style");
|
||||
error->all(FLERR,"Cannot set this attribute for this atom style");
|
||||
if (ivalue <= 0 || ivalue > atom->ndihedraltypes)
|
||||
error->all("Invalid value in set command");
|
||||
error->all(FLERR,"Invalid value in set command");
|
||||
topology(DIHEDRAL);
|
||||
iarg += 2;
|
||||
} else if (strcmp(arg[iarg],"improper") == 0) {
|
||||
if (iarg+2 > narg) error->all("Illegal set command");
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal set command");
|
||||
ivalue = atoi(arg[iarg+1]);
|
||||
if (atom->avec->impropers_allow == 0)
|
||||
error->all("Cannot set this attribute for this atom style");
|
||||
error->all(FLERR,"Cannot set this attribute for this atom style");
|
||||
if (ivalue <= 0 || ivalue > atom->nimpropertypes)
|
||||
error->all("Invalid value in set command");
|
||||
error->all(FLERR,"Invalid value in set command");
|
||||
topology(IMPROPER);
|
||||
iarg += 2;
|
||||
} else if (strcmp(arg[iarg],"meso_e") == 0) {
|
||||
if (iarg+2 > narg) error->all("Illegal set command");
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal set command");
|
||||
dvalue = atof(arg[iarg+1]);
|
||||
if (!atom->e_flag)
|
||||
error->all("Cannot set this attribute for this atom style");
|
||||
error->all(FLERR,"Cannot set this attribute for this atom style");
|
||||
set(MESO_E);
|
||||
iarg += 2;
|
||||
} else if (strcmp(arg[iarg],"meso_cv") == 0) {
|
||||
if (iarg+2 > narg) error->all("Illegal set command");
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal set command");
|
||||
dvalue = atof(arg[iarg+1]);
|
||||
if (!atom->cv_flag)
|
||||
error->all("Cannot set this attribute for this atom style");
|
||||
error->all(FLERR,"Cannot set this attribute for this atom style");
|
||||
set(MESO_CV);
|
||||
iarg += 2;
|
||||
} else if (strcmp(arg[iarg],"meso_rho") == 0) {
|
||||
if (iarg+2 > narg) error->all("Illegal set command");
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal set command");
|
||||
dvalue = atof(arg[iarg+1]);
|
||||
if (!atom->rho_flag)
|
||||
error->all("Cannot set meso_rho for this atom style");
|
||||
error->all(FLERR,"Cannot set meso_rho for this atom style");
|
||||
set(MESO_RHO);
|
||||
iarg += 2;
|
||||
} else error->all("Illegal set command");
|
||||
} else error->all(FLERR,"Illegal set command");
|
||||
|
||||
// statistics
|
||||
|
||||
@ -326,7 +326,7 @@ void Set::selection(int n)
|
||||
|
||||
if (style == ATOM_SELECT) {
|
||||
if (atom->tag_enable == 0)
|
||||
error->all("Cannot use set atom with no atom IDs defined");
|
||||
error->all(FLERR,"Cannot use set atom with no atom IDs defined");
|
||||
force->bounds(id,BIG,nlo,nhi);
|
||||
|
||||
int *tag = atom->tag;
|
||||
@ -336,7 +336,7 @@ void Set::selection(int n)
|
||||
|
||||
} else if (style == MOL_SELECT) {
|
||||
if (atom->molecule_flag == 0)
|
||||
error->all("Cannot use set mol with no molecule IDs defined");
|
||||
error->all(FLERR,"Cannot use set mol with no molecule IDs defined");
|
||||
if (strcmp(id,"0") == 0) nlo = nhi = 0;
|
||||
else force->bounds(id,BIG,nlo,nhi);
|
||||
|
||||
@ -355,7 +355,7 @@ void Set::selection(int n)
|
||||
|
||||
} else if (style == GROUP_SELECT) {
|
||||
int igroup = group->find(id);
|
||||
if (igroup == -1) error->all("Could not find set group ID");
|
||||
if (igroup == -1) error->all(FLERR,"Could not find set group ID");
|
||||
int groupbit = group->bitmask[igroup];
|
||||
|
||||
int *mask = atom->mask;
|
||||
@ -365,7 +365,7 @@ void Set::selection(int n)
|
||||
|
||||
} else if (style == REGION_SELECT) {
|
||||
int iregion = domain->find_region(id);
|
||||
if (iregion == -1) error->all("Set region ID does not exist");
|
||||
if (iregion == -1) error->all(FLERR,"Set region ID does not exist");
|
||||
|
||||
double **x = atom->x;
|
||||
for (int i = 0; i < n; i++)
|
||||
@ -448,7 +448,7 @@ void Set::set(int keyword)
|
||||
|
||||
} else if (keyword == QUAT) {
|
||||
if (atom->ellipsoid[i] < 0)
|
||||
error->one("Cannot set quaternion for atom that is not an ellipsoid");
|
||||
error->one(FLERR,"Cannot set quaternion for atom that is not an ellipsoid");
|
||||
double *quat = avec_ellipsoid->bonus[atom->ellipsoid[i]].quat;
|
||||
double theta2 = 0.5 * PI * wvalue/180.0;
|
||||
double sintheta2 = sin(theta2);
|
||||
@ -547,7 +547,7 @@ void Set::setrandom(int keyword)
|
||||
for (i = 0; i < nlocal; i++)
|
||||
if (select[i]) {
|
||||
if (ellipsoid[i] < 0)
|
||||
error->one("Cannot set quaternion for atom "
|
||||
error->one(FLERR,"Cannot set quaternion for atom "
|
||||
"that is not an ellipsoid");
|
||||
quat = bonus[ellipsoid[i]].quat;
|
||||
random->reset(seed,x[i]);
|
||||
@ -568,7 +568,7 @@ void Set::setrandom(int keyword)
|
||||
for (i = 0; i < nlocal; i++)
|
||||
if (select[i]) {
|
||||
if (ellipsoid[i] < 0)
|
||||
error->one("Cannot set quaternion for atom "
|
||||
error->one(FLERR,"Cannot set quaternion for atom "
|
||||
"that is not an ellipsoid");
|
||||
quat = bonus[ellipsoid[i]].quat;
|
||||
random->reset(seed,x[i]);
|
||||
@ -618,7 +618,7 @@ void Set::topology(int keyword)
|
||||
for (int i = 0; i < nlocal; i++)
|
||||
for (m = 0; m < atom->num_bond[i]; m++) {
|
||||
atom1 = atom->map(atom->bond_atom[i][m]);
|
||||
if (atom1 == -1) error->one("Bond atom missing in set command");
|
||||
if (atom1 == -1) error->one(FLERR,"Bond atom missing in set command");
|
||||
if (select[i] && select[atom1]) {
|
||||
atom->bond_type[i][m] = ivalue;
|
||||
count++;
|
||||
@ -636,7 +636,7 @@ void Set::topology(int keyword)
|
||||
atom2 = atom->map(atom->angle_atom2[i][m]);
|
||||
atom3 = atom->map(atom->angle_atom3[i][m]);
|
||||
if (atom1 == -1 || atom2 == -1 || atom3 == -1)
|
||||
error->one("Angle atom missing in set command");
|
||||
error->one(FLERR,"Angle atom missing in set command");
|
||||
if (select[atom1] && select[atom2] && select[atom3]) {
|
||||
atom->angle_type[i][m] = ivalue;
|
||||
count++;
|
||||
@ -655,7 +655,7 @@ void Set::topology(int keyword)
|
||||
atom3 = atom->map(atom->dihedral_atom3[i][m]);
|
||||
atom4 = atom->map(atom->dihedral_atom4[i][m]);
|
||||
if (atom1 == -1 || atom2 == -1 || atom3 == -1 || atom4 == -1)
|
||||
error->one("Dihedral atom missing in set command");
|
||||
error->one(FLERR,"Dihedral atom missing in set command");
|
||||
if (select[atom1] && select[atom2] && select[atom3] && select[atom4]) {
|
||||
atom->dihedral_type[i][m] = ivalue;
|
||||
count++;
|
||||
@ -674,7 +674,7 @@ void Set::topology(int keyword)
|
||||
atom3 = atom->map(atom->improper_atom3[i][m]);
|
||||
atom4 = atom->map(atom->improper_atom4[i][m]);
|
||||
if (atom1 == -1 || atom2 == -1 || atom3 == -1 || atom4 == -1)
|
||||
error->one("Improper atom missing in set command");
|
||||
error->one(FLERR,"Improper atom missing in set command");
|
||||
if (select[atom1] && select[atom2] && select[atom3] && select[atom4]) {
|
||||
atom->improper_type[i][m] = ivalue;
|
||||
count++;
|
||||
|
||||
Reference in New Issue
Block a user