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

Public Member Functions

 RationalSwitchPK (double d0, double r0, int n, int m)
 Constructor. More...
 
double Evaluate (double rij, double &df) const override
 Evaluate the pairwise kernel function. More...
 
- Public Member Functions inherited from SSAGES::PairwiseKernel
virtual ~PairwiseKernel ()
 Destructor.
 

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_
 Exponent of numerator in switching function (controls stiffness).
 
int m_
 Exponent of denominator in switching function (controls stiffness).
 

Detailed Description

Rational Switching Function.

A switching function of a rational form.

Definition at line 120 of file PairwiseKernel.h.

Constructor & Destructor Documentation

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

Constructor.

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

Construct a GaussianPK.

Definition at line 139 of file PairwiseKernel.h.

139  :
140  d0_(d0), r0_(r0), n_(n), m_(m) {}
double r0_
Cutoff distance.
double d0_
Minimum linear shift value.
int n_
Exponent of numerator in switching function (controls stiffness).
int m_
Exponent of denominator in switching function (controls stiffness).

Member Function Documentation

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

Build RationalSwitchPK from JSON value.

Parameters
jsonJSON value node.
pathPath for JSON path specification.
Returns
Pointer to new RationalSwitchPK.
Parameters
jsonJSON value node.
Returns
Pointer to new RationalSwitchPK.

Definition at line 77 of file PairwiseKernel.cpp.

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

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

78  {
79  Json::ObjectRequirement validator;
80  Json::Value schema;
81  Json::CharReaderBuilder rbuilder;
82  Json::CharReader* reader = rbuilder.newCharReader();
83 
84  reader->parse(JsonSchema::RationalSwitchPK.c_str(),
85  JsonSchema::RationalSwitchPK.c_str() + JsonSchema::RationalSwitchPK.size(),
86  &schema, nullptr);
87  validator.Parse(schema, path);
88 
89  // Validate inputs.
90  validator.Validate(json, path);
91  if(validator.HasErrors())
92  throw BuildException(validator.GetErrors());
93  return new RationalSwitchPK(
94  json["d0"].asDouble(),
95  json["r0"].asDouble(),
96  json["n"].asInt(),
97  json["m"].asInt()
98  );
99  }
bool HasErrors()
Check if errors have occured.
Definition: Requirement.h:86
RationalSwitchPK(double d0, double r0, int n, int m)
Constructor.
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
inlineoverridevirtual

Evaluate the pairwise kernel function.

Parameters
rijdistance between two atoms.
dfReference to variable which will store the gradient.
Returns
value of pairwise kernel function.

Implements SSAGES::PairwiseKernel.

Definition at line 142 of file PairwiseKernel.h.

References SSAGES::PairwiseKernel::Build().

143  {
144  const auto xarg = (rij - d0_)/r0_;
145  const auto xn = std::pow(xarg, n_);
146  const auto xm = std::pow(xarg, m_);
147  const auto f = (1.-xn)/(1.-xm);
148 
149  df = f/(d0_-rij)*(n_*xn/(1.-xn)+m_*xm/(xm-1.));
150  return f;
151  }
double r0_
Cutoff distance.
double d0_
Minimum linear shift value.
int n_
Exponent of numerator in switching function (controls stiffness).
int m_
Exponent of denominator in switching function (controls stiffness).

Here is the call graph for this function:


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