git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@11300 f3b2605a-c512-4ea7-a41b-209d697bcdaa
This commit is contained in:
@ -832,7 +832,10 @@ void FixPour::options(int narg, char **arg)
|
|||||||
if (iarg+2 > narg) error->all(FLERR,"Illegal fix pour command");
|
if (iarg+2 > narg) error->all(FLERR,"Illegal fix pour command");
|
||||||
int imol = atom->find_molecule(arg[iarg+1]);
|
int imol = atom->find_molecule(arg[iarg+1]);
|
||||||
if (imol == -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;
|
mode = MOLECULE;
|
||||||
onemol = atom->molecules[imol];
|
onemol = atom->molecules[imol];
|
||||||
iarg += 2;
|
iarg += 2;
|
||||||
|
|||||||
@ -577,7 +577,10 @@ void FixDeposit::options(int narg, char **arg)
|
|||||||
if (iarg+2 > narg) error->all(FLERR,"Illegal fix deposit command");
|
if (iarg+2 > narg) error->all(FLERR,"Illegal fix deposit command");
|
||||||
int imol = atom->find_molecule(arg[iarg+1]);
|
int imol = atom->find_molecule(arg[iarg+1]);
|
||||||
if (imol == -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;
|
mode = MOLECULE;
|
||||||
onemol = atom->molecules[imol];
|
onemol = atom->molecules[imol];
|
||||||
iarg += 2;
|
iarg += 2;
|
||||||
|
|||||||
@ -152,7 +152,11 @@ FixRigidSmall::FixRigidSmall(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
if (iarg+2 > narg) error->all(FLERR,"Illegal fix rigid/small command");
|
if (iarg+2 > narg) error->all(FLERR,"Illegal fix rigid/small command");
|
||||||
int imol = atom->find_molecule(arg[iarg+1]);
|
int imol = atom->find_molecule(arg[iarg+1]);
|
||||||
if (imol == -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];
|
onemol = atom->molecules[imol];
|
||||||
iarg += 2;
|
iarg += 2;
|
||||||
} else error->all(FLERR,"Illegal fix rigid/small command");
|
} else error->all(FLERR,"Illegal fix rigid/small command");
|
||||||
|
|||||||
@ -155,7 +155,10 @@ FixShake::FixShake(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
if (iarg+2 > narg) error->all(FLERR,"Illegal fix shake command");
|
if (iarg+2 > narg) error->all(FLERR,"Illegal fix shake command");
|
||||||
int imol = atom->find_molecule(arg[iarg+1]);
|
int imol = atom->find_molecule(arg[iarg+1]);
|
||||||
if (imol == -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];
|
onemol = atom->molecules[imol];
|
||||||
iarg += 2;
|
iarg += 2;
|
||||||
} else error->all(FLERR,"Illegal fix shake command");
|
} 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
|
// error check for Molecule template
|
||||||
|
|
||||||
if (onemol && onemol->shakeflag == 0)
|
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
|
// allocate bond and angle distance arrays, indexed from 1 to n
|
||||||
|
|
||||||
|
|||||||
29
src/atom.cpp
29
src/atom.cpp
@ -42,7 +42,6 @@ using namespace LAMMPS_NS;
|
|||||||
using namespace MathConst;
|
using namespace MathConst;
|
||||||
|
|
||||||
#define DELTA 1
|
#define DELTA 1
|
||||||
#define DELTA_MOLECULE 1
|
|
||||||
#define DELTA_MEMSTR 1024
|
#define DELTA_MEMSTR 1024
|
||||||
#define EPSILON 1.0e-6
|
#define EPSILON 1.0e-6
|
||||||
#define CUDA_CHUNK 3000
|
#define CUDA_CHUNK 3000
|
||||||
@ -117,7 +116,7 @@ Atom::Atom(LAMMPS *lmp) : Pointers(lmp)
|
|||||||
|
|
||||||
// user-defined molecules
|
// user-defined molecules
|
||||||
|
|
||||||
nmolecule = maxmol = 0;
|
nmolecule = 0;
|
||||||
molecules = NULL;
|
molecules = NULL;
|
||||||
|
|
||||||
// custom atom arrays
|
// 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)
|
void Atom::add_molecule(int narg, char **arg)
|
||||||
{
|
{
|
||||||
if (narg < 1) error->all(FLERR,"Illegal molecule command");
|
if (narg < 2) error->all(FLERR,"Illegal molecule command");
|
||||||
if (find_molecule(arg[0]) >= 0) error->all(FLERR,"Reuse of molecule ID");
|
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;
|
||||||
if (nmolecule == maxmol) {
|
|
||||||
maxmol += DELTA_MOLECULE;
|
|
||||||
molecules = (Molecule **)
|
molecules = (Molecule **)
|
||||||
memory->srealloc(molecules,maxmol*sizeof(Molecule *),"atom::molecules");
|
memory->srealloc(molecules,nmolecule*sizeof(Molecule *),"atom::molecules");
|
||||||
}
|
|
||||||
|
|
||||||
molecules[nmolecule++] = new Molecule(lmp,narg,arg);
|
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++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
find which molecule has molecule ID
|
find first molecule in set with template ID
|
||||||
return -1 if does not exist
|
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
|
add info to current atom ilocal from molecule template onemol and its iatom
|
||||||
offset = atom ID preceeding IDs of atoms in this molecule
|
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,
|
void Atom::add_molecule_atom(Molecule *onemol, int iatom,
|
||||||
|
|||||||
@ -113,9 +113,12 @@ class Atom : protected Pointers {
|
|||||||
int cs_flag,csforce_flag,vforce_flag,ervelforce_flag,etag_flag;
|
int cs_flag,csforce_flag,vforce_flag,ervelforce_flag,etag_flag;
|
||||||
int rho_flag,e_flag,cv_flag,vest_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;
|
class Molecule **molecules;
|
||||||
|
|
||||||
// extra peratom info in restart file destined for fix & diag
|
// extra peratom info in restart file destined for fix & diag
|
||||||
|
|||||||
@ -124,8 +124,11 @@ void CreateAtoms::command(int narg, char **arg)
|
|||||||
} else if (strcmp(arg[iarg],"mol") == 0) {
|
} else if (strcmp(arg[iarg],"mol") == 0) {
|
||||||
if (iarg+3 > narg) error->all(FLERR,"Illegal create_atoms command");
|
if (iarg+3 > narg) error->all(FLERR,"Illegal create_atoms command");
|
||||||
int imol = atom->find_molecule(arg[iarg+1]);
|
int imol = atom->find_molecule(arg[iarg+1]);
|
||||||
if (imol == -1)
|
if (imol == -1) error->all(FLERR,"Molecule template ID for "
|
||||||
error->all(FLERR,"Molecule ID for create_atoms does not exist");
|
"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;
|
mode = MOLECULE;
|
||||||
onemol = atom->molecules[imol];
|
onemol = atom->molecules[imol];
|
||||||
molseed = force->inumeric(FLERR,arg[iarg+2]);
|
molseed = force->inumeric(FLERR,arg[iarg+2]);
|
||||||
|
|||||||
@ -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;
|
me = comm->me;
|
||||||
|
|
||||||
if (narg != 2) error->all(FLERR,"Illegal molecule command");
|
int n = strlen(idarg) + 1;
|
||||||
|
|
||||||
int n = strlen(arg[0]) + 1;
|
|
||||||
id = new char[n];
|
id = new char[n];
|
||||||
strcpy(id,arg[0]);
|
strcpy(id,idarg);
|
||||||
|
|
||||||
for (int i = 0; i < n-1; i++)
|
for (int i = 0; i < n-1; i++)
|
||||||
if (!isalnum(id[i]) && id[i] != '_')
|
if (!isalnum(id[i]) && id[i] != '_')
|
||||||
error->all(FLERR,
|
error->all(FLERR,"Molecule template ID must be "
|
||||||
"Molecule ID must be alphanumeric or underscore characters");
|
"alphanumeric or underscore characters");
|
||||||
|
|
||||||
char *file = arg[1];
|
|
||||||
|
|
||||||
// initialize all fields to empty
|
// initialize all fields to empty
|
||||||
|
|
||||||
|
|||||||
@ -20,7 +20,9 @@ namespace LAMMPS_NS {
|
|||||||
|
|
||||||
class Molecule : protected Pointers {
|
class Molecule : protected Pointers {
|
||||||
public:
|
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
|
// number of atoms,bonds,etc in molecule
|
||||||
|
|
||||||
@ -97,7 +99,7 @@ class Molecule : protected Pointers {
|
|||||||
double **dxbody; // displacement of each atom relative to COM
|
double **dxbody; // displacement of each atom relative to COM
|
||||||
// in body frame (diagonalized interia tensor)
|
// in body frame (diagonalized interia tensor)
|
||||||
|
|
||||||
Molecule(class LAMMPS *, int, char **);
|
Molecule(class LAMMPS *, char *, char *);
|
||||||
~Molecule();
|
~Molecule();
|
||||||
void compute_center();
|
void compute_center();
|
||||||
void compute_mass();
|
void compute_mass();
|
||||||
|
|||||||
Reference in New Issue
Block a user