29#ifndef CLASSIC_MULTIPOLETBASE_H
30#define CLASSIC_MULTIPOLETBASE_H
142 virtual void setMaxOrder(
const std::size_t& maxOrder);
169 bool setFringeField(
const double& s0,
const double& lambda_left,
const double& lambda_right);
196 void setAperture(
const double& vertAp,
const double& horizAp);
215 virtual void getDimensions(
double& zBegin,
double& zEnd)
const;
303 double getFnDerivX(
const std::size_t& n,
const double& x,
const double& s);
311 double getFnDerivS(
const std::size_t& n,
const double& x,
const double& s);
318 virtual double getFn(
const std::size_t& n,
const double& x,
const double& s) = 0;
327 auto Rview = pc->R.getView();
328 auto Pview = pc->P.getView();
333 return apply(R(i), P(i), t, E, B);
408 std::vector<double> temp(2, 0.0);
414 std::vector<double> temp(2, 0.0);
Interface for a single beam element.
PartBunch_t * RefPartBunch_m
Calculate the Tanh function (e.g.
double getLambda() const
Return lambda (end length)
~MultipoleTBase()
Destructor.
virtual double getRadius(const double &s)=0
Radius of curvature.
BMultipoleField dummy
Not implemented.
double getBoundingBoxLength() const
Get distance between centre of magnet and entrance.
std::size_t getTransMaxOrder() const
Get the maximum order in the given transverse profile.
virtual void setBendAngle(const double &angle)
Set the bending angle of the magnet.
bool insideAperture(const Vector_t< double, 3 > &R)
Tests if inside the magnet.
virtual double getFn(const std::size_t &n, const double &x, const double &s)=0
Calculate fn(x, s) by expanding the differential operator (from Laplacian and scalar potential) in te...
double boundingBoxLength_m
Distance between centre of magnet and entrance.
std::vector< double > getFringeLength() const
Return vector of 2 doubles [left fringe length, right fringelength].
virtual void transformCoords(Vector_t< double, 3 > &R)=0
Transform to Frenet-Serret coordinates for sector magnets.
void setRotation(const double &rot)
Set the angle of rotation of the magnet around its axis To make skew components.
virtual void transformBField(Vector_t< double, 3 > &B, const Vector_t< double, 3 > &R)=0
Transform B-field from Frenet-Serret coordinates to lab coordinates.
void setLength(const double &length)
Set the length of the magnet If straight-> Actual length If curved -> Arc length.
double getDipoleConstant() const
Get the dipole constant B_0.
endfieldmodel::Tanh fringeField_l
virtual void setMaxOrder(const std::size_t &maxOrder)
Set the number of terms used in calculation of field components Maximum power of z in Bz is 2 * maxO...
double verticalApert_m
Assume rectangular aperture with these dimensions.
double getRotation() const
Get the angle of rotation of the magnet around its axis.
std::vector< double > getAperture() const
Get the aperture dimensions Returns a vector of 2 doubles.
double getLength() const
Get the length of the magnet.
bool bends() const
Return true if dipole component not zero.
std::vector< double > transProfile_m
List of transverse profile coefficients.
std::size_t maxOrder_m
Number of terms in z expansion used in calculating field components.
double getEntranceAngle() const
Get the entrance angle.
virtual double getBx(const Vector_t< double, 3 > &R)
Returns the radial component of the field Returns zero far outside fringe field .
std::size_t getMaxOrder() const
Get the number of terms used in calculation of field components.
void initialise(PartBunch_t *, double &startField, double &endField)
Initialise the MultipoleT.
virtual double getBs(const Vector_t< double, 3 > &R)
Returns the component of the field along the central axis Returns zero far outside fringe field .
void finalise()
Finalise the MultipoleT - sets bunch to nullptr.
endfieldmodel::Tanh fringeField_r
std::vector< double > getTransProfile() const
Get all terms of transverse profile.
Vector_t< double, 3 > rotateFrame(const Vector_t< double, 3 > &R)
Rotate frame for skew elements Consecutive rotations: 1st -> about central axis 2nd -> azimuthal rot...
double getTransDeriv(const std::size_t &n, const double &x)
Returns the value of the transverse field n-th derivative at x Transverse field is a polynomial in x...
double getBz(const Vector_t< double, 3 > &R)
Returns the vertical field component Returns zero far outside fringe field .
MultipoleTBase()
Default constructor.
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)
Calculate the field at some arbitrary position If particle is outside field map true is returned,...
virtual double getScaleFactor(const double &x, const double &s)=0
Returns the scale factor .
void setEntranceAngle(const double &entranceAngle)
Set the entrance angle.
std::size_t transMaxOrder_m
Highest power in given mid-plane field.
void setTransProfile(const std::size_t &n, const double &Bn)
Set transverse profile T(x) T(x) = B_0 + B1 x + B2 x^2 + B3 x^3 + ...
double getFnDerivX(const std::size_t &n, const double &x, const double &s)
Calculate partial derivative of fn wrt x using a 5-point finite difference formula Error of order ste...
EMField & getField()
Return a dummy field value.
bool setFringeField(const double &s0, const double &lambda_left, const double &lambda_right)
Set fringe field model Tanh model used here .
void setDipoleConstant(const double &B0)
Set the dipole constant B_0.
double getFringeDeriv(const std::size_t &n, const double &s)
Returns the value of the fringe field n-th derivative at s.
virtual void getDimensions(double &zBegin, double &zEnd) const
Not implemented.
void setBoundingBoxLength(const double &boundingBoxLength)
Set distance between centre of magnet and enctrance.
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...
double getFnDerivS(const std::size_t &n, const double &x, const double &s)
Calculate partial derivative of fn wrt s using a 5-point finite difference formula Error of order ste...
void setAperture(const double &vertAp, const double &horizAp)
Set the aperture dimensions This element only supports a rectangular aperture.
double length_m
Magnet parameters.
void setTransMaxOrder(const std::size_t &transMaxOrder)
Set the maximum order in the given transverse profile.
virtual double getBendAngle() const
Get the bending angle of the magnet.
std::shared_ptr< ParticleContainer_t > getParticleContainer()
The magnetic field of a multipole.
Abstract base class for electromagnetic fields.