Extend compute pair to handle multiple instances of a given pair style
This commit is contained in:
@ -29,7 +29,7 @@ ComputePair::ComputePair(LAMMPS *lmp, int narg, char **arg) :
|
||||
Compute(lmp, narg, arg),
|
||||
pstyle(NULL), pair(NULL), one(NULL)
|
||||
{
|
||||
if (narg < 4 || narg > 5) error->all(FLERR,"Illegal compute pair command");
|
||||
if (narg < 4) error->all(FLERR,"Illegal compute pair command");
|
||||
|
||||
scalar_flag = 1;
|
||||
extscalar = 1;
|
||||
@ -41,19 +41,33 @@ ComputePair::ComputePair(LAMMPS *lmp, int narg, char **arg) :
|
||||
pstyle = new char[n];
|
||||
strcpy(pstyle,arg[3]);
|
||||
|
||||
if (narg == 5) {
|
||||
if (strcmp(arg[4],"epair") == 0) evalue = EPAIR;
|
||||
if (strcmp(arg[4],"evdwl") == 0) evalue = EVDWL;
|
||||
if (strcmp(arg[4],"ecoul") == 0) evalue = ECOUL;
|
||||
} else evalue = EPAIR;
|
||||
int iarg = 4;
|
||||
nsub = 0;
|
||||
|
||||
while (iarg < narg) {
|
||||
if (strcmp(arg[iarg],"evalue") == 0) {
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal compute pair command");
|
||||
if (strcmp(arg[iarg+1],"epair") == 0) evalue = EPAIR;
|
||||
else if (strcmp(arg[iarg+1],"evdwl") == 0) evalue = EVDWL;
|
||||
else if (strcmp(arg[iarg+1],"ecoul") == 0) evalue = ECOUL;
|
||||
else error->all(FLERR, "Unrecognized energy type");
|
||||
iarg += 2;
|
||||
} else if (strcmp(arg[iarg],"nsub") == 0) {
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal compute pair command");
|
||||
nsub = force->inumeric(FLERR,arg[iarg+1]);
|
||||
iarg += 2;
|
||||
} else error->all(FLERR,"Illegal compute pair command");
|
||||
|
||||
}
|
||||
|
||||
|
||||
// check if pair style with and without suffix exists
|
||||
|
||||
pair = force->pair_match(pstyle,1);
|
||||
pair = force->pair_match(pstyle,1,nsub);
|
||||
if (!pair && lmp->suffix) {
|
||||
strcat(pstyle,"/");
|
||||
strcat(pstyle,lmp->suffix);
|
||||
pair = force->pair_match(pstyle,1);
|
||||
pair = force->pair_match(pstyle,1,nsub);
|
||||
}
|
||||
|
||||
if (!pair)
|
||||
@ -84,7 +98,7 @@ void ComputePair::init()
|
||||
{
|
||||
// recheck for pair style in case it has been deleted
|
||||
|
||||
pair = force->pair_match(pstyle,1);
|
||||
pair = force->pair_match(pstyle,1,nsub);
|
||||
if (!pair)
|
||||
error->all(FLERR,"Unrecognized pair style in compute pair command");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user