36 planarArcGeometry_m(1., 1.), dummy(), endField_m(NULL) {
42 planarArcGeometry_m(right.planarArcGeometry_m),
43 dummy(), maxOrder_m(right.maxOrder_m), tanDelta_m(right.tanDelta_m),
44 k_m(right.k_m), Bz_m(right.Bz_m), r0_m(right.r0_m),
45 rMin_m(right.rMin_m), rMax_m(right.rMax_m), phiStart_m(right.phiStart_m),
46 phiEnd_m(right.phiEnd_m), azimuthalExtent_m(right.azimuthalExtent_m),
47 verticalExtent_m(right.verticalExtent_m), centre_m(right.centre_m),
48 dfCoefficients_m(right.dfCoefficients_m) {
114 double r =
sqrt(pos[0]*pos[0]+pos[2]*pos[2]);
115 double phi = -
atan2(pos[0], pos[2]);
121 B[0] += -bCyl[2]*
cos(phi) -bCyl[0]*
sin(phi);
122 B[2] += +bCyl[0]*
cos(phi) -bCyl[2]*
sin(phi);
133 if (r < rMin_m || r >
rMax_m) {
137 double normRadius = r/
r0_m;
147 std::vector<double> fringeDerivatives(
maxOrder_m+1, 0.);
148 for (
size_t i = 0; i < fringeDerivatives.size(); ++i) {
157 deltaB[1] = f2n*h*
pow(z/r,
n);
164 deltaB[2] = f2nplus1*h*
pow(z/r,
n+1);
181 dfCoefficients_m[
n+1] = std::vector<double>(dfCoefficients_m[
n].size()+1, 0);
182 for (
size_t i = 0; i < dfCoefficients_m[
n].size(); ++i) {
183 dfCoefficients_m[
n+1][i+1] = dfCoefficients_m[
n][i]/(
n+1);
185 if (
n+1 == maxOrder_m) {
188 dfCoefficients_m[
n+2] = std::vector<double>(dfCoefficients_m[
n].size()+2, 0);
189 for(
size_t i = 0; i < dfCoefficients_m[
n].size(); ++i) {
190 dfCoefficients_m[
n+2][i] = -(
k_m-
n)*(
k_m-
n)/(
n+1)*dfCoefficients_m[
n][i]/(
n+2);
192 for(
size_t i = 0; i < dfCoefficients_m[
n+1].size(); ++i) {
ParticleAttrib< Vector_t > P
Interface for basic beam line object.
void setEndField(endfieldmodel::EndFieldModel *endField)
bool getFieldValueCylindrical(const Vector_t &R, Vector_t &B) const
void setCurvature(double)
Set curvature.
Tps< T > sin(const Tps< T > &x)
Sine.
bool bends() const override
void initialise(PartBunchBase< double, 3 > *bunch, double &startField, double &endField) override
PlanarArcGeometry planarArcGeometry_m
void accept(BeamlineVisitor &visitor) const override
Tps< T > log(const Tps< T > &x)
Natural logarithm.
ScalingFFAMagnet(const std::string &name)
Abstract base class for accelerator geometry classes.
virtual EndFieldModel * clone() const =0
void setElType(ElemType elt)
set the element type as enumeration needed in the envelope tracker
std::vector< std::vector< double > > dfCoefficients_m
virtual void visitScalingFFAMagnet(const ScalingFFAMagnet &)=0
Apply the algorithm to a solenoid.
PartBunchBase< double, 3 > * RefPartBunch_m
PETE_TBTree< FnArcTan2, PETE_Scalar< Vektor< T1, Dim > >, typename T2::PETE_Expr_t > atan2(const Vektor< T1, Dim > &l, const PETE_Expr< T2 > &r)
Tps< T > pow(const Tps< T > &x, int y)
Integer power.
Abstract base class for electromagnetic fields.
EMField & getField() override
Tps< T > sqrt(const Tps< T > &x)
Square root.
bool apply(const size_t &i, const double &t, Vector_t &E, Vector_t &B) override
BGeometryBase & getGeometry() override
Tps< T > cos(const Tps< T > &x)
Cosine.
bool getFieldValue(const Vector_t &R, Vector_t &B) const
void calculateDfCoefficients()
endfieldmodel::EndFieldModel * endField_m
virtual double function(double x, int n) const =0
Interface for a single beam element.
virtual void setElementLength(double)
Set length.
ElementBase * clone() const override