diff --git a/doc/src/compute_rdf.rst b/doc/src/compute_rdf.rst index 85e758016e..1330c6f300 100644 --- a/doc/src/compute_rdf.rst +++ b/doc/src/compute_rdf.rst @@ -13,8 +13,8 @@ Syntax * ID, group-ID are documented in :doc:`compute ` command * rdf = style name of this compute command * Nbin = number of RDF bins -* itypeN = central atom type for Nth RDF histogram (see asterisk form below) -* jtypeN = distribution atom type for Nth RDF histogram (see asterisk form below) +* itypeN = central atom type for Nth RDF histogram (integer, type label, or asterisk form) +* jtypeN = distribution atom type for Nth RDF histogram (integer, type label, or asterisk form) * zero or more keyword/value pairs may be appended * keyword = *cutoff* @@ -96,14 +96,16 @@ is computed for :math:`g(r)` between all atom types. If one or more pairs are listed, then a separate histogram is generated for each *itype*,\ *jtype* pair. -The *itypeN* and *jtypeN* settings can be specified in one of two -ways. An explicit numeric value can be used, as in the fourth example -above. Or a wild-card asterisk can be used to specify a range of atom -types. This takes the form "\*" or "\*n" or "m\*" or "m\*n". If -:math:`N` is the number of atom types, then an asterisk with no numeric values -means all types from 1 to :math:`N`. A leading asterisk means all types from 1 -to n (inclusive). A trailing asterisk means all types from m to :math:`N` -(inclusive). A middle asterisk means all types from m to n (inclusive). +The *itypeN* and *jtypeN* settings can be specified in one of three +ways. One or both of the types in the I,J pair can be a +:doc:`type label `. Or an explicit numeric value can be +used, as in the fourth example above. Or a wild-card asterisk can be used +to specify a range of atom types. This takes the form "\*" or "\*n" or +"m\*" or "m\*n". If :math:`N` is the number of atom types, then an asterisk +with no numeric values means all types from 1 to :math:`N`. A leading +asterisk means all types from 1 to n (inclusive). A trailing asterisk +means all types from m to :math:`N` (inclusive). A middle asterisk means +all types from m to n (inclusive). If both *itypeN* and *jtypeN* are single values, as in the fourth example above, this means that a :math:`g(r)` is computed where atoms of type *itypeN* diff --git a/src/compute_rdf.cpp b/src/compute_rdf.cpp index 89f3c91017..d5639bbb34 100644 --- a/src/compute_rdf.cpp +++ b/src/compute_rdf.cpp @@ -102,10 +102,20 @@ ComputeRDF::ComputeRDF(LAMMPS *lmp, int narg, char **arg) : } else { iarg = 4; for (int ipair = 0; ipair < npairs; ipair++) { - utils::bounds(FLERR,arg[iarg],1,atom->ntypes,ilo[ipair],ihi[ipair],error); - utils::bounds(FLERR,arg[iarg+1],1,atom->ntypes,jlo[ipair],jhi[ipair],error); - if (ilo[ipair] > ihi[ipair] || jlo[ipair] > jhi[ipair]) - error->all(FLERR,"Illegal compute rdf command"); + utils::bounds_typelabel(FLERR, arg[iarg], 1, atom->ntypes, ilo[ipair], ihi[ipair], error, lmp, Atom::ATOM); + utils::bounds_typelabel(FLERR, arg[iarg+1], 1, atom->ntypes, jlo[ipair], jhi[ipair], error, lmp, Atom::ATOM); + + // switch i,j if i > j, if wildcards were not used + + if ( (ilo[ipair] == ihi[ipair]) && + (jlo[ipair] == jhi[ipair]) && + (ilo[ipair] > jlo[ipair]) ) { + jlo[ipair] = ihi[ipair]; + ilo[ipair] = jhi[ipair]; + ihi[ipair] = ilo[ipair]; + jhi[ipair] = jlo[ipair]; + } + iarg += 2; } }