Skip to content

Commit 94fb0d7

Browse files
committed
Merge branch 'v2.10'
2 parents daf88e1 + 6d12097 commit 94fb0d7

7 files changed

Lines changed: 72 additions & 8 deletions

File tree

CHANGES/v2.9.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,5 @@ __New Patches:__
8686
## Version 2.9.5 (coming)
8787
- Fixed bug in derivatives of COSINUS switching function, see [here](https://github.com/plumed/plumed2/issues/1317).
8888
- Searching with bisection instead of linearly in the neigbourlist speeding up all CVs using NL.
89+
- Added FMT keyword in \ref METAINFERENCE
90+
- Several fixes in regression tests and in CI
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#! FIELDS time c
2+
20000.000000 1.000000
3+
#! FIELDS time c
4+
20000.000000 1.000000
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include ../../scripts/test.make
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
type=make
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#include <vector>
2+
#include <fstream>
3+
#include "plumed/wrapper/Plumed.h"
4+
#include <iostream>
5+
6+
using namespace PLMD;
7+
8+
template<typename T>
9+
void run(){
10+
11+
auto natoms=10;
12+
std::vector<T> masses;
13+
std::vector<std::array<T,3>> positions;
14+
std::vector<std::array<T,3>> forces;
15+
T box[3][3];
16+
T virial[3][3];
17+
18+
Plumed p;
19+
20+
p.cmd("setRealPrecision",int(sizeof(T)));
21+
p.cmd("setNatoms",natoms);
22+
p.cmd("setTimestep",(T)0.002);
23+
p.cmd("init");
24+
25+
p.cmd("readInputLines",
26+
"c: CONSTANT VALUE=1.0 \n"
27+
"PRINT ARG=c FILE=COLVAR RESTART=YES\n"
28+
);
29+
30+
// dummy settings, not really used
31+
positions.resize(natoms);
32+
masses.resize(natoms);
33+
forces.resize(natoms);
34+
35+
for(unsigned i=0;i<natoms;i++) for(unsigned j=0;j<3;j++) positions[i][j]=0.0;
36+
for(unsigned i=0;i<natoms;i++) for(unsigned j=0;j<3;j++) forces[i][j]=0.0;
37+
for(unsigned i=0;i<natoms;i++) masses[i]=1.0;
38+
39+
p.cmd("setStep",10000000);
40+
p.cmd("setMasses",&masses[0]);
41+
p.cmd("setPositions",&positions[0][0]);
42+
p.cmd("setForces",&forces[0][0]);
43+
44+
p.cmd("setBox",&box[0][0]);
45+
p.cmd("setVirial",&virial[0][0]);
46+
p.cmd("calc");
47+
48+
}
49+
50+
int main(){
51+
run<double>();
52+
run<float>();
53+
}

src/core/DataPassingObject.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,17 @@ void DataPassingObjectTyped<T>::saveValueAsDouble( const TypesafePtr & val ) {
9494
bvalue=double(val.template get<T>());
9595
}
9696

97+
template <>
98+
void DataPassingObjectTyped<float>::saveValueAsDouble( const TypesafePtr & val ) {
99+
hasbackup=true;
100+
bvalue=double(val.template get<float>());
101+
// The following is to avoid extra digits in case the MD code uses floats
102+
// e.g.: float f=0.002 when converted to double becomes 0.002000000094995
103+
// To avoid this, we keep only up to 6 significant digits after first one
104+
double magnitude=std::pow(10,std::floor(std::log10(bvalue)));
105+
bvalue = std::round(bvalue/magnitude*1e6)/1e6*magnitude;
106+
}
107+
97108
template <class T>
98109
void DataPassingObjectTyped<T>::setValuePointer( const TypesafePtr & val, const std::vector<std::size_t>& shape, const bool& isconst ) {
99110
if( shape.size()==0 ) {

src/core/PlumedMain.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -737,14 +737,6 @@ void PlumedMain::cmd(std::string_view word,const TypesafePtr & val) {
737737
if( !ts->setValuePointer("timestep", val ) ) {
738738
plumed_error();
739739
}
740-
// The following is to avoid extra digits in case the MD code uses floats
741-
// e.g.: float f=0.002 when converted to double becomes 0.002000000094995
742-
// To avoid this, we keep only up to 6 significant digits after first one
743-
if( getRealPrecision()<=4 ) {
744-
Value* tstepv = ts->copyOutput(0);
745-
double magnitude=std::pow(10,std::floor(std::log10(tstepv->get())));
746-
tstepv->set( std::round(tstepv->get()/magnitude*1e6)/1e6*magnitude );
747-
}
748740
ts->updateUnits( passtools.get() );
749741
}
750742
break;

0 commit comments

Comments
 (0)