65 bool revBeam,
bool revTrack):
326 double Ex = scale * sep.
getEx();
327 double Ey = scale * sep.
getEy();
350 double C =
cos(ks * length);
351 double S =
sin(ks * length);
354 Linear yt = C * itsMap[
Y] - S * itsMap[
X];
358 itsMap[
X] = C * xt + (S / ks) * pxt;
359 itsMap[
Y] = C * yt + (S / ks) * pyt;
360 itsMap[
PX] = C * pxt - (S * ks) * xt;
361 itsMap[
PY] = C * pyt - (S * ks) * yt;
364 itsMap[
T] += length * itsMap[
PT] * kin * kin;
411 (
double k,
double L,
double &
c,
double &s,
double &d,
double &f) {
412 double t = k * L * L;
415 s = L * (1.0 - t / 6.0);
416 d = L * L * (0.5 - t / 24.0);
417 f = L * L * L * ((1.0 / 6.0) - t / 120.0);
425 double r =
sqrt(- k);
437 itsMap[
Y] += length * itsMap[
PY];
438 itsMap[
T] += length * itsMap[
PT] * kin * kin;
445 double hx = scale * field.
normal(1);
446 double ex = hx *
tan(angle);
449 itsMap[
PY] -= ey * itsMap[
Y];
456 double hx = scale * field.
normal(1);
457 double ex = hx *
tan(angle);
460 itsMap[
PY] -= ey * itsMap[
Y];
482 double ks = (Fx[2] - Fy[1]) / 2.0;
484 Linear hx = h * (1.0 + pt) - Fx[0];
489 double refTime = refLength * kin * kin;
494 double cx, sx, dx, fx, cy, sy, dy, fy;
497 double wx = - kx * sx;
498 double wy = - ky * sy;
501 itsMap[
X] = cx * x + sx * px + dx * hx;
502 itsMap[
PX] = wx * x + cx * px + sx * hx;
503 itsMap[
Y] = cy * y + sy * py + dy * hy;
504 itsMap[
PY] = wy * y + cy * py + sy * hy;
505 itsMap[
T] += h * (sx * x + dx * px + fx * hx);
508 double s1 = (kx + ky) / 2.0;
509 double d1 = (kx - ky) / 2.0;
510 double root =
sqrt(d1 * d1 + ks * ks);
511 double c2 = d1 / root;
512 double s2 = ks / root;
515 double cu, su, du, fu, cv, sv, dv, fv;
516 double ku = s1 + (d1 * d1 - ks * ks) / root;
517 double kv = s1 - (d1 * d1 - ks * ks) / root;
520 double wu = - ku * su;
521 double wv = - kv * sv;
524 Linear u = c2 * x - s2 * y;
525 Linear v = c2 * y + s2 * x;
526 Linear pu = c2 * px - s2 * py;
527 Linear pv = c2 * py + s2 * px;
528 Linear hu = c2 * (h + hx) - s2 * hy;
529 Linear hv = c2 * hy + s2 * (h + hx);
532 itsMap[
X] = ((cu + cv) * x + (cu - cv) * u +
533 (su + sv) * px + (su - sv) * pu +
534 (du + dv) * hx + (du - dv) * hu) / 2.0;
535 itsMap[
PX] = ((wu + wv) * x + (wu - wv) * u +
536 (cu + cv) * px + (cu - cv) * pu +
537 (su + sv) * hx + (su - sv) * hu) / 2.0;
538 itsMap[
Y] = ((cu + cv) * y - (cu - cv) * v +
539 (su + sv) * py - (su - sv) * pv +
540 (du + dv) * hy - (du - dv) *
hv) / 2.0;
541 itsMap[
PY] = ((wu + wv) * y - (wu - wv) * v +
542 (cu + cv) * py - (cu - cv) * pv +
543 (su + sv) * hy - (su - sv) *
hv) / 2.0;
544 itsMap[
T] += ((su + sv) * x + (su - sv) * u +
545 (du + dv) * px + (du - dv) * pu +
546 (fu + fv) * hx + (fu - fv) * hu) * (h / 2.0);
552 itsMap[
T] += refTime * pt + length * h * x0;
562 std::cerr <<
" <*** ERROR ***> in LinearMapper::buildSBendVectorPotential():\n"
563 <<
" attempt to use an infinite radius of curvature." <<
std::endl;
564 throw DomainError(
"buildSBendVectorPotential(const BMultipoleField &, double)");
567 int order = field.
order();
587 Ae = Ae * x + field.
normal(i);
588 Ao = Ao * x - field.
skew(i);
595 Ae = + (Ae * hx1).integral(0);
612 if(++k > order)
break;
616 Ao = Ao.derivative(0);
620 if(++k > order)
break;
628 if(x0 != 0. || y0 != 0.) {
645 int order = field.
order();
658 Fx = Fxt + field.
normal(order);
659 Fy = Fyt - field.
skew(order);
694 int order = field.
order();
703 Linear kxt = x * kx - y * ky;
704 Linear kyt = x * ky + y * kx;
705 kx = kxt + field.
normal(order);
706 ky = kyt - field.
skew(order);
709 itsMap[
PX] -= kx * scale;
710 itsMap[
PY] += ky * scale;
720 Linear pz1 =
sqrt(pt * pt - px1 * px1 - py1 * py1);
722 itsMap[
PX] = euclid.
M(0, 0) * px1 + euclid.
M(1, 0) * py1 + euclid.
M(2, 0) * pz1;
723 itsMap[
PY] = euclid.
M(0, 1) * px1 + euclid.
M(1, 1) * py1 + euclid.
M(2, 1) * pz1;
724 Linear pz2 = euclid.
M(0, 2) * px1 + euclid.
M(1, 2) * py1 + euclid.
M(2, 2) * pz1;
729 euclid.
M(0, 0) * x + euclid.
M(1, 0) * y - euclid.
M(2, 0) * euclid.
getZ();
731 euclid.
M(0, 1) * x + euclid.
M(1, 1) * y - euclid.
M(2, 1) * euclid.
getZ();
733 euclid.
M(0, 2) * x + euclid.
M(1, 2) * y - euclid.
M(2, 2) * euclid.
getZ();
740 itsMap[
Y] = y2 - sByPz * itsMap[
PY];
741 itsMap[
T] += pt * (refTime / E + sByPz);
virtual double getExitFaceRotation() const =0
Get exit pole face rotation.
void applyLinearMap(double length, double refLength, double h, const FTps< double, 2 > &Fx, const FTps< double, 2 > &Fy)
Apply linear map, defined by the linear expansions Fx and Fy.
virtual ElementBase * getElement() const
Return the contained element.
virtual double getArcLength() const
Get arc length.
virtual void visitPatch(const Patch &pat)
Apply the algorithm to a patch.
Euclid3D & offset() const
Return the offset.
virtual BMultipoleField & getField() override=0
Get multipole expansion of field.
PETE_TUTree< FnAbs, typename T::PETE_Expr_t > abs(const PETE_Expr< T > &l)
virtual void visitAlignWrapper(const AlignWrapper &)
Apply the algorithm to an offset beamline object wrapper.
double getX() const
Get displacement.
virtual BDipoleField & getField()=0
Return the corrector field.
constexpr double e
The value of .
int getMaxOrder() const
Get maximum order.
double getE() const
The constant reference Energy per particle.
virtual double getAmplitude() const =0
Get RF amplitude.
double normal(int) const
Get component.
The field of a magnetic dipole.
virtual BMultipoleField & getField() override=0
Get multipole expansion of field.
Interface for septum magnet.
virtual BMultipoleField & getField() override=0
Get multipole field.
virtual void trackMap(FVps< double, 6 > &, const PartData &, bool revBeam, bool revTrack) const
Track a map.
void applyMultipoleBody(double length, double refLength, const BMultipoleField &field, double scale)
Apply body of SBend.
virtual void visitSeptum(const Septum &)
Apply the algorithm to a Septum.
Interface for electrostatic separator.
Euclid3D getExitPatch() const
Get patch.
virtual void trackMap(FVps< double, 6 > &map, const PartData &, bool revBeam, bool revTrack) const
Track a map.
virtual void visitLambertson(const Lambertson &)
Apply the algorithm to a Lambertson.
virtual double getArcLength() const
Get arc length.
virtual double getPhase() const =0
Get RF phase.
void applyExitFringe(double edge, const BMultipoleField &field, double scale)
Interface for beam position monitors.
Interface for RF Quadrupole.
A simple arc in the XZ plane.
Tps< T > sin(const Tps< T > &x)
Sine.
virtual double getBz() const =0
Get solenoid field Bz in Teslas.
virtual void visitRFCavity(const RFCavity &)
Apply the algorithm to a RFCavity.
Define the position of a misaligned element.
double getZ() const
Get displacement.
virtual void visitComponent(const Component &)
Apply the algorithm to an arbitrary component.
virtual double getElementLength() const override
Get design length.
virtual Euclid3D getEntranceTransform() const
Get entrance patch.
virtual void visitMultipole(const Multipole &)
Apply the algorithm to a Multipole.
virtual double getEx() const =0
Get horizontal component Ex of field in V/m.
virtual void visitFlexibleCollimator(const FlexibleCollimator &)
Apply the algorithm to a flexible collimator.
Interface for general corrector.
virtual double getEy() const =0
Get vertical component Ey of field in V/m.
Interface for beam diagnostics.
Euclid3D getEntrancePatch() const
Get patch.
virtual double getBy() const
Get vertical component.
virtual void visitSeparator(const Separator &)
Apply the algorithm to a Separator.
virtual PlanarArcGeometry & getGeometry() override=0
Get SBend geometry.
Tps< T > tan(const Tps< T > &x)
Tangent.
virtual double getEntryFaceRotation() const =0
Get pole entry face rotation.
Interface for drift space.
double getBeta() const
The relativistic beta per particle.
double M(int row, int col) const
Get component.
void applySBendBody(double length, double refLength, double h, const BMultipoleField &field, double scale)
Apply thin multipole kick (integrated over length) to all particles.
Interface for general multipole.
virtual void visitMonitor(const Monitor &)
Apply the algorithm to a Monitor.
static Euclid3D YRotation(double angle)
Make rotation.
T deg(T x)
Convert radians to degrees.
Euclid3D Inverse(const Euclid3D &t)
Euclidean inverse.
virtual double getElementLength() const override
Get design length.
LinearMap< double, 6 > itsMap
void applyTransform(const Euclid3D &, double refLength)
Apply transform.
Tps< T > cosh(const Tps< T > &x)
Hyperbolic cosine.
virtual double getExitFaceRotation() const =0
Get exit pole face rotation.
double getBendAngle() const
Get angle.
virtual void visitRBend0(const RBend &)
Apply the algorithm to a RBend.
virtual void getMap(LinearMap< double, 6 > &) const
Return the linear part of the accumulated map.
FTps< double, 2 > buildSBendVectorPotential(const BMultipoleField &, double h)
Construct the vector potential for a SBend.
virtual Euclid3D getExitTransform() const
Get exit patch.
virtual void visitSolenoid(const Solenoid &)
Apply the algorithm to a Solenoid.
double skew(int) const
Get component.
double getQ() const
The constant charge per particle.
virtual void accept(BeamlineVisitor &visitor) const =0
Apply visitor.
virtual void visitCorrector(const Corrector &)
Apply the algorithm to a Corrector.
virtual double getElementLength() const
Get design length.
virtual double getFrequency() const =0
Get RF frequencey.
constexpr double c
The velocity of light in m/s.
Interface for cyclotron collimator.
virtual void visitProbe(const Probe &prob)
Apply the algorithm to a probe.
Displacement and rotation in space.
Abstract beam-beam interaction.
virtual void visitBeamStripping(const BeamStripping &)
Apply the algorithm to a beam stripping.
bool isIdentity() const
Test for identity.
virtual void visitDegrader(const Degrader &)
Apply the algorithm to a drift.
Interface for cyclotron valley.
virtual double getBx() const
Get horizontal component.
virtual void visitDrift(const Drift &)
Apply the algorithm to a Drift.
virtual void visitSBend(const SBend &)
Apply the algorithm to a SBend.
static void makeFocus(double k, double L, double &c, double &s, double &d, double &f)
Helper function for finding first-order coefficients.
virtual double getElementLength() const
Get element length.
An abstract sequence of beam line components.
FTps substitute(const FMatrix< T, N, N > &M, int n) const
Substitute.
virtual void visitRFQuadrupole(const RFQuadrupole &)
Apply the algorithm to a RFQuadrupole.
virtual void visitCyclotronValley(const CyclotronValley &)
Apply the algorithm to a CyclotronValley.
virtual double getElementLength() const
Get element length.
virtual void visitDiagnostic(const Diagnostic &)
Apply the algorithm to a Diagnostic.
Tps< T > sqrt(const Tps< T > &x)
Square root.
virtual double getEntryFaceRotation() const =0
Get pole entry face rotation.
FTps derivative(int var) const
Partial derivative.
The geometry for a RBend element.
double getP() const
The constant reference momentum per particle.
LinearFun< double, 6 > Linear
virtual void visitParallelPlate(const ParallelPlate &)
Apply the algorithm to a ParallelPlate.
The magnetic field of a multipole.
double getM() const
The constant mass per particle.
void applyEntranceFringe(double edge, const BMultipoleField &field, double scale)
Transforms fringing fields.
Tps< T > cos(const Tps< T > &x)
Cosine.
virtual void visitMarker(const Marker &)
Apply the algorithm to a Marker.
FTps< double, 2 > Series2
virtual void visitBeamBeam(const BeamBeam &)
Apply the algorithm to a BeamBeam.
double getCurvature() const
Get curvature.
virtual void visitRBend(const RBend &)
Apply the algorithm to a rectangular bend.
virtual RBendGeometry & getGeometry() override=0
Get RBend geometry.
virtual double getBendAngle() const
Get angle.
virtual void visitMapIntegrator(const MapIntegrator &)
Apply the algorithm to an integrator capable of mapping.
void setTruncOrder(int order)
Set truncation order.
Linear function in N variables of type T.
Truncated power series in N variables of type T.
Interface for a geometric patch.
Interface for a single beam element.
virtual const Euclid3D & getPatch() const =0
Get patch transform.
virtual void visitCCollimator(const CCollimator &)
Apply the algorithm to a collimator.
const PartData itsReference
The reference information.
double getY() const
Get displacement.
void applyThinMultipole(const BMultipoleField &field, double factor)
Thin multipole kick.
Tps< T > sinh(const Tps< T > &x)
Hyperbolic sine.
static FTps makeVariable(int var)
Make variable.
int order() const
Return order.
virtual void setMap(const LinearMap< double, 6 > &)
Reset the linear part of the accumulated map for restart.
void applyDrift(double length)
Apply drift length.
Inform & endl(Inform &inf)
Interface for a Lambertson septum.