delete_bonds: direct type label support

This commit is contained in:
Jacob Gissinger
2024-05-11 14:05:48 -04:00
parent e881bb307c
commit c19db76eae
2 changed files with 38 additions and 16 deletions

View File

@ -43,6 +43,9 @@ Examples
delete_bonds all bond 0*3 special delete_bonds all bond 0*3 special
delete_bonds all stats delete_bonds all stats
labelmap atom 4 hc
delete_bonds all atom hc special
Description Description
""""""""""" """""""""""
@ -59,19 +62,20 @@ For all styles, by default, an interaction is only turned off (or on)
if all the atoms involved are in the specified group. See the *any* if all the atoms involved are in the specified group. See the *any*
keyword to change the behavior. keyword to change the behavior.
Several of the styles (\ *atom*, *bond*, *angle*, *dihedral*, Several of the styles (\ *atom*, *bond*, *angle*, *dihedral*, *improper*\ )
*improper*\ ) take a *type* as an argument. The specified *type* should take a *type* as an argument. The specified *type* can be a
be an integer from 0 to :math:`N`, where :math:`N` is the number of relevant :doc:`type label <Howto_type_labels>`. Otherwise, the type should be an
integer from 0 to :math:`N`, where :math:`N` is the number of relevant
types (atom types, bond types, etc.). A value of 0 is only relevant for types (atom types, bond types, etc.). A value of 0 is only relevant for
style *bond*\ ; see details below. In all cases, a wildcard asterisk style *bond*\ ; see details below. For numeric types, a wildcard asterisk
can be used in place of or in conjunction with the *type* argument to can be used in place of or in conjunction with the *type* argument to
specify a range of types. This takes the form "\*" or "\*n" or "m\*" or specify a range of types. This takes the form "\*" or "\*n" or "m\*" or
"m\*n". If :math:`N` is the number of types, then an asterisk with no numeric "m\*n". If :math:`N` is the number of types, then an asterisk with no
values means all types from 0 to :math:`N`. A leading asterisk means all numeric values means all types from 0 to :math:`N`. A leading asterisk
types from 0 to n (inclusive). A trailing asterisk means all types means all types from 0 to n (inclusive). A trailing asterisk means all
from m to N (inclusive). A middle asterisk means all types from m to types from m to N (inclusive). A middle asterisk means all types from m to
n (inclusive). Note that it is fine to include a type of 0 for n (inclusive). Note that it is fine to include a type of 0 for non-bond
non-bond styles; it will simply be ignored. styles; it will simply be ignored.
For style *multi* all bond, angle, dihedral, and improper interactions For style *multi* all bond, angle, dihedral, and improper interactions
of any type, involving atoms in the group, are turned off. of any type, involving atoms in the group, are turned off.

View File

@ -85,19 +85,37 @@ void DeleteBonds::command(int narg, char **arg)
if (narg < 3) error->all(FLERR,"Illegal delete_bonds command"); if (narg < 3) error->all(FLERR,"Illegal delete_bonds command");
int n = -1; int n = -1;
if (style == ATOM) n = atom->ntypes; char *typestr = nullptr;
if (style == BOND) n = atom->nbondtypes; if (style == ATOM) {
if (style == ANGLE) n = atom->nangletypes; n = atom->ntypes;
if (style == DIHEDRAL) n = atom->ndihedraltypes; typestr = utils::expand_type(FLERR, arg[2], Atom::ATOM, lmp);
if (style == IMPROPER) n = atom->nimpropertypes; }
if (style == BOND) {
n = atom->nbondtypes;
typestr = utils::expand_type(FLERR, arg[2], Atom::BOND, lmp);
}
if (style == ANGLE) {
n = atom->nangletypes;
typestr = utils::expand_type(FLERR, arg[2], Atom::ANGLE, lmp);
}
if (style == DIHEDRAL) {
n = atom->ndihedraltypes;
typestr = utils::expand_type(FLERR, arg[2], Atom::DIHEDRAL, lmp);
}
if (style == IMPROPER) {
n = atom->nimpropertypes;
typestr = utils::expand_type(FLERR, arg[2], Atom::IMPROPER, lmp);
}
tlist = new int[n+1]; tlist = new int[n+1];
for (int i = 0; i <= n; i++) tlist[i] = 0; for (int i = 0; i <= n; i++) tlist[i] = 0;
int nlo,nhi; int nlo,nhi;
utils::bounds(FLERR,arg[2],0,n,nlo,nhi,error); if (typestr) nlo = nhi = utils::inumeric(FLERR, typestr, false, lmp);
else utils::bounds(FLERR, arg[2], 0, n, nlo, nhi, error);
for (int i = nlo; i <= nhi; i++) tlist[i] = 1; for (int i = nlo; i <= nhi; i++) tlist[i] = 1;
iarg++; iarg++;
delete[] typestr;
} }
// grab optional keywords // grab optional keywords