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

Defines the class of Fourier polynomials. More...

#include <Basis.h>

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

Public Member Functions

 Fourier (unsigned int polyOrd, double boundLow, double boundUp, unsigned int nbins)
 Constructor. 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 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 double Weight (double)
 Calculates the weight of the basis function. More...
 
virtual ~BasisFunction ()
 Destructor.
 

Static Public Member Functions

static FourierBuild (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 Fourier polynomials.

Definition at line 299 of file Basis.h.

Constructor & Destructor Documentation

◆ Fourier()

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

Constructor.

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

Constructs an instance of the Fourier function class.

Definition at line 313 of file Basis.h.

313  :
314  BasisFunction(polyOrd, nbins, true, true, boundLow, boundUp)
315  {
316  }
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()

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

Build BasisFunction from JSON value.

Build the Fourier polynomial

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

Definition at line 49 of file Basis.cpp.

52  {
53  Json::ObjectRequirement validator;
54  Json::Value schema;
55  Json::CharReaderBuilder rbuilder;
56  Json::CharReader* reader = rbuilder.newCharReader();
57 
58  reader->parse(JsonSchema::FourierBasis.c_str(),
59  JsonSchema::FourierBasis.c_str() + JsonSchema::FourierBasis.size(),
60  &schema, nullptr);
61  validator.Parse(schema, path);
62 
63  //Validate Inputs
64  validator.Validate(json, path);
65  if(validator.HasErrors())
66  throw BuildException(validator.GetErrors());
67 
68  return new Fourier(
69  json["polynomial_order"].asInt(),
70  json["lower_bound"].asDouble(),
71  json["upper_bound"].asDouble(),
72  nbin
73  );
74  }
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
Fourier(unsigned int polyOrd, double boundLow, double boundUp, unsigned int nbins)
Constructor.
Definition: Basis.h:313

References Fourier(), 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:

◆ EvalGrad()

double SSAGES::Fourier::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 328 of file Basis.h.

329  {
330  return n == 0 ? 0.0 :
331  n % 2 == 0 ? (-2.0*floor(double(n)*0.5)*M_PI/(boundUp_-boundLow_))*(std::sin(2.0*floor(double(n)*0.5)*M_PI*x/(boundUp_-boundLow_))) :
332  (2.0*floor(double(n)*0.5)*M_PI/(boundUp_-boundLow_))*std::cos(2.0*floor(double(n)*0.5)*M_PI*x/(boundUp_-boundLow_));
333  }
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_.

◆ Evaluate()

double SSAGES::Fourier::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 321 of file Basis.h.

322  {
323  return n == 0 ? 0.5 :
324  n % 2 == 1 ? std::sin(2.0*floor(double(n)*0.5)*M_PI*x/(boundUp_-boundLow_)) :
325  std::cos(2.0*floor(double(n)*0.5)*M_PI*x/(boundUp_-boundLow_));
326  }

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

◆ GetNorm()

double SSAGES::Fourier::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 335 of file Basis.h.

336  {
337  //Assumes the period of the function is the range of the CV
338  return 2.0/(boundUp_-boundLow_);
339  }

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


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