direct type label support for mass command
This commit is contained in:
@ -10,7 +10,7 @@ Syntax
|
||||
|
||||
mass I value
|
||||
|
||||
* I = atom type (see asterisk form below)
|
||||
* I = atom type (see asterisk form below), or type label
|
||||
* value = mass
|
||||
|
||||
Examples
|
||||
@ -22,6 +22,9 @@ Examples
|
||||
mass * 62.5
|
||||
mass 2* 62.5
|
||||
|
||||
labelmap atom 1 C
|
||||
mass C 12.01
|
||||
|
||||
Description
|
||||
"""""""""""
|
||||
|
||||
@ -30,12 +33,16 @@ values can also be set in the :doc:`read_data <read_data>` data file
|
||||
using the "Masses" keyword. See the :doc:`units <units>` command for
|
||||
what mass units to use.
|
||||
|
||||
The I index can be specified in one of two ways. An explicit numeric
|
||||
value can be used, as in the first example above. Or a wild-card
|
||||
asterisk can be used to set the mass for multiple atom types. This
|
||||
takes the form "\*" or "\*n" or "n\*" or "m\*n". If N = the number of
|
||||
atom types, then an asterisk with no numeric values means all types
|
||||
from 1 to N. A leading asterisk means all types from 1 to n
|
||||
The I index can be specified in one of several ways. An explicit
|
||||
numeric value can be used, as in the first example above. Or I can be
|
||||
a type label, which is an alphanumeric string defined by the
|
||||
:doc:`labelmap <labelmap>` command or in a section of a data file read
|
||||
by the :doc:`read_data <read_data>` command, and which converts
|
||||
internally to a numeric type. Or a wild-card asterisk can be used to
|
||||
set the mass for multiple atom types. This takes the form "\*" or
|
||||
"\*n" or "n\*" or "m\*n", where m and n are numbers. If N = the
|
||||
number of atom types, then an asterisk with no numeric values means
|
||||
all types from 1 to N. A leading asterisk means all types from 1 to n
|
||||
(inclusive). A trailing asterisk means all types from n to N
|
||||
(inclusive). A middle asterisk means all types from m to n
|
||||
(inclusive).
|
||||
|
||||
@ -26,6 +26,10 @@ Examples
|
||||
pair_coeff * 3 morse.table ENTRY1
|
||||
pair_coeff 1 2 lj/cut 1.0 1.0 2.5 (for pair_style hybrid)
|
||||
|
||||
labelmap atom 1 C
|
||||
labelmap atom 2 H
|
||||
pair_coeff C H 1.0 1.0 2.5
|
||||
|
||||
Description
|
||||
"""""""""""
|
||||
|
||||
@ -41,7 +45,7 @@ alphanumeric string defined by the :doc:`labelmap <labelmap>` command
|
||||
or in a section of a data file read by the :doc:`read_data
|
||||
<read_data>` command, and which converts internally to a numeric type.
|
||||
Internally, LAMMPS will set coefficients for the symmetric J,I
|
||||
interaction to the same values as the I <= J interaction.
|
||||
interaction to the same values as the I,J interaction.
|
||||
|
||||
For numeric values only, a wildcard asterisk can be used in place of
|
||||
or in conjunction with the I,J arguments to set the coefficients for
|
||||
|
||||
@ -1849,6 +1849,14 @@ void Atom::set_mass(const char *file, int line, int /*narg*/, char **arg)
|
||||
{
|
||||
if (mass == nullptr) error->all(file,line,"Cannot set mass for this atom style");
|
||||
|
||||
if (!isdigit(arg[0][0]) && arg[0][0] != '*') {
|
||||
std::string typestr(arg[0]);
|
||||
int itype = atom->find_label(typestr,Atom::ATOM);
|
||||
mass[itype] = utils::numeric(FLERR,arg[1],false,lmp);
|
||||
mass_setflag[itype] = 1;
|
||||
|
||||
if (mass[itype] <= 0.0) error->all(file,line,"Invalid mass value");
|
||||
} else {
|
||||
int lo,hi;
|
||||
utils::bounds(file,line,arg[0],1,ntypes,lo,hi,error);
|
||||
if (lo < 1 || hi > ntypes) error->all(file,line,"Invalid type for mass set");
|
||||
@ -1859,6 +1867,7 @@ void Atom::set_mass(const char *file, int line, int /*narg*/, char **arg)
|
||||
|
||||
if (mass[itype] <= 0.0) error->all(file,line,"Invalid mass value");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user