From 26d22a4b7a54168ccf11211131c72d4848202bc5 Mon Sep 17 00:00:00 2001
From: Axel Kohlmeyer <akohlmey@gmail.com>
Date: Thu, 26 Apr 2018 10:02:42 -0400
Subject: [PATCH] restrain energy must be incremented. bugfix from robert
 meissner posted to lammps-users

---
 src/fix_restrain.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/fix_restrain.cpp b/src/fix_restrain.cpp
index af11136d78..a949d1f6d5 100644
--- a/src/fix_restrain.cpp
+++ b/src/fix_restrain.cpp
@@ -261,7 +261,7 @@ void FixRestrain::restrain_bond(int m)
   if (r > 0.0) fbond = -2.0*rk/r;
   else fbond = 0.0;
 
-  energy = rk*dr;
+  energy += rk*dr;
 
   // apply force to each of 2 atoms
 
@@ -368,7 +368,7 @@ void FixRestrain::restrain_angle(int m)
   dtheta = acos(c) - target[m];
   tk = k * dtheta;
 
-  energy = tk*dtheta;
+  energy += tk*dtheta;
 
   a = -2.0 * tk * s;
   a11 = a*c / rsq1;
@@ -549,7 +549,7 @@ void FixRestrain::restrain_dihedral(int m)
   df1 *= -mult;
   p += 1.0;
 
-  energy = k * p;
+  energy += k * p;
 
   fg = vb1x*vb2xm + vb1y*vb2ym + vb1z*vb2zm;
   hg = vb3x*vb2xm + vb3y*vb2ym + vb3z*vb2zm;
-- 
GitLab