OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
endfieldmodel::Enge Class Reference

#include <Enge.h>

Inheritance diagram for endfieldmodel::Enge:
Inheritance graph
[legend]
Collaboration diagram for endfieldmodel::Enge:
Collaboration graph
[legend]

Public Member Functions

 Enge ()
 
 Enge (const std::vector< double > a, double x0, double lambda)
 
 ~Enge ()
 
Engeclone () const
 
void rescale (double scaleFactor)
 
double function (double x, int n) const
 
double getEndLength () const
 
double getCentreLength () const
 
std::ostream & print (std::ostream &out) const
 
std::vector< double > getCoefficients () const
 
void setCoefficients (std::vector< double > a)
 
double getLambda () const
 
void setLambda (double lambda)
 
double getX0 () const
 
void setX0 (double x0)
 
void setMaximumDerivative (size_t n)
 
double getEnge (double x, int n) const
 
double getDoubleEnge (double x, int n) const
 
double hN (double x, int n) const
 
double gN (double x, int n) const
 
- Public Member Functions inherited from endfieldmodel::EndFieldModel
virtual ~EndFieldModel ()
 
virtual std::ostream & print (std::ostream &out) const =0
 
virtual double function (double x, int n) const =0
 
virtual double getCentreLength () const =0
 
virtual double getEndLength () const =0
 
virtual EndFieldModelclone () const =0
 
virtual void setMaximumDerivative (size_t n)=0
 
virtual void rescale (double scaleFactor)=0
 

Static Public Member Functions

static void setEngeDiffIndices (size_t n)
 
static std::vector< std::vector< int > > getQIndex (int n)
 
static std::vector< std::vector< int > > getHIndex (int n)
 
- Static Public Member Functions inherited from endfieldmodel::EndFieldModel
static std::shared_ptr< EndFieldModelgetEndFieldModel (std::string name)
 
static void setEndFieldModel (std::string name, std::shared_ptr< EndFieldModel > efm)
 
static std::string getName (std::shared_ptr< EndFieldModel > efm)
 

Private Member Functions

 Enge (const Enge &enge)
 
Engeoperator= (const Enge &enge)
 

Private Attributes

std::vector< double > _a
 
double _lambda
 
double _x0
 

Static Private Attributes

static std::vector< std::vector< std::vector< int > > > _q
 
static std::vector< std::vector< std::vector< int > > > _h
 

Detailed Description

Enge class is a symmetric Enge function for analytical field models

Enge function is

\(f(x) = 1/(1+exp(h(x-x0)))+1/(1+exp(h(-x-x0)))-1\).

where h is a polynomial in x/lambda with polynomial coefficients a

Definition at line 47 of file Enge.h.

Constructor & Destructor Documentation

◆ Enge() [1/3]

endfieldmodel::Enge::Enge ( )
inline

Default constructor

Definition at line 50 of file Enge.h.

References setEngeDiffIndices().

Referenced by clone().

Here is the call graph for this function:

◆ Enge() [2/3]

endfieldmodel::Enge::Enge ( const std::vector< double >  a,
double  x0,
double  lambda 
)

Builds Enge function with parameters a_0, a_1, ..., lambda and x0.

Note that this class is in the inner loop of tracking, so many function calls are not checked for correct indexing. Call setMaximumDerivative before use.

Definition at line 153 of file Enge.cpp.

◆ ~Enge()

endfieldmodel::Enge::~Enge ( )
inline

Destructor - no mallocs, so does nothing

Definition at line 60 of file Enge.h.

◆ Enge() [3/3]

endfieldmodel::Enge::Enge ( const Enge enge)
private

Member Function Documentation

◆ clone()

Enge * endfieldmodel::Enge::clone ( ) const
virtual

Inheritable copy constructor - no mallocs, so does nothing

Implements endfieldmodel::EndFieldModel.

Definition at line 157 of file Enge.cpp.

References _a, _lambda, _x0, and Enge().

Here is the call graph for this function:

◆ function()

double endfieldmodel::Enge::function ( double  x,
int  n 
) const
inlinevirtual

Return the value of enge(x+x0) + enge(-x-x0) at some point x

Implements endfieldmodel::EndFieldModel.

Definition at line 155 of file Enge.h.

References getDoubleEnge(), and Hypervolume::n.

Here is the call graph for this function:

◆ getCentreLength()

double endfieldmodel::Enge::getCentreLength ( ) const
inlinevirtual

Nominal centre length is x0/2

Implements endfieldmodel::EndFieldModel.

Definition at line 176 of file Enge.h.

References _x0.

◆ getCoefficients()

std::vector< double > endfieldmodel::Enge::getCoefficients ( ) const
inline

Returns the enge polynomial coefficients (a_i)

Definition at line 84 of file Enge.h.

References _a.

◆ getDoubleEnge()

double endfieldmodel::Enge::getDoubleEnge ( double  x,
int  n 
) const
inline

Returns \(Enge(x-x0) + Enge(-x-x0)-1\) and its derivatives

Definition at line 167 of file Enge.h.

References _x0, getEnge(), and Hypervolume::n.

Referenced by function().

Here is the call graph for this function:

◆ getEndLength()

double endfieldmodel::Enge::getEndLength ( ) const
inlinevirtual

Nominal end length is lambda

Implements endfieldmodel::EndFieldModel.

Definition at line 180 of file Enge.h.

References _lambda.

◆ getEnge()

double endfieldmodel::Enge::getEnge ( double  x,
int  n 
) const

