fix for parallel angle and dihedral stress calculation

This commit is contained in:
Evangelos Voyiatzis
2025-07-01 14:13:30 +02:00
committed by GitHub
parent e74aeafbfb
commit f7b911181e
3 changed files with 66 additions and 57 deletions

View File

@ -129,9 +129,6 @@ package <Build_package>` doc page on for more info.
The method is implemented for orthogonal simulation boxes whose
size does not change in time, and axis-aligned planes.
Contributions from bonds, angles, and dihedrals are not compatible
with MPI parallel runs.
The method only works with two-body pair interactions, because it
requires the class method ``Pair::single()`` to be implemented, which is
not possible for manybody potentials. In particular, compute

View File

@ -105,6 +105,8 @@ ComputeStressMop::ComputeStressMop(LAMMPS *lmp, int narg, char **arg) : Compute(
while (iarg < narg) {
if (strcmp(arg[iarg], "conf") == 0) {
bondflag = 1;
angleflag = 1;
dihedralflag = 1;
for (i = 0; i < 3; i++) {
which[nvalues] = CONF;
nvalues++;
@ -116,6 +118,8 @@ ComputeStressMop::ComputeStressMop(LAMMPS *lmp, int narg, char **arg) : Compute(
}
} else if (strcmp(arg[iarg], "total") == 0) {
bondflag = 1;
angleflag = 1;
dihedralflag = 1;
for (i = 0; i < 3; i++) {
which[nvalues] = TOTAL;
nvalues++;
@ -132,11 +136,13 @@ ComputeStressMop::ComputeStressMop(LAMMPS *lmp, int narg, char **arg) : Compute(
nvalues++;
}
} else if (strcmp(arg[iarg], "angle") == 0) {
angleflag = 1;
for (i = 0; i < 3; i++) {
which[nvalues] = ANGLE;
nvalues++;
}
} else if (strcmp(arg[iarg], "dihedral") == 0) {
dihedralflag = 1;
for (i = 0; i < 3; i++) {
which[nvalues] = DIHEDRAL;
nvalues++;
@ -240,46 +246,47 @@ void ComputeStressMop::init()
if (force->pair->single_enable == 0)
error->all(FLERR, "Pair style does not support compute stress/mop");
// issue an error for unimplemented bond potentials
// issue an error for unimplemented bond/angle/dihedral potentials
if (bondflag == 1 && !(force->bond)) {
error->all(FLERR, "No bond style is defined for compute stress/mop");
}
if (angleflag == 1 && !(force->angle)) {
error->all(FLERR, "No angle style is defined for compute stress/mop");
}
if (dihedralflag == 1 && !(force->dihedral)) {
error->all(FLERR, "No dihedral style is defined for compute stress/mop");
}
if (angleflag == 1 && force->angle) {
if (force->angle->born_matrix_enable == 0) {
if ((strcmp(force->angle_style, "zero") != 0) && (strcmp(force->angle_style, "none") != 0))
error->all(FLERR, "compute stress/mop does not account for the selected angle potential");
}
}
if (dihedralflag == 1 && force->dihedral) {
if (force->dihedral->born_matrix_enable == 0) {
if ((strcmp(force->dihedral_style, "zero") != 0) &&
(strcmp(force->dihedral_style, "none") != 0))
error->one(FLERR, "compute stress/mop does not account for the selected dihedral potentials");
}
}
// Errors
if (comm->me == 0) {
// issue an error for unimplemented intramolecular potentials or Kspace.
// issue a warning for unimplemented improper potentials and Kspace.
if (force->angle) {
if (force->angle->born_matrix_enable == 0) {
if ((strcmp(force->angle_style, "zero") != 0) && (strcmp(force->angle_style, "none") != 0))
error->one(FLERR, "compute stress/mop does not account for angle potentials");
} else {
angleflag = 1;
if (comm->nprocs > 1)
error->one(FLERR,
"compute stress/mop with angles does not (yet) support MPI parallel runs");
}
}
if (force->dihedral) {
if (force->dihedral->born_matrix_enable == 0) {
if ((strcmp(force->dihedral_style, "zero") != 0) &&
(strcmp(force->dihedral_style, "none") != 0))
error->one(FLERR, "compute stress/mop does not account for dihedral potentials");
} else {
dihedralflag = 1;
if (comm->nprocs > 1)
error->one(FLERR,
"compute stress/mop with dihedrals does not (yet) support MPI parallel runs");
}
}
if (force->improper) {
if ((strcmp(force->improper_style, "zero") != 0) &&
(strcmp(force->improper_style, "none") != 0))
error->one(FLERR, "compute stress/mop does not account for improper potentials");
error->warning(FLERR, "compute stress/mop does not account for improper potentials");
}
if (force->kspace)
error->warning(FLERR, "compute stress/mop does not account for kspace contributions");
}

View File

@ -90,6 +90,8 @@ ComputeStressMopProfile::ComputeStressMopProfile(LAMMPS *lmp, int narg, char **a
while (iarg < narg) {
if (strcmp(arg[iarg], "conf") == 0) {
bondflag = 1;
angleflag = 1;
dihedralflag = 1;
for (i = 0; i < 3; i++) {
which[nvalues] = CONF;
nvalues++;
@ -101,6 +103,8 @@ ComputeStressMopProfile::ComputeStressMopProfile(LAMMPS *lmp, int narg, char **a
}
} else if (strcmp(arg[iarg], "total") == 0) {
bondflag = 1;
angleflag = 1;
dihedralflag = 1;
for (i = 0; i < 3; i++) {
which[nvalues] = TOTAL;
nvalues++;
@ -117,11 +121,13 @@ ComputeStressMopProfile::ComputeStressMopProfile(LAMMPS *lmp, int narg, char **a
nvalues++;
}
} else if (strcmp(arg[iarg], "angle") == 0) {
angleflag = 1;
for (i = 0; i < 3; i++) {
which[nvalues] = ANGLE;
nvalues++;
}
} else if (strcmp(arg[iarg], "dihedral") == 0) {
dihedralflag = 1;
for (i = 0; i < 3; i++) {
which[nvalues] = DIHEDRAL;
nvalues++;
@ -230,47 +236,46 @@ void ComputeStressMopProfile::init()
error->all(FLERR, "Pair style {} does not support compute stress/mop/profile",
force->pair_style);
// issue an error for unimplemented bond potentials
// issue an error for unimplemented bond/angle/dihedral potentials
if (bondflag == 1 && !(force->bond)) {
error->all(FLERR, "No bond style is defined for compute stress/mop/profile");
}
if (angleflag == 1 && !(force->angle)) {
error->all(FLERR, "No angle style is defined for compute stress/mop/profile");
}
if (dihedralflag == 1 && !(force->dihedral)) {
error->all(FLERR, "No dihedral style is defined for compute stress/mop/profile");
}
if (angleflag == 1 && force->angle) {
if (force->angle->born_matrix_enable == 0) {
if ((strcmp(force->angle_style, "zero") != 0) && (strcmp(force->angle_style, "none") != 0))
error->all(FLERR, "compute stress/mop/profile does not account for the selected angle potential");
}
}
if (dihedralflag == 1 && force->dihedral) {
if (force->dihedral->born_matrix_enable == 0) {
if ((strcmp(force->dihedral_style, "zero") != 0) &&
(strcmp(force->dihedral_style, "none") != 0))
error->one(FLERR, "compute stress/mop/profile does not account for the selected dihedral potentials");
}
}
// Errors
if (comm->me == 0) {
// issue an error for unimplemented intramolecular potentials or Kspace.
// issue an error for unimplemented improper potentials and Kspace.
if (force->angle) {
if (force->angle->born_matrix_enable == 0) {
if ((strcmp(force->angle_style, "zero") != 0) && (strcmp(force->angle_style, "none") != 0))
error->one(FLERR, "compute stress/mop/profile does not account for angle potentials");
} else {
angleflag = 1;
if (comm->nprocs > 1)
error->one(
FLERR,
"compute stress/mop/profile with angles does not (yet) support MPI parallel runs");
}
}
if (force->dihedral) {
if (force->dihedral->born_matrix_enable == 0) {
if ((strcmp(force->dihedral_style, "zero") != 0) &&
(strcmp(force->dihedral_style, "none") != 0))
error->one(FLERR, "compute stress/mop/profile does not account for dihedral potentials");
} else {
dihedralflag = 1;
if (comm->nprocs > 1)
error->one(
FLERR,
"compute stress/mop/profile with dihedrals does not (yet) support MPI parallel runs");
}
}
if (force->improper) {
if ((strcmp(force->improper_style, "zero") != 0) &&
(strcmp(force->improper_style, "none") != 0))
error->one(FLERR, "compute stress/mop/profile does not account for improper potentials");
error->warning(FLERR, "compute stress/mop/profile does not account for improper potentials");
}
if (force->kspace)
error->warning(FLERR, "compute stress/mop/profile does not account for kspace contributions");