34 :
Component(name), planarArcGeometry_m(1., 1.), dummy(), endField_m(nullptr) {
39 planarArcGeometry_m(right.planarArcGeometry_m),
41 maxOrder_m(right.maxOrder_m),
42 tanDelta_m(right.tanDelta_m),
48 phiStart_m(right.phiStart_m),
49 phiEnd_m(right.phiEnd_m),
50 azimuthalExtent_m(right.azimuthalExtent_m),
51 verticalExtent_m(right.verticalExtent_m),
52 centre_m(right.centre_m),
54 endFieldName_m(right.endFieldName_m),
55 dfCoefficients_m(right.dfCoefficients_m) {
83 auto Rview = pc->R.getView();
84 auto Pview = pc->P.getView();
88 return apply(R, P, t, E, B);
123 double r = std::sqrt(pos[0] * pos[0] + pos[2] * pos[2]);
124 double phi = std::atan2(
131 B[0] += bCyl[0] * std::cos(phi) - bCyl[2] * std::sin(phi);
132 B[2] += bCyl[0] * std::sin(phi) + bCyl[2] * std::cos(phi);
141 if (r < rMin_m || r >
rMax_m) {
145 double normRadius = r /
r0_m;
148 double h = std::pow(normRadius,
k_m) *
Bz_m;
158 std::vector<double> fringeDerivatives(
maxOrder_m + 1, 0.);
159 for (
size_t i = 0; i < fringeDerivatives.size(); ++i) {
168 deltaB[1] = f2n * h * std::pow(z / r, n);
175 deltaB[0] = (f2n * (
k_m - n) / (n + 1) -
tanDelta_m * f2nplus1) * h
176 * std::pow(z / r, n + 1);
178 f2nplus1 * h * std::pow(z / r, n + 1);
230 std::shared_ptr<endfieldmodel::EndFieldModel> efm =
virtual void visitScalingFFAMagnet(const ScalingFFAMagnet &)=0
Interface for a single beam element.
PartBunch_t * RefPartBunch_m
static std::shared_ptr< EndFieldModel > getEndFieldModel(std::string name)
Look up the EndFieldModel that has a given name.
virtual void rescale(double scaleFactor)=0
Rescale the end field lengths and offsets by a factor x0.
virtual double getCentreLength() const =0
Return the nominal flat top length of the magnet.
virtual double getEndLength() const =0
Return the nominal end field length of the magnet.
virtual double function(double x, int n) const =0
Return the value of the function or its n^th derivative.
virtual EndFieldModel * clone() const =0
Inheritable copy constructor - returns a deep copy of the EndFieldModel.
Sector bending magnet with an FFA-style field index and spiral end shape.
std::string endFieldName_m
void setupEndField()
setupEndField does some end field and geometry set-up
void accept(BeamlineVisitor &visitor) const override
Accept a beamline visitor.
void setAzimuthalExtent(double azimuthalExtent)
Set the maximum azimuthal displacement from \psi=0.
void finalise() override
Finalise the ScalingFFAMagnet - sets bunch to nullptr.
endfieldmodel::EndFieldModel * endField_m
void initialise()
Initialise the ScalingFFAMagnet.
ScalingFFAMagnet * clone() const override
Inheritable copy constructor.
ScalingFFAMagnet(const std::string &name)
Construct a new ScalingFFAMagnet.
void calculateDfCoefficients()
Calculate the df coefficients, ready for field generation.
void setPhiStart(double phiStart)
Set the offset of the magnet centre from the start.
EMField & getField() override
Return a dummy (0.) field value (what is this for?)
~ScalingFFAMagnet()
Destructor - deletes map.
void setEndField(endfieldmodel::EndFieldModel *endField)
Set the fringe field.
bool apply(const size_t &i, const double &t, Vector_t< double, 3 > &E, Vector_t< double, 3 > &B) override
Calculate the field at the position of the ith particle.
void setPhiEnd(double phiEnd)
Set the offset of the magnet end from the start.
bool getFieldValue(const Vector_t< double, 3 > &R, Vector_t< double, 3 > &B) const
Calculate the field at some arbitrary position in cartesian coordinates.
Vector_t< double, 3 > centre_m
double getR0() const
Get the radius constant R_0.
std::vector< std::vector< double > > dfCoefficients_m
bool getFieldValueCylindrical(const Vector_t< double, 3 > &R, Vector_t< double, 3 > &B) const
Calculate the field at some arbitrary position in cylindrical coordinates.
double getPhiStart() const
Get the offset of the magnet centre from the start.
BGeometryBase & getGeometry() override
Return the cell geometry.
bool bends() const override
Return true - ScalingFFAMagnet always bends the reference particle.
void initialise(PartBunch_t *bunch, double &startField, double &endField) override
Initialise the ScalingFFAMagnet.
PlanarArcGeometry planarArcGeometry_m
std::shared_ptr< ParticleContainer_t > getParticleContainer()
Abstract base class for accelerator geometry classes.
void setCurvature(double)
Set curvature.
virtual void setElementLength(double)
Set length.
Abstract base class for electromagnetic fields.