From 78d27e991873afd8d40605fc2e41b4885d96c8dc Mon Sep 17 00:00:00 2001 From: Daniele Date: Wed, 9 Oct 2024 14:52:06 +0200 Subject: [PATCH] FIX-2.9 Now the forces from LWALLS should be correct (#1111) * Now the forces from LWALLS should be correct (and maybe also the energies) * now the documentation reflects the code better --- src/bias/LWalls.cpp | 8 +++++++- src/bias/UWalls.cpp | 6 ++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/bias/LWalls.cpp b/src/bias/LWalls.cpp index 5e6834234a..dc39572687 100644 --- a/src/bias/LWalls.cpp +++ b/src/bias/LWalls.cpp @@ -35,10 +35,16 @@ The restraining potential starts acting on the system when the value of the CV i minus an offset \f$o_i\f$ (OFFSET). The expression for the bias due to the wall is given by: +for UPPER_WALLS: \f$ \sum_i {k_i}((x_i-a_i+o_i)/s_i)^e_i \f$ +for LOWER_WALLS: +\f$ + \sum_i {k_i}|(x_i-a_i-o_i)/s_i|^e_i +\f$ + \f$k_i\f$ (KAPPA) is an energy constant in internal unit of the code, \f$s_i\f$ (EPS) a rescaling factor and \f$e_i\f$ (EXP) the exponent determining the power law. By default: EXP = 2, EPS = 1.0, OFFSET = 0. @@ -133,7 +139,7 @@ void LWalls::calculate() { if( lscale < 0.) { const double k=kappa[i]; const double exponent=exp[i]; - double power = std::pow( lscale, exponent ); + double power = std::pow( -lscale, exponent ); f = -( k / epsilon ) * exponent * power / lscale; ene += k * power; totf2 += f * f; diff --git a/src/bias/UWalls.cpp b/src/bias/UWalls.cpp index 0abc063f9e..357b1c3b5a 100644 --- a/src/bias/UWalls.cpp +++ b/src/bias/UWalls.cpp @@ -35,10 +35,16 @@ The restraining potential starts acting on the system when the value of the CV i minus an offset \f$o_i\f$ (OFFSET). The expression for the bias due to the wall is given by: +for UPPER_WALLS: \f$ \sum_i {k_i}((x_i-a_i+o_i)/s_i)^e_i \f$ +for LOWER_WALLS: +\f$ + \sum_i {k_i}|(x_i-a_i-o_i)/s_i|^e_i +\f$ + \f$k_i\f$ (KAPPA) is an energy constant in internal unit of the code, \f$s_i\f$ (EPS) a rescaling factor and \f$e_i\f$ (EXP) the exponent determining the power law. By default: EXP = 2, EPS = 1.0, OFFSET = 0.