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

#include <Tanh.h>

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

Public Member Functions

 Tanh (double x0, double lambda, int max_index)
 
 Tanh ()
 
 Tanh (const Tanh &rhs)
 
 ~Tanh ()
 
EndFieldModelclone () const
 
double function (double x, int n) const
 
double getTanh (double x, int n) const
 
double getNegTanh (double x, int n) const
 
double getLambda () const
 
double getX0 () const
 
void setLambda (double lambda)
 
void setX0 (double x0)
 
std::ostream & print (std::ostream &out) const
 
- Public Member Functions inherited from endfieldmodel::EndFieldModel
virtual ~EndFieldModel ()
 

Static Public Member Functions

static std::vector< std::vector< int > > getTanhDiffIndices (size_t n)
 
static void setTanhDiffIndices (size_t n)
 

Private Attributes

double _x0
 
double _lambda
 

Static Private Attributes

static std::vector< std::vector< std::vector< int > > > _tdi
 

Detailed Description

Calculate the Tanh function (e.g. for multipole end fields).

DoubleTanh function is given by
\(T(x) = (tanh( (x+x0)/\lambda )-tanh( (x-x0)/\lambda ))/2\)
The derivatives of tanh(x) are given by
\(d^p tanh(x)/dx^p = \sum_q I_{pq} tanh^{q}(x)\)
where \(I_{pq}\) are calculated using some recursion relation. Using these expressions, one can calculate a recursion relation for higher order derivatives and hence calculate analytical derivatives at arbitrary order.

Definition at line 48 of file Tanh.h.

Constructor & Destructor Documentation

◆ Tanh() [1/3]

endfieldmodel::Tanh::Tanh ( double  x0,
double  lambda,
int  max_index 
)

Create a double tanh function

Here x0 is the centre length and lambda is the end length. max_index is used to set up for differentiation - don't try to calculate higher differentials than exist in max_index.

Definition at line 39 of file Tanh.cpp.

References setTanhDiffIndices().

Here is the call graph for this function:

◆ Tanh() [2/3]

endfieldmodel::Tanh::Tanh ( )
inline

Default constructor (initialises x0 and lambda to 0)

Definition at line 59 of file Tanh.h.

References setTanhDiffIndices().

Referenced by clone().

Here is the call graph for this function:

◆ Tanh() [3/3]

endfieldmodel::Tanh::Tanh ( const Tanh rhs)
inline

Copy constructor

Definition at line 62 of file Tanh.h.

◆ ~Tanh()

endfieldmodel::Tanh::~Tanh ( )

Destructor (no mallocs so does nothing)

Definition at line 43 of file Tanh.cpp.

Member Function Documentation

◆ clone()

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

Inherited copy constructor.

Implements endfieldmodel::EndFieldModel.

Definition at line 45 of file Tanh.cpp.

References Tanh().

Here is the call graph for this function:

◆ function()

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

Double Tanh is given by
\(d(x) = \)

Implements endfieldmodel::EndFieldModel.

Definition at line 72 of file Tanh.cpp.

References getNegTanh(), getTanh(), and Hypervolume::n.

Here is the call graph for this function:

◆ getLambda()

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

◆ getNegTanh()

double endfieldmodel::Tanh::getNegTanh ( double  x,
int  n 
) const

Returns the value of tanh((x-x0)/lambda) or its \(n^{th}\) derivative.

Definition at line 61 of file Tanh.cpp.

References _lambda, _tdi, _x0, Hypervolume::n, and tanh().

Referenced by function(), MultipoleTBase::getFringeDeriv(), and MultipoleT::getFringeDeriv().

Here is the call graph for this function:

◆ getTanh()

double endfieldmodel::Tanh::getTanh ( double  x,
int  n 
) const

Returns the value of tanh((x+x0)/lambda) or its \(n^{th}\) derivative.

Definition at line 50 of file Tanh.cpp.

References _lambda, _tdi, _x0, Hypervolume::n, and tanh().

Referenced by function(), MultipoleTBase::getFringeDeriv(), and MultipoleT::getFringeDeriv().

Here is the call graph for this function:

◆ getTanhDiffIndices()

std::vector< std::vector< int > > endfieldmodel::Tanh::getTanhDiffIndices ( size_t  n)
static

Get all the tanh differential indices \(I_{pq}\).

Returns vector of vector of ints where p indexes the differential and q indexes the tanh power - so

Definition at line 102 of file Tanh.cpp.

References _tdi, Hypervolume::n, and setTanhDiffIndices().

Here is the call graph for this function:

◆ getX0()

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

Return x0 (flat top length)

Definition at line 95 of file Tanh.h.

References _x0.

Referenced by MultipoleT::apply(), MultipoleT::transformCoords(), and OpalScalingFFAMagnet::update().

◆ print()

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

Bug - does nothing

Implements endfieldmodel::EndFieldModel.

Definition at line 108 of file Tanh.cpp.

References _lambda, and _x0.

◆ setLambda()

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

Set lambda (end length)

Definition at line 98 of file Tanh.h.

References _lambda.

Referenced by OpalScalingFFAMagnet::update(), and OpalVerticalFFAMagnet::update().

◆ setTanhDiffIndices()

void endfieldmodel::Tanh::setTanhDiffIndices ( size_t  n)
static

Set the value of tanh differential indices to nth order differentials.

Definition at line 76 of file Tanh.cpp.

References _tdi, endfieldmodel::CompactVector(), and Hypervolume::n.

Referenced by getTanhDiffIndices(), Tanh(), OpalScalingFFAMagnet::update(), and OpalVerticalFFAMagnet::update().

Here is the call graph for this function:

◆ setX0()

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

Set x0 (flat top length)

Definition at line 101 of file Tanh.h.

References _x0.

Referenced by OpalScalingFFAMagnet::update(), and OpalVerticalFFAMagnet::update().

Member Data Documentation

◆ _lambda

double endfieldmodel::Tanh::_lambda
private

Definition at line 106 of file Tanh.h.

Referenced by getLambda(), getNegTanh(), getTanh(), print(), and setLambda().

◆ _tdi

std::vector< std::vector< std::vector< int > > > endfieldmodel::Tanh::_tdi
staticprivate

_tdi indexes powers of tanh in d^n tanh/dx^n as sum of powers of tanh

For some reason we index as n, +a, -a, but the third index is redundant

Definition at line 112 of file Tanh.h.

Referenced by getNegTanh(), getTanh(), getTanhDiffIndices(), and setTanhDiffIndices().

◆ _x0

double endfieldmodel::Tanh::_x0
private

Definition at line 106 of file Tanh.h.

Referenced by getNegTanh(), getTanh(), getX0(), print(), and setX0().


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