fix handline of setflag and coeffs to correctly work with system, that have extra atom types.

This commit is contained in:
Axel Kohlmeyer 2019-05-10 10:26:33 -04:00
parent 928600a878
commit 238382e0ca
No known key found for this signature in database
GPG Key ID: D9B44E93BF0C375A
2 changed files with 40 additions and 24 deletions

View File

@ -805,9 +805,10 @@ void PairKolmogorovCrespiFull::coeff(int narg, char **arg)
error->all(FLERR,"Incorrect args for pair coefficients");
if (!allocated) allocate();
int ilo,ihi,jlo,jhi;
force->bounds(FLERR,arg[0],atom->ntypes,ilo,ihi);
force->bounds(FLERR,arg[1],atom->ntypes,jlo,jhi);
// insure I,J args are * *
if (strcmp(arg[0],"*") != 0 || strcmp(arg[1],"*") != 0)
error->all(FLERR,"Incorrect args for pair coefficients");
// read args that map atom types to elements in potential file
// map[i] = which element the Ith atom type is, -1 if NULL
@ -841,16 +842,23 @@ void PairKolmogorovCrespiFull::coeff(int narg, char **arg)
read_file(arg[2]);
double cut_one = cut_global;
// clear setflag since coeff() called once with I,J = * *
n = atom->ntypes;
for (int i = 1; i <= n; i++)
for (int j = i; j <= n; j++)
setflag[i][j] = 0;
// set setflag i,j for type pairs where both are mapped to elements
int count = 0;
for (int i = ilo; i <= ihi; i++) {
for (int j = MAX(jlo,i); j <= jhi; j++) {
cut[i][j] = cut_one;
for (int i = 1; i <= n; i++)
for (int j = i; j <= n; j++)
if (map[i] >= 0 && map[j] >= 0) {
setflag[i][j] = 1;
cut[i][j] = cut_global;
count++;
}
}
if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients");
}

View File

@ -226,9 +226,10 @@ void PairKolmogorovCrespiZ::coeff(int narg, char **arg)
error->all(FLERR,"Incorrect args for pair coefficients");
if (!allocated) allocate();
int ilo,ihi,jlo,jhi;
force->bounds(FLERR,arg[0],atom->ntypes,ilo,ihi);
force->bounds(FLERR,arg[1],atom->ntypes,jlo,jhi);
// insure I,J args are * *
if (strcmp(arg[0],"*") != 0 || strcmp(arg[1],"*") != 0)
error->all(FLERR,"Incorrect args for pair coefficients");
// read args that map atom types to elements in potential file
// map[i] = which element the Ith atom type is, -1 if NULL
@ -262,16 +263,23 @@ void PairKolmogorovCrespiZ::coeff(int narg, char **arg)
read_file(arg[2]);
double cut_one = cut_global;
// clear setflag since coeff() called once with I,J = * *
n = atom->ntypes;
for (int i = 1; i <= n; i++)
for (int j = i; j <= n; j++)
setflag[i][j] = 0;
// set setflag i,j for type pairs where both are mapped to elements
int count = 0;
for (int i = ilo; i <= ihi; i++) {
for (int j = MAX(jlo,i); j <= jhi; j++) {
cut[i][j] = cut_one;
for (int i = 1; i <= n; i++)
for (int j = i; j <= n; j++)
if (map[i] >= 0 && map[j] >= 0) {
setflag[i][j] = 1;
cut[i][j] = cut_global;
count++;
}
}
if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients");
}