SSAGES  0.8.5
Software Suite for Advanced General Ensemble Simulations
Public Member Functions | Static Public Member Functions | List of all members
SSAGES::Chebyshev Class Reference

Defines the class of Chebyshev polynomials. More...

#include <Basis.h>

Inheritance diagram for SSAGES::Chebyshev:
Inheritance graph
[legend]

Public Member Functions

 Chebyshev (unsigned int polyOrd, double boundLow, double boundUp, unsigned int nbins)
 Constructor. More...
 
double ChangeVariable (double x)
 Transforms variable from absolute value to [-1,1] between boundaries. More...
 
double Evaluate (double x, int n)
 Calculates the output of the basis function. More...
 
double EvalGrad (double x, int n)
 Calculates the gradient of the basis function. More...
 
double Weight (double x)
 Calculates the gradient of the basis function. More...
 
double GetNorm (int)
 Gets the norm of the basis function. More...
 
- Public Member Functions inherited from SSAGES::BasisFunction
 BasisFunction (unsigned int polyOrd, unsigned int nbins, bool isFinite, bool zeroOrder, double boundLow, double boundUp)
 Constructor. More...
 
unsigned int GetOrder ()
 Gets the order of the current polynomial. More...
 
unsigned int GetBins ()
 Gets the number of bins for the discretization. More...
 
bool GetZeroOrder ()
 Gets the flag for constant-order polynomials. More...
 
double GetLower ()
 Gets the lower bound on the CV. More...
 
double GetUpper ()
 Gets the upper bound on the CV. More...
 
double GetRange ()
 Gets the magnitude of the range of bounds. More...
 
virtual ~BasisFunction ()
 Destructor.
 

Static Public Member Functions

static ChebyshevBuild (const Json::Value &json, const std::string &path, unsigned int nbins)
 Build BasisFunction from JSON value. More...
 
- Static Public Member Functions inherited from SSAGES::BasisFunction
static BasisFunctionBuild (const Json::Value &json, const std::string &path, unsigned int nbins)
 Build BasisFunction from JSON value. More...
 

Additional Inherited Members

- Protected Attributes inherited from SSAGES::BasisFunction
unsigned int polyOrd_
 Order of the polynomial.
 
unsigned int nbins_
 Number of bins.
 
bool isFinite_
 Flag for finite-range polynomials.
 
bool zeroOrder_
 Flag for constant-order polynomials.
 
double boundLow_
 Lower bound on CV.
 
double boundUp_
 Upper bound on CV.
 

Detailed Description

Defines the class of Chebyshev polynomials.

Definition at line 201 of file Basis.h.

Constructor & Destructor Documentation

SSAGES::Chebyshev::Chebyshev ( unsigned int  polyOrd,
double  boundLow,
double  boundUp,
unsigned int  nbins 
)
inline

Constructor.

Parameters
polyOrdOrder of Chebyshev polynomial.
boundLowLower bounds of restraint springs.
boundUpUpper bounds of restraint springs.
nbinsNumber of bins.

Constructs an instance of the Chebyshev function class.

Definition at line 215 of file Basis.h.

215  :
216  BasisFunction(polyOrd, nbins, true, false, boundLow, boundUp)
217  {
218  }
BasisFunction(unsigned int polyOrd, unsigned int nbins, bool isFinite, bool zeroOrder, double boundLow, double boundUp)
Constructor.
Definition: Basis.h:84

Member Function Documentation

Chebyshev * SSAGES::Chebyshev::Build ( const Json::Value &  json,
const std::string &  path,
unsigned int  nbins 
)
static

Build BasisFunction from JSON value.

Build the Chebyshev polynomial

Parameters
jsonJSON value node.
pathPath for JSON path specification.
nbinsNumber of bins.
Returns
Pointer to new BasisFunction.

Definition at line 22 of file Basis.cpp.

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

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

