read_data: bond, etc. direct label support
This commit is contained in:
0
doc/src/Errors_messages.rst
Executable file → Normal file
0
doc/src/Errors_messages.rst
Executable file → Normal file
@ -587,7 +587,7 @@ label maps.
|
|||||||
.. parsed-literal::
|
.. parsed-literal::
|
||||||
|
|
||||||
ID = number of angle (1-Nangles)
|
ID = number of angle (1-Nangles)
|
||||||
type = angle type (1-Nangletype)
|
type = angle type (1-Nangletype, or type label)
|
||||||
atom1,atom2,atom3 = IDs of 1st,2nd,3rd atom in angle
|
atom1,atom2,atom3 = IDs of 1st,2nd,3rd atom in angle
|
||||||
|
|
||||||
example:
|
example:
|
||||||
@ -631,23 +631,24 @@ atom, bond, etc. types in terms of user-provided strings instead of
|
|||||||
numbers. If a type label section exists for a given interaction
|
numbers. If a type label section exists for a given interaction
|
||||||
(atom, bond, angle, dihedral or improper), then all types must be
|
(atom, bond, angle, dihedral or improper), then all types must be
|
||||||
assigned a type label for that interaction. Type label sections must
|
assigned a type label for that interaction. Type label sections must
|
||||||
come before any section that utilizes that type. The numeric types
|
come before any section that utilizes that type. Type labels can be
|
||||||
listed in the *Atoms*, *Bonds*, etc. section are first converted into
|
directly substituted for numeric types listed in the *Atoms*, *Bonds*,
|
||||||
their corresponding type label before being read into LAMMPS; type
|
etc. sections of data files. If numeric types are used, each
|
||||||
labels cannot be directly substituted for numeric types used in data
|
interaction type is first converted into its corresponding type label
|
||||||
files. Data files assign all types to the default label map; if the
|
before being read into LAMMPS. Data files assign all types to the
|
||||||
type label does not already exist, the type label is created as a new
|
default label map; if the type label does not already exist, the type
|
||||||
type and assigned to the default label map. The corresponding
|
label is created as a new type and assigned to the default label map.
|
||||||
interaction coefficients listed in the data file are associated to
|
The corresponding interaction coefficients listed in the data file are
|
||||||
this type. There must be enough space in the per-type data
|
associated to this type. There must be enough space in the per-type
|
||||||
arrays to create new types; see the *extra/atom/types* keyword for how
|
data arrays to create new types; see the *extra/atom/types* keyword
|
||||||
to reserve extra space for new types, e.g., when reading multiple data
|
for how to reserve extra space for new types, e.g., when reading
|
||||||
files. Note that, in this case, the numeric-to-label mapping within a
|
multiple data files. Note that, in this case, the numeric-to-label
|
||||||
data file does not necessary correspond to that of the simulation;
|
mapping within a data file does not necessary correspond to that of
|
||||||
once the default label map is fully defined, the :doc:`write_data <write_data>`
|
the simulation; once the default label map is fully defined, the
|
||||||
command can be used to print out the default label map at a given
|
:doc:`write_data <write_data>` command can be used to print out the
|
||||||
point in a simulation. See the :doc:`labelmap <labelmap>` command for
|
default label map at a given point in a simulation. See the
|
||||||
more discussion on how to use type label maps.
|
:doc:`labelmap <labelmap>` command for more discussion on how to use
|
||||||
|
type label maps.
|
||||||
|
|
||||||
----------
|
----------
|
||||||
|
|
||||||
@ -720,7 +721,7 @@ of analysis.
|
|||||||
The per-atom values have these meanings and units, listed alphabetically:
|
The per-atom values have these meanings and units, listed alphabetically:
|
||||||
|
|
||||||
* atom-ID = integer ID of atom
|
* atom-ID = integer ID of atom
|
||||||
* atom-type = type of atom (1-Ntype)
|
* atom-type = type of atom (1-Ntype, or type label)
|
||||||
* bodyflag = 1 for body particles, 0 for point particles
|
* bodyflag = 1 for body particles, 0 for point particles
|
||||||
* bond_nt = bond NT factor for MESONT particles (?? units)
|
* bond_nt = bond NT factor for MESONT particles (?? units)
|
||||||
* buckling = buckling factor for MESONT particles (?? units)
|
* buckling = buckling factor for MESONT particles (?? units)
|
||||||
@ -1044,7 +1045,7 @@ label maps.
|
|||||||
.. parsed-literal::
|
.. parsed-literal::
|
||||||
|
|
||||||
ID = bond number (1-Nbonds)
|
ID = bond number (1-Nbonds)
|
||||||
type = bond type (1-Nbondtype)
|
type = bond type (1-Nbondtype, or type label)
|
||||||
atom1,atom2 = IDs of 1st,2nd atom in bond
|
atom1,atom2 = IDs of 1st,2nd atom in bond
|
||||||
|
|
||||||
* example:
|
* example:
|
||||||
@ -1108,7 +1109,7 @@ use type label maps.
|
|||||||
.. parsed-literal::
|
.. parsed-literal::
|
||||||
|
|
||||||
ID = number of dihedral (1-Ndihedrals)
|
ID = number of dihedral (1-Ndihedrals)
|
||||||
type = dihedral type (1-Ndihedraltype)
|
type = dihedral type (1-Ndihedraltype, or type label)
|
||||||
atom1,atom2,atom3,atom4 = IDs of 1st,2nd,3rd,4th atom in dihedral
|
atom1,atom2,atom3,atom4 = IDs of 1st,2nd,3rd,4th atom in dihedral
|
||||||
|
|
||||||
* example:
|
* example:
|
||||||
@ -1227,7 +1228,7 @@ use type label maps.
|
|||||||
.. parsed-literal::
|
.. parsed-literal::
|
||||||
|
|
||||||
ID = number of improper (1-Nimpropers)
|
ID = number of improper (1-Nimpropers)
|
||||||
type = improper type (1-Nimpropertype)
|
type = improper type (1-Nimpropertype, or type label)
|
||||||
atom1,atom2,atom3,atom4 = IDs of 1st,2nd,3rd,4th atom in improper
|
atom1,atom2,atom3,atom4 = IDs of 1st,2nd,3rd,4th atom in improper
|
||||||
|
|
||||||
* example:
|
* example:
|
||||||
|
|||||||
@ -118,7 +118,8 @@ etc. types are written in the Atoms, Bonds, etc. sections. If the
|
|||||||
value is specified as *numeric*, then numeric types are used. If the
|
value is specified as *numeric*, then numeric types are used. If the
|
||||||
value is specified as *labels*, then interaction types are written as
|
value is specified as *labels*, then interaction types are written as
|
||||||
type labels using the default label map. When using type labels, the
|
type labels using the default label map. When using type labels, the
|
||||||
default label map must be written to the data file.
|
default label map (i.e., Type Label sections) must be written to the
|
||||||
|
data file.
|
||||||
|
|
||||||
The *pair* keyword lets you specify in what format the pair
|
The *pair* keyword lets you specify in what format the pair
|
||||||
coefficient information is written into the data file. If the value
|
coefficient information is written into the data file. If the value
|
||||||
|
|||||||
61
src/atom.cpp
61
src/atom.cpp
@ -53,6 +53,7 @@ using namespace MathConst;
|
|||||||
#define DELTA 1
|
#define DELTA 1
|
||||||
#define DELTA_PERATOM 64
|
#define DELTA_PERATOM 64
|
||||||
#define EPSILON 1.0e-6
|
#define EPSILON 1.0e-6
|
||||||
|
#define MAXLINE 256
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
@ -1198,9 +1199,9 @@ void Atom::data_atoms(int n, char *buf, tagint id_offset, tagint mol_offset,
|
|||||||
if (id_offset) tag[nlocal-1] += id_offset;
|
if (id_offset) tag[nlocal-1] += id_offset;
|
||||||
if (mol_offset) molecule[nlocal-1] += mol_offset;
|
if (mol_offset) molecule[nlocal-1] += mol_offset;
|
||||||
if (!isdigit(typestr[0])) {
|
if (!isdigit(typestr[0])) {
|
||||||
if (!atom->labelmapflag) error->one(FLERR,"Invalid Types section in molecule file");
|
if (!atom->labelmapflag) error->one(FLERR,"Invalid Atoms section in data file");
|
||||||
type[nlocal-1] = atom->find_label(typestr,Atom::ATOM);
|
type[nlocal-1] = atom->find_label(typestr,Atom::ATOM);
|
||||||
if (type[nlocal-1] == -1) error->one(FLERR,"Invalid Types section in molecule file");
|
if (type[nlocal-1] == -1) error->one(FLERR,"Invalid Atoms section in data file");
|
||||||
} else {
|
} else {
|
||||||
type[nlocal-1] = utils::inumeric(FLERR,typestr.c_str(),true,lmp);
|
type[nlocal-1] = utils::inumeric(FLERR,typestr.c_str(),true,lmp);
|
||||||
if (labelflag) type[nlocal-1] = ilabel[type[nlocal-1]-1];
|
if (labelflag) type[nlocal-1] = ilabel[type[nlocal-1]-1];
|
||||||
@ -1275,20 +1276,30 @@ void Atom::data_bonds(int n, char *buf, int *count, tagint id_offset,
|
|||||||
int m,tmp,itype,rv;
|
int m,tmp,itype,rv;
|
||||||
tagint atom1,atom2;
|
tagint atom1,atom2;
|
||||||
char *next;
|
char *next;
|
||||||
|
char typechar[MAXLINE];
|
||||||
|
std::string typestr;
|
||||||
int newton_bond = force->newton_bond;
|
int newton_bond = force->newton_bond;
|
||||||
|
|
||||||
for (int i = 0; i < n; i++) {
|
for (int i = 0; i < n; i++) {
|
||||||
next = strchr(buf,'\n');
|
next = strchr(buf,'\n');
|
||||||
*next = '\0';
|
*next = '\0';
|
||||||
rv = sscanf(buf,"%d %d " TAGINT_FORMAT " " TAGINT_FORMAT,
|
rv = sscanf(buf,"%d %s " TAGINT_FORMAT " " TAGINT_FORMAT,
|
||||||
&tmp,&itype,&atom1,&atom2);
|
&tmp,typechar,&atom1,&atom2);
|
||||||
if (rv != 4)
|
if (rv != 4)
|
||||||
error->one(FLERR,"Incorrect format of Bonds section in data file");
|
error->one(FLERR,"Incorrect format of Bonds section in data file");
|
||||||
if (id_offset) {
|
if (id_offset) {
|
||||||
atom1 += id_offset;
|
atom1 += id_offset;
|
||||||
atom2 += id_offset;
|
atom2 += id_offset;
|
||||||
}
|
}
|
||||||
|
typestr = typechar;
|
||||||
|
if (!isdigit(typestr[0])) {
|
||||||
|
if (!atom->labelmapflag) error->one(FLERR,"Invalid Bonds section in data file");
|
||||||
|
itype = atom->find_label(typestr,Atom::BOND);
|
||||||
|
if (itype == -1) error->one(FLERR,"Invalid Bonds section in data file");
|
||||||
|
} else {
|
||||||
|
itype = utils::inumeric(FLERR,typechar,true,lmp);
|
||||||
if (labelflag) itype = ilabel[itype-1];
|
if (labelflag) itype = ilabel[itype-1];
|
||||||
|
}
|
||||||
itype += type_offset;
|
itype += type_offset;
|
||||||
|
|
||||||
if ((atom1 <= 0) || (atom1 > map_tag_max) ||
|
if ((atom1 <= 0) || (atom1 > map_tag_max) ||
|
||||||
@ -1333,13 +1344,15 @@ void Atom::data_angles(int n, char *buf, int *count, tagint id_offset,
|
|||||||
int m,tmp,itype,rv;
|
int m,tmp,itype,rv;
|
||||||
tagint atom1,atom2,atom3;
|
tagint atom1,atom2,atom3;
|
||||||
char *next;
|
char *next;
|
||||||
|
char typechar[MAXLINE];
|
||||||
|
std::string typestr;
|
||||||
int newton_bond = force->newton_bond;
|
int newton_bond = force->newton_bond;
|
||||||
|
|
||||||
for (int i = 0; i < n; i++) {
|
for (int i = 0; i < n; i++) {
|
||||||
next = strchr(buf,'\n');
|
next = strchr(buf,'\n');
|
||||||
*next = '\0';
|
*next = '\0';
|
||||||
rv = sscanf(buf,"%d %d " TAGINT_FORMAT " " TAGINT_FORMAT " " TAGINT_FORMAT,
|
rv = sscanf(buf,"%d %s " TAGINT_FORMAT " " TAGINT_FORMAT " " TAGINT_FORMAT,
|
||||||
&tmp,&itype,&atom1,&atom2,&atom3);
|
&tmp,typechar,&atom1,&atom2,&atom3);
|
||||||
if (rv != 5)
|
if (rv != 5)
|
||||||
error->one(FLERR,"Incorrect format of Angles section in data file");
|
error->one(FLERR,"Incorrect format of Angles section in data file");
|
||||||
if (id_offset) {
|
if (id_offset) {
|
||||||
@ -1347,7 +1360,15 @@ void Atom::data_angles(int n, char *buf, int *count, tagint id_offset,
|
|||||||
atom2 += id_offset;
|
atom2 += id_offset;
|
||||||
atom3 += id_offset;
|
atom3 += id_offset;
|
||||||
}
|
}
|
||||||
|
typestr = typechar;
|
||||||
|
if (!isdigit(typestr[0])) {
|
||||||
|
if (!atom->labelmapflag) error->one(FLERR,"Invalid Angles section in data file");
|
||||||
|
itype = atom->find_label(typestr,Atom::ANGLE);
|
||||||
|
if (itype == -1) error->one(FLERR,"Invalid Angles section in data file");
|
||||||
|
} else {
|
||||||
|
itype = utils::inumeric(FLERR,typechar,true,lmp);
|
||||||
if (labelflag) itype = ilabel[itype-1];
|
if (labelflag) itype = ilabel[itype-1];
|
||||||
|
}
|
||||||
itype += type_offset;
|
itype += type_offset;
|
||||||
|
|
||||||
if ((atom1 <= 0) || (atom1 > map_tag_max) ||
|
if ((atom1 <= 0) || (atom1 > map_tag_max) ||
|
||||||
@ -1406,14 +1427,16 @@ void Atom::data_dihedrals(int n, char *buf, int *count, tagint id_offset,
|
|||||||
int m,tmp,itype,rv;
|
int m,tmp,itype,rv;
|
||||||
tagint atom1,atom2,atom3,atom4;
|
tagint atom1,atom2,atom3,atom4;
|
||||||
char *next;
|
char *next;
|
||||||
|
char typechar[MAXLINE];
|
||||||
|
std::string typestr;
|
||||||
int newton_bond = force->newton_bond;
|
int newton_bond = force->newton_bond;
|
||||||
|
|
||||||
for (int i = 0; i < n; i++) {
|
for (int i = 0; i < n; i++) {
|
||||||
next = strchr(buf,'\n');
|
next = strchr(buf,'\n');
|
||||||
*next = '\0';
|
*next = '\0';
|
||||||
rv = sscanf(buf,"%d %d " TAGINT_FORMAT " " TAGINT_FORMAT
|
rv = sscanf(buf,"%d %s " TAGINT_FORMAT " " TAGINT_FORMAT
|
||||||
" " TAGINT_FORMAT " " TAGINT_FORMAT,
|
" " TAGINT_FORMAT " " TAGINT_FORMAT,
|
||||||
&tmp,&itype,&atom1,&atom2,&atom3,&atom4);
|
&tmp,typechar,&atom1,&atom2,&atom3,&atom4);
|
||||||
if (rv != 6)
|
if (rv != 6)
|
||||||
error->one(FLERR,"Incorrect format of Dihedrals section in data file");
|
error->one(FLERR,"Incorrect format of Dihedrals section in data file");
|
||||||
if (id_offset) {
|
if (id_offset) {
|
||||||
@ -1422,7 +1445,15 @@ void Atom::data_dihedrals(int n, char *buf, int *count, tagint id_offset,
|
|||||||
atom3 += id_offset;
|
atom3 += id_offset;
|
||||||
atom4 += id_offset;
|
atom4 += id_offset;
|
||||||
}
|
}
|
||||||
|
typestr = typechar;
|
||||||
|
if (!isdigit(typestr[0])) {
|
||||||
|
if (!atom->labelmapflag) error->one(FLERR,"Invalid Dihedrals section in data file");
|
||||||
|
itype = atom->find_label(typestr,Atom::DIHEDRAL);
|
||||||
|
if (itype == -1) error->one(FLERR,"Invalid Dihedrals section in data file");
|
||||||
|
} else {
|
||||||
|
itype = utils::inumeric(FLERR,typechar,true,lmp);
|
||||||
if (labelflag) itype = ilabel[itype-1];
|
if (labelflag) itype = ilabel[itype-1];
|
||||||
|
}
|
||||||
itype += type_offset;
|
itype += type_offset;
|
||||||
|
|
||||||
if ((atom1 <= 0) || (atom1 > map_tag_max) ||
|
if ((atom1 <= 0) || (atom1 > map_tag_max) ||
|
||||||
@ -1498,14 +1529,16 @@ void Atom::data_impropers(int n, char *buf, int *count, tagint id_offset,
|
|||||||
int m,tmp,itype,rv;
|
int m,tmp,itype,rv;
|
||||||
tagint atom1,atom2,atom3,atom4;
|
tagint atom1,atom2,atom3,atom4;
|
||||||
char *next;
|
char *next;
|
||||||
|
char typechar[MAXLINE];
|
||||||
|
std::string typestr;
|
||||||
int newton_bond = force->newton_bond;
|
int newton_bond = force->newton_bond;
|
||||||
|
|
||||||
for (int i = 0; i < n; i++) {
|
for (int i = 0; i < n; i++) {
|
||||||
next = strchr(buf,'\n');
|
next = strchr(buf,'\n');
|
||||||
*next = '\0';
|
*next = '\0';
|
||||||
rv = sscanf(buf,"%d %d "
|
rv = sscanf(buf,"%d %s "
|
||||||
TAGINT_FORMAT " " TAGINT_FORMAT " " TAGINT_FORMAT " " TAGINT_FORMAT,
|
TAGINT_FORMAT " " TAGINT_FORMAT " " TAGINT_FORMAT " " TAGINT_FORMAT,
|
||||||
&tmp,&itype,&atom1,&atom2,&atom3,&atom4);
|
&tmp,typechar,&atom1,&atom2,&atom3,&atom4);
|
||||||
if (rv != 6)
|
if (rv != 6)
|
||||||
error->one(FLERR,"Incorrect format of Impropers section in data file");
|
error->one(FLERR,"Incorrect format of Impropers section in data file");
|
||||||
if (id_offset) {
|
if (id_offset) {
|
||||||
@ -1514,7 +1547,15 @@ void Atom::data_impropers(int n, char *buf, int *count, tagint id_offset,
|
|||||||
atom3 += id_offset;
|
atom3 += id_offset;
|
||||||
atom4 += id_offset;
|
atom4 += id_offset;
|
||||||
}
|
}
|
||||||
|
typestr = typechar;
|
||||||
|
if (!isdigit(typestr[0])) {
|
||||||
|
if (!atom->labelmapflag) error->one(FLERR,"Invalid Impropers section in data file");
|
||||||
|
itype = atom->find_label(typestr,Atom::IMPROPER);
|
||||||
|
if (itype == -1) error->one(FLERR,"Invalid Impropers section in data file");
|
||||||
|
} else {
|
||||||
|
itype = utils::inumeric(FLERR,typechar,true,lmp);
|
||||||
if (labelflag) itype = ilabel[itype-1];
|
if (labelflag) itype = ilabel[itype-1];
|
||||||
|
}
|
||||||
itype += type_offset;
|
itype += type_offset;
|
||||||
|
|
||||||
if ((atom1 <= 0) || (atom1 > map_tag_max) ||
|
if ((atom1 <= 0) || (atom1 > map_tag_max) ||
|
||||||
|
|||||||
Reference in New Issue
Block a user