diff --git a/src/read_dump.cpp b/src/read_dump.cpp index 82f5c969df..3002eaffc3 100644 --- a/src/read_dump.cpp +++ b/src/read_dump.cpp @@ -1217,27 +1217,19 @@ int ReadDump::fields_and_keywords(int narg, char **arg) iarg += 2; } else if (strcmp(arg[iarg],"box") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal read_dump command"); - if (strcmp(arg[iarg+1],"yes") == 0) boxflag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) boxflag = 0; - else error->all(FLERR,"Illegal read_dump command"); + boxflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"replace") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal read_dump command"); - if (strcmp(arg[iarg+1],"yes") == 0) replaceflag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) replaceflag = 0; - else error->all(FLERR,"Illegal read_dump command"); + replaceflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"purge") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal read_dump command"); - if (strcmp(arg[iarg+1],"yes") == 0) purgeflag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) purgeflag = 0; - else error->all(FLERR,"Illegal read_dump command"); + purgeflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"trim") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal read_dump command"); - if (strcmp(arg[iarg+1],"yes") == 0) trimflag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) trimflag = 0; - else error->all(FLERR,"Illegal read_dump command"); + trimflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"add") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal read_dump command"); @@ -1257,15 +1249,11 @@ int ReadDump::fields_and_keywords(int narg, char **arg) iarg += 3; } else if (strcmp(arg[iarg],"scaled") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal read_dump command"); - if (strcmp(arg[iarg+1],"yes") == 0) scaleflag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) scaleflag = 0; - else error->all(FLERR,"Illegal read_dump command"); + scaleflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"wrapped") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal read_dump command"); - if (strcmp(arg[iarg+1],"yes") == 0) wrapflag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) wrapflag = 0; - else error->all(FLERR,"Illegal read_dump command"); + wrapflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"format") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal read_dump command"); diff --git a/src/rerun.cpp b/src/rerun.cpp index f9bb507a11..ce21fbc2b8 100644 --- a/src/rerun.cpp +++ b/src/rerun.cpp @@ -106,11 +106,7 @@ void Rerun::command(int narg, char **arg) iarg += 2; } else if (strcmp(arg[iarg],"post") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal rerun command"); - if (strcmp(arg[iarg+1],"yes") == 0) { - postflag = 1; - } else if (strcmp(arg[iarg+1],"no") == 0) { - postflag = 0; - } else error->all(FLERR,"Illegal rerun command"); + postflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"dump") == 0) { break; diff --git a/src/reset_atom_ids.cpp b/src/reset_atom_ids.cpp index 3aea800b6f..822490ffc8 100644 --- a/src/reset_atom_ids.cpp +++ b/src/reset_atom_ids.cpp @@ -69,9 +69,7 @@ void ResetIDs::command(int narg, char **arg) while (iarg < narg) { if (strcmp(arg[iarg],"sort") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal reset_atom_ids command"); - if (strcmp(arg[iarg+1],"yes") == 0) sortflag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) sortflag = 0; - else error->all(FLERR,"Illegal reset_atom_ids command"); + sortflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else error->all(FLERR,"Illegal reset_atom_ids command"); } diff --git a/src/reset_mol_ids.cpp b/src/reset_mol_ids.cpp index cf5bcdec6e..ff3602a745 100644 --- a/src/reset_mol_ids.cpp +++ b/src/reset_mol_ids.cpp @@ -77,15 +77,11 @@ void ResetMolIDs::command(int narg, char **arg) while (iarg < narg) { if (strcmp(arg[iarg],"compress") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal reset_mol_ids command"); - if (strcmp(arg[iarg+1],"yes") == 0) compressflag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) compressflag = 0; - else error->all(FLERR,"Illegal reset_mol_ids command"); + compressflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"single") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal reset_mol_ids command"); - if (strcmp(arg[iarg+1],"yes") == 0) singleflag = 1; - else if (strcmp(arg[iarg+1],"no") == 0) singleflag = 0; - else error->all(FLERR,"Illegal reset_mol_ids command"); + singleflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"offset") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal reset_mol_ids command"); diff --git a/src/run.cpp b/src/run.cpp index 2d8b4816a4..a026580c83 100644 --- a/src/run.cpp +++ b/src/run.cpp @@ -77,15 +77,11 @@ void Run::command(int narg, char **arg) iarg += 2; } else if (strcmp(arg[iarg],"pre") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal run command"); - if (strcmp(arg[iarg+1],"no") == 0) preflag = 0; - else if (strcmp(arg[iarg+1],"yes") == 0) preflag = 1; - else error->all(FLERR,"Illegal run command"); + preflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"post") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal run command"); - if (strcmp(arg[iarg+1],"no") == 0) postflag = 0; - else if (strcmp(arg[iarg+1],"yes") == 0) postflag = 1; - else error->all(FLERR,"Illegal run command"); + postflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; // all remaining args are commands diff --git a/src/thermo.cpp b/src/thermo.cpp index eaf208c2eb..434012870b 100644 --- a/src/thermo.cpp +++ b/src/thermo.cpp @@ -556,16 +556,12 @@ void Thermo::modify_params(int narg, char **arg) } else if (strcmp(arg[iarg],"norm") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal thermo_modify command"); normuserflag = 1; - if (strcmp(arg[iarg+1],"no") == 0) normuser = 0; - else if (strcmp(arg[iarg+1],"yes") == 0) normuser = 1; - else error->all(FLERR,"Illegal thermo_modify command"); + normuser = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"flush") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal thermo_modify command"); - if (strcmp(arg[iarg+1],"no") == 0) flushflag = 0; - else if (strcmp(arg[iarg+1],"yes") == 0) flushflag = 1; - else error->all(FLERR,"Illegal thermo_modify command"); + flushflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"line") == 0) { diff --git a/src/velocity.cpp b/src/velocity.cpp index fa09f451df..c151691b38 100644 --- a/src/velocity.cpp +++ b/src/velocity.cpp @@ -36,6 +36,7 @@ using namespace LAMMPS_NS; enum{CREATE,SET,SCALE,RAMP,ZERO}; enum{ALL,LOCAL,GEOM}; +enum{UNIFORM,GAUSSIAN}; enum{NONE,CONSTANT,EQUAL,ATOM}; #define WARMUP 100 @@ -84,7 +85,7 @@ void Velocity::command(int narg, char **arg) // set defaults temperature = nullptr; - dist_flag = 0; + dist_flag = UNIFORM; sum_flag = 0; momentum_flag = 1; rotation_flag = 0; @@ -149,11 +150,12 @@ void Velocity::init_external(const char *extgroup) groupbit = group->bitmask[igroup]; temperature = nullptr; - dist_flag = 0; + dist_flag = UNIFORM; sum_flag = 0; momentum_flag = 1; rotation_flag = 0; loop_flag = ALL; + rfix = -1; scale_flag = 1; bias_flag = 0; } @@ -275,11 +277,11 @@ void Velocity::create(double t_desired, int seed) int natoms = static_cast (atom->natoms); for (i = 1; i <= natoms; i++) { - if (dist_flag == 0) { + if (dist_flag == UNIFORM) { vx = random->uniform() - 0.5; vy = random->uniform() - 0.5; vz = random->uniform() - 0.5; - } else { + } else { // GAUSSIAN vx = random->gaussian(); vy = random->gaussian(); vz = random->gaussian(); @@ -310,11 +312,11 @@ void Velocity::create(double t_desired, int seed) for (i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { - if (dist_flag == 0) { + if (dist_flag == UNIFORM) { vx = random->uniform() - 0.5; vy = random->uniform() - 0.5; vz = random->uniform() - 0.5; - } else { + } else { // GAUSSIAN vx = random->gaussian(); vy = random->gaussian(); vz = random->gaussian(); @@ -335,11 +337,11 @@ void Velocity::create(double t_desired, int seed) for (i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { random->reset(seed,x[i]); - if (dist_flag == 0) { + if (dist_flag == UNIFORM) { vx = random->uniform() - 0.5; vy = random->uniform() - 0.5; vz = random->uniform() - 0.5; - } else { + } else { // GAUSSIAN vx = random->gaussian(); vy = random->gaussian(); vz = random->gaussian(); @@ -824,27 +826,21 @@ void Velocity::options(int narg, char **arg) while (iarg < narg) { if (strcmp(arg[iarg],"dist") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal velocity command"); - if (strcmp(arg[iarg+1],"uniform") == 0) dist_flag = 0; - else if (strcmp(arg[iarg+1],"gaussian") == 0) dist_flag = 1; + if (strcmp(arg[iarg+1],"uniform") == 0) dist_flag = UNIFORM; + else if (strcmp(arg[iarg+1],"gaussian") == 0) dist_flag = GAUSSIAN; else error->all(FLERR,"Illegal velocity command"); iarg += 2; } else if (strcmp(arg[iarg],"sum") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal velocity command"); - if (strcmp(arg[iarg+1],"no") == 0) sum_flag = 0; - else if (strcmp(arg[iarg+1],"yes") == 0) sum_flag = 1; - else error->all(FLERR,"Illegal velocity command"); + sum_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"mom") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal velocity command"); - if (strcmp(arg[iarg+1],"no") == 0) momentum_flag = 0; - else if (strcmp(arg[iarg+1],"yes") == 0) momentum_flag = 1; - else error->all(FLERR,"Illegal velocity command"); + momentum_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"rot") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal velocity command"); - if (strcmp(arg[iarg+1],"no") == 0) rotation_flag = 0; - else if (strcmp(arg[iarg+1],"yes") == 0) rotation_flag = 1; - else error->all(FLERR,"Illegal velocity command"); + rotation_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"temp") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal velocity command"); @@ -856,9 +852,7 @@ void Velocity::options(int narg, char **arg) iarg += 2; } else if (strcmp(arg[iarg],"bias") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal velocity command"); - if (strcmp(arg[iarg+1],"no") == 0) bias_flag = 0; - else if (strcmp(arg[iarg+1],"yes") == 0) bias_flag = 1; - else error->all(FLERR,"Illegal velocity command"); + bias_flag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; } else if (strcmp(arg[iarg],"loop") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal velocity command");