Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
PLMD::SwitchingFunction Class Reference

Small class to compure switching functions. More...

#include <SwitchingFunction.h>

Public Member Functions

double calculate (double x, double &df) const
 Compute the switching function. More...
 
double calculateSqr (double distance2, double &dfunc) const
 Compute the switching function. More...
 
std::string description () const
 Returns a string with a description of the switching function. More...
 
double get_d0 () const
 Returns d0. More...
 
double get_dmax () const
 Return dmax. More...
 
double get_dmax2 () const
 Return dmax squared. More...
 
double get_r0 () const
 Returns r0. More...
 
void set (int nn, int mm, double r_0, double d_0)
 Set a "rational" switching function. More...
 
void set (const std::string &definition, std::string &errormsg)
 Set an arbitrary switching function. More...
 

Static Public Member Functions

static void registerKeywords (Keywords &keys)
 

Private Types

enum  {
  rational, exponential, gaussian, smap,
  cubic, tanh, cosinus, matheval,
  leptontype, nativeq
}
 Type of function. More...
 

Private Member Functions

double do_rational (double rdist, double &dfunc, int nn, int mm) const
 Low-level tool to compute rational functions. More...
 

Private Attributes

int a =0
 Parameters for smap function. More...
 
int b =0
 
double beta =0.0
 
double c =0.0
 
double d =0.0
 
double d0 =0.0
 Minimum distance (before this, function is one) More...
 
double dmax =0.0
 Maximum distance (after this, function is zero) More...
 
double dmax_2 =0.0
 Square of dmax, useful in calculateSqr() More...
 
std::vector< lepton::CompiledExpressionexpression
 Lepton expression. More...
 
std::vector< lepton::CompiledExpressionexpression_deriv
 Lepton expression for derivative. More...
 
bool fastrational =false
 Set to true for fast rational functions (depending on x**2 only) More...
 
bool init =false
 This is to check that switching function has been initialized. More...
 
double invr0 =0.0
 Inverse of scaling length. More...
 
double invr0_2 =0.0
 Square of invr0, useful in calculateSqr() More...
 
double lambda =0.0
 
std::string lepton_func
 Function for lepton;. More...
 
std::vector< double * > lepton_ref
 
std::vector< double * > lepton_ref_deriv
 
bool leptonx2 =false
 Set to true if lepton only uses x2. More...
 
int mm =0
 
int nn =6
 Exponents for rational function. More...
 
double ref =0.0
 
double shift =0.0
 
double stretch =1.0
 Parameters for stretching the function to zero at d_max. More...
 
enum PLMD::SwitchingFunction:: { ... }  type =rational
 Type of function. More...
 

Detailed Description

Small class to compure switching functions.

Switching functions are created using set() and then can be used with function calculate() or calculateSqr(). Since this is typically computed on a distance vector, the second all (calculateSqr()) allows to skip the calculation of a square root in some case, thus potentially increasing performances.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private

Type of function.

Enumerator
rational 
exponential 
gaussian 
smap 
cubic 
tanh 
cosinus 
matheval 
leptontype 
nativeq 

Member Function Documentation

◆ calculate()

double PLMD::SwitchingFunction::calculate ( double  x,
double &  df 
) const

Compute the switching function.

Returns s(x). df will be set to the value of the derivative of the switching function _divided_by_x

◆ calculateSqr()

double PLMD::SwitchingFunction::calculateSqr ( double  distance2,
double &  dfunc 
) const

Compute the switching function.

Returns \( s(\sqrt{x})\) . df will be set to the \( \frac{1}{\sqrt{x}}\frac{ds}{d\sqrt{x}}= 2 \frac{ds}{dx}\) (same as calculate()). The advantage is that in some case the expensive square root can be avoided (namely for rational functions, if nn and mm are even and d0 is zero)

◆ description()

std::string PLMD::SwitchingFunction::description ( ) const

Returns a string with a description of the switching function.

◆ do_rational()

double PLMD::SwitchingFunction::do_rational ( double  rdist,
double &  dfunc,
int  nn,
int  mm 
) const
private

