32 #include <gsl/gsl_math.h>
47 planarArcGeometry_m(1., 1.),
52 variableRadius_m(false),
53 boundingBoxLength_m(0.0),
60 fringeField_l(right.fringeField_l),
61 fringeField_r(right.fringeField_r),
62 maxOrder_m(right.maxOrder_m),
63 maxOrderX_m(right.maxOrderX_m),
64 recursion_VarRadius_m(right.recursion_VarRadius_m),
65 recursion_ConstRadius_m(right.recursion_ConstRadius_m),
66 transMaxOrder_m(right.transMaxOrder_m),
67 transProfile_m(right.transProfile_m),
68 planarArcGeometry_m(right.planarArcGeometry_m),
69 length_m(right.length_m),
70 angle_m(right.angle_m),
71 entranceAngle_m(right.entranceAngle_m),
72 rotation_m(right.rotation_m),
73 variableRadius_m(right.variableRadius_m),
74 boundingBoxLength_m(right.boundingBoxLength_m),
75 verticalApert_m(right.verticalApert_m),
76 horizApert_m(right.horizApert_m),
120 double Bx =
getBx(R_prime);
121 double Bs =
getBs(R_prime);
122 B[0] = Bx *
cos(theta) - Bs *
sin(theta);
123 B[2] = Bx *
sin(theta) + Bs *
cos(theta);
124 B[1] =
getBz(R_prime);
128 for(
int i = 0; i < 3; i++) {
153 R_pprime[1] = R_prime[1];
215 while (maxOrder >= N) {
224 while (maxOrder >= N) {
264 for(std::size_t i = 0; i <=
n; i++) {
268 f_n *= gsl_sf_pow_int(-1.0,
n);
269 Bz += gsl_sf_pow_int(
R[1], 2 *
n) / gsl_sf_fact(2 *
n) * f_n;
280 Bz += gsl_sf_pow_int(
R[1], 2 *
n) / gsl_sf_fact(2 *
n) * f_n;
295 for(std::size_t i = 0; i <=
n; i++) {
299 f_n *= gsl_sf_pow_int(-1.0,
n);
300 Bx += gsl_sf_pow_int(
R[1], 2 *
n + 1) /
301 gsl_sf_fact(2 *
n + 1) * f_n;
312 Bx += partialX_fn * gsl_sf_pow_int(
R[1], 2 *
n + 1)
313 / gsl_sf_fact(2 *
n + 1);
328 for(std::size_t i = 0; i <=
n; i++) {
332 f_n *= gsl_sf_pow_int(-1.0,
n);
333 Bs += gsl_sf_pow_int(
R[1], 2 *
n + 1) /
334 gsl_sf_fact(2 *
n + 1) * f_n;
345 Bs += partialS_fn * gsl_sf_pow_int(
R[1], 2 *
n + 1)
346 / gsl_sf_fact(2 *
n + 1);
376 for(std::size_t i = 1; i <=
n; i++) {
380 temp[j] = temp[j + 1] * (j + 1);
390 func += temp[k] * gsl_sf_pow_int(x, k);
416 std::vector<double> temp(2, 0.0);
423 std::vector<double> temp(2, 0.0);
432 return centralRadius;
454 double stepSize = 1
e-3;
455 deriv += 1. *
getFn(
n, x - 2. * stepSize, s);
456 deriv += -8. *
getFn(
n, x - stepSize, s);
457 deriv += 8. *
getFn(
n, x + stepSize, s);
458 deriv += -1. *
getFn(
n, x + 2. * stepSize, s);
459 deriv /= 12 * stepSize;
468 double stepSize = 1
e-3;
469 deriv += 1. *
getFn(
n, x, s - 2. * stepSize);
470 deriv += -8. *
getFn(
n, x, s - stepSize);
471 deriv += 8. *
getFn(
n, x, s + stepSize);
472 deriv += -1. *
getFn(
n, x, s + 2. * stepSize);
473 deriv /= 12 * stepSize;
485 for (std::size_t j = 0;
489 for (std::size_t i = 0;
496 .evaluatePolynomial(x / rho, i, j) *
498 gsl_sf_pow_int(rho, 2 *
n - i - 2 * j);
501 func *= gsl_sf_pow_int(-1.0,
n);
508 std::vector<double> fringeDerivatives;
509 for (std::size_t j = 0;
514 for (std::size_t i = 0;
518 for (std::size_t j = 0;
522 .evaluatePolynomial(x, y, i, j, fringeDerivatives)
523 * fringeDerivatives.at(j);
527 func *= gsl_sf_pow_int(-1.0,
n) * S_0 * rho;
Tps< T > log(const Tps< T > &x)
Natural logarithm.
Tps< T > cos(const Tps< T > &x)
Cosine.
Tps< T > cosh(const Tps< T > &x)
Hyperbolic cosine.
Tps< T > tanh(const Tps< T > &x)
Hyperbolic tangent.
Tps< T > sin(const Tps< T > &x)
Sine.
PETE_TUTree< FnAbs, typename T::PETE_Expr_t > abs(const PETE_Expr< T > &l)
PETE_TUTree< FnArcTan, typename T::PETE_Expr_t > atan(const PETE_Expr< T > &l)
double integrate(const double &a, const double &s0, const double &lambdaleft, const double &lambdaright, const int &n)
constexpr double alpha
The fine structure constant, no dimension.
constexpr double e
The value of.
ParticleAttrib< Vector_t > P
virtual void visitMultipoleT(const MultipoleT &)=0
Apply the algorithm to an arbitrary multipole.
Interface for a single beam element.
PartBunchBase< double, 3 > * RefPartBunch_m
double getNegTanh(double x, int n) const
double getTanh(double x, int n) const
std::vector< double > transProfile_m
void setDipoleConstant(double B0)
std::size_t transMaxOrder_m
void setAperture(double vertAp, double horizAp)
double getTransDeriv(std::size_t n, double x)
void setMaxOrder(std::size_t maxOrder)
std::vector< polynomial::RecursionRelationTwo > recursion_VarRadius_m
endfieldmodel::Tanh fringeField_r
endfieldmodel::Tanh fringeField_l
ElementBase * clone() const override
Vector_t rotateFrame(const Vector_t &R)
EMField & getField() override
double getScaleFactor(double x, double s)
double getFnDerivX(std::size_t n, double x, double s)
void accept(BeamlineVisitor &visitor) const override
void getDimensions(double &zBegin, double &zEnd) const override
double getFnDerivS(std::size_t n, double x, double s)
double getRadius(double s)
std::vector< polynomial::RecursionRelation > recursion_ConstRadius_m
double getBx(const Vector_t &R)
double getFn(std::size_t n, double x, double s)
bool setFringeField(double s0, double lambda_left, double lambda_right)
Vector_t transformCoords(const Vector_t &R)
bool apply(const Vector_t &R, const Vector_t &P, const double &t, Vector_t &E, Vector_t &B) override
double getFringeDeriv(int n, double s)
bool insideAperture(const Vector_t &R)
double getBz(const Vector_t &R)
Vector_t rotateFrameInverse(Vector_t &B)
PlanarArcGeometry planarArcGeometry_m
bool bends() const override
std::vector< double > getAperture() const
void setTransProfile(std::size_t n, double Bn)
double boundingBoxLength_m
MultipoleT(const std::string &name)
PlanarArcGeometry & getGeometry() override
void initialise(PartBunchBase< double, 3 > *, double &startField, double &endField) override
double getBs(const Vector_t &R)
std::vector< double > getFringeLength() const
std::vector< double > getTransformation() const
void resizeX(const std::size_t &xDerivatives)
void truncate(std::size_t highestXorder)
void truncate(std::size_t highestXorder)
void resizeX(const std::size_t &xDerivatives)
A simple arc in the XZ plane.
void setCurvature(double)
Set curvature.
virtual void setElementLength(double)
Set length.
Abstract base class for electromagnetic fields.