30 #include <gsl/gsl_sf_gamma.h>
49 boundingBoxLength_m(0.0),
51 horizontalApert_m(0.5) {
56 fringeField_l(right.fringeField_l),
57 fringeField_r(right.fringeField_r),
58 maxOrder_m(right.maxOrder_m),
59 transMaxOrder_m(right.transMaxOrder_m),
60 transProfile_m(right.transProfile_m),
61 length_m(right.length_m),
62 entranceAngle_m(right.entranceAngle_m),
63 rotation_m(right.rotation_m),
64 boundingBoxLength_m(right.boundingBoxLength_m),
65 verticalApert_m(right.verticalApert_m),
66 horizontalApert_m(right.horizontalApert_m),
83 B[0] =
getBx(R_prime);
84 B[1] =
getBz(R_prime);
85 B[2] =
getBs(R_prime);
91 for(
int i = 0; i < 3; i++) {
111 R_pprime[1] = R_prime[1];
131 const double &lambda_l,
132 const double &lambda_r) {
151 / gsl_sf_fact(2 *
n);
165 / gsl_sf_fact(2 *
n + 1);
180 / gsl_sf_fact(2 *
n + 1);
202 if (
n > transMaxOrder) {
206 for(std::size_t i = 1; i <=
n; i++) {
207 for(std::size_t j = 0; j <= transMaxOrder; j++) {
209 temp[j] = temp[j + 1] * (j + 1);
215 std::size_t k = transMaxOrder -
n + 1;
218 func = func * x + temp[k];
230 double stepSize = 1
e-3;
231 deriv += 1. *
getFn(
n, x - 2. * stepSize, s);
232 deriv += -8. *
getFn(
n, x - stepSize, s);
233 deriv += 8. *
getFn(
n, x + stepSize, s);
234 deriv += -1. *
getFn(
n, x + 2. * stepSize, s);
235 deriv /= 12 * stepSize;
246 double stepSize = 1
e-3;
247 deriv += 1. *
getFn(
n, x, s - 2. * stepSize);
248 deriv += -8. *
getFn(
n, x, s - stepSize);
249 deriv += 8. *
getFn(
n, x, s + stepSize);
250 deriv += -1. *
getFn(
n, x, s + 2. * stepSize);
251 deriv /= 12 * stepSize;
Tps< T > cos(const Tps< T > &x)
Cosine.
Tps< T > sin(const Tps< T > &x)
Sine.
PETE_TUTree< FnAbs, typename T::PETE_Expr_t > abs(const PETE_Expr< T > &l)
double integrate(const double &a, const double &s0, const double &lambdaleft, const double &lambdaright, const int &n)
constexpr double e
The value of.
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::size_t getTransMaxOrder() const
virtual double getFn(const std::size_t &n, const double &x, const double &s)=0
endfieldmodel::Tanh fringeField_l
virtual void transformCoords(Vector_t &R)=0
Vector_t rotateFrameInverse(Vector_t &B)
bool insideAperture(const Vector_t &R)
std::size_t getMaxOrder() const
endfieldmodel::Tanh fringeField_r
std::vector< double > getTransProfile() const
double getTransDeriv(const std::size_t &n, const double &x)
double getBz(const Vector_t &R)
virtual double getScaleFactor(const double &x, const double &s)=0
bool apply(const Vector_t &R, const Vector_t &P, const double &t, Vector_t &E, Vector_t &B)
virtual void transformBField(Vector_t &B, const Vector_t &R)=0
std::size_t transMaxOrder_m
double getFnDerivX(const std::size_t &n, const double &x, const double &s)
Vector_t rotateFrame(const Vector_t &R)
bool setFringeField(const double &s0, const double &lambda_left, const double &lambda_right)
virtual double getBx(const Vector_t &R)
double getFringeDeriv(const std::size_t &n, const double &s)
virtual double getBs(const Vector_t &R)
double getFnDerivS(const std::size_t &n, const double &x, const double &s)