Merge pull request #1240 from akohlmey/fix-tune-kspace-limits

Detect fix tune/kspace incompatible configurations
This commit is contained in:
Axel Kohlmeyer 2018-12-07 11:28:02 -05:00 committed by GitHub
commit c36f8390d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 86 additions and 75 deletions

View File

@ -86,6 +86,9 @@ package"_Build_package.html doc page for more info.
Do not set "neigh_modify once yes" or else this fix will never be
called. Reneighboring is required.
This fix is not compatible with a hybrid pair style, long-range dispersion,
TIP4P water support, or long-range point dipole support.
[Related commands:]
"kspace_style"_kspace_style.html, "boundary"_boundary.html

View File

@ -89,6 +89,14 @@ void FixTuneKspace::init()
error->all(FLERR,"Cannot use fix tune/kspace without a kspace style");
if (!force->pair)
error->all(FLERR,"Cannot use fix tune/kspace without a pair style");
if (strncmp(force->pair_style,"hybrid",6) == 0)
error->all(FLERR,"Cannot use fix tune/kspace with a hybrid pair style");
if (force->kspace->dispersionflag)
error->all(FLERR,"Cannot use fix tune/kspace with long-range dispersion");
if (force->kspace->tip4pflag)
error->all(FLERR,"Cannot use fix tune/kspace with TIP4P water");
if (force->kspace->dipoleflag)
error->all(FLERR,"Cannot use fix tune/kspace with dipole long-range solver");
double old_acc = force->kspace->accuracy/force->kspace->two_charge_force;
char old_acc_str[12];

View File

@ -52,6 +52,6 @@ void AngleDeprecated::settings(int, char **)
writemsg(lmp,"\nAngle style 'DEPRECATED' is a dummy style\n\n",0);
}
}
}

View File

@ -52,6 +52,6 @@ void BondDeprecated::settings(int, char **)
writemsg(lmp,"\nBond style 'DEPRECATED' is a dummy style\n\n",0);
}
}
}

View File

