diff --git a/doc/src/fix_adapt.rst b/doc/src/fix_adapt.rst index f857a6333c..7a551b554f 100644 --- a/doc/src/fix_adapt.rst +++ b/doc/src/fix_adapt.rst @@ -21,17 +21,17 @@ Syntax *pair* args = pstyle pparam I J v_name pstyle = pair style name (e.g., lj/cut) pparam = parameter to adapt over time - I,J = type pair(s) to set parameter for + I,J = type pair(s) to set parameter for (integer or type label) v_name = variable with name that calculates value of pparam *bond* args = bstyle bparam I v_name bstyle = bond style name (e.g., harmonic) bparam = parameter to adapt over time - I = type bond to set parameter for + I = type bond to set parameter for (integer or type label) v_name = variable with name that calculates value of bparam *angle* args = astyle aparam I v_name astyle = angle style name (e.g., harmonic) aparam = parameter to adapt over time - I = type angle to set parameter for + I = type angle to set parameter for (integer or type label) v_name = variable with name that calculates value of aparam *kspace* arg = v_name v_name = variable with name that calculates scale factor on :math:`k`-space terms @@ -254,10 +254,12 @@ should be specified to indicate which type pairs to apply it to. If a global parameter is specified, the :math:`I` and :math:`J` settings still need to be specified, but are ignored. -Similar to the :doc:`pair_coeff command `, :math:`I` and :math:`J` -can be specified in one of two ways. Explicit numeric values can be used for -each, as in the first example above. :math:`I \le J` is required. LAMMPS sets -the coefficients for the symmetric :math:`J,I` interaction to the same values. +Similar to the :doc:`pair_coeff command `, :math:`I` and +:math:`J` can be specified in one of several ways. Explicit numeric values +can be used for each, as in the first example above. Or, one or both of +the types in the I,J pair can be a :doc:`type label `. +LAMMPS sets the coefficients for the symmetric :math:`J,I` interaction to +the same values. A wild-card asterisk can be used in place of or in conjunction with the :math:`I,J` arguments to set the coefficients for multiple pairs of atom @@ -266,8 +268,9 @@ 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). Note that only type pairs with :math:`I \le J` are considered; if -asterisks imply type pairs where :math:`J < I`, they are ignored. +(inclusive). For the asterisk syntax, note that only type pairs with +:math:`I \le J` are considered; if asterisks imply type pairs where +:math:`J < I`, they are ignored. IMPORTANT NOTE: If :doc:`pair_style hybrid or hybrid/overlay ` is being used, then the *pstyle* will be a sub-style diff --git a/src/fix_adapt.cpp b/src/fix_adapt.cpp index 2a10b9d603..91e4ce7585 100644 --- a/src/fix_adapt.cpp +++ b/src/fix_adapt.cpp @@ -99,10 +99,32 @@ FixAdapt::FixAdapt(LAMMPS *lmp, int narg, char **arg) : adapt[nadapt].pair = nullptr; adapt[nadapt].pstyle = utils::strdup(arg[iarg+1]); adapt[nadapt].pparam = utils::strdup(arg[iarg+2]); - utils::bounds(FLERR,arg[iarg+3],1,atom->ntypes, - adapt[nadapt].ilo,adapt[nadapt].ihi,error); - utils::bounds(FLERR,arg[iarg+4],1,atom->ntypes, - adapt[nadapt].jlo,adapt[nadapt].jhi,error); + char *typestr = nullptr; + typestr = utils::expand_type(FLERR, arg[iarg+3], Atom::ATOM, lmp); + if (typestr) + adapt[nadapt].ilo = adapt[nadapt].ihi = utils::inumeric(FLERR, typestr, false, lmp); + else utils::bounds(FLERR, arg[iarg+3], 1, atom->ntypes, + adapt[nadapt].ilo, adapt[nadapt].ihi, error); + delete[] typestr; + typestr = nullptr; + typestr = utils::expand_type(FLERR, arg[iarg+4], Atom::ATOM, lmp); + if (typestr) + adapt[nadapt].jlo = adapt[nadapt].jhi = utils::inumeric(FLERR, typestr, false, lmp); + utils::bounds(FLERR, arg[iarg+4], 1, atom->ntypes, + adapt[nadapt].jlo, adapt[nadapt].jhi, error); + delete[] typestr; + + // switch i,j if i > j, if wildcards were not used + + if ( (adapt[nadapt].ilo == adapt[nadapt].ihi) && + (adapt[nadapt].jlo == adapt[nadapt].jhi) && + (adapt[nadapt].ilo > adapt[nadapt].jlo) ) { + adapt[nadapt].jlo = adapt[nadapt].ihi; + adapt[nadapt].ilo = adapt[nadapt].jhi; + adapt[nadapt].ihi = adapt[nadapt].ilo; + adapt[nadapt].jhi = adapt[nadapt].jlo; + } + if (utils::strmatch(arg[iarg+5],"^v_")) { adapt[nadapt].var = utils::strdup(arg[iarg+5]+2); } else error->all(FLERR,"Argument #{} must be variable not {}", iarg+6, arg[iarg+5]); @@ -114,8 +136,13 @@ FixAdapt::FixAdapt(LAMMPS *lmp, int narg, char **arg) : adapt[nadapt].bond = nullptr; adapt[nadapt].bstyle = utils::strdup(arg[iarg+1]); adapt[nadapt].bparam = utils::strdup(arg[iarg+2]); - utils::bounds(FLERR,arg[iarg+3],1,atom->nbondtypes, - adapt[nadapt].ilo,adapt[nadapt].ihi,error); + char *typestr = nullptr; + typestr = utils::expand_type(FLERR, arg[iarg+3], Atom::BOND, lmp); + if (typestr) + adapt[nadapt].ilo = adapt[nadapt].ihi = utils::inumeric(FLERR, typestr, false, lmp); + else utils::bounds(FLERR, arg[iarg+3], 1, atom->nbondtypes, + adapt[nadapt].ilo, adapt[nadapt].ihi, error); + delete[] typestr; if (utils::strmatch(arg[iarg+4],"^v_")) { adapt[nadapt].var = utils::strdup(arg[iarg+4]+2); } else error->all(FLERR,"Argument #{} must be variable not {}", iarg+5, arg[iarg+4]); @@ -127,8 +154,13 @@ FixAdapt::FixAdapt(LAMMPS *lmp, int narg, char **arg) : adapt[nadapt].angle = nullptr; adapt[nadapt].astyle = utils::strdup(arg[iarg+1]); adapt[nadapt].aparam = utils::strdup(arg[iarg+2]); - utils::bounds(FLERR,arg[iarg+3],1,atom->nangletypes, - adapt[nadapt].ilo,adapt[nadapt].ihi,error); + char *typestr = nullptr; + typestr = utils::expand_type(FLERR, arg[iarg+3], Atom::ANGLE, lmp); + if (typestr) + adapt[nadapt].ilo = adapt[nadapt].ihi = utils::inumeric(FLERR, typestr, false, lmp); + else utils::bounds(FLERR, arg[iarg+3], 1, atom->nangletypes, + adapt[nadapt].ilo, adapt[nadapt].ihi, error); + delete[] typestr; if (utils::strmatch(arg[iarg+4],"^v_")) { adapt[nadapt].var = utils::strdup(arg[iarg+4]+2); } else error->all(FLERR,"Argument #{} must be variable not {}", iarg+5, arg[iarg+4]);