Skip to content
Snippets Groups Projects
Commit a4b30c2d authored by Giovanni Bussi's avatar Giovanni Bussi
Browse files

Fix #139

This fixes an issue on periodicity of values.

Now all the values are brought within their periodic boundaries.
parent fa1c37d9
No related branches found
No related tags found
No related merge requests found
......@@ -82,6 +82,8 @@ private:
double inv_max_minus_min;
/// Complete the setup of the periodicity
void setupPeriodicity();
// bring value within PBCs
void applyPeriodicity();
public:
/// A constructor that can be used to make Vectors of values
Value();
......@@ -146,6 +148,14 @@ void copy( const Value& val1, Value& val2 );
void copy( const Value& val1, Value* val2 );
void add( const Value& val1, Value* valout );
inline
void Value::applyPeriodicity(){
if(periodicity==periodic){
value=min+difference(min,value);
if(value<min)value+=max_minus_min;
}
}
inline
void product( const Value& val1, const Value& val2, Value& valout ){
plumed_assert( val1.derivatives.size()==val2.derivatives.size() );
......@@ -174,12 +184,14 @@ inline
void Value::set(double v){
value_set=true;
value=v;
applyPeriodicity();
}
inline
void Value::add(double v){
value_set=true;
value+=v;
applyPeriodicity();
}
inline
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment