change the handling of reading "extra XXX per atom", so that the final choice is the larger of the value in the file and the keyword

This commit is contained in:
Axel Kohlmeyer
2017-06-29 16:09:23 -04:00
parent 38075455b6
commit aa3f4b7690
2 changed files with 23 additions and 13 deletions

View File

@ -968,6 +968,7 @@ void ReadData::header(int firstpass)
// search line for header keyword and set corresponding variable
// customize for new header lines
// check for triangles before angles so "triangles" not matched as "angles"
int extra_flag_value = 0;
if (strstr(line,"atoms")) {
sscanf(line,BIGINT_FORMAT,&natoms);
@ -1029,17 +1030,26 @@ void ReadData::header(int firstpass)
atom->nimpropertypes = nimpropertypes + extra_improper_types;
// these settings only used by first data file
// also, these are obsolescent. we parse them to maintain backward
// compatibility, but the recommended way is to set them via keywords
// in the LAMMPS input file. In case these flags are set in both,
// the input and the data file, we use the larger of the two.
} else if (strstr(line,"extra bond per atom")) {
if (addflag == NONE) sscanf(line,"%d",&atom->extra_bond_per_atom);
if (addflag == NONE) sscanf(line,"%d",&extra_flag_value);
atom->extra_bond_per_atom = MAX(atom->extra_bond_per_atom,extra_flag_value);
} else if (strstr(line,"extra angle per atom")) {
if (addflag == NONE) sscanf(line,"%d",&atom->extra_angle_per_atom);
if (addflag == NONE) sscanf(line,"%d",&extra_flag_value);
atom->extra_angle_per_atom = MAX(atom->extra_angle_per_atom,extra_flag_value);
} else if (strstr(line,"extra dihedral per atom")) {
if (addflag == NONE) sscanf(line,"%d",&atom->extra_dihedral_per_atom);
if (addflag == NONE) sscanf(line,"%d",&extra_flag_value);
atom->extra_dihedral_per_atom = MAX(atom->extra_dihedral_per_atom,extra_flag_value);
} else if (strstr(line,"extra improper per atom")) {
if (addflag == NONE) sscanf(line,"%d",&atom->extra_improper_per_atom);
if (addflag == NONE) sscanf(line,"%d",&extra_flag_value);
atom->extra_improper_per_atom = MAX(atom->extra_improper_per_atom,extra_flag_value);
} else if (strstr(line,"extra special per atom")) {
if (addflag == NONE) sscanf(line,"%d",&force->special_extra);
if (addflag == NONE) sscanf(line,"%d",&extra_flag_value);
force->special_extra = MAX(force->special_extra,extra_flag_value);
// local copy of box info
// so can treat differently for first vs subsequent data files

View File

@ -472,8 +472,8 @@ outside a non-periodic simulation box.
E: Subsequent read data induced too many bonds per atom
See the create_box extra/bond/per/atom or read_data "extra bond per
atom" header value to set this limit larger.
See the create_box extra/bond/per/atom or the read_data
extra/bond/per/atom keyword to set this limit larger.
E: Bonds assigned incorrectly
@ -482,8 +482,8 @@ This means there is something invalid about the topology definitions.
E: Subsequent read data induced too many angles per atom
See the create_box extra/angle/per/atom or read_data "extra angle per
atom" header value to set this limit larger.
See the create_box extra/angle/per/atom or the read_data
extra/angle/per/atom keyword to set this limit larger.
E: Angles assigned incorrectly
@ -493,8 +493,8 @@ definitions.
E: Subsequent read data induced too many dihedrals per atom
See the create_box extra/dihedral/per/atom or read_data "extra
dihedral per atom" header value to set this limit larger.
See the create_box extra/dihedral/per/atom or the read_data
extra/dihedral/per/atom keyword to set this limit larger.
E: Dihedrals assigned incorrectly
@ -504,8 +504,8 @@ definitions.
E: Subsequent read data induced too many impropers per atom
See the create_box extra/improper/per/atom or read_data "extra
improper per atom" header value to set this limit larger.
See the create_box extra/improper/per/atom or the read_data
extra/improper/per/atom keyword to set this limit larger.
E: Impropers assigned incorrectly