97 double r = std::sqrt(x * x + R[2] * R[2]);
98 double phi = std::atan2(R[2], x);
106 B[0] += -
r0Sign_m * (-bCyl[0] * std::cos(phi) + bCyl[2] * std::sin(phi));
107 B[2] += bCyl[0] * std::sin(phi) + bCyl[2] * std::cos(phi);
115 if (r < rMin_m || r >
rMax_m) {
121 double normRadius = r/std::abs(
r0_m);
128 double h = std::pow(normRadius,
k_m)*
Bz_m;
129 std::vector<double> fringeDerivatives(
maxOrder_m+1, 0.);
130 for (
size_t i = 0; i < fringeDerivatives.size(); ++i) {
131 fringeDerivatives[i] =
endField_m->function(phiSpiral, i);
137 for (
size_t n = 1; n < zOverRVec.size(); ++n) {
138 zOverRVec[n] = zOverRVec[n-1] * zOverR;
146 deltaB[1] = f2n * h * zOverRVec[n];
153 deltaB[2] =
r0Sign_m * f2nplus1 * h * zOverRVec[n+1];
196 std::shared_ptr<endfieldmodel::EndFieldModel> efm
virtual void visitScalingFFAMagnet(const ScalingFFAMagnet &)=0
Apply the algorithm to a scaling FFA magnet.
Component(const std::string &name)
Constructor with given name.
PartBunchBase< double, 3 > * RefPartBunch_m
static std::shared_ptr< EndFieldModel > getEndFieldModel(std::string name)
virtual void rescale(double scaleFactor)=0
virtual double getCentreLength() const =0
virtual double getEndLength() const =0
virtual void setMaximumDerivative(size_t n)=0
virtual EndFieldModel * clone() const =0
bool getFieldValue(const Vector_t &R, Vector_t &B) const
std::string endFieldName_m
void accept(BeamlineVisitor &visitor) const override
void setAzimuthalExtent(double azimuthalExtent)
endfieldmodel::EndFieldModel * endField_m
ScalingFFAMagnet * clone() const override
ScalingFFAMagnet(const std::string &name)
bool getFieldValueCylindrical(const Vector_t &R, Vector_t &B) const
void calculateDfCoefficients()
void setPhiStart(double phiStart)
EMField & getField() override
void setEndField(endfieldmodel::EndFieldModel *endField)
void setPhiEnd(double phiEnd)
std::vector< std::vector< double > > dfCoefficients_m
void initialise(PartBunchBase< double, 3 > *bunch, double &startField, double &endField) override
double getPhiStart() const
BGeometryBase & getGeometry() override
bool bends() const override
PlanarArcGeometry planarArcGeometry_m
Abstract base class for accelerator geometry classes.
Abstract base class for electromagnetic fields.
Vektor< double, 3 > Vector_t