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

This commit is contained in:
sjplimp 2014-01-22 18:33:55 +00:00
parent b7eb7f3301
commit 41c5be7a8e
9 changed files with 54 additions and 34 deletions

View File

@ -832,7 +832,10 @@ void FixPour::options(int narg, char **arg)
if (iarg+2 > narg) error->all(FLERR,"Illegal fix pour command");
int imol = atom->find_molecule(arg[iarg+1]);
if (imol == -1)
error->all(FLERR,"Molecule ID for fix pour does not exist");
error->all(FLERR,"Molecule template ID for fix pour does not exist");
if (atom->molecules[imol]->nset > 1 && comm->me == 0)
error->warning(FLERR,"Molecule template for "
"fix pour has multiple molecules");
mode = MOLECULE;
onemol = atom->molecules[imol];
iarg += 2;

View File

@ -577,10 +577,13 @@ void FixDeposit::options(int narg, char **arg)
if (iarg+2 > narg) error->all(FLERR,"Illegal fix deposit command");
int imol = atom->find_molecule(arg[iarg+1]);
if (imol == -1)
error->all(FLERR,"Molecule ID for fix deposit does not exist");
error->all(FLERR,"Molecule template ID for fix deposit does not exist");
if (atom->molecules[imol]->nset > 1 && comm->me == 0)
error->warning(FLERR,"Molecule template for "
"fix deposit has multiple molecules");
mode = MOLECULE;
onemol = atom->molecules[imol];
iarg += 2;
iarg += 2;
} else if (strcmp(arg[iarg],"rigid") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal fix deposit command");
int n = strlen(arg[iarg+1]) + 1;

View File

@ -152,7 +152,11 @@ FixRigidSmall::FixRigidSmall(LAMMPS *lmp, int narg, char **arg) :
if (iarg+2 > narg) error->all(FLERR,"Illegal fix rigid/small command");
int imol = atom->find_molecule(arg[iarg+1]);
if (imol == -1)
error->all(FLERR,"Molecule ID for fix rigid/small does not exist");
error->all(FLERR,"Molecule template ID for "
"fix rigid/small does not exist");
if (atom->molecules[imol]->nset > 1 && comm->me == 0)
error->warning(FLERR,"Molecule template for "
"fix rigid/small has multiple molecules");
onemol = atom->molecules[imol];
iarg += 2;
} else error->all(FLERR,"Illegal fix rigid/small command");

View File

@ -155,7 +155,10 @@ FixShake::FixShake(LAMMPS *lmp, int narg, char **arg) :
if (iarg+2 > narg) error->all(FLERR,"Illegal fix shake command");
int imol = atom->find_molecule(arg[iarg+1]);
if (imol == -1)
error->all(FLERR,"Molecule ID for fix shake does not exist");
error->all(FLERR,"Molecule template ID for fix shake does not exist");
if (atom->molecules[imol]->nset > 1 && comm->me == 0)
error->warning(FLERR,"Molecule template for "
"fix shake has multiple molecules");
onemol = atom->molecules[imol];
iarg += 2;
} else error->all(FLERR,"Illegal fix shake command");
@ -164,7 +167,7 @@ FixShake::FixShake(LAMMPS *lmp, int narg, char **arg) :
// error check for Molecule template
if (onemol && onemol->shakeflag == 0)
error->all(FLERR,"Fix shake molecule must have shake info");
error->all(FLERR,"Fix shake molecule template must have shake info");
// allocate bond and angle distance arrays, indexed from 1 to n

View File

