SSAGES  0.9.3
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

◆ RationalSwitchPK()

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 d0_
Minimum linear shift value.
int m_
Exponent of denominator in switching function (controls stiffness).
double r0_
Cutoff distance.
int n_
Exponent of numerator in switching function (controls stiffness).

Referenced by Build().

Here is the caller graph for this function:

Member Function Documentation

◆ Build()

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.

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  }
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
RationalSwitchPK(double d0, double r0, int n, int m)
Constructor.

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

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

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

◆ Evaluate()

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.

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  }

References d0_, m_, n_, and r0_.


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