From 5c5774c8a4caa567cf880b44a55fa0f86b94eb5a Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 12 Aug 2020 16:11:14 -0400 Subject: [PATCH] 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 --- src/create_atoms.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/create_atoms.cpp b/src/create_atoms.cpp index 3732662295..de20e15698 100644 --- a/src/create_atoms.cpp +++ b/src/create_atoms.cpp @@ -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");