A MetaDynamics Package
Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
SSAGES::RationalSwitchPK Class Reference

Rational Switching Function. More...

#include <PairwiseKernel.h>

Inheritance diagram for SSAGES::RationalSwitchPK:
Inheritance graph

Public Member Functions

 RationalSwitchPK (double d0, double r0, int n, int m)
 Constructor. More...
double Evaluate (double rij, double &df) const override
 Evaluate the switching function. More...

Static Public Member Functions

static RationalSwitchPKBuild (const Json::Value &json, const std::string &path)
 Build RationalSwitchPK from JSON value. More...
- Static Public Member Functions inherited from SSAGES::PairwiseKernel
static PairwiseKernelBuild (const Json::Value &json, const std::string &path)
 Build PairwiseKernel from JSON value. More...

Private Attributes

double d0_
 Minimum linear shift value.
double r0_
 Cutoff distance.
int n_
int m_
 Exponents of the switching function which control the stiffness.

Detailed Description

Rational Switching Function.

A switching function of a rational form.

Definition at line 122 of file PairwiseKernel.h.

Constructor & Destructor Documentation

SSAGES::RationalSwitchPK::RationalSwitchPK ( double  d0,
double  r0,
int  n,
int  m 


d0Minimum linear shift value.
r0Cutoff distance.
mAn exponent of the switching function.
nAn exponent of the switching function.

Construct a GaussianPK.

Definition at line 140 of file PairwiseKernel.h.

140  :
141  d0_(d0), r0_(r0), n_(n), m_(m) {}
double r0_
Cutoff distance.
double d0_
Minimum linear shift value.
int m_
Exponents of the switching function which control the stiffness.

Member Function Documentation

RationalSwitchPK * SSAGES::RationalSwitchPK::Build ( const Json::Value &  json,
const std::string &  path 

Build RationalSwitchPK from JSON value.

jsonJSON value node.
Pointer to new RationalSwitchPK.

Definition at line 74 of file PairwiseKernel.cpp.

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

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

75  {
76  Json::ObjectRequirement validator;
77  Json::Value schema;
78  Json::Reader reader;
80  reader.parse(JsonSchema::RationalSwitchPK, schema);
81  validator.Parse(schema, path);
83  // Validate inputs.
84  validator.Validate(json, path);
85  if(validator.HasErrors())
86  throw BuildException(validator.GetErrors());
87  return new RationalSwitchPK(
88  json["d0"].asDouble(),
89  json["r0"].asDouble(),
90  json["n"].asInt(),
91  json["m"].asInt()
92  );
93  }
bool HasErrors()
Check if errors have occured.
Definition: Requirement.h:86
RationalSwitchPK(double d0, double r0, int n, int m)
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.
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:

double SSAGES::RationalSwitchPK::Evaluate ( double  rij,
double &  df 
) const

Evaluate the switching function.

rijdistance between two atoms.
dfReference to variable which will store the gradient.
value of switching function.

Implements SSAGES::PairwiseKernel.

Definition at line 150 of file PairwiseKernel.h.

References SSAGES::PairwiseKernel::Build().

151  {
152  const auto xarg = (rij - d0_)/r0_;
153  const auto xn = std::pow(xarg, n_);
154  const auto xm = std::pow(xarg, m_);
155  const auto f = (1.-xn)/(1.-xm);
157  df = f/(d0_-rij)*(n_*xn/(1.-xn)+m_*xm/(xm-1.));
158  return f;
159  }
double r0_
Cutoff distance.
double d0_
Minimum linear shift value.
int m_
Exponents of the switching function which control the stiffness.

Here is the call graph for this function:

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