29#include <source_location>
31#include "gsl/gsl_sf_pow_int.h"
40 varRadiusGeometry_m(1.0, 1.0, 1.0, 1.0, 1.0),
47 maxOrderX_m(right.maxOrderX_m),
48 recursion_m(right.recursion_m),
49 varRadiusGeometry_m(right.varRadiusGeometry_m),
50 angle_m(right.angle_m) {
78 double prefactor = (length /
angle_m) *
79 (tanh((length / 2) / fringeLength[0])
80 + tanh((length / 2) / fringeLength[1]));
81 double theta = fringeLength[0] * log(cosh((R[2]
82 + (length / 2)) / fringeLength[0]))
83 - fringeLength[1] * log(cosh((R[2]
84 - (length / 2)) / fringeLength[1]));
86 double Bx = B[0], Bs = B[2];
87 B[0] = Bx * cos(theta) - Bs * sin(theta);
88 B[2] = Bx * sin(theta) + Bs * cos(theta);
94 while (maxOrder >= N) {
127 std::vector<double> fringeDerivatives;
128 for (std::size_t j = 0;
133 for (std::size_t i = 0;
137 for (std::size_t j = 0;
141 .evaluatePolynomial(x, y, i, j, fringeDerivatives)
142 * fringeDerivatives.at(j);
146 func *= gsl_sf_pow_int(-1.0, n) * S_0 * rho;
PartBunch_t * RefPartBunch_m
std::size_t getTransMaxOrder() const
Get the maximum order in the given transverse profile.
std::vector< double > getFringeLength() const
Return vector of 2 doubles [left fringe length, right fringelength].
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 getLength() const
Get the length of the magnet.
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 getFringeDeriv(const std::size_t &n, const double &s)
Returns the value of the fringe field n-th derivative at s.
std::vector< polynomial::RecursionRelationTwo > recursion_m
Objects for storing differential operator acting on Fn.
virtual void transformCoords(Vector_t< double, 3 > &R) override
Transform to Frenet-Serret coordinates for sector magnets.
virtual double getScaleFactor(const double &x, const double &s) override
Returns the scale factor .
~MultipoleTCurvedVarRadius()
Destructor.
virtual void transformBField(Vector_t< double, 3 > &B, const Vector_t< double, 3 > &R) override
Transform B-field from Frenet-Serret coordinates to lab coordinates.
virtual double getRadius(const double &s) override
Radius of curvature If radius of curvature is infinite, -1 is returned where S(s) is the fringe f...
virtual void setMaxOrder(const std::size_t &maxOrder) override
Set the number of terms used in calculation of field components Maximum power of z in Bz is 2 * maxO...
virtual ElementBase * clone() const override
Inheritable copy constructor.
virtual double getFn(const std::size_t &n, const double &x, const double &s) override
Calculate fn(x, s) by expanding the differential operator (from Laplacian and scalar potential) in te...
MultipoleTCurvedVarRadius(const std::string &name)
Constructor.
std::size_t maxOrderX_m
Highest order of polynomial expansions in x.
std::vector< double > getTransformation() const
Returns a list of transformed coordinates.
void truncate(std::size_t highestXorder)
Truncate series in x at highestXorder.
void resizeX(const std::size_t &xDerivatives)
Change number of x-derivatives to xDerivatives.