A MetaDynamics Package
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
SSAGES::CollectiveVariable Class Referenceabstract

Abstract class for a collective variable. More...

#include <CollectiveVariable.h>

Inheritance diagram for SSAGES::CollectiveVariable:
Inheritance graph

Public Member Functions

 CollectiveVariable ()
virtual ~CollectiveVariable ()
virtual void Initialize (const class Snapshot &)
 Initialize CV. More...
virtual void Evaluate (const class Snapshot &)=0
 Evaluate CV. More...
double GetValue () const
 Get current value of the CV. More...
virtual double GetMinimumImage (double) const
 Returns the minimum image of a CV based on the input location. More...
virtual double GetPeriodicValue (double location) const
 Apply periodic boundaries to a given value. More...
const std::vector< Vector3 > & GetGradient () const
 Get current gradient of the CV. More...
const Matrix3GetBoxGradient () const
 Get gradient contribution to box.
const std::array< double, 2 > & GetBoundaries ()
 Get CV boundaries. More...
virtual double GetDifference (double location) const

Static Public Member Functions

static CollectiveVariableBuildCV (const Json::Value &json, const std::string &path)
 Set up collective variable. More...

Protected Attributes

std::vector< Vector3grad_
 Gradient vector dCv/dxi.
Matrix3 boxgrad_
 Gradient w.r.t box vectors dCv/dHij.
double val_
 Current value of CV.
std::array< double, 2 > bounds_
 Bounds on CV.

Detailed Description

Abstract class for a collective variable.

Definition at line 39 of file CollectiveVariable.h.

Member Function Documentation

