29#ifndef CLASSIC_MULTIPOLET_H
30#define CLASSIC_MULTIPOLET_H
86#include "gsl/gsl_sf.h"
105 void getDimensions(
double& zBegin,
double& zEnd)
const override;
141 bool bends()
const override;
191 bool setFringeField(
double s0,
double lambda_left,
double lambda_right);
335 double getFnDerivX(std::size_t n,
double x,
double s);
343 double getFnDerivS(std::size_t n,
double x,
double s);
350 double getFn(std::size_t n,
double x,
double s);
Interface for a single beam element.
Calculate the Tanh function (e.g.
void setBendAngle(double angle)
Set the bending angle of the magnet.
void setRotation(double rot)
Set the angle of rotation of the magnet around its axis To make skew components.
std::size_t getTransMaxOrder() const
Get the maximum order in the given transverse profile.
std::vector< double > transProfile_m
List of transverse profile coefficients.
void setDipoleConstant(double B0)
Set the dipole constant B_0.
double getBoundingBoxLength() const
Get distance between centre of magnet and entrance.
std::size_t transMaxOrder_m
Highest power in given mid-plane field.
void setMaxXOrder(std::size_t maxXOrder)
Set the number of terms used in polynomial expansions.
void setAperture(double vertAp, double horizAp)
Set the aperture dimensions This element only supports a rectangular aperture.
BMultipoleField dummy
Not implemented.
Vector_t< double, 3 > rotateFrameInverse(Vector_t< double, 3 > &B)
Inverse of the 1st rotation in rotateFrame() method Used to rotate B field back to global coordinate...
Vector_t< double, 3 > transformCoords(const Vector_t< double, 3 > &R)
Transform to Frenet-Serret coordinates for sector magnets.
MultipoleT operator=(const MultipoleT &rhs)
double getTransDeriv(std::size_t n, double x)
Returns the value of the transverse field n-th derivative at x.
void setMaxOrder(std::size_t maxOrder)
Set the number of terms used in calculation of field components Maximum power of z in Bz is 2 * maxO...
std::vector< polynomial::RecursionRelationTwo > recursion_VarRadius_m
Objects for storing differential operator acting on Fn.
void initialise()
Initialises the geometry.
bool apply(const Vector_t< double, 3 > &R, const Vector_t< double, 3 > &P, const double &t, Vector_t< double, 3 > &E, Vector_t< double, 3 > &B) override
Calculate the field at some arbitrary position If particle is outside field map true is returned,...
endfieldmodel::Tanh fringeField_r
endfieldmodel::Tanh fringeField_l
void setEntranceAngle(double entranceAngle)
Set the entrance angle.
double getBz(const Vector_t< double, 3 > &R)
ElementBase * clone() const override
Inheritable copy constructor.
bool insideAperture(const Vector_t< double, 3 > &R)
Tests if inside the magnet.
double getLength() const
Get the length of the magnet.
void setTransMaxOrder(std::size_t transMaxOrder)
Set the maximum order in the given transverse profile.
EMField & getField() override
Return a dummy field value.
double getScaleFactor(double x, double s)
Returns the scale factor .
double getFnDerivX(std::size_t n, double x, double s)
Calculate partial derivative of fn wrt x using a 5-point finite difference formula Error of order st...
void accept(BeamlineVisitor &visitor) const override
Accept a beamline visitor.
void setBoundingBoxLength(const double &boundingBoxLength)
Set distance between centre of magnet and enctrance.
double verticalApert_m
Assume rectangular aperture with these dimensions.
double getChordLength() const
Not used.
std::size_t getMaxOrder() const
Get the number of terms used in calculation of field components.
void getDimensions(double &zBegin, double &zEnd) const override
Not implemented.
bool getVarRadius() const
Get the value of variableRadius_m.
double getFnDerivS(std::size_t n, double x, double s)
Calculate partial derivative of fn wrt s using a 5-point finite difference formuln Error of order ste...
std::size_t maxOrderX_m
Highest order of polynomial expansions in x.
double getRadius(double s)
Radius of curvature If radius of curvature is infinite, -1 is returned If radius is constant,...
std::vector< polynomial::RecursionRelation > recursion_ConstRadius_m
double getBx(const Vector_t< double, 3 > &R)
Get field component methods.
std::size_t getMaxXOrder() const
Get highest power of x in polynomial expansions.
double length_m
Magnet parameters.
double getFn(std::size_t n, double x, double s)
Calculate fn(x, s) by expanding the differential operator (from Laplacian and scalar potential) in te...
bool setFringeField(double s0, double lambda_left, double lambda_right)
Set fringe field model Tanh model used here .
void initialise(PartBunch_t *, double &startField, double &endField) override
Initialise the MultipoleT.
void finalise() override
Finalise the MultipoleT - sets bunch to nullptr.
double getFringeDeriv(int n, double s)
Returns the value of the fringe field n-th derivative at s.
double getDipoleConstant() const
Get the dipole constant B_0.
void setVarRadius()
Set variable radius flag to true.
PlanarArcGeometry planarArcGeometry_m
Geometry.
void setLength(double length)
Set the length of the magnet If straight-> Actual length If curved -> Arc length .
bool bends() const override
Return true if dipole component not zero.
std::vector< double > getAperture() const
Get the aperture dimensions Returns a vector of 2 doubles.
double getRotation() const
Get the angle of rotation of the magnet around its axis.
void setTransProfile(std::size_t n, double Bn)
Set transverse profile T(x) T(x) = B_0 + B1 x + B2 x^2 + B3 x^3 + ...
double getBendRadius() const
Get the bending radius Not used, when needed radius is found from length_m / angle_m.
std::size_t maxOrder_m
Field expansion parameters Number of terms in z expansion used in calculating field components.
bool variableRadius_m
Variable radius flag.
double boundingBoxLength_m
Distance between centre of magnet and entrance.
MultipoleT(const std::string &name)
Constructor.
std::vector< double > getTransProfile() const
Get all terms of transverse profile.
double getEntranceAngle() const
Get the entrance angle.
Vector_t< double, 3 > rotateFrame(const Vector_t< double, 3 > &R)
Rotate frame for skew elements Consecutive rotations: 1st -> about central axis 2nd -> azimuthal rota...
double getBendAngle() const
Get the bending angle of the magnet.
double getBs(const Vector_t< double, 3 > &R)
PlanarArcGeometry & getGeometry() override
Return the cell geometry.
std::vector< double > getFringeLength() const
Return vector of 2 doubles [left fringe length, right fringelength].
A simple arc in the XZ plane.
The magnetic field of a multipole.
Abstract base class for electromagnetic fields.