25  {
26  Json::ObjectRequirement validator;
27  Json::Value schema;
28  Json::CharReaderBuilder rbuilder;
29  Json::CharReader* reader = rbuilder.newCharReader();
30 
31  reader->parse(JsonSchema::ChebyshevBasis.c_str(),
32  JsonSchema::ChebyshevBasis.c_str() + JsonSchema::ChebyshevBasis.size(),
33  &schema, nullptr);
34  validator.Parse(schema, path);
35 
36  //Validate Inputs
37  validator.Validate(json, path);
38  if(validator.HasErrors())
39  throw BuildException(validator.GetErrors());
40 
41  return new Chebyshev(
42  json["polynomial_order"].asInt(),
43  json["lower_bound"].asDouble(),
44  json["upper_bound"].asDouble(),
45  nbin
46  );
47  }
bool HasErrors()
Check if errors have occured.
Definition: Requirement.h:86
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.
Chebyshev(unsigned int polyOrd, double boundLow, double boundUp, unsigned int nbins)
Constructor.
Definition: Basis.h:215
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::Chebyshev::ChangeVariable ( double  x)
inline

Transforms variable from absolute value to [-1,1] between boundaries.

Parameters
xVariable to transform.
Returns
Relative value between lower (-1) and upper (1) bounds on CV.

Definition at line 226 of file Basis.h.

227  {
228  return (x-boundLow_)*2.0/(boundUp_ - boundLow_)-1.0;
229  }
double boundUp_
Upper bound on CV.
Definition: Basis.h:69
double boundLow_
Lower bound on CV.
Definition: Basis.h:68
double SSAGES::Chebyshev::EvalGrad ( double  val,
int  order 
)
inlinevirtual

Calculates the gradient of the basis function.

Parameters
valInput value for function.
orderOrder of the polynomial.
Returns
Gradient for function.

Reimplemented from SSAGES::BasisFunction.

Definition at line 239 of file Basis.h.

240  {
241  double xMod = ChangeVariable(x);
242  return n == 0 ? 0.0 :
243  n == 1 ? 1.0 :
244  2.0*(Evaluate(x,n-1) + xMod * EvalGrad(x,n-1)) - EvalGrad(x,n-2);
245  }
double EvalGrad(double x, int n)
Calculates the gradient of the basis function.
Definition: Basis.h:239
double Evaluate(double x, int n)
Calculates the output of the basis function.
Definition: Basis.h:231
double ChangeVariable(double x)
Transforms variable from absolute value to [-1,1] between boundaries.
Definition: Basis.h:226
double SSAGES::Chebyshev::Evaluate ( double  val,
int  order 
)
inlinevirtual

Calculates the output of the basis function.

Parameters
valInput value for function.
orderOrder of the polynomial.
Returns
Output value for function.

Reimplemented from SSAGES::BasisFunction.

Definition at line 231 of file Basis.h.

232  {
233  double xMod = ChangeVariable(x);
234  return n == 0 ? 1.0 :
235  n == 1 ? xMod :
236  2.0*xMod*Evaluate(x,n-1) - Evaluate(x,n-2);
237  }
double Evaluate(double x, int n)
Calculates the output of the basis function.
Definition: Basis.h:231
double ChangeVariable(double x)
Transforms variable from absolute value to [-1,1] between boundaries.
Definition: Basis.h:226
double SSAGES::Chebyshev::GetNorm ( int  order)
inlinevirtual

Gets the norm of the basis function.

Parameters
orderOrder of the polynomial.
Returns
Norm of a specific order of polynomial.

Reimplemented from SSAGES::BasisFunction.

Definition at line 253 of file Basis.h.

254  {
255  return 2.0/M_PI;
256  }
double SSAGES::Chebyshev::Weight ( double  val)
inlinevirtual

Calculates the gradient of the basis function.

Parameters
valInput value for function.
Returns
Gradient of function.

Reimplemented from SSAGES::BasisFunction.

Definition at line 247 of file Basis.h.

248  {
249  double xMod = ChangeVariable(x);
250  return 1.0/sqrt(1.0-xMod*xMod);
251  }
double ChangeVariable(double x)
Transforms variable from absolute value to [-1,1] between boundaries.
Definition: Basis.h:226

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