check equal style variable evaluation for bad values

This commit is contained in:
Axel Kohlmeyer
2024-11-15 15:12:56 -05:00
parent ec129f167e
commit 35f1fb9d6d

View File

@ -55,7 +55,7 @@ FixSpringSelf::FixSpringSelf(LAMMPS *lmp, int narg, char **arg) :
} else {
k = utils::numeric(FLERR,arg[3],false,lmp);
kstyle = CONSTANT;
if (k <= 0.0) error->all(FLERR,"Illegal force constatnt for fix spring/self command");
if (k <= 0.0) error->all(FLERR,"Illegal force constant for fix spring/self command");
}
xflag = yflag = zflag = 1;
@ -202,8 +202,11 @@ void FixSpringSelf::post_force(int /*vflag*/)
if ((kstyle == CONSTANT) || (kstyle == EQUAL)) {
// update k if equal style variable
if (kstyle == EQUAL) k = input->variable->compute_equal(kvar);
if (kstyle == EQUAL) {
k = input->variable->compute_equal(kvar);
if (k < 0.0)
error->all(FLERR,"Evaluation of {} gave bad value {} for fix spring/self", kstr, k);
}
for (int i = 0; i < nlocal; i++)
if (mask[i] & groupbit) {
domain->unmap(x[i],image[i],unwrap);