OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
MultipoleTStraight Class Referencefinal

#include <MultipoleTStraight.h>

Inheritance diagram for MultipoleTStraight:
Inheritance graph
Collaboration diagram for MultipoleTStraight:
Collaboration graph

Public Member Functions

 MultipoleTStraight (MultipoleT *element)
 
void initialise () override
 
BGeometryBasegetGeometry () override
 
void getField (Kokkos::View< Vector_t< double, 3 > * > R, Kokkos::View< Vector_t< double, 3 > * > E, Kokkos::View< Vector_t< double, 3 > * > B, double scaling, size_t count) override
 
bool getField (const Vector_t< double, 3 > &R, Vector_t< double, 3 > &E, Vector_t< double, 3 > &B, double scaling) override
 
void generateTanhCoefficients (unsigned int numDerivatives)
 

Static Public Member Functions

static KOKKOS_INLINE_FUNCTION double factorial (unsigned int n)
 
static KOKKOS_INLINE_FUNCTION double powerInteger (double x, unsigned int n)
 
static KOKKOS_INLINE_FUNCTION void calcTransverseDerivatives (const Kokkos::Array< double, MultipoleTConfig::NumPoles > &poles, unsigned int numDerivatives, double x, Kokkos::Array< double, MaxDerivatives > &derivatives)
 
template<class ViewType >
static KOKKOS_INLINE_FUNCTION void calcFringeDerivatives (const double &s0, const double &lambdaLeft, const double &lambdaRight, double s, const ViewType &tanhCoefficients, Kokkos::Array< double, MaxDerivatives > &derivatives)
 
static KOKKOS_INLINE_FUNCTION Vector_t< double, 3 > rotateFrame (const Vector_t< double, 3 > &R, const MultipoleTConfig &config)
 
static KOKKOS_INLINE_FUNCTION void calcPowers (double value, unsigned int maxPower, Kokkos::Array< double, MaxPowerInteger > &powers)
 

Static Public Attributes

static constexpr size_t MaxFactorial = 20
 
static constexpr size_t MaxPowerInteger = 20
 
static constexpr unsigned int MaxDerivatives = 20
 

Protected Attributes

MultipoleTelement_m
 
Kokkos::View< double ** > tanhCoefficientsGpu_m
 
Kokkos::View< double ** >::host_mirror_type tanhCoefficientsHost_m
 

Static Private Member Functions

static KOKKOS_INLINE_FUNCTION Vector_t< double, 3 > toMagnetCoords (const Vector_t< double, 3 > &R, const MultipoleTConfig &config)
 
template<class ViewType >
static KOKKOS_INLINE_FUNCTION bool computeBField (const Vector_t< double, 3 > &R, Vector_t< double, 3 > &B, double scaling, const MultipoleTConfig &config, const ViewType &tanhCoefficients)
 

Private Attributes

StraightGeometry straightGeometry_m
 

Detailed Description


MultipoleTiStraight defines a straight combined function magnet (up to arbitrary multipole component) with fringe fields


Class category: AbsBeamline
$Author: Titus Dascalu, Martin Duy Tat, Chris Rogers


The field is obtained from the scalar potential

\[ V = f_0(x,s) z + f_1 (x,s) \frac{z^3}{3!} + f_2 (x,s) \frac{z^5}{5!} + ... \]


(x,z,s) -> Frenet-Serret local coordinates along the magnet
z -> vertical component
assume mid-plane symmetry
set field on mid-plane -> \( B_z = f_0(x,s) = T(x) \cdot S(s) \)
T(x) -> transverse profile; this is a polynomial describing the field expansion on the mid-plane inside the magnet (not in the fringe field); 1st term is the dipole strength, 2nd term is the quadrupole gradient * x, etc.
-> when setting the magnet, one gives the multipole coefficients of this polynomial (i.e. dipole strength, quadrupole gradient, etc.)

----------— example --------------------------------------------—
Setting a combined function magnet with dipole, quadrupole and sextupole components:
\( T(x) = B_0 + B_1 \cdot x + B_2 \cdot x^2 \)
user gives \( B_0, B_1, B_2 \)
----------— example end ----------------------------------------—

S(s) -> fringe field
recursion -> \( f_n (x,s) = (-1)^n \cdot \sum_{i=0}^{n} C_n^i \cdot T^{(2i)} \cdot S^{(2n-2i)} \)
for curved magnets the above recursion is more complicated
\( C_n^i \) -> binomial coeff; \( T^{(n)} \) -> n-th derivative


Definition at line 70 of file MultipoleTStraight.h.

Constructor & Destructor Documentation

◆ MultipoleTStraight()

MultipoleTStraight::MultipoleTStraight ( MultipoleT element)
explicit

Constructor

Definition at line 21 of file MultipoleTStraight.cpp.

Member Function Documentation

◆ calcFringeDerivatives()

template<class ViewType >
KOKKOS_INLINE_FUNCTION void MultipoleTBase::calcFringeDerivatives ( const double &  s0,
const double &  lambdaLeft,
const double &  lambdaRight,
double  s,
const ViewType &  tanhCoefficients,
Kokkos::Array< double, MaxDerivatives > &  derivatives 
)
staticinherited

Definition at line 186 of file MultipoleTBase.h.

Referenced by MultipoleTCurvedConstRadius::computeBField(), and computeBField().

◆ calcPowers()

KOKKOS_INLINE_FUNCTION void MultipoleTBase::calcPowers ( double  value,
unsigned int  maxPower,
Kokkos::Array< double, MaxPowerInteger > &  powers 
)
staticinherited

Definition at line 235 of file MultipoleTBase.h.

Referenced by MultipoleTCurvedConstRadius::computeBField().