Low-level tool to compute rational functions.

It is separated since it is called both by calculate() and calculateSqr()

◆ get_d0()

double PLMD::SwitchingFunction::get_d0 ( ) const

Returns d0.

◆ get_dmax()

double PLMD::SwitchingFunction::get_dmax ( ) const

Return dmax.

◆ get_dmax2()

double PLMD::SwitchingFunction::get_dmax2 ( ) const

Return dmax squared.

◆ get_r0()

double PLMD::SwitchingFunction::get_r0 ( ) const

Returns r0.

◆ registerKeywords()

void PLMD::SwitchingFunction::registerKeywords ( Keywords keys)
static

◆ set() [1/2]

void PLMD::SwitchingFunction::set ( int  nn,
int  mm,
double  r_0,
double  d_0 
)

Set a "rational" switching function.

Notice that a d_max is set automatically to a value such that f(d_max)=0.00001.

◆ set() [2/2]

void PLMD::SwitchingFunction::set ( const std::string &  definition,
std::string &  errormsg 
)

Set an arbitrary switching function.

Parse the string in definition and possibly returns errors in the errormsg string

Member Data Documentation

◆ a

int PLMD::SwitchingFunction::a =0
private

Parameters for smap function.

◆ b

int PLMD::SwitchingFunction::b =0
private

◆ beta

double PLMD::SwitchingFunction::beta =0.0
private

◆ c

double PLMD::SwitchingFunction::c =0.0
private

◆ d

double PLMD::SwitchingFunction::d =0.0
private

◆ d0

double PLMD::SwitchingFunction::d0 =0.0
private

Minimum distance (before this, function is one)

◆ dmax

double PLMD::SwitchingFunction::dmax =0.0
private

Maximum distance (after this, function is zero)

◆ dmax_2

double PLMD::SwitchingFunction::dmax_2 =0.0
private

Square of dmax, useful in calculateSqr()

◆ expression

std::vector<lepton::CompiledExpression> PLMD::SwitchingFunction::expression
private

Lepton expression.

Warning
Since lepton::CompiledExpression is mutable, a vector is necessary for multithreading!

◆ expression_deriv

std::vector<lepton::CompiledExpression> PLMD::SwitchingFunction::expression_deriv
private

Lepton expression for derivative.

Warning
Since lepton::CompiledExpression is mutable, a vector is necessary for multithreading!

◆ fastrational

bool PLMD::SwitchingFunction::fastrational =false
private

Set to true for fast rational functions (depending on x**2 only)

◆ init

bool PLMD::SwitchingFunction::init =false
private

This is to check that switching function has been initialized.

◆ invr0

double PLMD::SwitchingFunction::invr0 =0.0
private

Inverse of scaling length.

We store the inverse to avoid a division

◆ invr0_2

double PLMD::SwitchingFunction::invr0_2 =0.0
private

Square of invr0, useful in calculateSqr()

◆ lambda

double PLMD::SwitchingFunction::lambda =0.0
private

◆ lepton_func

std::string PLMD::SwitchingFunction::lepton_func
private

Function for lepton;.

◆ lepton_ref

std::vector<double*> PLMD::SwitchingFunction::lepton_ref
private

◆ lepton_ref_deriv

std::vector<double*> PLMD::SwitchingFunction::lepton_ref_deriv
private

◆ leptonx2

bool PLMD::SwitchingFunction::leptonx2 =false
private

Set to true if lepton only uses x2.

◆ mm

int PLMD::SwitchingFunction::mm =0
private

◆ nn

int PLMD::SwitchingFunction::nn =6
private

Exponents for rational function.

◆ ref

double PLMD::SwitchingFunction::ref =0.0
private

◆ shift

double PLMD::SwitchingFunction::shift =0.0
private

◆ stretch

double PLMD::SwitchingFunction::stretch =1.0
private

Parameters for stretching the function to zero at d_max.

◆ type

enum { ... } PLMD::SwitchingFunction::type

Type of function.


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