From ef4e0d163a2060400bcdbbfe81d6a58519f2e223 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 13 Jun 2016 16:07:51 -0400 Subject: [PATCH] can only set respa_level for fix if r-RESPA active. fix off-by-one error --- src/fix_setforce.cpp | 8 +++++++- src/fix_spring_self.cpp | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/fix_setforce.cpp b/src/fix_setforce.cpp index 8152343f4b..90ade71ed7 100644 --- a/src/fix_setforce.cpp +++ b/src/fix_setforce.cpp @@ -133,10 +133,16 @@ int FixSetForce::modify_param(int narg, char **arg) { if (strcmp(arg[0],"respa_level") == 0) { if (narg < 2) error->all(FLERR,"Illegal fix_modify command"); + + if (strstr(update->integrate_style,"respa")) + nlevels_respa = ((Respa *) update->integrate)->nlevels; + else + error->all(FLERR,"Trying to set r-RESPA level without using r-RESPA"); + int lvl = force->inumeric(FLERR,arg[1]); if ((lvl < -1) || (lvl == 0) || lvl > (nlevels_respa)) error->all(FLERR,"Illegal fix_modify command"); - respa_level = lvl; + respa_level = lvl-1; return 2; } return 0; diff --git a/src/fix_spring_self.cpp b/src/fix_spring_self.cpp index 281287f84f..a6e9e42c64 100644 --- a/src/fix_spring_self.cpp +++ b/src/fix_spring_self.cpp @@ -120,10 +120,16 @@ int FixSpringSelf::modify_param(int narg, char **arg) { if (strcmp(arg[0],"respa_level") == 0) { if (narg < 2) error->all(FLERR,"Illegal fix_modify command"); + + if (strstr(update->integrate_style,"respa")) + nlevels_respa = ((Respa *) update->integrate)->nlevels; + else + error->all(FLERR,"Trying to set r-RESPA level without using r-RESPA"); + int lvl = force->inumeric(FLERR,arg[1]); if ((lvl < -1) || (lvl == 0) || lvl > (nlevels_respa)) error->all(FLERR,"Illegal fix_modify command"); - respa_level = lvl; + respa_level = lvl-1; return 2; } return 0;