@ -45,7 +45,7 @@ enum{DEGREE, RADIAN, COSINE};
ComputeADF::ComputeADF(LAMMPS *lmp, int narg, char **arg) :
Compute(lmp, narg, arg),
ilo(NULL), ihi(NULL), jlo(NULL), jhi(NULL), klo(NULL), khi(NULL),
ilo(NULL), ihi(NULL), jlo(NULL), jhi(NULL), klo(NULL), khi(NULL),
hist(NULL), histall(NULL),
rcutinnerj(NULL), rcutinnerk(NULL),
rcutouterj(NULL), rcutouterk(NULL),
@ -53,7 +53,7 @@ ComputeADF::ComputeADF(LAMMPS *lmp, int narg, char **arg) :
iatomcount(NULL), iatomcountall(NULL), iatomflag(NULL),
maxjatom(NULL), maxkatom(NULL),
numjatom(NULL), numkatom(NULL),
neighjatom(NULL),neighkatom(NULL),
neighjatom(NULL),neighkatom(NULL),
jatomflag(NULL), katomflag(NULL),
maxjkatom(NULL), numjkatom(NULL),
neighjkatom(NULL), bothjkatom(NULL), delrjkatom(NULL)
@ -99,7 +99,7 @@ ComputeADF::ComputeADF(LAMMPS *lmp, int narg, char **arg) :
if (!nargtriple) ntriples = 1;
else {
if (nargtriple % nargsperadf)
if (nargtriple % nargsperadf)
error->all(FLERR,"Illegal compute adf command");
ntriples = nargtriple/nargsperadf;
}
@ -140,8 +140,8 @@ ComputeADF::ComputeADF(LAMMPS *lmp, int narg, char **arg) :
force->bounds(FLERR,arg[iarg],atom->ntypes,ilo[m],ihi[m]);
force->bounds(FLERR,arg[iarg+1],atom->ntypes,jlo[m],jhi[m]);
force->bounds(FLERR,arg[iarg+2],atom->ntypes,klo[m],khi[m]);
if (ilo[m] > ihi[m] ||
jlo[m] > jhi[m] ||
if (ilo[m] > ihi[m] ||
jlo[m] > jhi[m] ||
klo[m] > khi[m])
error->all(FLERR,"Illegal compute adf command");
rcutinnerj[m] = force->numeric(FLERR,arg[iarg+3]);
@ -157,7 +157,7 @@ ComputeADF::ComputeADF(LAMMPS *lmp, int narg, char **arg) :
}
// identify central atom types
int i,j,k;
for (int m = 0; m < ntriples; m++) {
@ -311,13 +311,13 @@ void ComputeADF::init()
int x0;
if (ordinate_style == DEGREE) {
deltax = MY_PI / nbin * rad2deg;
deltaxinv = nbin / MY_PI;
deltax = MY_PI / nbin * rad2deg;
deltaxinv = nbin / MY_PI;
x0 = 0.0;
} else if (ordinate_style == RADIAN) {
deltax = MY_PI / nbin;
deltaxinv = nbin / MY_PI;
deltaxinv = nbin / MY_PI;
x0 = 0.0;
} else if (ordinate_style == COSINE) {
@ -392,7 +392,7 @@ void ComputeADF::compute_array()
// tally the ADFs
// all three atoms i, j, and k must be in fix group
// tally I,J,K triple only if I is central atom
// and J,K matches unordered neighbor types (JJ,KK)
// and J,K matches unordered neighbor types (JJ,KK)
double **x = atom->x;
int *type = atom->type;
@ -422,22 +422,22 @@ void ComputeADF::compute_array()
numkatom[m] = 0;
numjkatom[m] = 0;
}
for (jj = 0; jj < jnum; jj++) {
j = jlist[jj];
factor_lj = special_lj[sbmask(j)];
factor_coul = special_coul[sbmask(j)];
j &= NEIGHMASK;
// if both weighting factors are 0, skip this pair
// could be 0 and still be in neigh list for long-range Coulombics
// want consistency with non-charged triples which wouldn't be in list
if (factor_lj == 0.0 && factor_coul == 0.0) continue;
if (!(mask[j] & groupbit)) continue;
jtype = type[j];
delx = xtmp - x[j][0];
dely = ytmp - x[j][1];
delz = ztmp - x[j][2];
@ -451,8 +451,8 @@ void ComputeADF::compute_array()
if (!iatomflag[m][itype]) continue;
int jflag = 0;
if (jatomflag[m][jtype] &&
rsq >= rcutinnerj[m]*rcutinnerj[m] &&
if (jatomflag[m][jtype] &&
rsq >= rcutinnerj[m]*rcutinnerj[m] &&
rsq <= rcutouterj[m]*rcutouterj[m]) {
jflag = 1;
jatom = numjatom[m]++;
@ -462,10 +462,10 @@ void ComputeADF::compute_array()
memory->grow(neighjatom[m],maxjatom[m],"adf:neighjatom");
}
}
int kflag = 0;
if (katomflag[m][jtype] &&
rsq >= rcutinnerk[m]*rcutinnerk[m] &&
if (katomflag[m][jtype] &&
rsq >= rcutinnerk[m]*rcutinnerk[m] &&
rsq <= rcutouterk[m]*rcutouterk[m]) {
kflag = 1;
katom = numkatom[m]++;
@ -492,7 +492,7 @@ void ComputeADF::compute_array()
memory->grow(delrjkatom[m],maxjkatom[m],4,"adf:delrjkatom");
}
// indicate if atom in both lists
// indicate if atom in both lists
if (jflag && kflag)
bothjkatom[m][jk] = 1;
@ -558,7 +558,7 @@ void ComputeADF::compute_array()
// copy into output array
for (m = 0; m < ntriples; m++) {
double count = 0;
for (ibin = 0; ibin < nbin; ibin++)
count += histall[m][ibin];

View File

@ -53,7 +53,7 @@ ComputeAngleLocal::ComputeAngleLocal(LAMMPS *lmp, int narg, char **arg) :
bstyle = new int[nvalues];
vstr = new char*[nvalues];
vvar = new int[nvalues];
nvalues = 0;
tflag = 0;
nvar = 0;
@ -78,7 +78,7 @@ ComputeAngleLocal::ComputeAngleLocal(LAMMPS *lmp, int narg, char **arg) :
setflag = 0;
tstr = NULL;
while (iarg < narg) {
if (strcmp(arg[iarg],"set") == 0) {
setflag = 1;
@ -114,7 +114,7 @@ ComputeAngleLocal::ComputeAngleLocal(LAMMPS *lmp, int narg, char **arg) :
if (!input->variable->internalstyle(tvar))
error->all(FLERR,"Variable for compute angle/local is invalid style");
}
} else if (setflag)
} else if (setflag)
error->all(FLERR,"Compute angle/local set with no variable");
// initialize output
@ -289,7 +289,7 @@ int ComputeAngleLocal::compute_angles(int flag)
if (nvalues == 1) ptr = &vlocal[m];
else ptr = alocal[m];
if (nvar) {
ivar = 0;
if (tstr) input->variable->internal_set(tvar,theta);

View File

@ -55,7 +55,7 @@ ComputeBondLocal::ComputeBondLocal(LAMMPS *lmp, int narg, char **arg) :
bstyle = new int[nvalues];
vstr = new char*[nvalues];
vvar = new int[nvalues];
nvalues = 0;
nvar = 0;
@ -82,7 +82,7 @@ ComputeBondLocal::ComputeBondLocal(LAMMPS *lmp, int narg, char **arg) :
setflag = 0;
dstr = NULL;
while (iarg < narg) {
if (strcmp(arg[iarg],"set") == 0) {
setflag = 1;
@ -117,10 +117,10 @@ ComputeBondLocal::ComputeBondLocal(LAMMPS *lmp, int narg, char **arg) :
if (!input->variable->internalstyle(dvar))
error->all(FLERR,"Variable for compute bond/local is invalid style");
}
} else if (setflag)
} else if (setflag)
error->all(FLERR,"Compute bond/local set with no variable");
// set singleflag if need to call bond->single()
// set velflag if compute any quantities based on velocities

View File

@ -117,7 +117,7 @@ ComputeChunkSpreadAtom(LAMMPS *lmp, int narg, char **arg) :
"does not exist");
char *ptr = strstr(modify->compute[icompute]->style,"/chunk");
if (!ptr || (ptr != modify->compute[icompute]->style +
if (!ptr || (ptr != modify->compute[icompute]->style +
strlen(modify->compute[icompute]->style) - strlen("/chunk")))
error->all(FLERR,"Compute for compute chunk/spread/atom "
"does not calculate per-chunk values");

View File

@ -56,7 +56,7 @@ ComputeDihedralLocal::ComputeDihedralLocal(LAMMPS *lmp, int narg, char **arg) :
bstyle = new int[nvalues];
vstr = new char*[nvalues];
vvar = new int[nvalues];
nvalues = 0;
nvar = 0;
@ -77,11 +77,11 @@ ComputeDihedralLocal::ComputeDihedralLocal(LAMMPS *lmp, int narg, char **arg) :
setflag = 0;
pstr = NULL;
while (iarg < narg) {
if (strcmp(arg[iarg],"set") == 0) {
setflag = 1;
if (iarg+3 > narg)
if (iarg+3 > narg)
error->all(FLERR,"Illegal compute dihedral/local command");
if (strcmp(arg[iarg+1],"phi") == 0) {
delete [] pstr;
@ -115,7 +115,7 @@ ComputeDihedralLocal::ComputeDihedralLocal(LAMMPS *lmp, int narg, char **arg) :
if (!input->variable->internalstyle(pvar))
error->all(FLERR,"Variable for compute dihedral/local is invalid style");
}
} else if (setflag)
} else if (setflag)
error->all(FLERR,"Compute dihedral/local set with no variable");
// initialize output
@ -295,17 +295,17 @@ int ComputeDihedralLocal::compute_dihedrals(int flag)
if (rasq > 0) ra2inv = 1.0/rasq;
if (rbsq > 0) rb2inv = 1.0/rbsq;
rabinv = sqrt(ra2inv*rb2inv);
c = (ax*bx + ay*by + az*bz)*rabinv;
s = rg*rabinv*(ax*vb3x + ay*vb3y + az*vb3z);
if (c > 1.0) c = 1.0;
if (c < -1.0) c = -1.0;
phi = atan2(s,c);
if (nvalues == 1) ptr = &vlocal[m];
else ptr = alocal[m];
if (nvar) {
ivar = 0;
if (pstr) input->variable->internal_set(pvar,phi);

View File

@ -48,7 +48,7 @@ ComputeDisplaceAtom::ComputeDisplaceAtom(LAMMPS *lmp, int narg, char **arg) :
int iarg = 3;
while (iarg < narg) {
if (strcmp(arg[iarg],"refresh") == 0) {
if (iarg+2 > narg)
if (iarg+2 > narg)
error->all(FLERR,"Illegal compute displace/atom command");
refreshflag = 1;
delete [] rvar;
@ -63,7 +63,7 @@ ComputeDisplaceAtom::ComputeDisplaceAtom(LAMMPS *lmp, int narg, char **arg) :
if (refreshflag) {
ivar = input->variable->find(rvar);
if (ivar < 0)
if (ivar < 0)
error->all(FLERR,"Variable name for compute displace/atom does not exist");
if (input->variable->atomstyle(ivar) == 0)
error->all(FLERR,"Compute displace/atom variable "

View File

@ -77,7 +77,7 @@ ComputeRDF::ComputeRDF(LAMMPS *lmp, int narg, char **arg) :
// pairwise args
if (nargpair == 0) npairs = 1;
else {
else {
if (nargpair % 2) error->all(FLERR,"Illegal compute rdf command");
npairs = nargpair/2;
}

View File

@ -51,7 +51,7 @@ ComputeReduceChunk::ComputeReduceChunk(LAMMPS *lmp, int narg, char **arg) :
init_chunk();
// mode
if (strcmp(arg[4],"sum") == 0) mode = SUM;
else if (strcmp(arg[4],"min") == 0) mode = MINN;
else if (strcmp(arg[4],"max") == 0) mode = MAXX;
@ -118,7 +118,7 @@ ComputeReduceChunk::ComputeReduceChunk(LAMMPS *lmp, int narg, char **arg) :
}
// error check
for (int i = 0; i < nvalues; i++) {
if (which[i] == COMPUTE) {
int icompute = modify->find_compute(ids[i]);
@ -134,11 +134,11 @@ ComputeReduceChunk::ComputeReduceChunk(LAMMPS *lmp, int narg, char **arg) :
if (argindex[i] && modify->compute[icompute]->size_peratom_cols == 0)
error->all(FLERR,"Compute reduce/chunk compute does not "
"calculate a per-atom array");
if (argindex[i] &&
if (argindex[i] &&
argindex[i] > modify->compute[icompute]->size_peratom_cols)
error->all(FLERR,
"Compute reduce/chunk compute array is accessed out-of-range");
} else if (which[i] == FIX) {
int ifix = modify->find_fix(ids[i]);
if (ifix < 0)
@ -156,7 +156,7 @@ ComputeReduceChunk::ComputeReduceChunk(LAMMPS *lmp, int narg, char **arg) :
if (argindex[i] && argindex[i] > modify->fix[ifix]->size_peratom_cols)
error->all(FLERR,"Compute reduce/chunk fix array is "
"accessed out-of-range");
} else if (which[i] == VARIABLE) {
int ivariable = input->variable->find(ids[i]);
if (ivariable < 0)
@ -181,7 +181,7 @@ ComputeReduceChunk::ComputeReduceChunk(LAMMPS *lmp, int narg, char **arg) :
}
// setup
if (mode == SUM) initvalue = 0.0;
else if (mode == MINN) initvalue = BIG;
else if (mode == MAXX) initvalue = -BIG;
@ -199,7 +199,7 @@ ComputeReduceChunk::ComputeReduceChunk(LAMMPS *lmp, int narg, char **arg) :
ComputeReduceChunk::~ComputeReduceChunk()
{
delete [] idchunk;
delete [] which;
delete [] argindex;
for (int m = 0; m < nvalues; m++) delete [] ids[m];
@ -210,7 +210,7 @@ ComputeReduceChunk::~ComputeReduceChunk()
memory->destroy(vglobal);
memory->destroy(alocal);
memory->destroy(aglobal);
memory->destroy(varatom);
}
@ -284,11 +284,11 @@ void ComputeReduceChunk::compute_vector()
}
// perform local reduction of single peratom value
compute_one(0,vlocal,1);
// reduce the per-chunk values across all procs
if (mode == SUM)
MPI_Allreduce(vlocal,vglobal,nchunk,MPI_DOUBLE,MPI_SUM,world);
else if (mode == MINN)
@ -296,7 +296,7 @@ void ComputeReduceChunk::compute_vector()
else if (mode == MAXX)
MPI_Allreduce(vlocal,vglobal,nchunk,MPI_DOUBLE,MPI_MAX,world);
}
/* ---------------------------------------------------------------------- */
void ComputeReduceChunk::compute_array()
@ -324,11 +324,11 @@ void ComputeReduceChunk::compute_array()
}
// perform local reduction of all peratom values
for (int m = 0; m < nvalues; m++) compute_one(m,&alocal[0][m],nvalues);
// reduce the per-chunk values across all procs
if (mode == SUM)
MPI_Allreduce(&alocal[0][0],&aglobal[0][0],nchunk*nvalues,
MPI_DOUBLE,MPI_SUM,world);
@ -339,13 +339,13 @@ void ComputeReduceChunk::compute_array()
MPI_Allreduce(&alocal[0][0],&aglobal[0][0],nchunk*nvalues,
MPI_DOUBLE,MPI_MAX,world);
}
/* ---------------------------------------------------------------------- */
void ComputeReduceChunk::compute_one(int m, double *vchunk, int nstride)
{
// initialize per-chunk values in accumulation vector
for (int i = 0; i < nchunk; i += nstride) vchunk[i] = initvalue;
// loop over my atoms
@ -382,7 +382,7 @@ void ComputeReduceChunk::compute_one(int m, double *vchunk, int nstride)
combine(vchunk[index*nstride],acompute[i][argindexm1]);
}
}
// access fix fields, check if fix frequency is a match
} else if (which[m] == FIX) {

View File

@ -576,11 +576,11 @@ void CreateAtoms::add_single()
if (triclinic) {
domain->x2lamda(xone,lamda);
if (remapflag) {
if (domain->xperiodic && (lamda[0] < 0.0 || lamda[0] >= 1.0))
if (domain->xperiodic && (lamda[0] < 0.0 || lamda[0] >= 1.0))
lamda[0] = 0.0;
if (domain->yperiodic && (lamda[1] < 0.0 || lamda[1] >= 1.0))
if (domain->yperiodic && (lamda[1] < 0.0 || lamda[1] >= 1.0))
lamda[1] = 0.0;
if (domain->zperiodic && (lamda[2] < 0.0 || lamda[2] >= 1.0))
if (domain->zperiodic && (lamda[2] < 0.0 || lamda[2] >= 1.0))
lamda[2] = 0.0;
}
coord = lamda;

View File

@ -68,7 +68,7 @@ void DeleteAtoms::command(int narg, char **arg)
if (allflag) {
int igroup = group->find("all");
if ((igroup >= 0) &&
if ((igroup >= 0) &&
modify->check_rigid_group_overlap(group->bitmask[igroup]))
error->warning(FLERR,"Attempting to delete atoms in rigid bodies");
} else {

View File

@ -52,6 +52,6 @@ void DihedralDeprecated::settings(int, char **)
writemsg(lmp,"\nDihedral style 'DEPRECATED' is a dummy style\n\n",0);
}
}
}

View File

@ -205,7 +205,7 @@ void FixGroup::set_group()
// invoke atom-style variable if defined
// set post_integrate flag to 1, then unset after
// this is for any compute to check if it needs to
// this is for any compute to check if it needs to
// operate differently due to invocation this early in timestep
// e.g. perform ghost comm update due to atoms having just moved

View File

@ -191,7 +191,7 @@ void FixRestrain::min_setup(int vflag)
void FixRestrain::post_force(int /*vflag*/)
{
energy = 0.0;
ebond = 0.0;
eangle = 0.0;
edihed = 0.0;
@ -658,7 +658,7 @@ double FixRestrain::compute_vector(int n)
} else if (n == 1) {
MPI_Allreduce(&eangle,&eangle_all,1,MPI_DOUBLE,MPI_SUM,world);
return eangle_all;
} else if (n == 2) {
} else if (n == 2) {
MPI_Allreduce(&edihed,&edihed_all,1,MPI_DOUBLE,MPI_SUM,world);
return edihed_all;
} else {

View File

@ -52,6 +52,6 @@ void ImproperDeprecated::settings(int, char **)
writemsg(lmp,"\nImproper style 'DEPRECATED' is a dummy style\n\n",0);
}
}
}

View File

@ -957,7 +957,7 @@ void lammps_gather_atoms_concat(void *ptr, char *name,
}
// perform MPI_Allgatherv on each proc's chunk of Nlocal atoms
int nprocs = lmp->comm->nprocs;
int *recvcounts,*displs;
@ -1078,7 +1078,7 @@ void lammps_gather_atoms_subset(void *ptr, char *name,
LAMMPS *lmp = (LAMMPS *) ptr;
BEGIN_CAPTURE
{
{
int i,j,m,offset;
tagint id;
@ -1319,9 +1319,9 @@ void lammps_scatter_atoms(void *ptr, char *name,
------------------------------------------------------------------------- */
void lammps_scatter_atoms_subset(void *ptr, char *name,
int type, int count,
int type, int count,
int ndata, int *ids, void *data)
{
{
LAMMPS *lmp = (LAMMPS *) ptr;
BEGIN_CAPTURE

View File

@ -52,6 +52,6 @@ void PairDeprecated::settings(int, char **)
writemsg(lmp,"\nPair style 'DEPRECATED' is a dummy style\n\n",0);
}
}
}

View File

@ -255,7 +255,7 @@ void WriteData::header()
}
}
if (fixflag)
if (fixflag)
for (int i = 0; i < modify->nfix; i++)
if (modify->fix[i]->wd_header)
for (int m = 0; m < modify->fix[i]->wd_header; m++)