SSAGES  0.9.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 #include <array>
28 
29 // Forward declare.
30 namespace Json {
31  class Value;
32 }
33 
34 namespace SSAGES
35 {
37 
41  {
42  protected:
44  std::vector<Vector3> grad_;
45 
48 
50  double val_;
51 
53  std::array<double, 2> bounds_;
54  public:
57  grad_(0), boxgrad_(Matrix3::Zero()), val_(0), bounds_{{0,0}}
58  {}
59 
61  virtual ~CollectiveVariable() {}
62 
64 
69  virtual void Initialize(const class Snapshot&) {}
70 
72 
77  virtual void Evaluate(const class Snapshot&) = 0;
78 
80 
86  double GetValue() const
87  {
88  return val_;
89  }
90 
92 
98  virtual double GetMinimumImage(double /*location*/) const
99  {
100  return val_;
101  }
102 
104 
113  virtual double GetPeriodicValue(double location) const
114  {
115  return location;
116  }
117 
119 
127  const std::vector<Vector3>& GetGradient() const
128  {
129  return grad_;
130  }
131 
133 
138  const Matrix3& GetBoxGradient() const
139  {
140  return boxgrad_;
141  }
142 
144 
151  const std::array<double, 2>& GetBoundaries()
152  {
153  return bounds_;
154  }
155 
158 
168  virtual double GetDifference(double location) const
169  {
170  return val_ - location;
171  }
172 
174 
184  static CollectiveVariable* BuildCV(const Json::Value& json, const std::string& path);
185  };
186 }
Abstract class for a collective variable.
virtual double GetDifference(double location) const
virtual double GetPeriodicValue(double location) const
Apply periodic boundaries to a given value.
const std::array< double, 2 > & GetBoundaries()
Get CV boundaries.
Matrix3 boxgrad_
Gradient w.r.t box vectors dCv/dHij.
std::vector< Vector3 > grad_
Gradient vector dCv/dxi.
virtual ~CollectiveVariable()
Destructor.
double val_
Current value of CV.
double GetValue() const
Get current value of the CV.
virtual void Initialize(const class Snapshot &)
Initialize CV.
virtual void Evaluate(const class Snapshot &)=0
Evaluate CV.
const Matrix3 & GetBoxGradient() const
Get gradient contribution to box.
std::array< double, 2 > bounds_
Bounds on CV.
const std::vector< Vector3 > & GetGradient() const
Get current gradient of the CV.
virtual double GetMinimumImage(double) const
Returns the minimum image of a CV based on the input location.
Class containing a snapshot of the current simulation in time.
Definition: Snapshot.h:48
Eigen::Matrix3d Matrix3
3x3 matrix.
Definition: types.h:42