From e3b414314e1495eba7704ad071d4fd3c28a9033f Mon Sep 17 00:00:00 2001
From: Giovanni Bussi <giovanni.bussi@gmail.com>
Date: Wed, 27 Jan 2016 22:05:33 +0100
Subject: [PATCH] Better regtest

---
 regtest/basic/rt-make-7/COLVAR.reference |  9 +++++
 regtest/basic/rt-make-7/H1.reference     | 11 +++++++
 regtest/basic/rt-make-7/H2.reference     |  6 ++++
 regtest/basic/rt-make-7/main.cpp         | 42 +++++++++++++++++-------
 regtest/basic/rt-make-7/output.reference | 20 +++++++++++
 regtest/basic/rt-make-7/plumed.dat       |  3 ++
 6 files changed, 79 insertions(+), 12 deletions(-)
 create mode 100644 regtest/basic/rt-make-7/H1.reference
 create mode 100644 regtest/basic/rt-make-7/H2.reference
 create mode 100644 regtest/basic/rt-make-7/output.reference
 create mode 100644 regtest/basic/rt-make-7/plumed.dat

diff --git a/regtest/basic/rt-make-7/COLVAR.reference b/regtest/basic/rt-make-7/COLVAR.reference
index 298bd6e7b..2ada8659c 100644
--- a/regtest/basic/rt-make-7/COLVAR.reference
+++ b/regtest/basic/rt-make-7/COLVAR.reference
@@ -1,2 +1,11 @@
 #! FIELDS time d d1
  0.000000 5.196152 5.196152
+ 0.000000 5.196152 5.196152
+ 0.000000 5.196152 5.196152
+ 0.000000 5.196152 5.196152
+ 0.000000 5.196152 5.196152
+ 0.000000 5.196152 5.196152
+ 0.000000 5.196152 5.196152
+ 0.000000 5.196152 5.196152
+ 0.000000 5.196152 5.196152
+ 0.000000 5.196152 5.196152
diff --git a/regtest/basic/rt-make-7/H1.reference b/regtest/basic/rt-make-7/H1.reference
new file mode 100644
index 000000000..3455e864a
--- /dev/null
+++ b/regtest/basic/rt-make-7/H1.reference
@@ -0,0 +1,11 @@
+#! FIELDS time d sigma_d height biasf
+#! SET multivariate false
+                      0      5.196152422706632                      1                      0                      1
+                      0      5.196152422706632                      1                      0                      1
+                      0      5.196152422706632                      1                      0                      1
+                      0      5.196152422706632                      1                      0                      1
+                      0      5.196152422706632                      1                      0                      1
+                      0      5.196152422706632                      1                      0                      1
+                      0      5.196152422706632                      1                      0                      1
+                      0      5.196152422706632                      1                      0                      1
+                      0      5.196152422706632                      1                      0                      1
diff --git a/regtest/basic/rt-make-7/H2.reference b/regtest/basic/rt-make-7/H2.reference
new file mode 100644
index 000000000..e31d41c65
--- /dev/null
+++ b/regtest/basic/rt-make-7/H2.reference
@@ -0,0 +1,6 @@
+#! FIELDS time d sigma_d height biasf
+#! SET multivariate false
+                      0      5.196152422706632                      1                      0                      1
+                      0      5.196152422706632                      1                      0                      1
+                      0      5.196152422706632                      1                      0                      1
+                      0      5.196152422706632                      1                      0                      1
diff --git a/regtest/basic/rt-make-7/main.cpp b/regtest/basic/rt-make-7/main.cpp
index 46fcf0b95..d39d7b4b3 100644
--- a/regtest/basic/rt-make-7/main.cpp
+++ b/regtest/basic/rt-make-7/main.cpp
@@ -1,5 +1,6 @@
 #include "plumed/wrapper/Plumed.h"
 #include <vector>
+#include <fstream>
 
 using namespace PLMD;
 
@@ -21,18 +22,35 @@ int main(){
   plumed->cmd("readInputLine","d: DISTANCE ATOMS=1,2");
   plumed->cmd("readInputLine","d1: DISTANCE ATOMS={1 2}"); // check if braces are parsed correctly
   plumed->cmd("readInputLine","PRINT ARG=d,d1 FILE=COLVAR");
-  plumed->cmd("readInputLine","METAD ARG=d PACE=1 SIGMA=1 HEIGHT=1 FILE=H1");
-  plumed->cmd("readInputLine","METAD ARG=d PACE=1 SIGMA=1 HEIGHT=1 FILE=H2");
-
-
-  int step=1;
-  plumed->cmd("setStep",&step);
-  plumed->cmd("setPositions",&positions[0]);
-  plumed->cmd("setBox",&box[0]);
-  plumed->cmd("setForces",&forces[0]);
-  plumed->cmd("setVirial",&virial[0]);
-  plumed->cmd("setMasses",&masses[0]);
-  plumed->cmd("calc");
+  plumed->cmd("readInputLine","RESTRAINT ARG=d AT=0 KAPPA=1");
+  plumed->cmd("readInputLine","METAD ARG=d PACE=1 SIGMA=1 HEIGHT=0 FILE=H1");
+  plumed->cmd("readInputLine","METAD ARG=d PACE=2 SIGMA=1 HEIGHT=0 FILE=H2");
+
+  std::ofstream ofs("output");
+
+  for(int step=0;step<10;step++){
+    plumed->cmd("setStep",&step);
+    plumed->cmd("setPositions",&positions[0]);
+    plumed->cmd("setBox",&box[0]);
+    plumed->cmd("setForces",&forces[0]);
+    plumed->cmd("setVirial",&virial[0]);
+    plumed->cmd("setMasses",&masses[0]);
+// first compute using modified positions:
+    positions[0]=0.5;
+    plumed->cmd("prepareCalc");
+    plumed->cmd("performCalcNoUpdate");
+    positions[0]=0;
+    double bias;
+    plumed->cmd("getBias",&bias);
+    ofs<<bias<<"\n";
+// first compute using regular positions:
+    plumed->cmd("prepareCalc");
+    plumed->cmd("performCalcNoUpdate");
+    plumed->cmd("getBias",&bias);
+    ofs<<bias<<"\n";
+// hills should only be added at regular positions:
+    plumed->cmd("update");
+  }
 
   delete plumed;
   return 0;
diff --git a/regtest/basic/rt-make-7/output.reference b/regtest/basic/rt-make-7/output.reference
new file mode 100644
index 000000000..9711af092
--- /dev/null
+++ b/regtest/basic/rt-make-7/output.reference
@@ -0,0 +1,20 @@
+12.125
+13.5
+12.125
+13.5
+12.125
+13.5
+12.125
+13.5
+12.125
+13.5
+12.125
+13.5
+12.125
+13.5
+12.125
+13.5
+12.125
+13.5
+12.125
+13.5
diff --git a/regtest/basic/rt-make-7/plumed.dat b/regtest/basic/rt-make-7/plumed.dat
new file mode 100644
index 000000000..28977ccf0
--- /dev/null
+++ b/regtest/basic/rt-make-7/plumed.dat
@@ -0,0 +1,3 @@
+THIS IS A CRAPPY INPUT
+
+USED HERE TO BE SURE THAT PLUMED DOES NOT READ IT BY DEFAULT
-- 
GitLab