diff --git a/regtest/mapping/rt-adapt/Makefile b/regtest/mapping/rt-adapt/Makefile
new file mode 100755
index 0000000000000000000000000000000000000000..3703b27cea227aa053fb6d1d73f861e4384dbcee
--- /dev/null
+++ b/regtest/mapping/rt-adapt/Makefile
@@ -0,0 +1 @@
+include ../../scripts/test.make
diff --git a/regtest/mapping/rt-adapt/colvar.reference b/regtest/mapping/rt-adapt/colvar.reference
new file mode 100644
index 0000000000000000000000000000000000000000..e7bc2309e32399e14338736fe6e1068535d83754
--- /dev/null
+++ b/regtest/mapping/rt-adapt/colvar.reference
@@ -0,0 +1,102 @@
+#! FIELDS time d1.x d1.y pp.gspath pp.gzpath
+ 0.000000   0.0000   0.0000   0.1980   0.4534
+ 1.000000  -0.0017  -0.0004   0.1984   0.4550
+ 2.000000  -0.0031  -0.0003   0.1989   0.4560
+ 3.000000  -0.0042   0.0004   0.1995   0.4563
+ 4.000000  -0.0051   0.0012   0.2001   0.4565
+ 5.000000  -0.0070   0.0023   0.2011   0.4572
+ 6.000000  -0.0085   0.0038   0.2022   0.4574
+ 7.000000  -0.0100   0.0052   0.2033   0.4576
+ 8.000000  -0.0111   0.0068   0.2042   0.4573
+ 9.000000  -0.0128   0.0080   0.2052   0.4579
+ 10.000000  -0.0139   0.0097   0.2063   0.4576
+ 11.000000  -0.0137   0.0117   0.2069   0.4561
+ 12.000000  -0.0129   0.0138   0.2075   0.4542
+ 13.000000  -0.0116   0.0155   0.2077   0.4520
+ 14.000000  -0.0099   0.0177   0.2080   0.4493
+ 15.000000  -0.0081   0.0199   0.2082   0.4465
+ 16.000000  -0.0058   0.0223   0.2084   0.4432
+ 17.000000  -0.0036   0.0243   0.2084   0.4402
+ 18.000000  -0.0015   0.0261   0.2084   0.4374
+ 19.000000   0.0000   0.0273   0.2084   0.4355
+ 20.000000   0.0026   0.0283   0.2079   0.4329
+ 21.000000   0.0052   0.0291   0.2073   0.4304
+ 22.000000   0.0084   0.0300   0.2066   0.4274
+ 23.000000   0.0122   0.0311   0.2058   0.4238
+ 24.000000   0.0160   0.0326   0.2051   0.4200
+ 25.000000   0.0203   0.0344   0.2044   0.4155
+ 26.000000   0.0248   0.0362   0.2035   0.4109
+ 27.000000   0.0294   0.0384   0.2029   0.4060
+ 28.000000   0.0340   0.0411   0.2024   0.4009
+ 29.000000   0.0379   0.0443   0.2023   0.3957
+ 30.000000   0.0422   0.0482   0.2024   0.3900
+ 31.000000   0.0467   0.0519   0.2023   0.3841
+ 32.000000   0.0514   0.0559   0.2023   0.3779
+ 33.000000   0.0566   0.0598   0.2021   0.3715
+ 34.000000   0.0614   0.0636   0.2019   0.3654
+ 35.000000   0.0665   0.0672   0.2016   0.3592
+ 36.000000   0.0713   0.0708   0.2014   0.3532
+ 37.000000   0.0766   0.0738   0.2008   0.3472
+ 38.000000   0.0819   0.0767   0.2001   0.3413
+ 39.000000   0.0871   0.0798   0.1996   0.3353
+ 40.000000   0.0912   0.0832   0.1995   0.3300
+ 41.000000   0.0953   0.0866   0.1995   0.3247
+ 42.000000   0.1005   0.0907   0.1994   0.3181
+ 43.000000   0.1053   0.0947   0.1993   0.3118
+ 44.000000   0.1100   0.0995   0.1996   0.3051
+ 45.000000   0.1152   0.1043   0.1997   0.2980
+ 46.000000   0.1205   0.1096   0.1999   0.2906
+ 47.000000   0.1262   0.1151   0.2001   0.2827
+ 48.000000   0.1316   0.1201   0.2003   0.2753
+ 49.000000   0.1373   0.1249   0.2002   0.2679
+ 50.000000   0.1424   0.1295   0.2003   0.2610
+ 51.000000   0.1474   0.1335   0.2709   0.1568
+ 52.000000   0.1519   0.1376   0.2720   0.1635
+ 53.000000   0.1565   0.1413   0.2727   0.1698
+ 54.000000   0.1613   0.1443   0.2728   0.1755
+ 55.000000   0.1662   0.1470   0.2725   0.1809
+ 56.000000   0.1708   0.1498   0.2726   0.1863
+ 57.000000   0.1761   0.1525   0.2721   0.1920
+ 58.000000   0.1813   0.1549   0.2268   0.1981
+ 59.000000   0.1868   0.1571   0.2228   0.2055
+ 60.000000   0.1915   0.1594   0.2199   0.2118
+ 61.000000   0.1961   0.1623   0.2174   0.2183
+ 62.000000   0.2006   0.1656   0.2151   0.2251
+ 63.000000   0.2055   0.1687   0.2126   0.2319
+ 64.000000   0.2105   0.1714   0.2099   0.2388
+ 65.000000   0.2161   0.1747   0.2071   0.2465
+ 66.000000   0.2214   0.1774   0.2044   0.2535
+ 67.000000   0.2269   0.1798   0.2015   0.2605
+ 68.000000   0.2324   0.1828   0.1987   0.2655
+ 69.000000   0.2377   0.1850   0.1957   0.2667
+ 70.000000   0.2422   0.1872   0.1930   0.2680
+ 71.000000   0.2471   0.1891   0.1488   0.2508
+ 72.000000   0.2516   0.1916   0.1452   0.2533
+ 73.000000   0.2556   0.1935   0.1423   0.2552
+ 74.000000   0.2597   0.1950   0.1395   0.2567
+ 75.000000   0.2637   0.1965   0.1369   0.2582
+ 76.000000   0.2672   0.1978   0.1347   0.2596
+ 77.000000   0.2708   0.1993   0.1325   0.2612
+ 78.000000   0.2741   0.2007   0.1305   0.2626
+ 79.000000   0.2778   0.2012   0.1284   0.2631
+ 80.000000   0.2810   0.2016   0.1266   0.2635
+ 81.000000   0.2843   0.2024   0.1247   0.2644
+ 82.000000   0.2875   0.2029   0.1230   0.2648
+ 83.000000   0.2914   0.2032   0.1209   0.2652
+ 84.000000   0.2956   0.2036   0.1187   0.2656
+ 85.000000   0.2994   0.2046   0.1167   0.2667
+ 86.000000   0.3034   0.2059   0.1145   0.2680
+ 87.000000   0.3081   0.2076   0.1121   0.2697
+ 88.000000   0.3127   0.2092   0.1097   0.2714
+ 89.000000   0.3180   0.2115   0.1069   0.2736
+ 90.000000   0.3230   0.2139   0.1043   0.2761
+ 91.000000   0.3284   0.2170   0.1015   0.2792
+ 92.000000   0.3342   0.2201   0.0985   0.2815
+ 93.000000   0.3396   0.2232   0.0957   0.2831
+ 94.000000   0.3453   0.2266   0.0927   0.2848
+ 95.000000   0.3512   0.2302   0.0895   0.2867
+ 96.000000   0.3563   0.2332   0.0866   0.2883
+ 97.000000   0.3620   0.2354   0.0836   0.2888
+ 98.000000   0.3680   0.2377   0.0802   0.2894
+ 99.000000   0.3742   0.2403   0.0766   0.2902
+ 100.000000   0.3799   0.2432   0.0732   0.2913
diff --git a/regtest/mapping/rt-adapt/config b/regtest/mapping/rt-adapt/config
new file mode 100755
index 0000000000000000000000000000000000000000..7847f3b6f0d3bb031cf252b35e07d3e422f6c1f0
--- /dev/null
+++ b/regtest/mapping/rt-adapt/config
@@ -0,0 +1,2 @@
+type=driver
+arg="--noatoms --plumed plumed.dat"
diff --git a/regtest/mapping/rt-adapt/incolvar b/regtest/mapping/rt-adapt/incolvar
new file mode 100644
index 0000000000000000000000000000000000000000..1b1e93c80962847d48b638bcdf58e79c980d2a4e
--- /dev/null
+++ b/regtest/mapping/rt-adapt/incolvar
@@ -0,0 +1,102 @@
+#! FIELDS time d1.x d1.y ff bb.bias bb.ff_bias pb.s pb.z pp.gspath pp.gzpath mm.bias mm.work
+ 0.000000 0.000000 0.000000 -48.401274 -48.401274 -48.401274 0.197970 0.453413 0.197970 0.453413 0.000000 0.000000
+ 0.001000 -0.001717 -0.000446 -48.146037 -48.146037 -48.146037 0.198366 0.455003 0.198366 0.455003 0.000000 0.000000
+ 0.002000 -0.003122 -0.000324 -47.990324 -47.990324 -47.990324 0.198876 0.455985 0.198876 0.455985 0.000000 0.000000
+ 0.003000 -0.004193 0.000404 -47.940664 -47.940664 -47.940664 0.199507 0.456318 0.199507 0.456318 0.000000 0.000000
+ 0.004000 -0.005131 0.001208 -47.914899 -47.914899 -47.914899 0.200122 0.456500 0.200122 0.456500 0.000000 0.000000
+ 0.005000 -0.006960 0.002255 -47.807571 -47.807571 -47.807571 0.201124 0.457197 0.201124 0.457197 0.000000 0.000000
+ 0.006000 -0.008520 0.003767 -47.781067 -47.781067 -47.781067 0.202215 0.457385 0.202215 0.457385 0.000000 0.000000
+ 0.007000 -0.010010 0.005230 -47.756112 -47.756112 -47.756112 0.203264 0.457553 0.203264 0.457553 0.000000 0.000000
+ 0.008000 -0.011077 0.006775 -47.788511 -47.788511 -47.788511 0.204204 0.457348 0.204204 0.457348 0.000000 0.000000
+ 0.009000 -0.012840 0.007959 -47.699323 -47.699323 -47.699323 0.205236 0.457903 0.205236 0.457903 0.000000 0.000000
+ 0.010000 -0.013923 0.009740 -47.750526 -47.750526 -47.750526 0.206271 0.457556 0.206271 0.457556 0.000000 0.000000
+ 0.011000 -0.013674 0.011689 -47.974953 -47.974953 -47.974953 0.206931 0.456092 0.206931 0.456092 0.000000 0.000000
+ 0.012000 -0.012922 0.013779 -48.270270 -48.270270 -48.270270 0.207479 0.454154 0.207479 0.454154 0.000000 0.000000
+ 0.013000 -0.011595 0.015531 -48.598243 -48.598243 -48.598243 0.207708 0.452004 0.207708 0.452004 0.000000 0.000000
+ 0.014000 -0.009874 0.017705 -49.010533 -49.010533 -49.010533 0.207968 0.449280 0.207968 0.449280 0.000000 0.000000
+ 0.015000 -0.008088 0.019917 -49.430325 -49.430325 -49.430325 0.208221 0.446481 0.208221 0.446481 0.000000 0.000000
+ 0.016000 -0.005833 0.022327 -49.919924 -49.919924 -49.919924 0.208395 0.443199 0.208395 0.443199 0.000000 0.000000
+ 0.017000 -0.003556 0.024273 -50.366174 -50.366174 -50.366174 0.208384 0.440204 0.208384 0.440204 0.000000 0.000000
+ 0.018000 -0.001468 0.026136 -50.779427 -50.779427 -50.779427 0.208404 0.437406 0.208404 0.437406 0.000000 0.000000
+ 0.019000 0.000001 0.027307 -51.056397 -51.056397 -51.056397 0.208366 0.435528 0.208366 0.435528 0.000000 0.000000
+ 0.020000 0.002598 0.028274 -51.449479 -51.449479 -51.449479 0.207876 0.432932 0.207876 0.432932 0.000000 0.000000
+ 0.021000 0.005180 0.029124 -51.830121 -51.830121 -51.830121 0.207348 0.430424 0.207348 0.430424 0.000000 0.000000
+ 0.022000 0.008407 0.029995 -52.289022 -52.289022 -52.289022 0.206615 0.427416 0.206615 0.427416 0.000000 0.000000
+ 0.023000 0.012235 0.031093 -52.838108 -52.838108 -52.838108 0.205770 0.423804 0.205770 0.423804 0.000000 0.000000
+ 0.024000 0.015951 0.032647 -53.409607 -53.409607 -53.409607 0.205136 0.419978 0.205136 0.419978 0.000000 0.000000
+ 0.025000 0.020295 0.034445 -54.073364 -54.073364 -54.073364 0.204387 0.415517 0.204387 0.415517 0.000000 0.000000
+ 0.026000 0.024844 0.036182 -54.753612 -54.753612 -54.753612 0.203547 0.410942 0.203547 0.410942 0.000000 0.000000
+ 0.027000 0.029429 0.038396 -55.470669 -55.470669 -55.470669 0.202877 0.406027 0.202877 0.406027 0.000000 0.000000
+ 0.028000 0.033952 0.041051 -56.206755 -56.206755 -56.206755 0.202396 0.400871 0.202396 0.400871 0.000000 0.000000
+ 0.029000 0.037908 0.044337 -56.911052 -56.911052 -56.911052 0.202342 0.395729 0.202342 0.395729 0.000000 0.000000
+ 0.030000 0.042190 0.048152 -57.677591 -57.677591 -57.677591 0.202381 0.389995 0.202381 0.389995 0.000000 0.000000
+ 0.031000 0.046655 0.051934 -58.448297 -58.448297 -58.448297 0.202348 0.384143 0.202348 0.384143 0.000000 0.000000
+ 0.032000 0.051430 0.055917 -59.251603 -59.251603 -59.251603 0.202288 0.377927 0.202288 0.377927 0.000000 0.000000
+ 0.033000 0.056560 0.059827 -60.074866 -60.074866 -60.074866 0.202084 0.371489 0.202084 0.371489 0.000000 0.000000
+ 0.034000 0.061396 0.063586 -60.838206 -60.838206 -60.838206 0.201920 0.365373 0.201920 0.365373 0.000000 0.000000
+ 0.035000 0.066519 0.067161 -61.609134 -61.609134 -61.609134 0.201591 0.359160 0.201591 0.359160 0.000000 0.000000
+ 0.036000 0.071298 0.070812 -62.327581 -62.327581 -62.327581 0.201404 0.353157 0.201404 0.353157 0.000000 0.000000
+ 0.037000 0.076618 0.073788 -63.063897 -63.063897 -63.063897 0.200781 0.347188 0.200781 0.347188 0.000000 0.000000
+ 0.038000 0.081922 0.076657 -63.781129 -63.781129 -63.781129 0.200123 0.341301 0.200123 0.341301 0.000000 0.000000
+ 0.039000 0.087091 0.079810 -64.479870 -64.479870 -64.479870 0.199618 0.335330 0.199618 0.335330 0.000000 0.000000
+ 0.040000 0.091194 0.083160 -65.050574 -65.050574 -65.050574 0.199540 0.330035 0.199540 0.330035 0.000000 0.000000
+ 0.041000 0.095286 0.086648 -65.609291 -65.609291 -65.609291 0.199518 0.324659 0.199518 0.324659 0.000000 0.000000
+ 0.042000 0.100476 0.090711 -66.287276 -66.287276 -66.287276 0.199352 0.318075 0.199352 0.318075 0.000000 0.000000
+ 0.043000 0.105291 0.094688 -66.900531 -66.900531 -66.900531 0.199278 0.311832 0.199278 0.311832 0.000000 0.000000
+ 0.044000 0.109998 0.099512 -67.495388 -67.495388 -67.495388 0.199561 0.305116 0.199561 0.305116 0.000000 0.000000
+ 0.045000 0.115203 0.104335 -68.115540 -68.115540 -68.115540 0.199680 0.298024 0.199680 0.298024 0.000000 0.000000
+ 0.046000 0.120531 0.109569 -68.723067 -68.723067 -68.723067 0.199914 0.290570 0.199914 0.290570 0.000000 0.000000
+ 0.047000 0.126195 0.115075 -69.332947 -69.332947 -69.332947 0.200142 0.282683 0.200142 0.282683 0.000000 0.000000
+ 0.048000 0.131649 0.120119 -69.886133 -69.886133 -69.886133 0.200262 0.275258 0.200262 0.275258 0.000000 0.000000
+ 0.049000 0.137273 0.124900 -70.425196 -70.425196 -70.425196 0.200227 0.267877 0.200227 0.267877 0.000000 0.000000
+ 0.050000 0.142435 0.129497 -70.891791 -70.891791 -70.891791 0.200274 0.260965 0.200274 0.260965 0.000000 0.000000
+ 0.051000 0.147407 0.133456 -71.320628 -71.320628 -71.320628 0.200141 0.254615 0.200141 0.254615 0.000000 0.000000
+ 0.052000 0.151858 0.137621 -71.677613 -71.677613 -71.677613 0.200258 0.248524 0.200258 0.248524 0.000000 0.000000
+ 0.053000 0.156529 0.141298 -72.040710 -72.040710 -72.040710 0.200117 0.242586 0.200117 0.242586 0.000000 0.000000
+ 0.054000 0.161313 0.144301 -72.406797 -72.406797 -72.406797 0.199681 0.237003 0.199681 0.237003 0.000000 0.000000
+ 0.055000 0.166179 0.146970 -72.770613 -72.770613 -72.770613 0.199092 0.231578 0.199092 0.231578 0.000000 0.000000
+ 0.056000 0.170779 0.149809 -73.093320 -73.093320 -73.093320 0.198655 0.226243 0.198655 0.226243 0.000000 0.000000
+ 0.057000 0.176086 0.152541 -73.461312 -73.461312 -73.461312 0.197944 0.220444 0.197944 0.220444 0.000000 0.000000
+ 0.058000 0.181282 0.154857 -73.815461 -73.815461 -73.815461 0.197111 0.215000 0.197111 0.215000 0.000000 0.000000
+ 0.059000 0.186806 0.157065 -74.183854 -74.183854 -74.183854 0.196130 0.209380 0.196130 0.209380 0.000000 0.000000
+ 0.060000 0.191460 0.159417 -74.465356 -74.465356 -74.465356 0.195489 0.204322 0.195489 0.204322 0.000000 0.000000
+ 0.061000 0.196053 0.162267 -74.710435 -74.710435 -74.710435 0.195059 0.198984 0.195059 0.198984 0.000000 0.000000
+ 0.062000 0.200608 0.165605 -74.917691 -74.917691 -74.917691 0.194827 0.193356 0.194827 0.193356 0.000000 0.000000
+ 0.063000 0.205460 0.168661 -75.139444 -75.139444 -75.139444 0.194390 0.187688 0.194390 0.187688 0.000000 0.000000
+ 0.064000 0.210535 0.171402 -75.372417 -75.372417 -75.372417 0.193758 0.182058 0.193758 0.182058 0.000000 0.000000
+ 0.065000 0.216077 0.174716 -75.591572 -75.591572 -75.591572 0.193191 0.175700 0.193191 0.175700 0.000000 0.000000
+ 0.066000 0.221372 0.177398 -75.803633 -75.803633 -75.803633 0.192465 0.169941 0.192465 0.169941 0.000000 0.000000
+ 0.067000 0.226852 0.179845 -76.020860 -76.020860 -76.020860 0.191589 0.164198 0.191589 0.164198 0.000000 0.000000
+ 0.068000 0.232410 0.182822 -76.195115 -76.195115 -76.195115 0.190889 0.158048 0.190889 0.158048 0.000000 0.000000
+ 0.069000 0.237718 0.184955 -76.382516 -76.382516 -76.382516 0.189949 0.152640 0.189949 0.152640 0.000000 0.000000
+ 0.070000 0.242210 0.187184 -76.502907 -76.502907 -76.502907 0.189315 0.147785 0.189315 0.147785 0.000000 0.000000
+ 0.071000 0.247114 0.189092 -76.651668 -76.651668 -76.651668 0.188424 0.142830 0.188424 0.142830 0.000000 0.000000
+ 0.072000 0.251631 0.191554 -76.730708 -76.730708 -76.730708 0.187871 0.137804 0.187871 0.137804 0.000000 0.000000
+ 0.073000 0.255619 0.193465 -76.805730 -76.805730 -76.805730 0.187282 0.133538 0.187282 0.133538 0.000000 0.000000
+ 0.074000 0.259721 0.195007 -76.900851 -76.900851 -76.900851 0.186516 0.129429 0.186516 0.129429 0.000000 0.000000
+ 0.075000 0.263655 0.196460 -76.984843 -76.984843 -76.984843 0.185771 0.125505 0.185771 0.125505 0.000000 0.000000
+ 0.076000 0.267201 0.197848 -77.047279 -77.047279 -77.047279 0.185130 0.121916 0.185130 0.121916 0.000000 0.000000
+ 0.077000 0.270756 0.199337 -77.095062 -77.095062 -77.095062 0.184524 0.118254 0.184524 0.118254 0.000000 0.000000
+ 0.078000 0.274139 0.200747 -77.133683 -77.133683 -77.133683 0.183944 0.114774 0.183944 0.114774 0.000000 0.000000
+ 0.079000 0.277811 0.201220 -77.249969 -77.249969 -77.249969 0.182913 0.111689 0.182913 0.111689 0.000000 0.000000
+ 0.080000 0.280986 0.201603 -77.348978 -77.348978 -77.348978 0.182011 0.109039 0.182011 0.109039 0.000000 0.000000
+ 0.081000 0.284253 0.202416 -77.413238 -77.413238 -77.413238 0.181242 0.106039 0.181242 0.106039 0.000000 0.000000
+ 0.082000 0.287490 0.202855 -77.502538 -77.502538 -77.502538 0.180342 0.103305 0.180342 0.103305 0.000000 0.000000
+ 0.083000 0.291433 0.203236 -77.619648 -77.619648 -77.619648 0.179185 0.100075 0.179185 0.100075 0.000000 0.000000
+ 0.084000 0.295553 0.203622 -77.737956 -77.737956 -77.737956 0.177973 0.096708 0.177973 0.096708 0.000000 0.000000
+ 0.085000 0.299372 0.204624 -77.784917 -77.784917 -77.784917 0.177095 0.093167 0.177095 0.093167 0.000000 0.000000
+ 0.086000 0.303408 0.205948 -77.802147 -77.802147 -77.802147 0.176267 0.089249 0.176267 0.089249 0.000000 0.000000
+ 0.087000 0.308103 0.207621 -77.797966 -77.797966 -77.797966 0.175355 0.084606 0.175355 0.084606 0.000000 0.000000
+ 0.088000 0.312686 0.209223 -77.784029 -77.784029 -77.784029 0.174452 0.080093 0.174452 0.080093 0.000000 0.000000
+ 0.089000 0.317977 0.211463 -77.713278 -77.713278 -77.713278 0.173560 0.074628 0.173560 0.074628 0.000000 0.000000
+ 0.090000 0.323022 0.213948 -77.592470 -77.592470 -77.592470 0.172841 0.069188 0.172841 0.069188 0.000000 0.000000
+ 0.091000 0.328387 0.216964 -77.404029 -77.404029 -77.404029 0.172219 0.063159 0.172219 0.063159 0.000000 0.000000
+ 0.092000 0.334166 0.220105 -77.186336 -77.186336 -77.186336 0.171508 0.056734 0.171508 0.056734 0.000000 0.000000
+ 0.093000 0.339563 0.223176 -76.943864 -76.943864 -76.943864 0.170896 0.050645 0.170896 0.050645 0.000000 0.000000
+ 0.094000 0.345324 0.226618 -76.640253 -76.640253 -76.640253 0.170306 0.044037 0.170306 0.044037 0.000000 0.000000
+ 0.095000 0.351165 0.230171 -76.296505 -76.296505 -76.296505 0.169732 0.037296 0.169732 0.037296 0.000000 0.000000
+ 0.096000 0.356329 0.233231 -75.977758 -75.977758 -75.977758 0.169192 0.031389 0.169192 0.031389 0.000000 0.000000
+ 0.097000 0.361994 0.235445 -75.737191 -75.737191 -75.737191 0.168167 0.025659 0.168167 0.025659 0.000000 0.000000
+ 0.098000 0.367995 0.237678 -75.472302 -75.472302 -75.472302 0.167036 0.019661 0.167036 0.019661 0.000000 0.000000
+ 0.099000 0.374196 0.240311 -75.133144 -75.133144 -75.133144 0.165993 0.013250 0.165993 0.013250 0.000000 0.000000
+ 0.100000 0.379920 0.243158 -74.743124 -74.743124 -74.743124 0.165188 0.007061 0.165188 0.007061 0.000000 0.000000
diff --git a/regtest/mapping/rt-adapt/mypath.pdb b/regtest/mapping/rt-adapt/mypath.pdb
new file mode 100644
index 0000000000000000000000000000000000000000..1d66439c408639898b7966139d6424798fe39dcb
--- /dev/null
+++ b/regtest/mapping/rt-adapt/mypath.pdb
@@ -0,0 +1,40 @@
+REMARK ARG=d1.x,d1.y d1.x=1.12000000000000000000 d1.y=-.60000000000000000000
+END
+REMARK ARG=d1.x,d1.y d1.x=.99000000000000000000 d1.y=-.45000000000000000000
+END
+REMARK ARG=d1.x,d1.y d1.x=.86000000000000000000 d1.y=-.30000000000000000000
+END
+REMARK ARG=d1.x,d1.y d1.x=.73000000000000000000 d1.y=-.15000000000000000000
+END
+REMARK ARG=d1.x,d1.y d1.x=.60000000000000000000 d1.y=0
+END
+REMARK ARG=d1.x,d1.y d1.x=.47000000000000000000 d1.y=.15000000000000000000
+END
+REMARK ARG=d1.x,d1.y d1.x=.34000000000000000000 d1.y=.30000000000000000000
+END
+REMARK ARG=d1.x,d1.y d1.x=.21000000000000000000 d1.y=.45000000000000000000
+END
+REMARK ARG=d1.x,d1.y d1.x=.08000000000000000000 d1.y=.60000000000000000000
+END
+REMARK ARG=d1.x,d1.y d1.x=-.05000000000000000000 d1.y=.75000000000000000000
+END
+REMARK ARG=d1.x,d1.y d1.x=-.18000000000000000000 d1.y=.90000000000000000000
+END
+REMARK ARG=d1.x,d1.y d1.x=-.31000000000000000000 d1.y=1.05000000000000000000
+END
+REMARK ARG=d1.x,d1.y d1.x=-.44000000000000000000 d1.y=1.20000000000000000000
+END
+REMARK ARG=d1.x,d1.y d1.x=-.57000000000000000000 d1.y=1.35000000000000000000
+END
+REMARK ARG=d1.x,d1.y d1.x=-.70000000000000000000 d1.y=1.50000000000000000000
+END
+REMARK ARG=d1.x,d1.y d1.x=-.83000000000000000000 d1.y=1.65000000000000000000
+END
+REMARK ARG=d1.x,d1.y d1.x=-.96000000000000000000 d1.y=1.80000000000000000000
+END
+REMARK ARG=d1.x,d1.y d1.x=-1.09000000000000000000 d1.y=1.95000000000000000000
+END
+REMARK ARG=d1.x,d1.y d1.x=-1.22000000000000000000 d1.y=2.10000000000000000000
+END
+REMARK ARG=d1.x,d1.y d1.x=-1.35000000000000000000 d1.y=2.25000000000000000000
+END
diff --git a/regtest/mapping/rt-adapt/out-path.pdb.reference b/regtest/mapping/rt-adapt/out-path.pdb.reference
new file mode 100644
index 0000000000000000000000000000000000000000..9aa192f3033ca12fbd0b492c25820806a78a18d5
--- /dev/null
+++ b/regtest/mapping/rt-adapt/out-path.pdb.reference
@@ -0,0 +1,162 @@
+# PATH AT STEP 50 TIME 50.000000 
+REMARK TYPE=EUCLIDEAN
+REMARK ARG=d1.x,d1.y
+REMARK d1.x=1.2247   d1.y=-0.7208  
+END
+REMARK TYPE=EUCLIDEAN
+REMARK ARG=d1.x,d1.y
+REMARK d1.x=1.0685   d1.y=-0.5406  
+END
+REMARK TYPE=EUCLIDEAN
+REMARK ARG=d1.x,d1.y
+REMARK d1.x=0.9123   d1.y=-0.3604  
+END
+REMARK TYPE=EUCLIDEAN
+REMARK ARG=d1.x,d1.y
+REMARK d1.x=0.7562   d1.y=-0.1802  
+END
+REMARK TYPE=EUCLIDEAN
+REMARK ARG=d1.x,d1.y
+REMARK d1.x=0.6000   d1.y=0.0000   
+END
+REMARK TYPE=EUCLIDEAN
+REMARK ARG=d1.x,d1.y
+REMARK d1.x=0.3691   d1.y=-0.0597  
+END
+REMARK TYPE=EUCLIDEAN
+REMARK ARG=d1.x,d1.y
+REMARK d1.x=0.1307   d1.y=-0.0637  
+END
+REMARK TYPE=EUCLIDEAN
+REMARK ARG=d1.x,d1.y
+REMARK d1.x=-0.0379  d1.y=0.1048   
+END
+REMARK TYPE=EUCLIDEAN
+REMARK ARG=d1.x,d1.y
+REMARK d1.x=-0.0364  d1.y=0.3433   
+END
+REMARK TYPE=EUCLIDEAN
+REMARK ARG=d1.x,d1.y
+REMARK d1.x=0.0385   d1.y=0.5697   
+END
+REMARK TYPE=EUCLIDEAN
+REMARK ARG=d1.x,d1.y
+REMARK d1.x=-0.0753  d1.y=0.7792   
+END
+REMARK TYPE=EUCLIDEAN
+REMARK ARG=d1.x,d1.y
+REMARK d1.x=-0.2315  d1.y=0.9594   
+END
+REMARK TYPE=EUCLIDEAN
+REMARK ARG=d1.x,d1.y
+REMARK d1.x=-0.3877  d1.y=1.1396   
+END
+REMARK TYPE=EUCLIDEAN
+REMARK ARG=d1.x,d1.y
+REMARK d1.x=-0.5438  d1.y=1.3198   
+END
+REMARK TYPE=EUCLIDEAN
+REMARK ARG=d1.x,d1.y
+REMARK d1.x=-0.7000  d1.y=1.5000   
+END
+REMARK TYPE=EUCLIDEAN
+REMARK ARG=d1.x,d1.y
+REMARK d1.x=-0.8562  d1.y=1.6802   
+END
+REMARK TYPE=EUCLIDEAN
+REMARK ARG=d1.x,d1.y
+REMARK d1.x=-1.0123  d1.y=1.8604   
+END
+REMARK TYPE=EUCLIDEAN
+REMARK ARG=d1.x,d1.y
+REMARK d1.x=-1.1685  d1.y=2.0406   
+END
+REMARK TYPE=EUCLIDEAN
+REMARK ARG=d1.x,d1.y
+REMARK d1.x=-1.3247  d1.y=2.2208   
+END
+REMARK TYPE=EUCLIDEAN
+REMARK ARG=d1.x,d1.y
+REMARK d1.x=-1.4808  d1.y=2.4010   
+END
+# PATH AT STEP 100 TIME 100.000000 
+REMARK TYPE=EUCLIDEAN
+REMARK ARG=d1.x,d1.y
+REMARK d1.x=1.1683   d1.y=-0.6557  
+END
+REMARK TYPE=EUCLIDEAN
+REMARK ARG=d1.x,d1.y
+REMARK d1.x=1.0262   d1.y=-0.4918  
+END
+REMARK TYPE=EUCLIDEAN
+REMARK ARG=d1.x,d1.y
+REMARK d1.x=0.8841   d1.y=-0.3279  
+END
+REMARK TYPE=EUCLIDEAN
+REMARK ARG=d1.x,d1.y
+REMARK d1.x=0.7421   d1.y=-0.1639  
+END
+REMARK TYPE=EUCLIDEAN
+REMARK ARG=d1.x,d1.y
+REMARK d1.x=0.6000   d1.y=0.0000   
+END
+REMARK TYPE=EUCLIDEAN
+REMARK ARG=d1.x,d1.y
+REMARK d1.x=0.4307   d1.y=0.1356   
+END
+REMARK TYPE=EUCLIDEAN
+REMARK ARG=d1.x,d1.y
+REMARK d1.x=0.2174   d1.y=0.0958   
+END
+REMARK TYPE=EUCLIDEAN
+REMARK ARG=d1.x,d1.y
+REMARK d1.x=0.0447   d1.y=0.2270   
+END
+REMARK TYPE=EUCLIDEAN
+REMARK ARG=d1.x,d1.y
+REMARK d1.x=0.0027   d1.y=0.4398   
+END
+REMARK TYPE=EUCLIDEAN
+REMARK ARG=d1.x,d1.y
+REMARK d1.x=-0.0245  d1.y=0.6550   
+END
+REMARK TYPE=EUCLIDEAN
+REMARK ARG=d1.x,d1.y
+REMARK d1.x=-0.1342  d1.y=0.8422   
+END
+REMARK TYPE=EUCLIDEAN
+REMARK ARG=d1.x,d1.y
+REMARK d1.x=-0.2738  d1.y=1.0082   
+END
+REMARK TYPE=EUCLIDEAN
+REMARK ARG=d1.x,d1.y
+REMARK d1.x=-0.4159  d1.y=1.1721   
+END
+REMARK TYPE=EUCLIDEAN
+REMARK ARG=d1.x,d1.y
+REMARK d1.x=-0.5579  d1.y=1.3361   
+END
+REMARK TYPE=EUCLIDEAN
+REMARK ARG=d1.x,d1.y
+REMARK d1.x=-0.7000  d1.y=1.5000   
+END
+REMARK TYPE=EUCLIDEAN
+REMARK ARG=d1.x,d1.y
+REMARK d1.x=-0.8421  d1.y=1.6639   
+END
+REMARK TYPE=EUCLIDEAN
+REMARK ARG=d1.x,d1.y
+REMARK d1.x=-0.9841  d1.y=1.8279   
+END
+REMARK TYPE=EUCLIDEAN
+REMARK ARG=d1.x,d1.y
+REMARK d1.x=-1.1262  d1.y=1.9918   
+END
+REMARK TYPE=EUCLIDEAN
+REMARK ARG=d1.x,d1.y
+REMARK d1.x=-1.2683  d1.y=2.1557   
+END
+REMARK TYPE=EUCLIDEAN
+REMARK ARG=d1.x,d1.y
+REMARK d1.x=-1.4104  d1.y=2.3196   
+END
diff --git a/regtest/mapping/rt-adapt/plumed.dat b/regtest/mapping/rt-adapt/plumed.dat
new file mode 100644
index 0000000000000000000000000000000000000000..8d9f2be39fb48a7f051073b8b2f0da594f2b11b2
--- /dev/null
+++ b/regtest/mapping/rt-adapt/plumed.dat
@@ -0,0 +1,18 @@
+#UNITS NATURAL
+#
+#d1: DISTANCE ATOMS=1,2 COMPONENTS
+#ff: MATHEVAL ARG=d1.x,d1.y PERIODIC=NO FUNC=(-200*exp(-(x-1)^2-10*(y)^2)-100*exp(-(x-0)^2-10*(y-0.5)^2)-170*exp(-6.5*(x+0.5)^2+11*(x+0.5)*(y-1.5)-6.5*(y-1.5)^2)+15*exp(0.7*(x+1.0)^2+0.6*(x+1.0)*(y-1.0)+0.7*(y-1.0)^2))
+#
+#bb: BIASVALUE ARG=ff
+#
+#pb: PATHCV ARG=d1.x,d1.y INFILE=initial-path.xy FIXED=5,15 PACE=500
+
+d1: READ VALUES=d1.x,d1.y FILE=incolvar IGNORE_TIME
+
+pp: ADAPTIVE_PATH TYPE=EUCLIDEAN FIXED=5,15 UPDATE=50 WFILE=out-path.pdb WSTRIDE=50 FMT=%8.4f REFERENCE=mypath.pdb
+
+PRINT ARG=d1.x,d1.y,pp.* FMT=%8.4f FILE=colvar
+
+# mm: METAD ARG=pp.gspath PACE=100 SIGMA=0.1 HEIGHT=5 
+
+# PRINT ARG=d1.x,d1.y,ff,bb.*,pb.*,pp.*,mm.* FILE=colvar 
diff --git a/src/mapping/AdaptivePath.cpp b/src/mapping/AdaptivePath.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..6c02d788005ea62f8a056cab9a79a5ae7ef00c57
--- /dev/null
+++ b/src/mapping/AdaptivePath.cpp
@@ -0,0 +1,193 @@
+/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+   Copyright (c) 2012-2016 The plumed team
+   (see the PEOPLE file at the root of the distribution for a list of names)
+
+   See http://www.plumed.org for more information.
+
+   This file is part of plumed, version 2.
+
+   plumed is free software: you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as published by
+   the Free Software Foundation, either version 3 of the License, or
+   (at your option) any later version.
+
+   plumed is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with plumed.  If not, see <http://www.gnu.org/licenses/>.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
+#include "Mapping.h"
+#include "TrigonometricPathVessel.h"
+#include "reference/PathReparameterization.h"
+#include "reference/Direction.h"
+#include "core/ActionRegister.h"
+
+//+PLUMEDOC COLVAR ADAPTIVE_PATH
+/*
+Adaptive path cvs. 
+
+\par Examples
+
+*/
+//+ENDPLUMEDOC
+
+namespace PLMD {
+namespace mapping{
+
+class AdaptivePath : public Mapping {
+private:
+  OFile pathfile;
+  std::string ofmt;
+  double fadefact, tolerance;
+  unsigned update_str, wstride;
+  std::vector<unsigned> fixedn;
+  TrigonometricPathVessel* mypathv;
+  std::vector<double> wsum;
+  Direction displacement,displacement2;
+  std::vector<Direction> pdisplacements;
+public:
+  static void registerKeywords( Keywords& keys );
+  explicit AdaptivePath(const ActionOptions&);
+  void calculate();
+  void performTask( const unsigned& , const unsigned& , MultiValue& ) const ;
+  double getLambda() { return 0.0; }
+  double transformHD( const double& dist, double& df ) const ;
+  void update();
+};
+
+PLUMED_REGISTER_ACTION(AdaptivePath,"ADAPTIVE_PATH")
+
+void AdaptivePath::registerKeywords( Keywords& keys ){
+  Mapping::registerKeywords( keys ); keys.remove("PROPERTY"); 
+  keys.add("compulsory","FIXED","the positions in the list of input frames of the two path nodes whose positions remain fixed during the path optimization");
+  keys.add("compulsory","HALFLIFE","-1","the number of MD steps after which a previously measured path distance weighs only 50% in the average. This option may increase convergence by allowing to \"forget\" the memory of a bad initial guess path. The default is to set this to infinity");
+  keys.add("compulsory","UPDATE","the frequency with which the path should be updated");
+  keys.add("compulsory","TOLERANCE","1E-6","the tolerance to use for the path updating algorithm that makes all frames equidistant");
+  keys.add("optional","WFILE","file on which to write out the path");
+  keys.add("compulsory","FMT","%f","the format to use for output files");
+  keys.add("optional","WSTRIDE","frequency with which to write out the path");
+}
+
+AdaptivePath::AdaptivePath(const ActionOptions& ao):
+Action(ao),
+Mapping(ao),
+fixedn(2),
+displacement(ReferenceConfigurationOptions("DIRECTION")),
+displacement2(ReferenceConfigurationOptions("DIRECTION"))
+{
+  setLowMemOption( true ); parseVector("FIXED",fixedn);
+  if( fixedn[0]<1 || fixedn[1]>getNumberOfReferencePoints() ) error("fixed nodes must be in range from 0 to number of nodes");
+  if( fixedn[0]>=fixedn[1] ) error("invalid selection for fixed nodes first index provided must be smaller than second index");
+  log.printf("  fixing position of frames numbered %u and %u \n",fixedn[0],fixedn[1]);
+  fixedn[0]--; fixedn[1]--;   // Set fixed notes with c++ indexing starting from zero 
+  parse("UPDATE",update_str); if( update_str<1 ) error("update frequency for path should be greater than or equal to one"); 
+  log.printf("  updating path every %u MD steps \n",update_str);
+
+  double halflife; parse("HALFLIFE",halflife);
+  log.printf("  weight of contribution to frame halves every %f steps \n",halflife);
+  if( halflife<0 ) fadefact=1.0;
+  else fadefact = exp( -0.693147180559945 / static_cast<double>(halflife) );
+
+  // Create the list of tasks (and reset projections of frames)
+  std::vector<std::string> argument_names( getNumberOfArguments() );
+  for(unsigned i=0;i<getNumberOfArguments();++i) argument_names[i] = getPntrToArgument(i)->getName();
+  displacement.setNamesAndAtomNumbers( getAbsoluteIndexes(), argument_names );
+  displacement2.setNamesAndAtomNumbers( getAbsoluteIndexes(), argument_names );
+  for(int i=0;i<getNumberOfReferencePoints();++i){
+      addTaskToList( i ); pdisplacements.push_back( Direction(ReferenceConfigurationOptions("DIRECTION")) ); 
+      setPropertyValue( i, 0, static_cast<double>( i - static_cast<int>(fixedn[0]) ) / static_cast<double>( fixedn[1] - fixedn[0] ) );
+      pdisplacements[i].setNamesAndAtomNumbers( getAbsoluteIndexes(), argument_names ); wsum.push_back( 0.0 );
+  }
+  plumed_assert( getPropertyValue( fixedn[0], 0 )==0.0 && getPropertyValue( fixedn[1], 0 )==1.0 ); 
+  // And activate them all
+  deactivateAllTasks();
+  for(unsigned i=0;i<getFullNumberOfTasks();++i) taskFlags[i]=1;
+  lockContributors();
+
+  // Setup the vessel to hold the trig path 
+  std::string input; addVessel("GPATH", input, -1 ); 
+  readVesselKeywords(); 
+  // Check that there is only one vessel - the one holding the trig path
+  plumed_dbg_assert( getNumberOfVessels()==1 );
+  // Retrieve the path vessel
+  mypathv = dynamic_cast<TrigonometricPathVessel*>( getPntrToVessel(0) );
+  plumed_assert( mypathv );
+
+  // Information for write out
+  std::string wfilename; parse("WFILE",wfilename); 
+  if( wfilename.length()>0 ){
+      wstride=0; parse("WSTRIDE",wstride); parse("FMT",ofmt);
+      pathfile.link(*this); pathfile.open( wfilename ); pathfile.setHeavyFlush();
+      if( wstride<update_str ) error("makes no sense to write out path more frequently than update stride");
+      log.printf("  writing path out every %u steps to file named %s with format %s \n",wstride,wfilename.c_str(),ofmt.c_str());
+  }
+}
+
+void AdaptivePath::calculate(){
+  runAllTasks();
+}
+
+void AdaptivePath::performTask( const unsigned& task_index, const unsigned& current, MultiValue& myvals ) const {
+  // This builds a pack to hold the derivatives
+  ReferenceValuePack mypack( getNumberOfArguments(), getNumberOfAtoms(), myvals );
+  finishPackSetup( current, mypack );
+  // Calculate the distance from the frame
+  double val=calculateDistanceFunction( current, mypack, true );
+  // Put the element value in element zero
+  myvals.setValue( 0, val ); myvals.setValue( 1, 1.0 );
+  return;
+}
+
+double AdaptivePath::transformHD( const double& dist, double& df ) const {
+  df=1.0; return dist;
+}
+
+void AdaptivePath::update(){
+  double weight2 = -1.*mypathv->dx;
+  double weight1 = 1.0 + mypathv->dx;
+  if( weight1>1.0 ){ 
+      weight1=1.0; weight2=0.0;
+  } else if( weight2>1.0 ){
+      weight1=0.0; weight2=1.0;
+  }
+  // Add projections to dispalcement accumulators
+  ReferenceConfiguration* myref = getReferenceConfiguration( mypathv->iclose1 );
+  myref->extractDisplacementVector( getPositions(), getArguments(), mypathv->cargs, false, false, displacement );
+  getReferenceConfiguration( mypathv->iclose2 )->extractDisplacementVector( myref->getReferencePositions(), getArguments(), myref->getReferenceArguments(), false, false, displacement2 );
+  displacement.addDirection( -mypathv->dx, displacement2 );
+  pdisplacements[mypathv->iclose1].addDirection( weight1, displacement );
+  pdisplacements[mypathv->iclose2].addDirection( weight2, displacement );
+  // Update weight accumulators
+  wsum[mypathv->iclose1] *= fadefact;
+  wsum[mypathv->iclose2] *= fadefact;
+  wsum[mypathv->iclose1] += weight1;
+  wsum[mypathv->iclose2] += weight2;
+
+  // This does the update of the path if it is time to
+  if( (getStep()>0) && (getStep()%update_str==0) ){ 
+      wsum[fixedn[0]]=wsum[fixedn[1]]=0.; 
+      for(unsigned inode=0;inode<getNumberOfReferencePoints();++inode){
+          if( wsum[inode]>0 ){
+              // First displace the node by the weighted direction
+              getReferenceConfiguration( inode )->displaceReferenceConfiguration( 1./wsum[inode], pdisplacements[inode] );
+              // Reset the displacement  
+              pdisplacements[inode].zeroDirection();
+          }
+      }
+      // Now ensure all the nodes of the path are equally spaced
+      PathReparameterization myspacings( getPbc(), getArguments(), getAllReferenceConfigurations() );
+      myspacings.reparameterize( fixedn[0], fixedn[1], tolerance );
+  }
+  if( (getStep()>0) && (getStep()%wstride==0) ){
+       pathfile.printf("# PATH AT STEP %d TIME %f \n", getStep(), getTime() );
+       std::vector<ReferenceConfiguration*>& myconfs=getAllReferenceConfigurations();
+       for(unsigned i=0;i<myconfs.size();++i) myconfs[i]->print( pathfile, ofmt, atoms.getUnits().getLength()/0.1 );
+       pathfile.flush();
+  }
+}
+
+}
+}