OPAL (Object Oriented Parallel Accelerator Library) 2024.2
OPAL
endfieldmodel::EndFieldModel Class Referenceabstract

#include <EndFieldModel.h>

Inheritance diagram for endfieldmodel::EndFieldModel:
Inheritance graph
Collaboration diagram for endfieldmodel::EndFieldModel:
Collaboration graph

Public Member Functions

virtual ~EndFieldModel ()
 Destructor. More...
 
virtual std::ostream & print (std::ostream &out) const =0
 Stream a human readable description of the end field model to out. More...
 
virtual double function (double x, int n) const =0
 Return the value of the function or its n^th derivative. More...
 
virtual double getCentreLength () const =0
 Return the nominal flat top length of the magnet. More...
 
virtual double getEndLength () const =0
 Return the nominal end field length of the magnet. More...
 
virtual EndFieldModelclone () const =0
 Inheritable copy constructor - returns a deep copy of the EndFieldModel. More...
 
virtual void setMaximumDerivative (size_t n)=0
 Set the maximum derivative that will be required to be calculated. More...
 
virtual void rescale (double scaleFactor)=0
 Rescale the end field lengths and offsets by a factor x0. More...
 

Static Public Member Functions

static std::shared_ptr< EndFieldModelgetEndFieldModel (std::string name)
 Look up the EndFieldModel that has a given name. More...
 
static void setEndFieldModel (std::string name, std::shared_ptr< EndFieldModel > efm)
 Add a value to the lookup table. More...
 
static std::string getName (std::shared_ptr< EndFieldModel > efm)
 Get the name corresponding to a given EndFieldModel. More...
 

Static Private Attributes

static std::map< std::string, std::shared_ptr< EndFieldModel > > efm_map
 

Detailed Description

Definition at line 38 of file EndFieldModel.h.

Constructor & Destructor Documentation

◆ ~EndFieldModel()

virtual endfieldmodel::EndFieldModel::~EndFieldModel ( )
inlinevirtual

Destructor.

Definition at line 41 of file EndFieldModel.h.

Member Function Documentation

◆ clone()

virtual EndFieldModel * endfieldmodel::EndFieldModel::clone ( ) const
pure virtual

Inheritable copy constructor - returns a deep copy of the EndFieldModel.

Implemented in endfieldmodel::AsymmetricEnge, endfieldmodel::Enge, and endfieldmodel::Tanh.

Referenced by ScalingFFAMagnet::ScalingFFAMagnet(), and ScalingFFAMagnet::setupEndField().

◆ function()

virtual double endfieldmodel::EndFieldModel::function ( double  x,
int  n 
) const
pure virtual

Return the value of the function or its n^th derivative.

Parameters
xreturns d^n f(x)/dx^n
nthe derivative

Implemented in endfieldmodel::AsymmetricEnge, endfieldmodel::Enge, and endfieldmodel::Tanh.

Referenced by ScalingFFAMagnet::getFieldValueCylindrical().

◆ getCentreLength()

virtual double endfieldmodel::EndFieldModel::getCentreLength ( ) const
pure virtual

Return the nominal flat top length of the magnet.

Implemented in endfieldmodel::AsymmetricEnge, endfieldmodel::Enge, and endfieldmodel::Tanh.

Referenced by ScalingFFAMagnet::setupEndField().

◆ getEndFieldModel()

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

Look up the EndFieldModel that has a given name.

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

Definition at line 63 of file EndFieldModel.cpp.

References efm_map, and name.

Referenced by PyOpal::PyEndFieldModel::function(), and ScalingFFAMagnet::setupEndField().

◆ getEndLength()

virtual double endfieldmodel::EndFieldModel::getEndLength ( ) const
pure virtual

Return the nominal end field length of the magnet.

Implemented in endfieldmodel::AsymmetricEnge, endfieldmodel::Enge, and endfieldmodel::Tanh.

Referenced by ScalingFFAMagnet::setupEndField().

◆ getName()

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

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
GeneralClassicExceptionif efm is not recognised

Definition at line 77 of file EndFieldModel.cpp.

References efm_map.

◆ print()

virtual std::ostream & endfieldmodel::EndFieldModel::print ( std::ostream &  out) const
pure virtual

Stream a human readable description of the end field model to out.

Implemented in endfieldmodel::AsymmetricEnge, endfieldmodel::Enge, and endfieldmodel::Tanh.

◆ rescale()

virtual void endfieldmodel::EndFieldModel::rescale ( double  scaleFactor)
pure virtual

Rescale the end field lengths and offsets by a factor x0.

If before rescaling the endfieldmodel returns f(x), after rescaling the endfieldmodel should return f(x*scaleFactor)

Implemented in endfieldmodel::AsymmetricEnge, endfieldmodel::Enge, and endfieldmodel::Tanh.

Referenced by ScalingFFAMagnet::setupEndField(), and OpalScalingFFAMagnet::update().

◆ setEndFieldModel()

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

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 72 of file EndFieldModel.cpp.

References efm_map, and name.

Referenced by OpalScalingFFAMagnet::setupDefaultEndField(), OpalAsymmetricEnge::update(), and OpalEnge::update().

◆ setMaximumDerivative()

virtual void endfieldmodel::EndFieldModel::setMaximumDerivative ( size_t  n)
pure virtual

Set the maximum derivative that will be required to be calculated.

Some end field models e.g. Enge use recursion relations to calculate analytically derivatives at high order. By setting the maximum derivative these models can set up the tables of recursion coefficients at set-up time which makes the derivative lookup faster.

Implemented in endfieldmodel::AsymmetricEnge, endfieldmodel::Enge, and endfieldmodel::Tanh.

Referenced by ScalingFFAMagnet::setupEndField().

Member Data Documentation

◆ efm_map

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

Definition at line 108 of file EndFieldModel.h.

Referenced by getEndFieldModel(), getName(), and setEndFieldModel().


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