◆ calcTransverseDerivatives()

KOKKOS_INLINE_FUNCTION void MultipoleTBase::calcTransverseDerivatives ( const Kokkos::Array< double, MultipoleTConfig::NumPoles > &  poles,
unsigned int  numDerivatives,
double  x,
Kokkos::Array< double, MaxDerivatives > &  derivatives 
)
staticinherited

Helper function that calculates transverse derivatives for multipole fields

Definition at line 166 of file MultipoleTBase.h.

References MultipoleTConfig::NumPoles, and MultipoleTBase::powerInteger().

Referenced by MultipoleTCurvedConstRadius::computeBField(), and computeBField().

Here is the call graph for this function:

◆ computeBField()

template<class ViewType >
KOKKOS_INLINE_FUNCTION bool MultipoleTStraight::computeBField ( const Vector_t< double, 3 > &  R,
Vector_t< double, 3 > &  B,
double  scaling,
const MultipoleTConfig config,
const ViewType &  tanhCoefficients 
)
staticprivate

◆ factorial()

KOKKOS_INLINE_FUNCTION double MultipoleTBase::factorial ( unsigned int  n)
staticinherited

Helper function that returns factorial of n for n<=20 on both host and GPU

Definition at line 126 of file MultipoleTBase.h.

References MultipoleTBase::MaxFactorial.

Referenced by MultipoleTCurvedConstRadius::computeBField(), and computeBField().

◆ generateTanhCoefficients()

void MultipoleTBase::generateTanhCoefficients ( unsigned int  numDerivatives)
inherited

◆ getField() [1/2]

bool MultipoleTStraight::getField ( const Vector_t< double, 3 > &  ,
Vector_t< double, 3 > &  ,
Vector_t< double, 3 > &  ,
double   
)
overridevirtual

Return the field for a single point

Implements MultipoleTBase.

Definition at line 41 of file MultipoleTStraight.cpp.

References computeBField(), MultipoleTBase::element_m, MultipoleT::getConfig(), and MultipoleTBase::tanhCoefficientsHost_m.

Here is the call graph for this function:

◆ getField() [2/2]

void MultipoleTStraight::getField ( Kokkos::View< Vector_t< double, 3 > * >  R,
Kokkos::View< Vector_t< double, 3 > * >  E,
Kokkos::View< Vector_t< double, 3 > * >  B,
double  scaling,
size_t  count 
)
overridevirtual

Return the field for an array of points

Implements MultipoleTBase.

◆ getGeometry()

BGeometryBase * MultipoleTStraight::getGeometry ( )
inlineoverridevirtual

Return the cell geometry

Implements MultipoleTBase.

Definition at line 77 of file MultipoleTStraight.h.

References straightGeometry_m.

◆ initialise()

void MultipoleTStraight::initialise ( )
overridevirtual

◆ powerInteger()

KOKKOS_INLINE_FUNCTION double MultipoleTBase::powerInteger ( double  x,
unsigned int  n 
)
staticinherited

Helper function that returns x^n for 0<=n<=20 on both host and GPU

Definition at line 153 of file MultipoleTBase.h.

Referenced by MultipoleTBase::calcTransverseDerivatives(), MultipoleTCurvedConstRadius::computeBField(), and computeBField().

◆ rotateFrame()

KOKKOS_INLINE_FUNCTION Vector_t< double, 3 > MultipoleTBase::rotateFrame ( const Vector_t< double, 3 > &  R,
const MultipoleTConfig config 
)
staticinherited

Apply two 2D rotation matrices to coordinate vector Rotate around central axis => skew fields Rotate azimuthally => entrance angle

Definition at line 217 of file MultipoleTBase.h.

References MultipoleTConfig::entranceAngle_m, and MultipoleTConfig::rotation_m.

Referenced by MultipoleTCurvedConstRadius::toMagnetCoords(), and toMagnetCoords().

◆ toMagnetCoords()

KOKKOS_INLINE_FUNCTION Vector_t< double, 3 > MultipoleTStraight::toMagnetCoords ( const Vector_t< double, 3 > &  R,
const MultipoleTConfig config 
)
staticprivate

Definition at line 100 of file MultipoleTStraight.h.

References MultipoleTConfig::length_m, and MultipoleTBase::rotateFrame().

Referenced by computeBField().

Here is the call graph for this function:

Member Data Documentation

◆ element_m

MultipoleT* MultipoleTBase::element_m
protectedinherited

◆ MaxDerivatives

constexpr unsigned int MultipoleTBase::MaxDerivatives = 20
staticconstexprinherited

Definition at line 103 of file MultipoleTBase.h.

Referenced by MultipoleT::validateConfiguration().

◆ MaxFactorial

constexpr size_t MultipoleTBase::MaxFactorial = 20
staticconstexprinherited

Definition at line 101 of file MultipoleTBase.h.

Referenced by MultipoleTBase::factorial().

◆ MaxPowerInteger

constexpr size_t MultipoleTBase::MaxPowerInteger = 20
staticconstexprinherited

Definition at line 102 of file MultipoleTBase.h.

◆ straightGeometry_m

StraightGeometry MultipoleTStraight::straightGeometry_m
private

Geometry

Definition at line 89 of file MultipoleTStraight.h.

Referenced by getGeometry(), and initialise().

◆ tanhCoefficientsGpu_m

Kokkos::View<double**> MultipoleTBase::tanhCoefficientsGpu_m
protectedinherited

Definition at line 82 of file MultipoleTBase.h.

Referenced by MultipoleTBase::generateTanhCoefficients().

◆ tanhCoefficientsHost_m

Kokkos::View<double**>::host_mirror_type MultipoleTBase::tanhCoefficientsHost_m
protectedinherited

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