From 5793786c0380dbc517cf47b04af5f7558bdef475 Mon Sep 17 00:00:00 2001
From: Giovanni Bussi <giovanni.bussi@gmail.com>
Date: Fri, 19 Apr 2013 11:15:13 +0200
Subject: [PATCH] Fixed VOLUME derivatives

Notice that now it is also possible to use VOLUME with NUMERICAL_DERIVATIVES
(so as to debug). I tested with NPT and a box of water and seems to work correctly.
---
 src/colvar/Volume.cpp | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/colvar/Volume.cpp b/src/colvar/Volume.cpp
index f9fd3a7d1..b022c7556 100644
--- a/src/colvar/Volume.cpp
+++ b/src/colvar/Volume.cpp
@@ -78,7 +78,7 @@ void Volume::registerKeywords( Keywords& keys ){
   Action::registerKeywords( keys );
   ActionWithValue::registerKeywords( keys );
   ActionAtomistic::registerKeywords( keys );
-  keys.remove("NUMERICAL_DERIVATIVES"); 
+//  keys.remove("NUMERICAL_DERIVATIVES"); 
   keys.addFlag("COMPONENTS",false,"use xx, yy, zz, alpha, beta, gamma as the colvars rather than the box volume");
 }
 
@@ -89,8 +89,9 @@ void Volume::calculate(){
 // todo
   };
 
-  setBoxDerivatives(-1.0*Tensor::identity());
-  setValue         (getBox().determinant());
+  double v=getBox().determinant();
+  setBoxDerivatives(-v*Tensor::identity());
+  setValue         (v);
 }
 
 }
-- 
GitLab