Skip to content

Commit

Permalink
Merge pull request lammps#4159 from evoyiatzis/patch-1
Browse files Browse the repository at this point in the history
Make compute stress/mop and stress/mop/profile compatible with 2D systems
  • Loading branch information
stanmoore1 authored May 14, 2024
2 parents ada53dc + 83a4ff0 commit 008a8fc
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 19 deletions.
2 changes: 1 addition & 1 deletion doc/src/compute_stress_mop.rst
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ These styles are part of the EXTRA-COMPUTE package. They are only
enabled if LAMMPS is built with that package. See the :doc:`Build
package <Build_package>` doc page on for more info.

The method is only implemented for 3d orthogonal simulation boxes whose
The method is implemented for orthogonal simulation boxes whose
size does not change in time, and axis-aligned planes.

The method only works with two-body pair interactions, because it
Expand Down
25 changes: 15 additions & 10 deletions src/EXTRA-COMPUTE/compute_stress_mop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ ComputeStressMop::ComputeStressMop(LAMMPS *lmp, int narg, char **arg) : Compute(
error->all(FLERR, "Plane for compute stress/mop is out of bounds");
}

if (pos < (domain->boxlo[dir] + domain->prd_half[dir])) {
if (pos < (domain->boxlo[dir] + domain->prd_half[dir])) {
pos1 = pos + domain->prd[dir];
} else {
pos1 = pos - domain->prd[dir];
Expand Down Expand Up @@ -146,14 +146,14 @@ ComputeStressMop::ComputeStressMop(LAMMPS *lmp, int narg, char **arg) : Compute(

// Error checks:

// 3D only

if (domain->dimension != 3) error->all(FLERR, "Compute stress/mop requires a 3d system");

// orthogonal simulation box
if (domain->triclinic != 0)
error->all(FLERR, "Compute stress/mop is incompatible with triclinic simulation box");

// 2D and pressure calculation in the Z coordinate
if (domain->dimension == 2 && dir == Z)
error->all(FLERR, "Compute stress/mop is incompatible with Z in 2d system");

// Initialize some variables

values_local = values_global = vector = nullptr;
Expand Down Expand Up @@ -210,10 +210,14 @@ void ComputeStressMop::init()

// Plane area

area = 1;
int i;
for (i = 0; i < 3; i++) {
if (i != dir) area = area * domain->prd[i];
if (domain->dimension == 3) {
area = 1;
int i;
for (i = 0; i < 3; i++) {
if (i != dir) area = area * domain->prd[i];
}
} else {
area = (dir == X) ? domain->prd[1] : domain->prd[0];
}

// Timestep Value
Expand Down Expand Up @@ -404,6 +408,7 @@ void ComputeStressMop::compute_pairs()
xj[0] = atom->x[j][0];
xj[1] = atom->x[j][1];
xj[2] = atom->x[j][2];

delx = xi[0] - xj[0];
dely = xi[1] - xj[1];
delz = xi[2] - xj[2];
Expand All @@ -420,7 +425,7 @@ void ComputeStressMop::compute_pairs()
values_local[m + 1] += fpair * (xi[1] - xj[1]) / area * nktv2p;
values_local[m + 2] += fpair * (xi[2] - xj[2]) / area * nktv2p;
} else if (((xi[dir] < pos) && (xj[dir] > pos)) ||
((xi[dir] < pos1) && (xj[dir] > pos1))) {
((xi[dir] < pos1) && (xj[dir] > pos1))) {
pair->single(i, j, itype, jtype, rsq, factor_coul, factor_lj, fpair);
values_local[m] -= fpair * (xi[0] - xj[0]) / area * nktv2p;
values_local[m + 1] -= fpair * (xi[1] - xj[1]) / area * nktv2p;
Expand Down
17 changes: 10 additions & 7 deletions src/EXTRA-COMPUTE/compute_stress_mop_profile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ ComputeStressMopProfile::ComputeStressMopProfile(LAMMPS *lmp, int narg, char **a

// 3D only

if (domain->dimension < 3)
error->all(FLERR, "Compute stress/mop/profile incompatible with simulation dimension");
if (domain->dimension == 2 && dir == Z)
error->all(FLERR, "Compute stress/mop/profile incompatible with Z in 2d system");

// orthogonal simulation box

Expand Down Expand Up @@ -198,11 +198,14 @@ void ComputeStressMopProfile::init()
ftm2v = force->ftm2v;

// plane area

area = 1;
int i;
for (i = 0; i < 3; i++) {
if (i != dir) area = area * domain->prd[i];
if (domain->dimension == 3) {
area = 1;
int i;
for (i = 0; i < 3; i++) {
if (i != dir) area = area * domain->prd[i];
}
} else {
area = (dir == X) ? domain->prd[1] : domain->prd[0];
}

// timestep Value
Expand Down
3 changes: 2 additions & 1 deletion src/REAXFF/fix_reaxff_species.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,13 +346,14 @@ int FixReaxFFSpecies::setmask()
void FixReaxFFSpecies::setup(int /*vflag*/)
{
ntotal = static_cast<int>(atom->natoms);
if (Name == nullptr) memory->create(Name, nutypes, "reaxff/species:Name");

if (!eleflag) {
for (int i = 0; i < ntypes; i++)
eletype[i] = reaxff->eletype[i+1];
GetUniqueElements();
}
memory->destroy(Name);
memory->create(Name, nutypes, "reaxff/species:Name");

post_integrate();
}
Expand Down

0 comments on commit 008a8fc

Please sign in to comment.