Loading...
Searching...
No Matches
PLMD::SwitchingFunction Class Reference

Small class to compute switching functions. More...

#include <SwitchingFunction.h>

Public Member Functions

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

Static Public Member Functions

static void registerKeywords (Keywords &keys)
 

Private Member Functions

void copyFunction (const SwitchingFunction &)
 

Private Attributes

std::unique_ptr< switchContainers::Switchfunction {nullptr}
 

Detailed Description

Small class to compute 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.

Constructor & Destructor Documentation

◆ SwitchingFunction() [1/3]

PLMD::SwitchingFunction::SwitchingFunction ( )
default

◆ SwitchingFunction() [2/3]

PLMD::SwitchingFunction::SwitchingFunction ( const SwitchingFunction & other)

◆ SwitchingFunction() [3/3]

PLMD::SwitchingFunction::SwitchingFunction ( SwitchingFunction && other)

◆ ~SwitchingFunction()

PLMD::SwitchingFunction::~SwitchingFunction ( )
default

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)

◆ copyFunction()

void PLMD::SwitchingFunction::copyFunction ( const SwitchingFunction & other)
private

◆ description()

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

Returns a string with a description of the switching function.

◆ get_d0()

double PLMD::SwitchingFunction::get_d0 ( ) const

Returns d0.

◆ get_data()

const switchContainers::Data & PLMD::SwitchingFunction::get_data ( ) const

Return the settings of the switching function.

◆ 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.

◆ operator=() [1/2]

SwitchingFunction & PLMD::SwitchingFunction::operator= ( const SwitchingFunction & other)

◆ operator=() [2/2]

SwitchingFunction & PLMD::SwitchingFunction::operator= ( SwitchingFunction && other)

◆ registerKeywords()

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

◆ set() [1/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

◆ set() [2/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.

Member Data Documentation

◆ function

std::unique_ptr<switchContainers::Switch> PLMD::SwitchingFunction::function {nullptr}
private

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