SSAGES  0.8.5
Software Suite for Advanced General Ensemble Simulations
PairwiseKernel.h
1 
21 #pragma once
22 
23 #include <cmath>
24 #include "json/json.h"
25 
26 namespace SSAGES
27 {
29 
45  {
46  public:
47 
49 
55  virtual double Evaluate(double rij, double& df) const = 0;
56 
58 
64  static PairwiseKernel* Build(const Json::Value& json, const std::string& path);
65 
67  virtual ~PairwiseKernel() {}
68  };
69 
71 
76  class GaussianPK : public PairwiseKernel
77  {
78  private:
79  double mu_;
80  double sigma_;
81 
82  public:
84 
91  GaussianPK(double mu, double sigma) :
92  mu_(mu), sigma_(sigma) {}
93 
94  double Evaluate(double rij, double& df) const
95  {
96  const auto dx = (rij - mu_)/sigma_;
97  const auto f = exp( - dx*dx/2.);
98  const auto pre = - dx/sigma_;
99 
100  df = pre * f;
101  return f;
102  }
103 
105 
111  static GaussianPK* Build(const Json::Value& json, const std::string& path);
112  };
113 
115 
121  {
122  private:
123  double d0_;
124  double r0_;
125  int n_;
126  int m_;
127 
128  public:
130 
139  RationalSwitchPK(double d0, double r0, int n, int m) :
140  d0_(d0), r0_(r0), n_(n), m_(m) {}
141 
142  double Evaluate(double rij, double& df) const override
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  }
152 
154 
160  static RationalSwitchPK* Build(const Json::Value& json, const std::string& path);
161  };
162 }
double r0_
Cutoff distance.
double d0_
Minimum linear shift value.
RationalSwitchPK(double d0, double r0, int n, int m)
Constructor.
int n_
Exponent of numerator in switching function (controls stiffness).
virtual double Evaluate(double rij, double &df) const =0
Evaluate the pairwise kernel function.
double mu_
Center of Gaussian.
double Evaluate(double rij, double &df) const override
Evaluate the pairwise kernel function.
Pairwise kernel base class.
double sigma_
Width of Gaussian.
Gaussian Function.
GaussianPK(double mu, double sigma)
Constructor.
double Evaluate(double rij, double &df) const
Evaluate the pairwise kernel function.
Rational Switching Function.
virtual ~PairwiseKernel()
Destructor.
int m_
Exponent of denominator in switching function (controls stiffness).
static PairwiseKernel * Build(const Json::Value &json, const std::string &path)
Build PairwiseKernel from JSON value.