Add ddx, dy and dz computes to compute bond/local and property/local

This commit is contained in:
Tim Bernhard
2021-11-18 17:22:32 +01:00
parent 515ef7bece
commit 36e4e3e746
4 changed files with 41 additions and 9 deletions

View File

@ -34,7 +34,7 @@ using namespace LAMMPS_NS;
#define DELTA 10000
#define EPSILON 1.0e-12
enum{DIST,VELVIB,OMEGA,ENGTRANS,ENGVIB,ENGROT,ENGPOT,FORCE,FX,FY,FZ,VARIABLE};
enum{DIST,DX,DY,DZ,VELVIB,OMEGA,ENGTRANS,ENGVIB,ENGROT,ENGPOT,FORCE,FX,FY,FZ,VARIABLE};
/* ---------------------------------------------------------------------- */
@ -63,6 +63,9 @@ ComputeBondLocal::ComputeBondLocal(LAMMPS *lmp, int narg, char **arg) :
int iarg;
for (iarg = 3; iarg < narg; iarg++) {
if (strcmp(arg[iarg],"dist") == 0) bstyle[nvalues++] = DIST;
else if (strcmp(arg[iarg],"dx") == 0) bstyle[nvalues++] = DX;
else if (strcmp(arg[iarg],"dy") == 0) bstyle[nvalues++] = DY;
else if (strcmp(arg[iarg],"dz") == 0) bstyle[nvalues++] = DZ;
else if (strcmp(arg[iarg],"engpot") == 0) bstyle[nvalues++] = ENGPOT;
else if (strcmp(arg[iarg],"force") == 0) bstyle[nvalues++] = FORCE;
else if (strcmp(arg[iarg],"fx") == 0) bstyle[nvalues++] = FX;
@ -384,11 +387,23 @@ int ComputeBondLocal::compute_bonds(int flag)
if (dstr) input->variable->internal_set(dvar,sqrt(rsq));
}
// to make sure dx, dy and dz are always from the lower to the higher id
double directionCorrection = atom1 > atom2 ? -1.0 : 1.0;
for (int n = 0; n < nvalues; n++) {
switch (bstyle[n]) {
case DIST:
ptr[n] = sqrt(rsq);
break;
case DX:
ptr[n] = dx*directionCorrection;
break;
case DY:
ptr[n] = dy*directionCorrection;
break;
case DZ:
ptr[n] = dz*directionCorrection;
break;
case ENGPOT:
ptr[n] = engpot;
break;

View File

@ -31,7 +31,7 @@ using namespace LAMMPS_NS;
#define DELTA 10000
enum{DIST,ENG,FORCE,FX,FY,FZ,PN};
enum{DIST,ENG,FORCE,FX,FY,FZ,PN,DX,DY,DZ};
enum{TYPE,RADIUS};
/* ---------------------------------------------------------------------- */
@ -56,6 +56,9 @@ ComputePairLocal::ComputePairLocal(LAMMPS *lmp, int narg, char **arg) :
else if (strcmp(arg[iarg],"fx") == 0) pstyle[nvalues++] = FX;
else if (strcmp(arg[iarg],"fy") == 0) pstyle[nvalues++] = FY;
else if (strcmp(arg[iarg],"fz") == 0) pstyle[nvalues++] = FZ;
else if (strcmp(arg[iarg],"dx") == 0) pstyle[nvalues++] = DX;
else if (strcmp(arg[iarg],"dy") == 0) pstyle[nvalues++] = DY;
else if (strcmp(arg[iarg],"dz") == 0) pstyle[nvalues++] = DZ;
else if (arg[iarg][0] == 'p') {
int n = atoi(&arg[iarg][1]);
if (n <= 0) error->all(FLERR,
@ -92,7 +95,7 @@ ComputePairLocal::ComputePairLocal(LAMMPS *lmp, int narg, char **arg) :
singleflag = 0;
for (int i = 0; i < nvalues; i++)
if (pstyle[i] != DIST) singleflag = 1;
if (pstyle[i] != DIST && pstyle[i] != DX && pstyle[i] != DY && pstyle[i] != DZ) singleflag = 1;
if (nvalues == 1) size_local_cols = 0;
else size_local_cols = nvalues;
@ -269,6 +272,12 @@ int ComputePairLocal::compute_pairs(int flag)
case DIST:
ptr[n] = sqrt(rsq);
break;
case DX:
ptr[n] = delx;
case DY:
ptr[n] = dely;
case DZ:
ptr[n] = delz;
case ENG:
ptr[n] = eng;
break;