Returns the value of the Enge function or its \(n^{th}\) derivative.

Please call setEngeDiffIndices(n) before calling if n > max_index

Definition at line 40 of file Enge.cpp.

References getQIndex(), and Hypervolume::n.

Referenced by getDoubleEnge().

Here is the call graph for this function:

◆ getHIndex()

std::vector< std::vector< int > > endfieldmodel::Enge::getHIndex ( int  n)
inlinestatic

Return the indices for calculating the nth derivative of g(x) ito h(x)

Definition at line 163 of file Enge.h.

References _h, and Hypervolume::n.

◆ getLambda()

double endfieldmodel::Enge::getLambda ( ) const
inline

Returns the value of lambda

Definition at line 90 of file Enge.h.

References _lambda.

◆ getQIndex()

std::vector< std::vector< int > > endfieldmodel::Enge::getQIndex ( int  n)
inlinestatic

Return the indices for calculating the nth derivative of Enge ito g(x)

Definition at line 159 of file Enge.h.

References _q, and Hypervolume::n.

Referenced by getEnge().

◆ getX0()

double endfieldmodel::Enge::getX0 ( ) const
inline

Returns the value of x0

Definition at line 96 of file Enge.h.

References _x0.

◆ gN()

double endfieldmodel::Enge::gN ( double  x,
int  n 
) const

Returns \(g(x)\) or its \(n^{th}\) derivative.

Here \(g(x) = 1+exp(h(x))\). Please call setEngeDiffIndices(n) before calling if n > max_index

Definition at line 69 of file Enge.cpp.

References _h, exp(), hN(), and Hypervolume::n.

Here is the call graph for this function:

◆ hN()

double endfieldmodel::Enge::hN ( double  x,
int  n 
) const

Returns \(h(x)\) or its \(n^{th}\) derivative.

Here \(h(x) = a_0 + a_1 x/\lambda + a_2 x^2/lambda^2 + \ldots \) Please call setEngeDiffIndices(n) before calling if n > max_index

Definition at line 58 of file Enge.cpp.

References _a, _lambda, and Hypervolume::n.

Referenced by gN().

◆ operator=()

Enge & endfieldmodel::Enge::operator= ( const Enge enge)
private

◆ print()

std::ostream & endfieldmodel::Enge::print ( std::ostream &  out) const
virtual

Print human-readable version of enge

Implements endfieldmodel::EndFieldModel.

Definition at line 167 of file Enge.cpp.

References _a, _lambda, and _x0.

◆ rescale()

void endfieldmodel::Enge::rescale ( double  scaleFactor)
virtual

Rescale so Enge(x) -> Enge(scaleFactor*x)

Sets x0 to scaleFactor*x0 and lambda to scaleFactor*lambda

Implements endfieldmodel::EndFieldModel.

Definition at line 162 of file Enge.cpp.

References _lambda, and _x0.

◆ setCoefficients()

void endfieldmodel::Enge::setCoefficients ( std::vector< double >  a)
inline

Sets the enge polynomial coefficients (a_i)

Definition at line 87 of file Enge.h.

References _a, and a.

◆ setEngeDiffIndices()

void endfieldmodel::Enge::setEngeDiffIndices ( size_t  n)
static

Recursively calculate the indices for Enge and H

This will calculate the indices for Enge and H that are required to calculate the differential up to order n.

Definition at line 91 of file Enge.cpp.

References _h, _q, endfieldmodel::CompactVector(), and Hypervolume::n.

Referenced by Enge(), endfieldmodel::AsymmetricEnge::setMaximumDerivative(), and setMaximumDerivative().

Here is the call graph for this function:

◆ setLambda()

void endfieldmodel::Enge::setLambda ( double  lambda)
inline

Sets the value of lambda

Definition at line 93 of file Enge.h.

References _lambda.

◆ setMaximumDerivative()

void endfieldmodel::Enge::setMaximumDerivative ( size_t  n)
inlinevirtual

Calls setEngeDiffIndices to set the maximum derivative

Implements endfieldmodel::EndFieldModel.

Definition at line 151 of file Enge.h.

References Hypervolume::n, and setEngeDiffIndices().

Here is the call graph for this function:

◆ setX0()

void endfieldmodel::Enge::setX0 ( double  x0)
inline

Sets the value of x0

Definition at line 99 of file Enge.h.

References _x0.

Member Data Documentation

◆ _a

std::vector<double> endfieldmodel::Enge::_a
private

Definition at line 142 of file Enge.h.

Referenced by clone(), getCoefficients(), hN(), print(), and setCoefficients().

◆ _h

std::vector< std::vector< std::vector< int > > > endfieldmodel::Enge::_h
staticprivate

Indexes the derivatives of g in terms of h

Definition at line 148 of file Enge.h.

Referenced by getHIndex(), gN(), and setEngeDiffIndices().

◆ _lambda

double endfieldmodel::Enge::_lambda
private

Definition at line 143 of file Enge.h.

Referenced by clone(), getEndLength(), getLambda(), hN(), print(), rescale(), and setLambda().

◆ _q

std::vector< std::vector< std::vector< int > > > endfieldmodel::Enge::_q
staticprivate

Indexes the derivatives of enge in terms of g

Definition at line 146 of file Enge.h.

Referenced by getQIndex(), and setEngeDiffIndices().

◆ _x0

double endfieldmodel::Enge::_x0
private

Definition at line 143 of file Enge.h.

Referenced by clone(), getCentreLength(), getDoubleEnge(), getX0(), print(), rescale(), and setX0().


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