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

@ -256,7 +256,7 @@ void PairKolmogorovCrespiFull::compute(int eflag, int vflag)
// calculate the forces acted on the neighbors of atom i from atom j // calculate the forces acted on the neighbors of atom i from atom j
KC_neighs_i = KC_firstneigh[i]; KC_neighs_i = KC_firstneigh[i];
for (kk = 0; kk < KC_numneigh[i]; kk++) { for (kk = 0; kk < KC_numneigh[i]; kk++) {
k = KC_neighs_i[kk]; k = KC_neighs_i[kk];
if (k == i) continue; if (k == i) continue;
// derivatives of the product of rij and ni respect to rk, k=0,1,2, where atom k is the neighbors of atom i // derivatives of the product of rij and ni respect to rk, k=0,1,2, where atom k is the neighbors of atom i
@ -277,7 +277,7 @@ void PairKolmogorovCrespiFull::compute(int eflag, int vflag)
// calculate the forces acted on the neighbors of atom j from atom i // calculate the forces acted on the neighbors of atom j from atom i
KC_neighs_j = KC_firstneigh[j]; KC_neighs_j = KC_firstneigh[j];
for (ll = 0; ll < KC_numneigh[j]; ll++) { for (ll = 0; ll < KC_numneigh[j]; ll++) {
l = KC_neighs_j[ll]; l = KC_neighs_j[ll];
if (l == j) continue; if (l == j) continue;
// derivatives of the product of rji and nj respect to rl, l=0,1,2, where atom l is the neighbors of atom j // derivatives of the product of rji and nj respect to rl, l=0,1,2, where atom l is the neighbors of atom j
@ -805,9 +805,10 @@ void PairKolmogorovCrespiFull::coeff(int narg, char **arg)
error->all(FLERR,"Incorrect args for pair coefficients"); error->all(FLERR,"Incorrect args for pair coefficients");
if (!allocated) allocate(); if (!allocated) allocate();
int ilo,ihi,jlo,jhi; // insure I,J args are * *
force->bounds(FLERR,arg[0],atom->ntypes,ilo,ihi);
force->bounds(FLERR,arg[1],atom->ntypes,jlo,jhi); 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 // read args that map atom types to elements in potential file
// map[i] = which element the Ith atom type is, -1 if NULL // 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]); 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; int count = 0;
for (int i = ilo; i <= ihi; i++) { for (int i = 1; i <= n; i++)
for (int j = MAX(jlo,i); j <= jhi; j++) { for (int j = i; j <= n; j++)
cut[i][j] = cut_one; if (map[i] >= 0 && map[j] >= 0) {
setflag[i][j] = 1; setflag[i][j] = 1;
count++; cut[i][j] = cut_global;
} count++;
} }
if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients"); 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"); error->all(FLERR,"Incorrect args for pair coefficients");
if (!allocated) allocate(); if (!allocated) allocate();
int ilo,ihi,jlo,jhi; // insure I,J args are * *
force->bounds(FLERR,arg[0],atom->ntypes,ilo,ihi);
force->bounds(FLERR,arg[1],atom->ntypes,jlo,jhi); 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 // read args that map atom types to elements in potential file
// map[i] = which element the Ith atom type is, -1 if NULL // 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]); 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; int count = 0;
for (int i = ilo; i <= ihi; i++) { for (int i = 1; i <= n; i++)
for (int j = MAX(jlo,i); j <= jhi; j++) { for (int j = i; j <= n; j++)
cut[i][j] = cut_one; if (map[i] >= 0 && map[j] >= 0) {
setflag[i][j] = 1; setflag[i][j] = 1;
count++; cut[i][j] = cut_global;
} count++;
} }
if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients"); if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients");
} }