From 5be930fa760afe0b7163e1902fe04c7b4d017858 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 15 Jul 2021 16:40:15 -0400 Subject: [PATCH] cleanup --- src/USER-MISC/pair_e3b.cpp | 59 ++++++++++++++------------------------ 1 file changed, 21 insertions(+), 38 deletions(-) diff --git a/src/USER-MISC/pair_e3b.cpp b/src/USER-MISC/pair_e3b.cpp index e6d5935d86..3052356e1d 100644 --- a/src/USER-MISC/pair_e3b.cpp +++ b/src/USER-MISC/pair_e3b.cpp @@ -17,20 +17,22 @@ #include "pair_e3b.h" +#include "atom.h" +#include "citeme.h" +#include "comm.h" +#include "domain.h" +#include "error.h" +#include "force.h" +#include "memory.h" +#include "neigh_list.h" +#include "neighbor.h" +#include "update.h" + #include #include #include - -#include "atom.h" -#include "neighbor.h" -#include "neigh_list.h" -#include "force.h" -#include "comm.h" -#include "memory.h" -#include "error.h" -#include "update.h" -#include "domain.h" -#include "citeme.h" +#include +#include //these are defined here to avoid confusing hardcoded indices, but //they do not allow flexibility. If they are changed the code will break @@ -396,10 +398,6 @@ void PairE3B::coeff(int narg, char **arg) if (narg < 4) error->all(FLERR,"There must be at least one keyword given to pair_coeff"); - // ensure I,J args are * * - if (strcmp(arg[0],"*") != 0 || strcmp(arg[1],"*") != 0) - error->all(FLERR,"Incorrect args for pair coefficients"); - // clear setflag since coeff() called once with I,J = * * int n = atom->ntypes; for (int i = 1; i <= n; i++) @@ -411,7 +409,6 @@ void PairE3B::coeff(int narg, char **arg) //parse keyword/value pairs double bondL=0.0; //OH bond length bool repeatFlag=false; - int presetFlag; //clear parameters e2=ea=eb=ec=k3=k2=NAN; @@ -443,13 +440,9 @@ void PairE3B::coeff(int narg, char **arg) else if (checkKeyword(keyword,"neigh",1,narg-iarg)) pairPerAtom=utils::inumeric(FLERR,arg[iarg++],false,lmp); else if (checkKeyword(keyword,"preset",1,narg-iarg)) { - presetFlag=utils::inumeric(FLERR,arg[iarg++],false,lmp); + int presetFlag=utils::inumeric(FLERR,arg[iarg++],false,lmp); presetParam(presetFlag,repeatFlag,bondL); - } else { - char str[256]; - snprintf(str,256,"Keyword %s is unknown",keyword); - error->all(FLERR,str); - } + } else error->all(FLERR,"Keyword {} is unknown",keyword); } checkInputs(bondL); @@ -528,10 +521,8 @@ static const char cite_E3B3[] = "}\n\n"; void PairE3B::presetParam(const int flag,bool &repeatFlag,double &bondL) { - if (repeatFlag) { - error->all(FLERR, - "Cannot request two different sets of preset parameters"); - } + if (repeatFlag) + error->all(FLERR,"Cannot request two different sets of preset parameters"); repeatFlag=true; if (!std::isnan(ea) || !std::isnan(eb) || !std::isnan(ec) || @@ -552,18 +543,14 @@ void PairE3B::presetParam(const int flag,bool &repeatFlag,double &bondL) { } else if (strcmp(update->unit_style,"cgs") == 0) { econv=1.660578e-14; lconv=1e-8; - } else { - char str[256]; - snprintf(str,256, - "Pre-defined E3B parameters have not been set for %s units.", + } else error->all(FLERR, "Pre-defined E3B parameters have not been set for {} units.", update->unit_style); - error->all(FLERR,str); - } //here parameters are defined in kJ/mol and A //they will be converted to the lammps units after if (flag==2008) { - error->all(FLERR,"\"preset 2008\" is not yet supported, because this would require distinct k3 coefficients, use \"preset 2011\" or \"preset 2015\""); + error->all(FLERR,"\"preset 2008\" is not yet supported, because this would require distinct k3 coefficients, " + "use \"preset 2011\" or \"preset 2015\""); if (lmp->citeme) lmp->citeme->add(cite_E3B1); ea = 4699.6; eb =-2152.9; @@ -630,11 +617,7 @@ double PairE3B::init_one(int i, int j) bool PairE3B::checkKeyword(const char *thiskey,const char *test,const int nVal, const int nRem) { if (strcmp(thiskey,test) == 0) { - if (nRemall(FLERR,str); - } + if (nRemall(FLERR,"Too few arguments to '{}' keyword.",test); return true; } return false;