SSAGES  0.9.3
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 weight 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 193 of file Basis.h.

Constructor & Destructor Documentation

◆ Chebyshev()

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 207 of file Basis.h.

207  :
208  BasisFunction(polyOrd, nbins, true, false, boundLow, boundUp)
209  {
210  }
BasisFunction(unsigned int polyOrd, unsigned int nbins, bool isFinite, bool zeroOrder, double boundLow, double boundUp)
Constructor.
Definition: Basis.h:82

Referenced by Build().

Here is the caller graph for this function:

Member Function Documentation

◆ Build()

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.

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  }
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
Chebyshev(unsigned int polyOrd, double boundLow, double boundUp, unsigned int nbins)
Constructor.
Definition: Basis.h:207

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

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

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

◆ ChangeVariable()

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 218 of file Basis.h.

219  {
220  return (x-boundLow_)*2.0/(boundUp_ - boundLow_)-1.0;
221  }
double boundLow_
Lower bound on CV.
Definition: Basis.h:66
double boundUp_
Upper bound on CV.
Definition: Basis.h:67

References SSAGES::BasisFunction::boundLow_, and SSAGES::BasisFunction::boundUp_.

Referenced by EvalGrad(), Evaluate(), and Weight().

Here is the caller graph for this function:

◆ EvalGrad()

double SSAGES::Chebyshev::EvalGrad ( double  ,
int   
)
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 231 of file Basis.h.

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

References ChangeVariable(), and Evaluate().

Here is the call graph for this function:

◆ Evaluate()

double SSAGES::Chebyshev::Evaluate ( double  ,
int   
)
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 223 of file Basis.h.

224  {
225  double xMod = ChangeVariable(x);
226  return n == 0 ? 1.0 :
227  n == 1 ? xMod :
228  2.0*xMod*Evaluate(x,n-1) - Evaluate(x,n-2);
229  }

References ChangeVariable().

Referenced by EvalGrad().

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

◆ GetNorm()

double SSAGES::Chebyshev::GetNorm ( int  )
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 245 of file Basis.h.

246  {
247  return 2.0/M_PI;
248  }

◆ Weight()

double SSAGES::Chebyshev::Weight ( double  )
inlinevirtual

Calculates the weight of the basis function.

Parameters
valInput value for function.
Returns
Weight of function.

Reimplemented from SSAGES::BasisFunction.

Definition at line 239 of file Basis.h.

240  {
241  double xMod = ChangeVariable(x);
242  return 1.0/sqrt(1.0-xMod*xMod);
243  }

References ChangeVariable().

Here is the call graph for this function:

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