type fixes and error message updates

This commit is contained in:
Axel Kohlmeyer
2025-06-28 05:20:49 -04:00
parent ac7013432b
commit 7bc86899b3
6 changed files with 67 additions and 57 deletions

View File

@ -397,7 +397,7 @@ void FixPeriNeigh::setup(int /*vflag*/)
double FixPeriNeigh::memory_usage()
{
int nmax = atom->nmax;
int bytes = nmax * sizeof(int);
double bytes = nmax * sizeof(int);
bytes += (double)nmax*maxpartner * sizeof(tagint);
bytes += (double)nmax*maxpartner * sizeof(double);
if (isVES) {

View File

@ -58,14 +58,14 @@ FixQEqCTIP::FixQEqCTIP(LAMMPS *lmp, int narg, char **arg) :
iarg += 2;
} else if (strcmp(arg[iarg], "maxrepeat") == 0) {
if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "fix qeq/ctip maxrepeat", error);
maxrepeat = utils::numeric(FLERR, arg[iarg + 1], false, lmp);
maxrepeat = utils::inumeric(FLERR, arg[iarg + 1], false, lmp);
iarg += 2;
} else if (strcmp(arg[iarg], "warn") == 0) {
if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "fix qeq/ctip warn", error);
maxwarn = utils::logical(FLERR, arg[iarg + 1], false, lmp);
iarg += 2;
} else
error->all(FLERR, "Unknown fix qeq/ctip keyword: {}", arg[iarg]);
error->all(FLERR, iarg, "Unknown fix qeq/ctip keyword: {}", arg[iarg]);
}
extract_ctip();
@ -180,7 +180,8 @@ void FixQEqCTIP::init()
void FixQEqCTIP::extract_ctip()
{
Pair *pair = force->pair_match("^coul/ctip",0);
if (pair == nullptr) error->all(FLERR,"No pair style coul/ctip for fix qeq/ctip");
if (pair == nullptr)
error->all(FLERR, Error::NOLASTLINE, "No pair style coul/ctip for fix qeq/ctip");
int tmp;
chi = (double *) pair->extract("chi",tmp);
eta = (double *) pair->extract("eta",tmp);
@ -192,7 +193,8 @@ void FixQEqCTIP::extract_ctip()
omega = (double *) pair->extract("omega",tmp);
if (chi == nullptr || eta == nullptr || gamma == nullptr || zeta == nullptr ||
zcore == nullptr || qmin == nullptr || qmax == nullptr || omega == nullptr)
error->all(FLERR, "Fix qeq/ctip could not extract all params from pair style coul/ctip");
error->all(FLERR, Error::NOLASTLINE,
"Fix qeq/ctip could not extract all params from pair style coul/ctip");
}
@ -223,7 +225,7 @@ void FixQEqCTIP::pre_force(int /*vflag*/)
}
if (i > maxrepeat && comm->me == 0)
error->all(FLERR,"Fix qeq some charges not bound within the domain");
error->all(FLERR, Error::NOLASTLINE, "Fix qeq some charges not bound within the domain");
if (force->kspace) force->kspace->qsum_qsq();
}
@ -322,7 +324,8 @@ void FixQEqCTIP::compute_H()
}
if (m_fill >= H.m)
error->all(FLERR,"Fix qeq/ctip has insufficient H matrix size: m_fill={} H.m={}\n",m_fill, H.m);
error->all(FLERR, Error::NOLASTLINE,
"Fix qeq/ctip has insufficient H matrix size: m_fill={} H.m={}\n",m_fill, H.m);
}
/* ---------------------------------------------------------------------- */

View File

