49 NormalComponents(right.NormalComponents),
50 NormalComponentErrors(right.NormalComponentErrors),
51 SkewComponents(right.SkewComponents),
52 SkewComponentErrors(right.SkewComponentErrors),
53 max_SkewComponent_m(right.max_SkewComponent_m),
54 max_NormalComponent_m(right.max_NormalComponent_m),
55 nSlices_m(right.nSlices_m) {
62 NormalComponents(1, 0.0),
63 NormalComponentErrors(1, 0.0),
64 SkewComponents(1, 0.0),
65 SkewComponentErrors(1, 0.0),
66 max_SkewComponent_m(1),
67 max_NormalComponent_m(1),
172 Inform msg(
"Multipole::addK()");
180 for(
int j = 0; j < l; j++)
183 double Grad = temp_n / l;
196 Inform msg(
"Multipole::addK()");
210 for(
int j = 0; j < l; j++)
213 double G = temp_n / l;
218 K +=
Vector_t(cf * dx, -cf * dy, 0.0);
249 B(0) += 4 *
NormalComponents[i] * (Rn[3](0) * Rn[1](1) - Rn[1](0) * Rn[3](1));
250 B(1) +=
NormalComponents[i] * (Rn[4](0) - 6 * Rn[2](0) * Rn[2](1) + Rn[4](1));
255 double powMinusOne = 1;
256 double Bx = 0.0, By = 0.0;
257 for (
int j = 1; j <= (i + 1) / 2; ++ j) {
258 Bx += powMinusOne *
NormalComponents[i] * (Rn[i - 2 * j + 1](0) * fact[i - 2 * j + 1] *
259 Rn[2 * j - 1](1) * fact[2 * j - 1]);
260 By += powMinusOne *
NormalComponents[i] * (Rn[i - 2 * j + 2](0) * fact[i - 2 * j + 2] *
261 Rn[2 * j - 2](1) * fact[2 * j - 2]);
265 if ((i + 1) / 2 == i / 2) {
267 By += powMinusOne *
NormalComponents[i] * (Rn[i - 2 * j + 2](0) * fact[i - 2 * j + 2] *
268 Rn[2 * j - 2](1) * fact[2 * j - 2]);
275 Rn[i + 1](0) = Rn[i](0) *
R(0);
276 Rn[i + 1](1) = Rn[i](1) *
R(1);
277 fact[i + 1] = fact[i] / (i + 1);
309 B(0) -=
SkewComponents[i] * (Rn[4](0) - 6 * Rn[2](0) * Rn[2](1) + Rn[4](1));
310 B(1) += 4 *
SkewComponents[i] * (Rn[3](0) * Rn[1](1) - Rn[1](0) * Rn[3](1));
315 double powMinusOne = 1;
316 double Bx = 0, By = 0;
317 for (
int j = 1; j <= (i + 1) / 2; ++ j) {
318 Bx -= powMinusOne *
SkewComponents[i] * (Rn[i - 2 * j + 2](0) * fact[i - 2 * j + 2] *
319 Rn[2 * j - 2](1) * fact[2 * j - 2]);
320 By += powMinusOne *
SkewComponents[i] * (Rn[i - 2 * j + 1](0) * fact[i - 2 * j + 1] *
321 Rn[2 * j - 1](1) * fact[2 * j - 1]);
325 if ((i + 1) / 2 == i / 2) {
327 Bx -= powMinusOne *
SkewComponents[i] * (Rn[i - 2 * j + 2](0) * fact[i - 2 * j + 2] *
328 Rn[2 * j - 2](1) * fact[2 * j - 2]);
336 Rn[i + 1](0) = Rn[i](0) *
R(0);
337 Rn[i + 1](1) = Rn[i](1) *
R(1);
338 fact[i + 1] = fact[i] / (i + 1);
352 for (
unsigned int d = 0; d < 3; ++ d) {
virtual bool isInside(const Vector_t &r) const override
double getNormalComponent(int n) const
Get normal component.
void setSkewComponent(int, double)
Set skew component.
virtual void addKT(int i, double t, Vector_t &K) override
std::vector< double > NormalComponentErrors
bool isFocusing(unsigned int component) const
virtual void accept(BeamlineVisitor &) const override
Apply visitor to Multipole.
void setNormalComponent(int, double)
Set normal component.
virtual void getDimensions(double &zBegin, double &zEnd) const override
virtual bool applyToReferenceParticle(const Vector_t &R, const Vector_t &P, const double &t, Vector_t &E, Vector_t &B) override
Interface for general multipole.
Field< Vektor< T, 1U >, 1U, Cartesian< 1U, MFLOAT >, Cell > & Grad(Field< T, 1U, Cartesian< 1U, MFLOAT >, Vert > &x, Field< Vektor< T, 1U >, 1U, Cartesian< 1U, MFLOAT >, Cell > &r)
int max_NormalComponent_m
virtual bool apply(const size_t &i, const double &t, Vector_t &E, Vector_t &B) override
virtual double getGamma(int i)
std::vector< double > NormalComponents
void setElType(ElemType elt)
set the element type as enumeration needed in the envelope tracker
virtual double getElementLength() const
Get design length.
double getSkewComponent(int n) const
Get skew component.
virtual double getBeta(int i)
constexpr double c
The velocity of light in m/s.
double getChargePerParticle() const
get the macro particle charge
virtual double getY0(int i)
std::size_t getNSlices() const
PartBunchBase< double, 3 > * RefPartBunch_m
virtual bool bends() const override
virtual void initialise(PartBunchBase< double, 3 > *bunch, double &startField, double &endField) override
Tps< T > pow(const Tps< T > &x, int y)
Integer power.
Vektor< double, 3 > Vector_t
void computeField(Vector_t R, Vector_t &E, Vector_t &B)
std::vector< double > SkewComponents
virtual double getX0(int i)
virtual void finalise() override
constexpr double q_e
The elementary charge in As.
std::vector< double > SkewComponentErrors
bool isInsideTransverse(const Vector_t &r, double f=1) const
Interface for a single beam element.
virtual void visitMultipole(const Multipole &)=0
Apply the algorithm to a multipole.
void setNSlices(const std::size_t &nSlices)
virtual void addKR(int i, double t, Vector_t &K) override
virtual ElementBase::ElementType getType() const override
Get element type std::string.