OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
endfieldmodel::Enge Class Reference

#include <Enge.h>

Inheritance diagram for endfieldmodel::Enge:
Inheritance graph
Collaboration diagram for endfieldmodel::Enge:
Collaboration graph

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
 

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 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
 
static std::map< std::string, std::shared_ptr< EndFieldModel > > efm_map
 

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 156 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 154 of file Enge.h.

References getDoubleEnge().

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 171 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 160 of file Enge.h.

References _x0, and getEnge().

Referenced by function().

Here is the call graph for this function:

◆ getEndFieldModel()

std::shared_ptr< EndFieldModel > endfieldmodel::EndFieldModel::getEndFieldModel ( std::string  name)
staticinherited

Look up the EndFieldModel that has a given name

Parameters
namename of the EndFieldModel
Returns
shared_ptr to the appropriate EndFieldModel.
Exceptions
GeneralOpalExceptionif name is not recognised

Definition at line 63 of file EndFieldModel.cpp.

References endfieldmodel::EndFieldModel::efm_map.

Referenced by ScalingFFAMagnet::setupEndField().

◆ getEndLength()

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

Nominal end length is lambda

Implements endfieldmodel::EndFieldModel.

Definition at line 173 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 39 of file Enge.cpp.

References getQIndex(), gN(), and gsl_sf_pow_int().

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 158 of file Enge.h.

References _h.

◆ getLambda()

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

Returns the value of lambda

Definition at line 90 of file Enge.h.

References _lambda.

◆ getName()

std::string endfieldmodel::EndFieldModel::getName ( std::shared_ptr< EndFieldModel efm)
staticinherited

Get the name corresponding to a given EndFieldModel

Parameters
efmEndFieldModel to lookup
Returns
name corresponding to the EndFieldModel. Note that this just does a dumb loop over the stored map values; so O(N).
Exceptions
GeneralOpalExceptionif efm is not recognised

Definition at line 77 of file EndFieldModel.cpp.

References endfieldmodel::EndFieldModel::efm_map.

◆ 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 156 of file Enge.h.

References _q.

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 68 of file Enge.cpp.

References _h, gsl_sf_pow_int(), and hN().

Referenced by getEnge().

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 57 of file Enge.cpp.

References _a, _lambda, gsl_sf_fact(), and gsl_sf_pow_int().

Referenced by gN().

Here is the call graph for this function:

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

◆ setEndFieldModel()

void endfieldmodel::EndFieldModel::setEndFieldModel ( std::string  name,
std::shared_ptr< EndFieldModel efm 
)
staticinherited

Add a value to the lookup table

Parameters
namename of the EndFieldModel. If name already exists in the map, it is overwritten with the new value.
efmshared_ptr to the EndFieldModel.

Definition at line 73 of file EndFieldModel.cpp.

References endfieldmodel::EndFieldModel::efm_map.

◆ 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, and endfieldmodel::CompactVector().

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 152 of file Enge.h.

References 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 143 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 149 of file Enge.h.

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

◆ _lambda

double endfieldmodel::Enge::_lambda
private

Definition at line 144 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 147 of file Enge.h.

Referenced by getQIndex(), and setEngeDiffIndices().

◆ _x0

double endfieldmodel::Enge::_x0
private

Definition at line 144 of file Enge.h.

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

◆ efm_map

std::map< std::string, std::shared_ptr< EndFieldModel > > endfieldmodel::EndFieldModel::efm_map
staticprivateinherited

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