@ -375,15 +375,15 @@ FixBondReact::FixBondReact(LAMMPS *lmp, int narg, char **arg) :
"'rate_limit' has too few arguments");
rate_limit[0][rxn] = 1; // serves as flag for rate_limit keyword
if (strncmp(arg[iarg+1],"v_",2) == 0) read_variable_keyword(&arg[iarg+1][2],NRATE,rxn);
else rate_limit[1][rxn] = utils::numeric(FLERR,arg[iarg+1],false,lmp);
rate_limit[2][rxn] = utils::numeric(FLERR,arg[iarg+2],false,lmp);
else rate_limit[1][rxn] = utils::inumeric(FLERR,arg[iarg+1],false,lmp);
rate_limit[2][rxn] = utils::inumeric(FLERR,arg[iarg+2],false,lmp);
iarg += 3;
} else if (strcmp(arg[iarg],"stabilize_steps") == 0) {
if (stabilization_flag == 0) error->all(FLERR,"Stabilize_steps keyword "
"used without stabilization keyword");
if (iarg+2 > narg) error->all(FLERR,"Illegal fix bond/react command: "
"'stabilize_steps' has too few arguments");
limit_duration[rxn] = utils::numeric(FLERR,arg[iarg+1],false,lmp);
limit_duration[rxn] = utils::inumeric(FLERR,arg[iarg+1],false,lmp);
stabilize_steps_flag[rxn] = 1;
iarg += 2;
} else if (strcmp(arg[iarg],"custom_charges") == 0) {

View File

@ -95,10 +95,10 @@ FixQEqReaxFF::FixQEqReaxFF(LAMMPS *lmp, int narg, char **arg) :
else if (strcmp(arg[iarg],"nowarn") == 0) maxwarn = 0;
else if (strcmp(arg[iarg],"maxiter") == 0) {
if (iarg+1 > narg-1)
error->all(FLERR,"Illegal fix {} command", style);
imax = utils::numeric(FLERR,arg[iarg+1],false,lmp);
error->all(FLERR, iarg, "Illegal fix {} command", style);
imax = utils::inumeric(FLERR,arg[iarg+1],false,lmp);
iarg++;
} else error->all(FLERR,"Illegal fix {} command", style);
} else error->all(FLERR, iarg, "Illegal fix {} command", style);
iarg++;
}
shld = nullptr;
@ -187,7 +187,7 @@ void FixQEqReaxFF::post_constructor()
pertype_parameters(pertype_option);
if (dual_enabled)
error->all(FLERR,"Dual keyword only supported with fix qeq/reaxff/omp");
error->all(FLERR, Error::NOLASTLINE, "Dual keyword only supported with fix qeq/reaxff/omp");
}
/* ---------------------------------------------------------------------- */
@ -212,14 +212,15 @@ void FixQEqReaxFF::pertype_parameters(char *arg)
if (utils::strmatch(arg,"^reaxff")) {
reaxflag = 1;
Pair *pair = force->pair_match("^reaxff",0);
if (!pair) error->all(FLERR,"No reaxff pair style for fix qeq/reaxff");
if (!pair) error->all(FLERR, Error::NOLASTLINE, "No reaxff pair style for fix qeq/reaxff");
int tmp, tmp_all;
chi = (double *) pair->extract("chi",tmp);
eta = (double *) pair->extract("eta",tmp);
gamma = (double *) pair->extract("gamma",tmp);
if ((chi == nullptr) || (eta == nullptr) || (gamma == nullptr))
error->all(FLERR, "Fix qeq/reaxff could not extract all QEq parameters from pair reaxff");
error->all(FLERR, Error::NOLASTLINE,
"Fix qeq/reaxff could not extract all QEq parameters from pair reaxff");
tmp = tmp_all = 0;
for (int i = 0; i < nlocal; ++i) {
if (mask[i] & groupbit) {
@ -229,10 +230,10 @@ void FixQEqReaxFF::pertype_parameters(char *arg)
}
MPI_Allreduce(&tmp, &tmp_all, 1, MPI_INT, MPI_MAX, world);
if (tmp_all)
error->all(FLERR, "No QEq parameters for atom type {} provided by pair reaxff", tmp_all);
error->all(FLERR, Error::NOLASTLINE, "No QEq parameters for atom type {} provided by pair reaxff", tmp_all);
return;
} else if (utils::strmatch(arg,"^reax/c")) {
error->all(FLERR, "Fix qeq/reaxff keyword 'reax/c' is obsolete; please use 'reaxff'");
error->all(FLERR, Error::NOLASTLINE, "Fix qeq/reaxff keyword 'reax/c' is obsolete; please use 'reaxff'");
} else if (platform::file_is_readable(arg)) {
; // arg is readable file. will read below
} else {
@ -270,7 +271,7 @@ void FixQEqReaxFF::pertype_parameters(char *arg)
gamma[itype] = values.next_double();
}
} catch (std::exception &e) {
error->one(FLERR,e.what());
error->one(FLERR, Error::NOLASTLINE, e.what());
}
}
@ -363,7 +364,7 @@ void FixQEqReaxFF::allocate_matrix()
}
bigint m_cap_big = (bigint)MAX(m * safezone, mincap * REAX_MIN_NBRS);
if (m_cap_big > MAXSMALLINT)
error->one(FLERR,"Too many neighbors in fix {}",style);
error->one(FLERR, Error::NOLASTLINE, "Too many neighbors in fix {}",style);
m_cap = m_cap_big;
H.n = n_cap;
@ -397,10 +398,10 @@ void FixQEqReaxFF::reallocate_matrix()
void FixQEqReaxFF::init()
{
if (!atom->q_flag)
error->all(FLERR,"Fix {} requires atom attribute q", style);
error->all(FLERR, Error::NOLASTLINE, "Fix {} requires atom attribute q", style);
if (group->count(igroup) == 0)
error->all(FLERR,"Fix {} group has no atoms", style);
error->all(FLERR, Error::NOLASTLINE, "Fix {} group has no atoms", style);
// compute net charge and print warning if too large
@ -412,7 +413,7 @@ void FixQEqReaxFF::init()
MPI_Allreduce(&qsum_local,&qsum,1,MPI_DOUBLE,MPI_SUM,world);
if ((comm->me == 0) && (fabs(qsum) > QSUMSMALL))
error->warning(FLERR,"Fix {} group is not charge neutral, net charge = {:.8}" + utils::errorurl(29), style, qsum);
error->warning(FLERR, "Fix {} group is not charge neutral, net charge = {:.8}" + utils::errorurl(29), style, qsum);
// get pointer to fix efield if present. there may be at most one instance of fix efield in use.
@ -420,26 +421,26 @@ void FixQEqReaxFF::init()
auto fixes = modify->get_fix_by_style("^efield");
if (fixes.size() == 1) efield = dynamic_cast<FixEfield *>(fixes.front());
else if (fixes.size() > 1)
error->all(FLERR, "There may be only one fix efield instance used with fix {}", style);
error->all(FLERR, Error::NOLASTLINE, "There may be only one fix efield instance used with fix {}", style);
// ensure that fix efield is properly initialized before accessing its data and check some settings
if (efield) {
efield->init();
if (strcmp(update->unit_style,"real") != 0)
error->all(FLERR,"Must use unit_style real with fix {} and external fields", style);
error->all(FLERR, Error::NOLASTLINE, "Must use unit_style real with fix {} and external fields", style);
if (efield->varflag == FixEfield::ATOM && efield->pstyle != FixEfield::ATOM)
error->all(FLERR,"Atom-style external electric field requires atom-style "
"potential variable when used with fix {}", style);
error->all(FLERR, Error::NOLASTLINE, "Atom-style external electric field requires atom-style "
"potential variable when used with fix {}", style);
if (((efield->xstyle != FixEfield::CONSTANT) && domain->xperiodic) ||
((efield->ystyle != FixEfield::CONSTANT) && domain->yperiodic) ||
((efield->zstyle != FixEfield::CONSTANT) && domain->zperiodic))
error->all(FLERR,"Must not have electric field component in direction of periodic "
error->all(FLERR, Error::NOLASTLINE, "Must not have electric field component in direction of periodic "
"boundary when using charge equilibration with ReaxFF.");
if (((fabs(efield->ex) > SMALL) && domain->xperiodic) ||
((fabs(efield->ey) > SMALL) && domain->yperiodic) ||
((fabs(efield->ez) > SMALL) && domain->zperiodic))
error->all(FLERR,"Must not have electric field component in direction of periodic "
error->all(FLERR, Error::NOLASTLINE, "Must not have electric field component in direction of periodic "
"boundary when using charge equilibration with ReaxFF.");
}
@ -494,7 +495,7 @@ void FixQEqReaxFF::init_taper()
if (fabs(swa) > 0.01 && comm->me == 0)
error->warning(FLERR,"Fix qeq/reaxff has non-zero lower Taper radius cutoff");
if (swb < 0)
error->all(FLERR, "Fix qeq/reaxff has negative upper Taper radius cutoff");
error->all(FLERR, Error::NOLASTLINE, "Fix qeq/reaxff has negative upper Taper radius cutoff");
else if (swb < 5 && comm->me == 0)
error->warning(FLERR,"Fix qeq/reaxff has very low Taper radius cutoff");
@ -720,7 +721,7 @@ void FixQEqReaxFF::compute_H()
}
if (m_fill >= H.m)
error->all(FLERR,"Fix qeq/reaxff H matrix size has been exceeded: m_fill={} H.m={}\n",
error->all(FLERR, Error::NOLASTLINE, "Fix qeq/reaxff H matrix size has been exceeded: m_fill={} H.m={}\n",
m_fill, H.m);
}

View File

@ -83,10 +83,11 @@ FixQtpieReaxFF::FixQtpieReaxFF(LAMMPS *lmp, int narg, char **arg) :
maxwarn = 1;
scale = 1.0;
if ((narg < 9) || (narg > 14)) error->all(FLERR,"Illegal fix {} command", style);
if ((narg < 9) || (narg > 14))
error->all(FLERR,"Illegal fix {} command: incorrect number of parameters", style);
nevery = utils::inumeric(FLERR,arg[3],false,lmp);
if (nevery <= 0) error->all(FLERR,"Illegal fix {} command", style);
if (nevery <= 0) error->all(FLERR, 3, "Illegal fix {} command", style);
swa = utils::numeric(FLERR,arg[4],false,lmp);
swb = utils::numeric(FLERR,arg[5],false,lmp);
@ -99,15 +100,15 @@ FixQtpieReaxFF::FixQtpieReaxFF(LAMMPS *lmp, int narg, char **arg) :
if (strcmp(arg[iarg],"nowarn") == 0) maxwarn = 0;
else if (strcmp(arg[iarg],"maxiter") == 0) {
if (iarg+1 > narg-1)
error->all(FLERR,"Illegal fix {} command", style);
imax = utils::numeric(FLERR,arg[iarg+1],false,lmp);
error->all(FLERR, iarg, "Illegal fix {} command", style);
imax = utils::inumeric(FLERR,arg[iarg+1],false,lmp);
iarg++;
} else if (strcmp(arg[iarg],"scale") == 0) {
if (iarg+1 > narg-1)
error->all(FLERR,"Illegal fix {} command", style);
error->all(FLERR, iarg, "Illegal fix {} command", style);
scale = utils::numeric(FLERR,arg[iarg+1],false,lmp);
iarg++;
} else error->all(FLERR,"Illegal fix {} command", style);
} else error->all(FLERR, iarg, "Illegal fix {} command", style);
iarg++;
}
shld = nullptr;
@ -252,7 +253,7 @@ void FixQtpieReaxFF::pertype_parameters(char *arg)
}
fclose(fp);
} catch (std::exception &e) {
error->one(FLERR,e.what());
error->one(FLERR, Error::NOLASTLINE, e.what());
}
}
@ -269,14 +270,15 @@ void FixQtpieReaxFF::pertype_parameters(char *arg)
if (utils::strmatch(arg,"^reaxff")) {
reaxflag = 1;
Pair *pair = force->pair_match("^reaxff",0);
if (!pair) error->all(FLERR,"No reaxff pair style for fix qtpie/reaxff");
if (!pair) error->all(FLERR, Error::NOLASTLINE, "No reaxff pair style for fix qtpie/reaxff");
int tmp, tmp_all;
chi = (double *) pair->extract("chi",tmp);
eta = (double *) pair->extract("eta",tmp);
gamma = (double *) pair->extract("gamma",tmp);
if ((chi == nullptr) || (eta == nullptr) || (gamma == nullptr))
error->all(FLERR, "Fix qtpie/reaxff could not extract qtpie parameters from pair reaxff");
error->all(FLERR, Error::NOLASTLINE,
"Fix qtpie/reaxff could not extract qtpie parameters from pair reaxff");
tmp = tmp_all = 0;
for (int i = 0; i < nlocal; ++i) {
if (mask[i] & groupbit) {
@ -286,10 +288,12 @@ void FixQtpieReaxFF::pertype_parameters(char *arg)
}
MPI_Allreduce(&tmp, &tmp_all, 1, MPI_INT, MPI_MAX, world);
if (tmp_all)
error->all(FLERR, "No qtpie parameters for atom type {} provided by pair reaxff", tmp_all);
error->all(FLERR, Error::NOLASTLINE,
"No qtpie parameters for atom type {} provided by pair reaxff", tmp_all);
return;
} else if (utils::strmatch(arg,"^reax/c")) {
error->all(FLERR, "Fix qtpie/reaxff keyword 'reax/c' is obsolete; please use 'reaxff'");
error->all(FLERR, Error::NOLASTLINE,
"Fix qtpie/reaxff keyword 'reax/c' is obsolete; please use 'reaxff'");
} else if (platform::file_is_readable(arg)) {
; // arg is readable file. will read below
} else {
@ -416,9 +420,9 @@ void FixQtpieReaxFF::allocate_matrix()
i = ilist[ii];
m += numneigh[i];
}
bigint m_cap_big = (bigint)MAX(m * safezone, mincap * REAX_MIN_NBRS);
auto m_cap_big = (bigint)MAX(m * safezone, mincap * REAX_MIN_NBRS);
if (m_cap_big > MAXSMALLINT)
error->one(FLERR,"Too many neighbors in fix {}",style);
error->one(FLERR, Error::NOLASTLINE, "Too many neighbors in fix {}",style);
m_cap = m_cap_big;
H.n = n_cap;
@ -452,10 +456,10 @@ void FixQtpieReaxFF::reallocate_matrix()
void FixQtpieReaxFF::init()
{
if (!atom->q_flag)
error->all(FLERR,"Fix {} requires atom attribute q", style);
error->all(FLERR, Error::NOLASTLINE, "Fix {} requires atom attribute q", style);
if (group->count(igroup) == 0)
error->all(FLERR,"Fix {} group has no atoms", style);
error->all(FLERR, Error::NOLASTLINE, "Fix {} group has no atoms", style);
// compute net charge and print warning if too large
double qsum_local = 0.0, qsum = 0.0;
@ -473,25 +477,26 @@ void FixQtpieReaxFF::init()
auto fixes = modify->get_fix_by_style("^efield");
if (fixes.size() == 1) efield = dynamic_cast<FixEfield *>(fixes.front());
else if (fixes.size() > 1)
error->all(FLERR, "There may be only one fix efield instance used with fix {}", style);
error->all(FLERR, Error::NOLASTLINE,
"There may be only one fix efield instance used with fix {}", style);
// ensure that fix efield is properly initialized before accessing its data and check some settings
if (efield) {
efield->init();
if (strcmp(update->unit_style,"real") != 0)
error->all(FLERR,"Must use unit_style real with fix {} and external fields", style);
error->all(FLERR, Error::NOLASTLINE, "Must use unit_style real with fix {} and external fields", style);
if (efield->groupbit != 1){ // if efield is not applied to all atoms
error->all(FLERR,"Must use group id all for fix efield when using fix {}", style);
error->all(FLERR, Error::NOLASTLINE, "Must use group id all for fix efield when using fix {}", style);
}
if (efield->region){ // if efield is not applied to all atoms
error->all(FLERR,"Keyword region not supported for fix efield when using fix {}", style);
error->all(FLERR, Error::NOLASTLINE, "Keyword region not supported for fix efield when using fix {}", style);
}
if (efield->varflag == FixEfield::ATOM && efield->pstyle != FixEfield::ATOM)
error->all(FLERR,"Atom-style external electric field requires atom-style "
"potential variable when used with fix {}", style);
error->all(FLERR, Error::NOLASTLINE, "Atom-style external electric field requires atom-style "
"potential variable when used with fix {}", style);
} else {
if (utils::strmatch(style,"^qeq/rel/reax") && comm->me == 0)
error->warning(FLERR, "Use fix qeq/reaxff instead of fix {} when not using fix efield\n",
@ -551,9 +556,9 @@ void FixQtpieReaxFF::init_taper()
if (fabs(swa) > 0.01 && comm->me == 0)
error->warning(FLERR,"Fix qtpie/reaxff has non-zero lower Taper radius cutoff");
if (swb < 0)
error->all(FLERR, "Fix qtpie/reaxff has negative upper Taper radius cutoff");
error->all(FLERR, Error::NOLASTLINE, "Fix qtpie/reaxff has negative upper Taper radius cutoff");
else if (swb < 5 && comm->me == 0)
error->warning(FLERR,"Fix qtpie/reaxff has very low Taper radius cutoff");
error->warning(FLERR, "Fix qtpie/reaxff has very low Taper radius cutoff");
d7 = pow(swb - swa, 7);
swa2 = SQR(swa);
@ -804,7 +809,8 @@ void FixQtpieReaxFF::compute_H()
}
if (m_fill >= H.m)
error->all(FLERR,"Fix qtpie/reaxff H matrix size has been exceeded: m_fill={} H.m={}\n",
error->all(FLERR, Error::NOLASTLINE,
"Fix qtpie/reaxff H matrix size has been exceeded: m_fill={} H.m={}\n",
m_fill, H.m);
}
@ -1158,7 +1164,7 @@ void FixQtpieReaxFF::calc_chi_eff()
{
memset(&chi_eff[0],0,atom->nmax*sizeof(double));
const auto x = (const double * const *)atom->x;
const auto *const x = (const double * const *)atom->x;
const int *type = atom->type;
double dx,dy,dz,dist_sq,overlap,sum_n,sum_d,chia,chib,phia,phib;

View File

@ -175,7 +175,7 @@ void Timer::print_timeout(FILE *fp)
// time since init_timeout()
const double d = platform::walltime() - timeout_start;
// remaining timeout in seconds
int s = _timeout - d;
int s = (int) (_timeout - d);
// remaining 1/100ths of seconds
const int hs = 100 * ((_timeout - d) - s);
// breaking s down into second/minutes/hours