SSAGES  0.8.3
Software Suite for Advanced General Ensemble Simulations
Public Member Functions | Static Public Member Functions | List of all members
SSAGES::BoxVolumeCV Class Reference

Collective variable on the volume of a box. More...

#include <BoxVolumeCV.h>

Inheritance diagram for SSAGES::BoxVolumeCV:
Inheritance graph

Public Member Functions

 BoxVolumeCV ()
void Initialize (const Snapshot &) override
 Initialize the CV.
void Evaluate (const Snapshot &snapshot) override
 Evaluate the CV. More...
- Public Member Functions inherited from SSAGES::CollectiveVariable
 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 BoxVolumeCVBuild (const Json::Value &json, const std::string &path)
 Set up collective variable. More...
- Static Public Member Functions inherited from SSAGES::CollectiveVariable
static CollectiveVariableBuildCV (const Json::Value &json, const std::string &path)
 Set up collective variable. More...

Additional Inherited Members

- Protected Attributes inherited from SSAGES::CollectiveVariable
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

Collective variable on the volume of a box.

Collective variable on the volume of a box.

Definition at line 36 of file BoxVolumeCV.h.

Member Function Documentation

◆ Build()

static BoxVolumeCV* SSAGES::BoxVolumeCV::Build ( 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 65 of file BoxVolumeCV.h.

References BoxVolumeCV(), Json::Requirement::GetErrors(), Json::Requirement::HasErrors(), Json::ObjectRequirement::Parse(), and Json::ObjectRequirement::Validate().

Referenced by SSAGES::CollectiveVariable::BuildCV().

66  {
67  Json::ObjectRequirement validator;
68  Json::Value schema;
69  Json::CharReaderBuilder rbuilder;
70  Json::CharReader* reader = rbuilder.newCharReader();
72  reader->parse(JsonSchema::BoxVolumeCV.c_str(),
73  JsonSchema::BoxVolumeCV.c_str() + JsonSchema::BoxVolumeCV.size(),
74  &schema, NULL);
75  validator.Parse(schema, path);
77  // Validate inputs.
78  validator.Validate(json, path);
79  if(validator.HasErrors())
80  throw BuildException(validator.GetErrors());
82  return new BoxVolumeCV();
83  }
bool HasErrors()
Check if errors have occured.
Definition: Requirement.h:86
virtual void Parse(Value json, const std::string &path) override
Parse JSON value to generate Requirement(s).
std::vector< std::string > GetErrors()
Get list of error messages.
Definition: Requirement.h:92
Requirements on an object.
Definition: BoxVolumeCV.h:40
virtual void Validate(const Value &json, const std::string &path) override
Validate JSON value.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Evaluate()

void SSAGES::BoxVolumeCV::Evaluate ( const Snapshot snapshot)

Evaluate the CV.

snapshotCurrent simulation snapshot.

Definition at line 52 of file BoxVolumeCV.h.

References SSAGES::CollectiveVariable::boxgrad_, SSAGES::Snapshot::GetCommunicator(), SSAGES::Snapshot::GetNumAtoms(), SSAGES::Snapshot::GetVolume(), SSAGES::CollectiveVariable::grad_, and SSAGES::CollectiveVariable::val_.

53  {
54  // Fill empty gradient.
55  auto n = snapshot.GetNumAtoms();
56  std::fill(grad_.begin(), grad_.end(), Vector3{0,0,0});
57  grad_.resize(n, Vector3{0,0,0});
59  val_ = snapshot.GetVolume();
60  if(snapshot.GetCommunicator().rank() == 0)
61  boxgrad_ = val_*Matrix3::Identity();
62  }
std::vector< Vector3 > grad_
Gradient vector dCv/dxi.
Eigen::Vector3d Vector3
Three-dimensional vector.
Definition: types.h:33
double val_
Current value of CV.
Matrix3 boxgrad_
Gradient w.r.t box vectors dCv/dHij.
Here is the call graph for this function:

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