Skip to content

Commit

Permalink
check equal style variable evaluation for bad values
Browse files Browse the repository at this point in the history
  • Loading branch information
akohlmey committed Nov 15, 2024
1 parent ec129f1 commit 35f1fb9
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/fix_spring_self.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 35f1fb9

Please sign in to comment.