SSAGES  0.9.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
[legend]

Public Member Functions

 BoxVolumeCV ()
 Constructor.
 
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 ()
 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 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 
)
inlinestatic

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 65 of file BoxVolumeCV.h.

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

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

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

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

◆ Evaluate()

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

Evaluate the CV.

Parameters
snapshotCurrent simulation snapshot.

Definition at line 52 of file BoxVolumeCV.h.

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});
58 
59  val_ = snapshot.GetVolume();
60  if(snapshot.GetCommunicator().rank() == 0)
61  boxgrad_ = val_*Matrix3::Identity();
62  }
Matrix3 boxgrad_
Gradient w.r.t box vectors dCv/dHij.
std::vector< Vector3 > grad_
Gradient vector dCv/dxi.
double val_
Current value of CV.
Eigen::Vector3d Vector3
Three-dimensional vector.
Definition: types.h:33

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

Here is the call graph for this function:

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