diff --git a/doc/src/delete_bonds.rst b/doc/src/delete_bonds.rst index 0b30ae5588..e03c4b3ac7 100644 --- a/doc/src/delete_bonds.rst +++ b/doc/src/delete_bonds.rst @@ -43,6 +43,9 @@ Examples delete_bonds all bond 0*3 special delete_bonds all stats + labelmap atom 4 hc + delete_bonds all atom hc special + 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* keyword to change the behavior. -Several of the styles (\ *atom*, *bond*, *angle*, *dihedral*, -*improper*\ ) take a *type* as an argument. The specified *type* should -be an integer from 0 to :math:`N`, where :math:`N` is the number of relevant +Several of the styles (\ *atom*, *bond*, *angle*, *dihedral*, *improper*\ ) +take a *type* as an argument. The specified *type* can be a +:doc:`type label `. 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 -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 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 -values means all types from 0 to :math:`N`. A leading asterisk means all -types from 0 to n (inclusive). A trailing asterisk means all 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 -non-bond styles; it will simply be ignored. +"m\*n". If :math:`N` is the number of types, then an asterisk with no +numeric values means all types from 0 to :math:`N`. A leading asterisk +means all types from 0 to n (inclusive). A trailing asterisk means all +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 non-bond +styles; it will simply be ignored. For style *multi* all bond, angle, dihedral, and improper interactions of any type, involving atoms in the group, are turned off. diff --git a/src/delete_bonds.cpp b/src/delete_bonds.cpp index 1f8fe71bff..056851bec1 100644 --- a/src/delete_bonds.cpp +++ b/src/delete_bonds.cpp @@ -85,19 +85,37 @@ void DeleteBonds::command(int narg, char **arg) if (narg < 3) error->all(FLERR,"Illegal delete_bonds command"); int n = -1; - if (style == ATOM) n = atom->ntypes; - if (style == BOND) n = atom->nbondtypes; - if (style == ANGLE) n = atom->nangletypes; - if (style == DIHEDRAL) n = atom->ndihedraltypes; - if (style == IMPROPER) n = atom->nimpropertypes; + char *typestr = nullptr; + if (style == ATOM) { + n = atom->ntypes; + typestr = utils::expand_type(FLERR, arg[2], Atom::ATOM, lmp); + } + 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]; for (int i = 0; i <= n; i++) tlist[i] = 0; 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; iarg++; + delete[] typestr; } // grab optional keywords