Missing factor of 2 in cos-acceleration
authorJiannan Liu <ljn917@gmail.com>
Wed, 19 Dec 2018 00:08:19 +0000 (19:08 -0500)
committerPaul Bauer <paul.bauer.q@gmail.com>
Wed, 19 Dec 2018 15:12:50 +0000 (16:12 +0100)
The bug was introduced in commit 69470fc4e9fd990eb53b22c17dc7a699c583d126

Last working version is 2016.5

Affected 2018 and 2019

Fixes #2572

Change-Id: Ibad31b0d8cec7c5f4b77a73b1fbab0ff114b50b6

docs/release-notes/2018/2018.5.rst
src/gromacs/mdlib/update.cpp

index b73325f74bad4f4b5bbc9b5008c442431fe4389a..61573df4dd3bf66cdfa03f178ea1afd3629969e5 100644 (file)
@@ -38,6 +38,14 @@ cause a slight loss of accuracy in inhomogeneous systems.
 
 :issue: `2808`
 
+Fix acceleration with ``cos-acceleration``
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+A factor of 2 was missing from the acceleration value, leading to incorrect
+results when e.g. calculating viscosities.
+
+:issue: `2572`
+
 Fixes for ``gmx`` tools
 ^^^^^^^^^^^^^^^^^^^^^^^
 
index deff9cccd30f2696a485db2031503716f98cc53b..627e0a21ff3a9db5cb1608503dcd0775b66071ce 100644 (file)
@@ -448,6 +448,8 @@ updateMDLeapfrogGeneral(int                         start,
     int  gt       = 0;
     real factorNH = 0;
 
+    real omega_Z  = 2*static_cast<real>(M_PI)/box[ZZ][ZZ];
+
     for (int n = start; n < nrend; n++)
     {
         if (cTC)
@@ -475,7 +477,7 @@ updateMDLeapfrogGeneral(int                         start,
                 rvec_sub(v[n], grpstat[ga].u, vRel);
                 break;
             case AccelerationType::cosine:
-                cosineZ = std::cos(x[n][ZZ]*static_cast<real>(M_PI)/box[ZZ][ZZ]);
+                cosineZ = std::cos(x[n][ZZ]*omega_Z);
                 vCosine = cosineZ*ekind->cosacc.vcos;
                 /* Avoid scaling the cosine profile velocity */
                 copy_rvec(v[n], vRel);