use utils::numeric() instead of atof(), improve error messages

This commit is contained in:
Axel Kohlmeyer
2022-12-09 16:29:32 -05:00
parent f6d6e1ef01
commit f24cb96517
4 changed files with 8 additions and 10 deletions

View File

@ -43,8 +43,7 @@ using namespace FixConst;
FixSMDTlsphDtReset::FixSMDTlsphDtReset(LAMMPS *lmp, int narg, char **arg) :
Fix(lmp, narg, arg) {
if (narg != 4)
error->all(FLERR, "Illegal fix smd/adjust_dt command");
if (narg != 4) error->all(FLERR, "Illegal fix smd/adjust_dt command");
// set time_depend, else elapsed time accumulation can be messed up
@ -57,7 +56,7 @@ FixSMDTlsphDtReset::FixSMDTlsphDtReset(LAMMPS *lmp, int narg, char **arg) :
extvector = 0;
restart_global = 1; // this fix stores global (i.e., not per-atom) info: elaspsed time
safety_factor = atof(arg[3]);
safety_factor = utils::numeric(FLERR,arg[3],false,lmp);
// initializations
t_elapsed = 0.0;

View File

@ -263,7 +263,7 @@ void PairHertz::coeff(int narg, char **arg) {
utils::bounds(FLERR,arg[0], 1, atom->ntypes, ilo, ihi, error);
utils::bounds(FLERR,arg[1], 1, atom->ntypes, jlo, jhi, error);
double bulkmodulus_one = atof(arg[2]);
double bulkmodulus_one = utils::numeric(FLERR,arg[2],false,lmp);
// set short-range force constant
double kn_one = 0.0;

View File

@ -345,7 +345,7 @@ void PairTriSurf::coeff(int narg, char **arg) {
utils::bounds(FLERR,arg[0], 1,atom->ntypes, ilo, ihi, error);
utils::bounds(FLERR,arg[1], 1,atom->ntypes, jlo, jhi, error);
double bulkmodulus_one = atof(arg[2]);
double bulkmodulus_one = utils::numeric(FLERR,arg[2],false,lmp);
// set short-range force constant
double kn_one = 0.0;

View File

@ -45,7 +45,7 @@ using namespace MathConst;
FixQBMSST::FixQBMSST(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg)
{
if (narg < 5) error->all(FLERR,"Illegal fix qbmsst command");
if (narg < 5) utils::missing_cmd_args(FLERR,"fix qbmsst",error);
if (strcmp(arg[3],"x") == 0) {
direction = 0;
@ -57,11 +57,10 @@ FixQBMSST::FixQBMSST(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg)
direction = 2;
box_change |= BOX_CHANGE_Z;
} else {
error->all(FLERR,"Illegal fix qbmsst command");
error->all(FLERR,"Unknown fix qbmsst direction keyword: {}", arg[3]);
}
velocity = atof(arg[4]);
if (velocity < 0)
error->all(FLERR,"Illegal fix qbmsst command");
velocity = utils::numeric(FLERR,arg[4],false,lmp);
if (velocity < 0) error->all(FLERR,"Illegal fix qbmsst velocity value {}", velocity);
// default parameters