From 4a05628938da2092de98ffa4d603863230b816a5 Mon Sep 17 00:00:00 2001 From: Steve Plimpton Date: Tue, 30 Nov 2021 08:22:38 -0700 Subject: [PATCH] bug fixes from Doug Spearot --- doc/src/delete_atoms.rst | 28 ++++++++++++++-------------- src/delete_atoms.cpp | 11 ++++++----- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/doc/src/delete_atoms.rst b/doc/src/delete_atoms.rst index e25e314310..f78f295011 100644 --- a/doc/src/delete_atoms.rst +++ b/doc/src/delete_atoms.rst @@ -81,9 +81,9 @@ be deleted when running on different numbers of processors. For style *porosity* a specified *fraction* of atoms are deleted which are both in the specified group and within the specified region. The -region-ID can be specified as NULL to only impose the group -criterion. Likewise, specifying the group-ID as *all* will only impose -the region criterion. +region-ID can be specified as NULL to only impose the group criterion. +Likewise, specifying the group-ID as *all* will only impose the region +criterion. For example, if fraction is 0.1, then 10% of the eligible atoms will be deleted. The atoms to delete are chosen randomly. There is no @@ -97,8 +97,8 @@ number of atoms in the system. Note that this is not done for molecular systems (see the :doc:`atom_style ` command), regardless of the *compress* setting, since it would foul up the bond connectivity that has already been assigned. However, the -:doc:`reset_atom_ids ` command can be used after this command to -accomplish the same thing. +:doc:`reset_atom_ids ` command can be used after this +command to accomplish the same thing. Note that the re-assignment of IDs is not really a compression, where gaps in atom IDs are removed by decrementing atom IDs that are larger. @@ -108,15 +108,15 @@ the :doc:`create_atoms ` command explains. A molecular system with fixed bonds, angles, dihedrals, or improper interactions, is one where the topology of the interactions is -typically defined in the data file read by the -:doc:`read_data ` command, and where the interactions -themselves are defined with the :doc:`bond_style `, -:doc:`angle_style `, etc commands. If you delete atoms -from such a system, you must be careful not to end up with bonded -interactions that are stored by remaining atoms but which include -deleted atoms. This will cause LAMMPS to generate a "missing atoms" -error when the bonded interaction is computed. The *bond* and *mol* -keywords offer two ways to do that. +typically defined in the data file read by the :doc:`read_data +` command, and where the interactions themselves are +defined with the :doc:`bond_style `, :doc:`angle_style +`, etc commands. If you delete atoms from such a system, +you must be careful not to end up with bonded interactions that are +stored by remaining atoms but which include deleted atoms. This will +cause LAMMPS to generate a "missing atoms" error when the bonded +interaction is computed. The *bond* and *mol* keywords offer two ways +to do that. It the *bond* keyword is set to *yes* then any bond or angle or dihedral or improper interaction that includes a deleted atom is also diff --git a/src/delete_atoms.cpp b/src/delete_atoms.cpp index ad6efa13f0..8558af0b5b 100644 --- a/src/delete_atoms.cpp +++ b/src/delete_atoms.cpp @@ -431,7 +431,7 @@ void DeleteAtoms::delete_porosity(int narg, char **arg) if (strcmp(arg[2],"NULL") == 0) regionflag = 0; else { regionflag = 1; - int iregion = domain->find_region(arg[2]); + iregion = domain->find_region(arg[2]); if (iregion == -1) error->all(FLERR,"Could not find delete_atoms region ID"); domain->regions[iregion]->prematch(); } @@ -448,17 +448,18 @@ void DeleteAtoms::delete_porosity(int narg, char **arg) memory->create(dlist,nlocal,"delete_atoms:dlist"); for (int i = 0; i < nlocal; i++) dlist[i] = 0; - // delete fraction of atoms in both group and region + // delete fraction of atoms which are in both group and region double **x = atom->x; int *mask = atom->mask; int groupbit = group->bitmask[igroup]; - for (int i = 0; i < nlocal; i++) { + for (int i = 0; i < nlocal; i++) { if (!(mask[i] & groupbit)) continue; - if (regionflag && domain->regions[iregion]->match(x[i][0],x[i][1],x[i][2])) - if (random->uniform() <= porosity_fraction) dlist[i] = 1; + if (regionflag && + !domain->regions[iregion]->match(x[i][0],x[i][1],x[i][2])) continue; + if (random->uniform() <= porosity_fraction) dlist[i] = 1; } delete random;