From db9e8aa43c9a083cc37f29fd2b6a8da90e0fbbf8 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Wed, 17 Apr 2024 00:57:07 -0400 Subject: [PATCH] last minute fix for https://matsci.org/t/errors-encountered-in-the-pyrolysis-of-organic-polymers-under-reaxff-force-field/54818 --- src/REAXFF/reaxff_ffield.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/REAXFF/reaxff_ffield.cpp b/src/REAXFF/reaxff_ffield.cpp index b941d7d0f0..7dfa2ee1cb 100644 --- a/src/REAXFF/reaxff_ffield.cpp +++ b/src/REAXFF/reaxff_ffield.cpp @@ -39,6 +39,7 @@ using LAMMPS_NS::utils::open_potential; using LAMMPS_NS::utils::getsyserror; +using LAMMPS_NS::utils::strmatch; using LAMMPS_NS::utils::uppercase; using LAMMPS_NS::EOFException; using LAMMPS_NS::ValueTokenizer; @@ -71,7 +72,7 @@ namespace ReaxFF { filename, lineno, want, values.count())) if (control->me == 0) { - FILE *fp = LAMMPS_NS::utils::open_potential(filename, lmp, nullptr); + FILE *fp = open_potential(filename, lmp, nullptr); if (!fp) error->one(FLERR,"The ReaxFF parameter file {} cannot be opened: {}", filename, getsyserror()); @@ -81,9 +82,11 @@ namespace ReaxFF { try { int i,j,k,l,m,n,lineno = 0; - // skip header comment line + // check if header comment line is present - reader.skip_line(); + auto line = reader.next_line(); + if (strmatch(line, "^\\s*[0-9]+\\s+!.*general parameters.*")) + THROW_ERROR("First line of ReaxFF potential file must be a comment or empty"); ++lineno; // set some defaults