@ -42,7 +42,6 @@ using namespace LAMMPS_NS;
using namespace MathConst;
#define DELTA 1
#define DELTA_MOLECULE 1
#define DELTA_MEMSTR 1024
#define EPSILON 1.0e-6
#define CUDA_CHUNK 3000
@ -117,7 +116,7 @@ Atom::Atom(LAMMPS *lmp) : Pointers(lmp)
// user-defined molecules
nmolecule = maxmol = 0;
nmolecule = 0;
molecules = NULL;
// custom atom arrays
@ -1293,27 +1292,30 @@ int Atom::shape_consistency(int itype,
}
/* ----------------------------------------------------------------------
add a new molecule template
add a new molecule template = set of molecules
------------------------------------------------------------------------- */
void Atom::add_molecule(int narg, char **arg)
{
if (narg < 1) error->all(FLERR,"Illegal molecule command");
if (find_molecule(arg[0]) >= 0) error->all(FLERR,"Reuse of molecule ID");
if (narg < 2) error->all(FLERR,"Illegal molecule command");
if (find_molecule(arg[0]) >= 0)
error->all(FLERR,"Reuse of molecule template ID");
// extend molecule list if necessary
int nprevious = nmolecule;
nmolecule += narg-1;
molecules = (Molecule **)
memory->srealloc(molecules,nmolecule*sizeof(Molecule *),"atom::molecules");
if (nmolecule == maxmol) {
maxmol += DELTA_MOLECULE;
molecules = (Molecule **)
memory->srealloc(molecules,maxmol*sizeof(Molecule *),"atom::molecules");
for (int i = 1; i < narg; i++) {
molecules[nprevious] = new Molecule(lmp,arg[0],arg[i]);
if (i == 1) molecules[nprevious]->nset = narg-1;
else molecules[nprevious]->nset = 0;
nprevious++;
}
molecules[nmolecule++] = new Molecule(lmp,narg,arg);
}
/* ----------------------------------------------------------------------
find which molecule has molecule ID
find first molecule in set with template ID
return -1 if does not exist
------------------------------------------------------------------------- */
@ -1328,6 +1330,7 @@ int Atom::find_molecule(char *id)
/* ----------------------------------------------------------------------
add info to current atom ilocal from molecule template onemol and its iatom
offset = atom ID preceeding IDs of atoms in this molecule
called by fixes and commands that add molecules
------------------------------------------------------------------------- */
void Atom::add_molecule_atom(Molecule *onemol, int iatom,

View File

@ -113,9 +113,12 @@ class Atom : protected Pointers {
int cs_flag,csforce_flag,vforce_flag,ervelforce_flag,etag_flag;
int rho_flag,e_flag,cv_flag,vest_flag;
// molecules
// molecule templates
// each template can be a set of consecutive molecules
// each with same ID (stored in molecules)
// 1st molecule in template stores nset = # in set
int nmolecule,maxmol;
int nmolecule;
class Molecule **molecules;
// extra peratom info in restart file destined for fix & diag

View File

@ -124,8 +124,11 @@ void CreateAtoms::command(int narg, char **arg)
} else if (strcmp(arg[iarg],"mol") == 0) {
if (iarg+3 > narg) error->all(FLERR,"Illegal create_atoms command");
int imol = atom->find_molecule(arg[iarg+1]);
if (imol == -1)
error->all(FLERR,"Molecule ID for create_atoms does not exist");
if (imol == -1) error->all(FLERR,"Molecule template ID for "
"create_atoms does not exist");
if (atom->molecules[imol]->nset > 1 && comm->me == 0)
error->warning(FLERR,"Molecule template for "
"create_atoms has multiple molecules");
mode = MOLECULE;
onemol = atom->molecules[imol];
molseed = force->inumeric(FLERR,arg[iarg+2]);

View File

@ -33,22 +33,18 @@ using namespace MathConst;
/* ---------------------------------------------------------------------- */
Molecule::Molecule(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp)
Molecule::Molecule(LAMMPS *lmp, char *idarg, char *file) : Pointers(lmp)
{
me = comm->me;
if (narg != 2) error->all(FLERR,"Illegal molecule command");
int n = strlen(arg[0]) + 1;
int n = strlen(idarg) + 1;
id = new char[n];
strcpy(id,arg[0]);
strcpy(id,idarg);
for (int i = 0; i < n-1; i++)
if (!isalnum(id[i]) && id[i] != '_')
error->all(FLERR,
"Molecule ID must be alphanumeric or underscore characters");
char *file = arg[1];
error->all(FLERR,"Molecule template ID must be "
"alphanumeric or underscore characters");
// initialize all fields to empty

View File

@ -20,7 +20,9 @@ namespace LAMMPS_NS {
class Molecule : protected Pointers {
public:
char *id;
char *id; // template id of this molecule, same for all molecules in set
int nset; // if first in set, # of molecules in this set
// else 0 if not first in set
// number of atoms,bonds,etc in molecule
@ -97,7 +99,7 @@ class Molecule : protected Pointers {
double **dxbody; // displacement of each atom relative to COM
// in body frame (diagonalized interia tensor)
Molecule(class LAMMPS *, int, char **);
Molecule(class LAMMPS *, char *, char *);
~Molecule();
void compute_center();
void compute_mass();