add missing type check and setting of ntypes for json data molecules
This commit is contained in:
@ -483,11 +483,18 @@ void Molecule::from_json(const std::string &molid, const json &moldata)
|
|||||||
count[iatom]++;
|
count[iatom]++;
|
||||||
}
|
}
|
||||||
// checks
|
// checks
|
||||||
|
ntypes = 0;
|
||||||
for (int i = 0; i < natoms; i++) {
|
for (int i = 0; i < natoms; i++) {
|
||||||
if (count[i] == 0) {
|
if (count[i] == 0) {
|
||||||
error->all(FLERR, Error::NOLASTLINE,
|
error->all(FLERR, Error::NOLASTLINE,
|
||||||
"Molecule template {}: atom {} missing in \"types\" JSON section", id, i + 1);
|
"Molecule template {}: atom {} missing in \"types\" JSON section", id, i + 1);
|
||||||
}
|
}
|
||||||
|
for (int i = 0; i < natoms; i++) {
|
||||||
|
if ((type[i] <= 0) || (domain->box_exist && (type[i] > atom->ntypes)))
|
||||||
|
error->all(FLERR, fileiarg, "Invalid atom type {} for atom {} in molecule file", type[i],
|
||||||
|
i + 1);
|
||||||
|
ntypes = MAX(ntypes, type[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
error->all(FLERR, Error::NOLASTLINE,
|
error->all(FLERR, Error::NOLASTLINE,
|
||||||
|
|||||||
Reference in New Issue
Block a user