compute_rdf: direct type label support

type label that is the same as the keyword ('cutoff') will break things. if syntax is otherwise 'correct', then will throw a syntax error. perhaps could run through typelabels to check first?
This commit is contained in:
Jacob Gissinger
2024-05-12 16:11:36 -04:00
parent c324afeaf1
commit f007be620a
2 changed files with 26 additions and 14 deletions

View File

@ -13,8 +13,8 @@ Syntax
* ID, group-ID are documented in :doc:`compute <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 <Howto_type_labels>`. 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*

View File

@ -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;
}
}