CollectiveVariable * SSAGES::CollectiveVariable::BuildCV ( const Json::Value &  json,
const std::string &  path 

Set up collective variable.

jsonJSON input value.
pathPath for JSON path specification.
Pointer to the CV built by this function. nullptr in case of unknown error.

Builds a CV from a JSON node. Returns a pointer to the built cv. If an unknown error is encountered, this function will return a nullptr, but generally it will throw a BuildException on failure.

Object lifetime is the caller's responsibility.

Definition at line 41 of file CollectiveVariable.cpp.

References SSAGES::AlphaRMSDCV::Build(), SSAGES::AntiBetaRMSDCV::Build(), SSAGES::ParallelBetaRMSDCV::Build(), and SSAGES::CVManager::cvmap_.

Referenced by SSAGES::ResourceHandler::Build().

42  {
43  // Get CV type.
44  auto type = json.get("type", "none").asString();
46  if(type == "Angle")
47  return AngleCV::Build(json, path);
48  else if(type == "BoxVolume")
49  return BoxVolumeCV::Build(json, path);
50  else if(type == "GyrationTensor")
51  return GyrationTensorCV::Build(json, path);
52  else if(type == "Pairwise")
53  return PairwiseCV::Build(json, path);
54  else if(type == "ParticleCoordinate")
55  return ParticleCoordinateCV::Build(json, path);
56  else if(type == "ParticlePosition")
57  return ParticlePositionCV::Build(json, path);
58  else if(type == "ParticleSeparation")
59  return ParticleSeparationCV::Build(json, path);
60  else if(type == "RouseMode")
61  return RouseModeCV::Build(json, path);
62  else if(type == "Torsional")
63  return TorsionalCV::Build(json, path);
64  else if (type == "AlphaRMSD")
65  return AlphaRMSDCV::Build(json, path);
66  else if (type == "ParallelBetaRMSD")
67  return ParallelBetaRMSDCV::Build(json, path);
68  else if (type == "AntiBetaRMSD")
69  return AntiBetaRMSDCV::Build(json, path);
70  else
71  throw std::invalid_argument(path + ": Unknown CV type specified.");
72  }
static AntiBetaRMSDCV * Build(const Json::Value &json, const std::string &path)
Set up collective variable.
static AlphaRMSDCV * Build(const Json::Value &json, const std::string &path)
Set up collective variable.
Definition: AlphaRMSDCV.h:233
static ParallelBetaRMSDCV * Build(const Json::Value &json, const std::string &path)
Set up collective variable.

Here is the call graph for this function:

Here is the caller graph for this function:

virtual void SSAGES::CollectiveVariable::Evaluate ( const class Snapshot )
pure virtual

Evaluate CV.

snapshotReference of the current simulation snapshot.

Evaluation of the CV. This function is called by the Hook in the post-integration phase every iteration. The CV should compute its value and gradient, storing them in a local private variable.

const std::array<double, 2>& SSAGES::CollectiveVariable::GetBoundaries ( )

Get CV boundaries.

List of lower and upper boundaries of the CV.

Returns the boundaries of the CV. These represent the bounds within which the CV is expected to be constrained. There is no requirement on the method to respect the values returned here.

Definition at line 152 of file CollectiveVariable.h.

153  {
154  return bounds_;
155  }
std::array< double, 2 > bounds_
Bounds on CV.
virtual double SSAGES::CollectiveVariable::GetDifference ( double  location) const

Get difference between current CV value and a given value, taking periodic boundaries into account.

locationValue whose distance from the current CV value should be calculated.
Difference taking periodic boundaries into account.

Returns the difference betwen the current cv value and Location: (value_ - Location) respecting periodic boundary conditions of the CV, if the CV has periodic boundary conditions. For example Torsional angle has boundaries at pi and -pi, in which the difference beteen the angles is 0 not 2pi

Reimplemented in SSAGES::TorsionalCV, and SSAGES::ParticleCoordinateCV.

Definition at line 169 of file CollectiveVariable.h.

170  {
171  return val_ - location;
172  }
double val_
Current value of CV.
const std::vector<Vector3>& SSAGES::CollectiveVariable::GetGradient ( ) const

Get current gradient of the CV.

Per-atom gradient of the CV.

Returns the current value of the CV gradient. This should be an n length vector, where n is the number of atoms in the snapshot. Each element in the vector is the derivative of the CV with respect to the atom's coordinate (dCV/dxi).

Definition at line 128 of file CollectiveVariable.h.

129  {
130  return grad_;
131  }
std::vector< Vector3 > grad_
Gradient vector dCv/dxi.
virtual double SSAGES::CollectiveVariable::GetMinimumImage ( double  ) const

Returns the minimum image of a CV based on the input location.

Minimum image of the CV

Takes the input location and applies the periodic boundary conditions to return a minimum image of the CV.

Reimplemented in SSAGES::TorsionalCV.

Definition at line 99 of file CollectiveVariable.h.

100  {
101  return val_;
102  }
double val_
Current value of CV.
virtual double SSAGES::CollectiveVariable::GetPeriodicValue ( double  location) const

Apply periodic boundaries to a given value.

locationValue to which the periodic boundaries should be applied.
Correct value.

Takes location and applies periodic boundaries of the CV on it and returns a correct value. Example would be torsional angle which has bounds at pi and -pi. If location = 2pi, GetPeriodicValue(location) would return 0.

Reimplemented in SSAGES::TorsionalCV, and SSAGES::ParticleCoordinateCV.

Definition at line 114 of file CollectiveVariable.h.

115  {
116  return location;
117  }
double SSAGES::CollectiveVariable::GetValue ( ) const

Get current value of the CV.

Current value of the CV.

Returns the current value of the CV which has been computed before via the call to CollectiveVariable::Evaluate().

Definition at line 87 of file CollectiveVariable.h.

88  {
89  return val_;
90  }
double val_
Current value of CV.
virtual void SSAGES::CollectiveVariable::Initialize ( const class Snapshot )

Initialize CV.

Initialization of the CV. This is an optional method and is called during the pre-simulation phase of the hook. It is typically used to allocate/reserve memory.

Definition at line 68 of file CollectiveVariable.h.

68 {}

The documentation for this class was generated from the following files: