SSAGES  0.1
A MetaDynamics Package
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Groups Pages
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 
78  virtual void Evaluate(const class Snapshot&) = 0;
79 
81 
87  double GetValue() const
88  {
89  return val_;
90  }
91 
93 
99  virtual double GetMinimumImage(double /*location*/) const
100  {
101  return val_;
102  }
103 
105 
114  virtual double GetPeriodicValue(double location) const
115  {
116  return location;
117  }
118 
120 
128  const std::vector<Vector3>& GetGradient() const
129  {
130  return grad_;
131  }
132 
134  /*
135  * \return Gradient of CV with respect to box.
136  *
137  * Returns the gradient of the CV with respect to the box.
138  */
139  const Matrix3& GetBoxGradient() const
140  {
141  return boxgrad_;
142  }
143 
145 
152  const std::array<double, 2>& GetBoundaries()
153  {
154  return bounds_;
155  }
156 
159 
169  virtual double GetDifference(double location) const
170  {
171  return val_ - location;
172  }
173 
175 
185  static CollectiveVariable* BuildCV(const Json::Value& json, const std::string& path);
186 
187  };
188 }
Eigen::Matrix3d Matrix3
3x3 matrix.
Definition: types.h:42
std::array< double, 2 > bounds_
Bounds on CV.
const std::array< double, 2 > & GetBoundaries()
Get CV boundaries.
std::vector< Vector3 > grad_
Gradient vector dCv/dxi.
const std::vector< Vector3 > & GetGradient() const
Get current gradient of the CV.
const Matrix3 & GetBoxGradient() const
Get gradient contribution to box.
double GetValue() const
Get current value of the CV.
virtual double GetDifference(double location) const
double val_
Current value of CV.
virtual double GetMinimumImage(double) const
Returns the minimum image of a CV based on the input location.
Abstract class for a collective variable.
Matrix3 boxgrad_
Gradient w.r.t box vectors dCv/dHij.
static CollectiveVariable * BuildCV(const Json::Value &json, const std::string &path)
Set up collective variable.
virtual double GetPeriodicValue(double location) const
Apply periodic boundaries to a given value.