honor atom-ids in Special Bonds section

This commit is contained in:
Axel Kohlmeyer
2025-06-21 12:36:31 -04:00
parent 9d38652033
commit 0caaca8a05

View File

@ -3166,6 +3166,7 @@ void Molecule::nspecial_read(int flag, char *line)
void Molecule::special_read(char *line)
{
for (int i = 0; i < natoms; ++i) count[i] = 0;
try {
for (int i = 0; i < natoms; i++) {
readline(line);
@ -3176,17 +3177,26 @@ void Molecule::special_read(char *line)
if (nwords != nspecial[i][2] + 1)
error->all(FLERR, fileiarg, "Molecule file special list does not match special count");
values.next_int(); // ignore
int iatom = values.next_int() - 1;
if (iatom < 0 || iatom >= natoms)
error->all(FLERR, fileiarg, "Invalid atom index in Special Bonds section of molecule file");
for (int m = 1; m < nwords; m++) {
special[i][m - 1] = values.next_tagint();
if (special[i][m - 1] <= 0 || special[i][m - 1] > natoms || special[i][m - 1] == i + 1)
error->all(FLERR, fileiarg, "Invalid atom index in Special Bonds section of molecule file");
tagint ival = values.next_tagint();
if ((ival <= 0) || (ival > natoms) || (ival == iatom + 1))
error->all(FLERR, fileiarg, "Invalid atom index {} in Special Bonds section of "
"molecule file", ival);
special[iatom][m - 1] = ival;
}
}
} catch (TokenizerException &e) {
error->all(FLERR, fileiarg, "Invalid line in Special Bonds section of molecule file: {}\n{}", e.what(),
line);
error->all(FLERR, fileiarg, "Invalid line in Special Bonds section of molecule file: {}\n{}",
e.what(), line);
}
for (int i = 0; i < natoms; i++) {
if (count[i] == 0)
error->all(FLERR, fileiarg, "Atom {} missing in Special Bonds section of molecule file",
i + 1);
}
}