60 using namespace Physics;
67 bool revBeam,
bool revTrack):
68 Tracker(beamline, reference, revBeam, revTrack)
75 bool revBeam,
bool revTrack):
76 Tracker(beamline, bunch, reference, revBeam, revTrack)
86 static const double explim = 150.0;
107 const double fk =
q_e * NN /
109 const double dx = displacement(0);
110 const double dy = displacement(1);
111 const double sx2 =
std::abs(sigma(0, 0));
112 const double sy2 =
std::abs(sigma(1, 1));
113 const double sx =
sqrt(sx2);
114 const double sy =
sqrt(sy2);
122 double xs = part.
x() - dx;
123 double ys = part.
y() - dy;
124 double rho2 = xs * xs + ys * ys;
125 double tk = rho2 / (2.0 * sx2);
130 }
else if(tk != 0.0) {
131 phi = fk * (1.0 -
exp(- tk)) / rho2;
134 part.
px() += xs * phi;
135 part.
py() += ys * phi;
147 double xs = part.
x() - dx;
148 double ys = part.
y() - dy;
151 std::complex<double>
W =
Werrf(std::complex<double>(xr, yr));
153 double tk = (xs * xs / sx2 + ys * ys / sy2) / 2.0;
155 W -=
exp(- tk) *
Werrf(std::complex<double>(xr * sy / sx, yr * sx / sy));
202 part.
px() -= field.
getBy() * scale;
203 part.
py() += field.
getBx() * scale;
284 if(length) scale *= length;
288 int order = field.
order();
293 double kx = + field.
normal(order);
294 double ky = - field.
skew(order);
297 double kxt = x * kx - y * ky;
298 double kyt = x * ky + y * kx;
299 kx = kxt + field.
normal(order);
300 ky = kyt - field.
skew(order);
303 part.
px() -= kx * scale - angle * (1.0 + part.
pt());
304 part.
py() += ky * scale;
305 part.
t() -= angle * x;
327 double pt = (part.
pt() + 1.0);
328 double speed = (
c * pt) /
sqrt(pt * pt + kin * kin);
329 double phase = as.
getPhase() + (freq * part.
t()) / speed;
330 part.
pt() += peak *
sin(phase) / pt;
357 if(length) scale *= length;
361 int order = field.
order();
366 double kx = + field.
normal(order);
367 double ky = - field.
skew(order);
370 double kxt = x * kx - y * ky;
371 double kyt = x * ky + y * kx;
372 kx = kxt + field.
normal(order);
373 ky = kyt - field.
skew(order);
376 part.
px() -= kx * scale - angle * (1.0 + part.
pt());
377 part.
py() += ky * scale;
378 part.
t() -= angle * x;
395 double Ex = scale * sep.
getEx();
396 double Ey = scale * sep.
getEy();
400 double pt = 1.0 + part.
pt();
401 part.
px() += Ex / pt;
402 part.
py() += Ey / pt;
426 double ref = kin * kin;
431 double pt = part.
pt() + 1.0;
432 double px = part.
px() + ks * part.
y();
433 double py = part.
py() - ks * part.
x();
434 double pz =
sqrt(pt * pt - px * px - py * py);
437 double C =
cos(k * length);
438 double S =
sin(k * length);
440 double xt = C * part.
x() + S * part.
y();
441 double yt = C * part.
y() - S * part.
x();
442 double pxt = C * part.
px() + S * part.
py();
443 double pyt = C * part.
py() - S * part.
px();
445 part.
x() = C * xt + (S / k) * pxt;
446 part.
y() = C * yt + (S / k) * pyt;
447 part.
px() = C * pxt - (S * k) * xt;
448 part.
py() = C * pyt - (S * k) * yt;
449 part.
t() += length * (pt * ref - (px * px + py * py + 3.0 * pt * pt *
ref) / 2.0);
461 double ref = kin * kin;
466 double px = part.
px();
467 double py = part.
py();
468 double pt = part.
pt();
469 double lByPz = length / (1.0 + pt);
470 part.
x() += px * lByPz;
471 part.
y() += py * lByPz;
472 part.
t() += length * (pt * ref - (px * px + py * py + 3.0 * pt * pt *
ref) / 2.0);
double & py()
Get reference to vertical momentum (no dimension).
virtual const Matrix3D & getBunchMoment() const =0
Get moments.
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 BDipoleField & getField()=0
Return the corrector field.
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.
virtual void visitBeamStripping(const BeamStripping &)
Apply the algorithm to a beam stripping.
Interface for septum magnet.
virtual BMultipoleField & getField() override=0
Get multipole field.
Interface for electrostatic separator.
virtual double getPhase() const =0
Get RF phase.
Interface for beam position monitors.
Interface for RF Quadrupole.
A simple arc in the XZ plane.
Tps< T > sin(const Tps< T > &x)
Sine.
double & x()
Get reference to horizontal position in m.
constexpr double two_pi
The value of .
virtual double getBz() const =0
Get solenoid field Bz in Teslas.
Tps< T > exp(const Tps< T > &x)
Exponential.
virtual double getElementLength() const override
Get design length.
virtual double getEx() const =0
Get horizontal component Ex of field in V/m.
Interface for general corrector.
virtual double getEy() const =0
Get vertical component Ey of field in V/m.
Interface for beam diagnostics.
virtual void visitBeamBeam(const BeamBeam &)
Apply algorithm to BeamBeam.
virtual double getBy() const
Get vertical component.
virtual PlanarArcGeometry & getGeometry() override=0
Get SBend geometry.
Interface for drift space.
Interface for general multipole.
FLieGenerator< T, N > real(const FLieGenerator< std::complex< T >, N > &)
Take real part of a complex generator.
T deg(T x)
Convert radians to degrees.
virtual double getElementLength() const override
Get design length.
virtual void visitSeptum(const Septum &)
Apply algorithm to Septum.
double getBendAngle() const
Get angle.
virtual double getBunchCharge() const =0
Get bunch charge.
virtual void visitParallelPlate(const ParallelPlate &)
Apply algorithm to Solenoid.
double skew(int) const
Get component.
double getQ() const
The constant charge per particle.
virtual void visitSeparator(const Separator &)
Apply algorithm to Separator.
virtual double getElementLength() const
Get design length.
OpalParticle get_part(int ii)
virtual void visitCorrector(const Corrector &)
Apply algorithm to Corrector.
virtual double getFrequency() const =0
Get RF frequencey.
constexpr double c
The velocity of light in m/s.
Interface for cyclotron collimator.
virtual void visitDrift(const Drift &)
Apply algorithm to Drift.
virtual void visitSBend(const SBend &)
Apply algorithm to SBend.
Abstract beam-beam interaction.
virtual void visitFlexibleCollimator(const FlexibleCollimator &)
Apply the algorithm to a flexible collimator.
std::complex< double > Werrf(std::complex< double > z)
Complex error function.
Interface for cyclotron valley.
virtual double getBx() const
Get horizontal component.
void applyDrift(double length)
virtual double getElementLength() const
Get element length.
An abstract sequence of beam line components.
const PartData itsReference
The reference information.
virtual const Vector3D & getBunchDisplacement() const =0
Get displacement.
size_t getLocalNum() const
void set_part(FVector< double, 6 > z, int ii)
virtual double getElementLength() const
Get element length.
double & pt()
Get reference to relative momentum error (no dimension).
Tps< T > sqrt(const Tps< T > &x)
Square root.
The geometry for a RBend element.
virtual void visitMarker(const Marker &)
Apply algorithm to Marker.
double getP() const
The constant reference momentum per particle.
virtual void visitDegrader(const Degrader &)
Apply the algorithm to a drift.
virtual void visitMonitor(const Monitor &)
Apply algorithm to Monitor.
virtual void visitProbe(const Probe &)
Apply algorithm to Probe.
The magnetic field of a multipole.
double getM() const
The constant mass per particle.
virtual void visitSolenoid(const Solenoid &)
Apply algorithm to Solenoid.
Tps< T > cos(const Tps< T > &x)
Cosine.
virtual void visitRFCavity(const RFCavity &)
Apply algorithm to RFCavity.
virtual void visitLambertson(const Lambertson &)
Apply algorithm to Lambertson.
constexpr double q_e
The elementary charge in As.
double & y()
Get reference to vertical displacement in m.
constexpr double epsilon_0
The permittivity of vacuum in As/Vm.
double & t()
Get reference to longitudinal displacement c*t in m.
virtual void visitDiagnostic(const Diagnostic &)
Apply algorithm to Diagnostic.
virtual RBendGeometry & getGeometry() override=0
Get RBend geometry.
virtual double getBendAngle() const
Get angle.
double & px()
Get reference to horizontal momentum (no dimension).
virtual void visitRBend(const RBend &)
Apply algorithm to RBend.
virtual void visitCCollimator(const CCollimator &)
Apply algorithm to Collimator.
FLieGenerator< T, N > imag(const FLieGenerator< std::complex< T >, N > &)
Take imaginary part of a complex generator.
virtual void visitRFQuadrupole(const RFQuadrupole &)
Apply algorithm to RFQuadrupole.
virtual void visitCyclotronValley(const CyclotronValley &)
Apply the algorithm to a CyclotronValley.
PartBunchBase< double, 3 > * itsBunch_m
The bunch of particles to be tracked.
int order() const
Return order.
virtual void visitMultipole(const Multipole &)
Apply algorithm to Multipole.
void applyThinMultipole(const BMultipoleField &field, double factor)
Interface for a Lambertson septum.
Track particles or bunches.