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

This commit is contained in:
sjplimp
2015-10-30 20:04:06 +00:00
parent 0aa77408f8
commit 354e20f431
1219 changed files with 10111 additions and 10111 deletions

View File

@ -11,8 +11,8 @@
See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */
#include "stdlib.h"
#include "string.h"
#include <stdlib.h>
#include <string.h>
#include "molecule.h"
#include "atom.h"
#include "atom_vec.h"
@ -35,7 +35,7 @@ using namespace MathConst;
/* ---------------------------------------------------------------------- */
Molecule::Molecule(LAMMPS *lmp, int narg, char **arg, int &index) :
Molecule::Molecule(LAMMPS *lmp, int narg, char **arg, int &index) :
Pointers(lmp)
{
me = comm->me;
@ -68,8 +68,8 @@ Molecule::Molecule(LAMMPS *lmp, int narg, char **arg, int &index) :
aoffset = force->inumeric(FLERR,arg[iarg+3]);
doffset = force->inumeric(FLERR,arg[iarg+4]);
ioffset = force->inumeric(FLERR,arg[iarg+5]);
if (toffset < 0 || boffset < 0 || aoffset < 0 ||
doffset < 0 || ioffset < 0)
if (toffset < 0 || boffset < 0 || aoffset < 0 ||
doffset < 0 || ioffset < 0)
error->all(FLERR,"Illegal molecule command");
iarg += 6;
} else if (strcmp(arg[iarg],"toff") == 0) {
@ -129,7 +129,7 @@ Molecule::Molecule(LAMMPS *lmp, int narg, char **arg, int &index) :
if (me == 0) fclose(fp);
// stats
if (me == 0) {
if (screen)
fprintf(screen,"Read molecule %s:\n"
@ -336,10 +336,10 @@ void Molecule::compute_inertia()
tensor[1][2] = tensor[2][1] = itensor[3];
tensor[0][2] = tensor[2][0] = itensor[4];
tensor[0][1] = tensor[1][0] = itensor[5];
if (MathExtra::jacobi(tensor,inertia,evectors))
error->all(FLERR,"Insufficient Jacobi rotations for rigid molecule");
ex[0] = evectors[0][0];
ex[1] = evectors[1][0];
ex[2] = evectors[2][0];
@ -351,23 +351,23 @@ void Molecule::compute_inertia()
ez[2] = evectors[2][2];
// if any principal moment < scaled EPSILON, set to 0.0
double max;
max = MAX(inertia[0],inertia[1]);
max = MAX(max,inertia[2]);
if (inertia[0] < EPSILON*max) inertia[0] = 0.0;
if (inertia[1] < EPSILON*max) inertia[1] = 0.0;
if (inertia[2] < EPSILON*max) inertia[2] = 0.0;
// enforce 3 evectors as a right-handed coordinate system
// flip 3rd vector if needed
MathExtra::cross3(ex,ey,cross);
if (MathExtra::dot3(cross,ez) < 0.0) MathExtra::negate3(ez);
// create quaternion
MathExtra::exyz_to_q(ex,ey,ez,quat);
// compute displacements in body frame defined by quat
@ -454,16 +454,16 @@ void Molecule::read(int flag)
if (natoms < 1) error->all(FLERR,"No or invalid atom count in molecule file");
if (nbonds < 0) error->all(FLERR,"Invalid bond count in molecule file");
if (nangles < 0) error->all(FLERR,"Invalid angle count in molecule file");
if (ndihedrals < 0)
if (ndihedrals < 0)
error->all(FLERR,"Invalid dihedral count in molecule file");
if (nimpropers < 0)
if (nimpropers < 0)
error->all(FLERR,"Invalid improper count in molecule file");
// count = vector for tallying bonds,angles,etc per atom
if (flag == 0) memory->create(count,natoms,"molecule:count");
else count = NULL;
// grab keyword and skip next line
parse_keyword(0,line,keyword);
@ -499,7 +499,7 @@ void Molecule::read(int flag)
bondflag = tag_require = 1;
bonds(flag,line);
} else if (strcmp(keyword,"Angles") == 0) {
if (nangles == 0)
if (nangles == 0)
error->all(FLERR,"Molecule file has angles but no nangles setting");
angleflag = tag_require = 1;
angles(flag,line);
@ -529,20 +529,20 @@ void Molecule::read(int flag)
} else if (strcmp(keyword,"Shake Atoms") == 0) {
shakeatomflag = tag_require = 1;
if (shaketypeflag) shakeflag = 1;
if (!shakeflagflag)
if (!shakeflagflag)
error->all(FLERR,"Molecule file shake flags not before shake atoms");
if (flag) shakeatom_read(line);
else skip_lines(natoms,line);
} else if (strcmp(keyword,"Shake Bond Types") == 0) {
shaketypeflag = 1;
if (shakeatomflag) shakeflag = 1;
if (!shakeflagflag)
if (!shakeflagflag)
error->all(FLERR,"Molecule file shake flags not before shake bonds");
if (flag) shaketype_read(line);
else skip_lines(natoms,line);
} else error->one(FLERR,"Unknown section in molecule file");
parse_keyword(1,line,keyword);
}
@ -555,7 +555,7 @@ void Molecule::read(int flag)
if (flag == 0) {
if ((nspecialflag && !specialflag) || (!nspecialflag && specialflag))
error->all(FLERR,"Molecule file needs both Special Bond sections");
if (specialflag && !bondflag)
if (specialflag && !bondflag)
error->all(FLERR,"Molecule file has special flags but no bonds");
if ((shakeflagflag || shakeatomflag || shaketypeflag) && !shakeflag)
error->all(FLERR,"Molecule file shake info is incomplete");
@ -582,7 +582,7 @@ void Molecule::coords(char *line)
readline(line);
if (i == 0) {
int nwords = atom->count_words(line);
if (nwords != 4)
if (nwords != 4)
error->all(FLERR,"Invalid Coords section in molecule file");
}
sscanf(line,"%d %lg %lg %lg",&tmp,&x[i][0],&x[i][1],&x[i][2]);
@ -593,7 +593,7 @@ void Molecule::coords(char *line)
if (domain->dimension == 2) {
for (int i = 0; i < natoms; i++)
if (x[i][2] != 0.0)
if (x[i][2] != 0.0)
error->all(FLERR,"Molecule file z coord must be 0.0 for 2d");
}
}
@ -610,7 +610,7 @@ void Molecule::types(char *line)
readline(line);
if (i == 0) {
int nwords = atom->count_words(line);
if (nwords != 2)
if (nwords != 2)
error->all(FLERR,"Invalid Types section in molecule file");
}
sscanf(line,"%d %d",&tmp,&type[i]);
@ -636,7 +636,7 @@ void Molecule::charges(char *line)
readline(line);
if (i == 0) {
int nwords = atom->count_words(line);
if (nwords != 2)
if (nwords != 2)
error->all(FLERR,"Invalid Charges section in molecule file");
}
sscanf(line,"%d %lg",&tmp,&q[i]);
@ -655,7 +655,7 @@ void Molecule::diameters(char *line)
readline(line);
if (i == 0) {
int nwords = atom->count_words(line);
if (nwords != 2)
if (nwords != 2)
error->all(FLERR,"Invalid Diameters section in molecule file");
}
sscanf(line,"%d %lg",&tmp,&radius[i]);
@ -665,7 +665,7 @@ void Molecule::diameters(char *line)
}
for (int i = 0; i < natoms; i++)
if (radius[i] < 0.0)
if (radius[i] < 0.0)
error->all(FLERR,"Invalid atom diameter in molecule file");
}
@ -680,7 +680,7 @@ void Molecule::masses(char *line)
readline(line);
if (i == 0) {
int nwords = atom->count_words(line);
if (nwords != 2)
if (nwords != 2)
error->all(FLERR,"Invalid Masses section in molecule file");
}
sscanf(line,"%d %lg",&tmp,&rmass[i]);
@ -714,7 +714,7 @@ void Molecule::bonds(int flag, char *line)
readline(line);
if (i == 0) {
int nwords = atom->count_words(line);
if (nwords != 4)
if (nwords != 4)
error->all(FLERR,"Invalid Bonds section in molecule file");
}
sscanf(line,"%d %d " TAGINT_FORMAT " " TAGINT_FORMAT,
@ -776,7 +776,7 @@ void Molecule::angles(int flag, char *line)
readline(line);
if (i == 0) {
int nwords = atom->count_words(line);
if (nwords != 5)
if (nwords != 5)
error->all(FLERR,"Invalid Angles section in molecule file");
}
sscanf(line,"%d %d " TAGINT_FORMAT " " TAGINT_FORMAT " " TAGINT_FORMAT,
@ -852,10 +852,10 @@ void Molecule::dihedrals(int flag, char *line)
readline(line);
if (i == 0) {
int nwords = atom->count_words(line);
if (nwords != 6)
if (nwords != 6)
error->all(FLERR,"Invalid Dihedrals section in molecule file");
}
sscanf(line,"%d %d " TAGINT_FORMAT " " TAGINT_FORMAT " "
sscanf(line,"%d %d " TAGINT_FORMAT " " TAGINT_FORMAT " "
TAGINT_FORMAT " " TAGINT_FORMAT " ",
&tmp,&itype,&atom1,&atom2,&atom3,&atom4);
itype += doffset;
@ -943,10 +943,10 @@ void Molecule::impropers(int flag, char *line)
readline(line);
if (i == 0) {
int nwords = atom->count_words(line);
if (nwords != 6)
if (nwords != 6)
error->all(FLERR,"Invalid Impropers section in molecule file");
}
sscanf(line,"%d %d " TAGINT_FORMAT " " TAGINT_FORMAT " "
sscanf(line,"%d %d " TAGINT_FORMAT " " TAGINT_FORMAT " "
TAGINT_FORMAT " " TAGINT_FORMAT " ",
&tmp,&itype,&atom1,&atom2,&atom3,&atom4);
itype += ioffset;
@ -1028,7 +1028,7 @@ void Molecule::nspecial_read(int flag, char *line)
readline(line);
if (i == 0) {
int nwords = atom->count_words(line);
if (nwords != 4)
if (nwords != 4)
error->all(FLERR,"Invalid Special Bond Counts section in "
"molecule file");
}
@ -1094,8 +1094,8 @@ void Molecule::special_generate()
error->one(FLERR,"Molecule auto special bond generation overflow");
special[i][count[i]++] = atom2 + 1;
special[atom2][count[atom2]++] = i + 1;
}
}
}
}
} else {
for (int i = 0; i < natoms; i++) {
nspecial[i][0] = num_bond[i];
@ -1104,7 +1104,7 @@ void Molecule::special_generate()
atom2 = bond_atom[i][j];
if (count[atom1] >= maxspecial)
error->one(FLERR,"");
special[i][count[atom1]++] = atom2;
special[i][count[atom1]++] = atom2;
}
}
}
@ -1129,15 +1129,15 @@ void Molecule::special_generate()
error->one(FLERR,"");
special[i][count[i]++] = special[special[i][m]-1][j];
nspecial[i][1]++;
}
}
}
}
}
}
// 1-4 neighbors with no duplicates
for (int i = 0; i < natoms; i++) nspecial[i][2] = nspecial[i][1];
for (int i = 0; i < natoms; i++) {
for (int m = nspecial[i][0]; m < nspecial[i][1]; m++) {
for (int j = 0; j < nspecial[special[i][m]-1][0]; j++) {
@ -1153,9 +1153,9 @@ void Molecule::special_generate()
error->one(FLERR,"");
special[i][count[i]++] = special[special[i][m]-1][j];
nspecial[i][2]++;
}
}
}
}
}
}
}
@ -1172,7 +1172,7 @@ void Molecule::shakeflag_read(char *line)
}
for (int i = 0; i < natoms; i++)
if (shake_flag[i] < 0 || shake_flag[i] > 4)
if (shake_flag[i] < 0 || shake_flag[i] > 4)
error->all(FLERR,"Invalid shake flag in molecule file");
}
@ -1195,7 +1195,7 @@ void Molecule::shakeatom_read(char *line)
sscanf(line,"%d " TAGINT_FORMAT " " TAGINT_FORMAT " " TAGINT_FORMAT,
&tmp,&shake_atom[i][0],&shake_atom[i][1],&shake_atom[i][2]);
else if (shake_flag[i] == 4)
sscanf(line,"%d " TAGINT_FORMAT " " TAGINT_FORMAT " "
sscanf(line,"%d " TAGINT_FORMAT " " TAGINT_FORMAT " "
TAGINT_FORMAT " " TAGINT_FORMAT,
&tmp,&shake_atom[i][0],&shake_atom[i][1],
&shake_atom[i][2],&shake_atom[i][3]);
@ -1257,7 +1257,7 @@ void Molecule::check_attributes(int flag)
for (int i = imol; i < imol+n; i++) {
Molecule *onemol = atom->molecules[imol];
// check per-atom attributes of molecule
// warn if not a match
@ -1266,7 +1266,7 @@ void Molecule::check_attributes(int flag)
if (onemol->radiusflag && !atom->radius_flag) mismatch = 1;
if (onemol->rmassflag && !atom->rmass_flag) mismatch = 1;
if (mismatch && me == 0)
if (mismatch && me == 0)
error->warning(FLERR,
"Molecule attributes do not match system attributes");
@ -1278,7 +1278,7 @@ void Molecule::check_attributes(int flag)
if (atom->ndihedraltypes < onemol->ndihedraltypes) mismatch = 1;
if (atom->nimpropertypes < onemol->nimpropertypes) mismatch = 1;
if (mismatch)
if (mismatch)
error->all(FLERR,"Molecule topology type exceeds system topology type");
// for molecular atom styles, check bond_per_atom,etc + maxspecial
@ -1295,13 +1295,13 @@ void Molecule::check_attributes(int flag)
atom->improper_per_atom < onemol->improper_per_atom) mismatch = 1;
if (atom->maxspecial < onemol->maxspecial) mismatch = 1;
if (mismatch)
if (mismatch)
error->all(FLERR,"Molecule toplogy/atom exceeds system topology/atom");
}
// warn if molecule topology defined but no special settings
if (onemol->bondflag && !onemol->specialflag)
if (onemol->bondflag && !onemol->specialflag)
if (me == 0) error->warning(FLERR,"Molecule has bond topology "
"but no special bond settings");
}
@ -1457,24 +1457,24 @@ void Molecule::deallocate()
memory->destroy(q);
memory->destroy(radius);
memory->destroy(rmass);
memory->destroy(num_bond);
memory->destroy(bond_type);
memory->destroy(bond_atom);
memory->destroy(num_angle);
memory->destroy(angle_type);
memory->destroy(angle_atom1);
memory->destroy(angle_atom2);
memory->destroy(angle_atom3);
memory->destroy(num_dihedral);
memory->destroy(dihedral_type);
memory->destroy(dihedral_atom1);
memory->destroy(dihedral_atom2);
memory->destroy(dihedral_atom3);
memory->destroy(dihedral_atom4);
memory->destroy(num_improper);
memory->destroy(improper_type);
memory->destroy(improper_atom1);
@ -1642,7 +1642,7 @@ void Molecule::print()
for (int i = 0; i < natoms; i++)
printf(" %d %g\n",i+1,rmass[i]);
}
if (bondflag) {
printf( "Bonds:\n");
for (int i = 0; i < natoms; i++) {