SSAGES  0.9.3
Software Suite for Advanced General Ensemble Simulations
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
[legend]

Public Member Functions

 CollectiveVariable ()
 Constructor.
 
virtual ~CollectiveVariable ()
 Destructor.
 
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. More...
 
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 40 of file CollectiveVariable.h.

Member Function Documentation

◆ BuildCV()

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

Set up collective variable.

Parameters
jsonJSON input value.
pathPath for JSON path specification.
Returns
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.

Warning
Object lifetime is the caller's responsibility.

Definition at line 43 of file CollectiveVariable.cpp.

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

References SSAGES::AlphaRMSDCV::Build(), SSAGES::AngleCV::Build(), SSAGES::ANNCV::Build(), SSAGES::AntiBetaRMSDCV::Build(), SSAGES::BoxVolumeCV::Build(), SSAGES::GyrationTensorCV::Build(), SSAGES::PairwiseCV::Build(), SSAGES::ParallelBetaRMSDCV::Build(), SSAGES::ParticleCoordinateCV::Build(), SSAGES::ParticlePositionCV::Build(), SSAGES::ParticleSeparationCV::Build(), SSAGES::RMSDCV::Build(), SSAGES::RouseModeCV::Build(), and SSAGES::TorsionalCV::Build().

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Evaluate()

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

Evaluate CV.

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.

◆ GetBoundaries()

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

Get CV boundaries.

Returns
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 151 of file CollectiveVariable.h.

152  {
153  return bounds_;
154  }
std::array< double, 2 > bounds_
Bounds on CV.

◆ GetBoxGradient()

const Matrix3& SSAGES::CollectiveVariable::GetBoxGradient ( ) const
inline

Get gradient contribution to box.

Returns
Gradient of CV with respect to box.

Returns the gradient of the CV with respect to the box.

Definition at line 138 of file CollectiveVariable.h.

139  {
140  return boxgrad_;
141  }
Matrix3 boxgrad_
Gradient w.r.t box vectors dCv/dHij.

◆ GetDifference()

virtual double SSAGES::CollectiveVariable::GetDifference ( double  location) const
inlinevirtual

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

Parameters
locationValue whose distance from the current CV value should be calculated.
Returns
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 168 of file CollectiveVariable.h.

169  {
170  return val_ - location;
171  }
double val_
Current value of CV.

◆ GetGradient()

const std::vector<Vector3>& SSAGES::CollectiveVariable::GetGradient ( ) const
inline

Get current gradient of the CV.

Returns
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 127 of file CollectiveVariable.h.

128  {
129  return grad_;
130  }
std::vector< Vector3 > grad_
Gradient vector dCv/dxi.

◆ GetMinimumImage()

virtual double SSAGES::CollectiveVariable::GetMinimumImage ( double  ) const
inlinevirtual

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

Returns
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 98 of file CollectiveVariable.h.

99  {
100  return val_;
101  }

◆ GetPeriodicValue()

virtual double SSAGES::CollectiveVariable::GetPeriodicValue ( double  location) const
inlinevirtual

Apply periodic boundaries to a given value.

Parameters
locationValue to which the periodic boundaries should be applied.
Returns
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 113 of file CollectiveVariable.h.

114  {
115  return location;
116  }

◆ GetValue()

double SSAGES::CollectiveVariable::GetValue ( ) const
inline

Get current value of the CV.

Returns
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 86 of file CollectiveVariable.h.

87  {
88  return val_;
89  }

◆ Initialize()

virtual void SSAGES::CollectiveVariable::Initialize ( const class Snapshot )
inlinevirtual

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 69 of file CollectiveVariable.h.

69 {}

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