add check for compatible lattice command when calling create_atoms

without this check it is possibly to use the dimension keyword after
using lattice and then create atoms with an unsuitable lattice setting
This commit is contained in:
Axel Kohlmeyer 2020-08-12 16:11:14 -04:00
parent 7e558e4628
commit 5c5774c8a4
No known key found for this signature in database
GPG Key ID: D9B44E93BF0C375A
1 changed files with 14 additions and 0 deletions

View File

@ -71,6 +71,20 @@ void CreateAtoms::command(int narg, char **arg)
error->all(FLERR,"Cannot create_atoms after "
"reading restart file with per-atom info");
// check for compatible lattice
int latsty = domain->lattice->style;
if (domain->dimension == 2) {
if (latsty == Lattice::SC || latsty == Lattice::BCC
|| latsty == Lattice::FCC || latsty == Lattice::HCP
|| latsty == Lattice::DIAMOND)
error->all(FLERR,"Lattice style incompatible with simulation dimension");
} else {
if (latsty == Lattice::SQ ||latsty == Lattice::SQ2
|| latsty == Lattice::HEX)
error->all(FLERR,"Lattice style incompatible with simulation dimension");
}
// parse arguments
if (narg < 2) error->all(FLERR,"Illegal create_atoms command");