SSAGES  0.8.3
Software Suite for Advanced General Ensemble Simulations
CollectiveVariable.h
1 
22 #pragma once
23 
24 #include "types.h"
25 #include <vector>
26 #include <map>
27 
28 // Forward declare.
29 namespace Json {
30  class Value;
31 }
32 
33 namespace SSAGES
34 {
36 
40  {
41  protected:
43  std::vector<Vector3> grad_;
44 
47 
49  double val_;
50 
52  std::array<double, 2> bounds_;
53  public:
56  grad_(0), boxgrad_(Matrix3::Zero()), val_(0), bounds_{{0,0}}
57  {}
58 
60  virtual ~CollectiveVariable() {}
61 
63 
68  virtual void Initialize(const class Snapshot&) {}
69 
71 
76  virtual void Evaluate(const class Snapshot&) = 0;
77 
79 
85  double GetValue() const
86  {
87  return val_;
88  }
89 
91 
97  virtual double GetMinimumImage(double /*location*/) const
98  {
99  return val_;
100  }
101 
103 
112  virtual double GetPeriodicValue(double location) const
113  {
114  return location;
115  }
116 
118 
126  const std::vector<Vector3>& GetGradient() const
127  {
128  return grad_;
129  }
130 
132  /*
133  * \return Gradient of CV with respect to box.
134  *
135  * Returns the gradient of the CV with respect to the box.
136  */
137  const Matrix3& GetBoxGradient() const
138  {
139  return boxgrad_;
140  }
141 
143 
150  const std::array<double, 2>& GetBoundaries()
151  {
152  return bounds_;
153  }
154 
157 
167  virtual double GetDifference(double location) const
168  {
169  return val_ - location;
170  }
171 
173 
183  static CollectiveVariable* BuildCV(const Json::Value& json, const std::string& path);
184  };
185 }
virtual void Initialize(const class Snapshot &)
Initialize CV.
Eigen::Matrix3d Matrix3
3x3 matrix.
Definition: types.h:42
std::array< double, 2 > bounds_
Bounds on CV.
Class containing a snapshot of the current simulation in time.
Definition: Snapshot.h:43
const std::vector< Vector3 > & GetGradient() const
Get current gradient of the CV.
const std::array< double, 2 > & GetBoundaries()
Get CV boundaries.
std::vector< Vector3 > grad_
Gradient vector dCv/dxi.
virtual ~CollectiveVariable()
Destructor.
virtual double GetDifference(double location) const
double GetValue() const
Get current value of the CV.
virtual double GetMinimumImage(double) const
Returns the minimum image of a CV based on the input location.
double val_
Current value of CV.
Abstract class for a collective variable.
Matrix3 boxgrad_
Gradient w.r.t box vectors dCv/dHij.
const Matrix3 & GetBoxGradient() const
Get gradient contribution to box.
virtual double GetPeriodicValue(double location) const
Apply periodic boundaries to a given value.