OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
LinearMapper.h
Go to the documentation of this file.
1 #ifndef MAD_LinearMapper_HH
2 #define MAD_LinearMapper_HH
3 
4 // ------------------------------------------------------------------------
5 // $RCSfile: LinearMapper.h,v $
6 // ------------------------------------------------------------------------
7 // $Revision: 1.3 $
8 // ------------------------------------------------------------------------
9 // Copyright: see Copyright.readme
10 // ------------------------------------------------------------------------
11 //
12 // Class: LinearMapper
13 //
14 // ------------------------------------------------------------------------
15 //
16 // $Date: 2000/12/31 07:12:38 $
17 // $Author: mad $
18 //
19 // ------------------------------------------------------------------------
20 
22 #include "FixedAlgebra/LinearMap.h"
23 
24 
25 class BMultipoleField;
26 class Euclid3D;
27 
28 template <class T, int N> class FTps;
29 template <class T, int N> class FVps;
30 
31 
32 // Class LinearMapper
33 // ------------------------------------------------------------------------
35 // Phase space coordinates numbering:
36 // [tab 3 b]
37 // [row]number [&]name [&]unit [/row]
38 // [row]0 [&]x [&]metres [/row]
39 // [row]1 [&]p_x/p_r [&]1 [/row]
40 // [row]2 [&]y [&]metres [/row]
41 // [row]3 [&]p_y/p_r [&]1 [/row]
42 // [row]4 [&]v*delta_t [&]metres [/row]
43 // [row]5 [&]delta_p/p_r [&]1 [/row]
44 // [/tab][p]
45 // Where $p_r$ is the constant reference momentum defining the reference
46 // frame velocity, $m$ is the rest mass of the particles, and $v$ is the
47 // instantaneous velocity of the particle.
48 // [p]
49 // Other units used:
50 // [tab 2 b]
51 // [row]quantity [&]unit [/row]
52 // [row]reference momentum [&]electron-volts [/row]
53 // [row]velocity [&]metres/second [/row]
54 // [row]accelerating voltage [&]volts [/row]
55 // [row]separator voltage [&]volts [/row]
56 // [row]frequencies [&]hertz [/row]
57 // [row]phase lags [&]$2*pi$ [/row]
58 // [/tab][p]
59 // Approximations used:
60 // [ul]
61 // [li] All elements are represented by maps for finite-length elements.
62 // [li] Geometric transformations ignore rotations about transverse axes and
63 // translations along the design orbit and truncate after second order.
64 // [li] Beam-beam elements are two-dimensional, and the second moment <x,y>
65 // of the opposite bunches vanish.
66 // [/ul]
67 
69 
70 public:
71 
73  // The beam line to be tracked is [b]bl[/b].
74  // The particle reference data are taken from [b]data[/b].
75  // If [b]revBeam[/b] is true, the beam runs from s = C to s = 0.
76  // If [b]revTrack[/b] is true, we track against the beam.
77  LinearMapper(const Beamline &beamline, const PartData &,
78  bool revBeam, bool revTrack);
79 
80  virtual ~LinearMapper();
81 
83  virtual void getMap(LinearMap<double, 6> &) const;
84 
86  virtual void getMap(FVps<double, 6> &) const;
87 
89  virtual void setMap(const LinearMap<double, 6> &);
90 
92  virtual void setMap(const FVps<double, 6> &);
93 
95  virtual void visitBeamBeam(const BeamBeam &);
96 
98  virtual void visitBeamStripping(const BeamStripping &);
99 
100 
102  virtual void visitCCollimator(const CCollimator &);
103 
105  // This override calls the component to track the map.
106  virtual void visitComponent(const Component &);
107 
109  virtual void visitCorrector(const Corrector &);
110 
112  virtual void visitDegrader(const Degrader &);
113 
115  virtual void visitDiagnostic(const Diagnostic &);
116 
118  virtual void visitDrift(const Drift &);
119 
121  virtual void visitFlexibleCollimator(const FlexibleCollimator &);
122 
124  virtual void visitLambertson(const Lambertson &);
125 
127  virtual void visitMarker(const Marker &);
128 
130  virtual void visitMonitor(const Monitor &);
131 
133  virtual void visitMultipole(const Multipole &);
134 
136  virtual void visitPatch(const Patch &pat);
137 
139  virtual void visitProbe(const Probe &prob);
140 
142  virtual void visitRBend0(const RBend &);
143  virtual void visitRBend(const RBend &); // exp(:-H:) version
145  virtual void visitRFCavity(const RFCavity &);
146 
148  virtual void visitRFQuadrupole(const RFQuadrupole &);
149 
151  virtual void visitSBend(const SBend &);
152 
154  virtual void visitSeparator(const Separator &);
155 
157  virtual void visitSeptum(const Septum &);
158 
160  virtual void visitSolenoid(const Solenoid &);
161 
163  virtual void visitAlignWrapper(const AlignWrapper &);
164 
166  virtual void visitParallelPlate(const ParallelPlate &);
167 
169  virtual void visitCyclotronValley(const CyclotronValley &);
170 
171 
173  virtual void visitMapIntegrator(const MapIntegrator &);
174 
175 protected:
176 
178  // Propagate current map through a drift.
179  void applyDrift(double length);
180 
182  void applyEntranceFringe(double edge,
183  const BMultipoleField &field, double scale);
184  void applyExitFringe(double edge,
185  const BMultipoleField &field, double scale);
186 
188  void applyLinearMap(double length, double refLength, double h,
189  const FTps<double, 2> &Fx, const FTps<double, 2> &Fy);
190 
192  void applyMultipoleBody(double length, double refLength,
193  const BMultipoleField &field, double scale);
194 
196  void applySBendBody(double length, double refLength, double h,
197  const BMultipoleField &field, double scale);
198 
200  // Apply a thin multipole kick (integrated over length) to current map.
201  void applyThinMultipole(const BMultipoleField &field, double factor);
202 
204  // Propagate current map through a geometric transformation.
205  void applyTransform(const Euclid3D &, double refLength);
206 
209  buildSBendVectorPotential(const BMultipoleField &, double h);
210 
211 
212  // The linear map being accumulated.
214 
215 private:
216 
217  // Not implemented.
218  LinearMapper();
219  LinearMapper(const LinearMapper &);
220  void operator=(const LinearMapper &);
221 
223  static void makeFocus
224  (double k, double L, double &c, double &s, double &d, double &f);
225 
226 };
227 
228 #endif // MAD_LinearMapper_HH
Build transfer map.
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 void visitPatch(const Patch &pat)
Apply the algorithm to a patch.
virtual ~LinearMapper()
virtual void visitAlignWrapper(const AlignWrapper &)
Apply the algorithm to an offset beamline object wrapper.
Interface for septum magnet.
Definition: Septum.h:11
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.
Definition: Separator.h:33
virtual void visitLambertson(const Lambertson &)
Apply the algorithm to a Lambertson.
void applyExitFringe(double edge, const BMultipoleField &field, double scale)
Interface for beam position monitors.
Definition: Monitor.h:41
Interface for RF Quadrupole.
Definition: RFQuadrupole.h:30
virtual void visitRFCavity(const RFCavity &)
Apply the algorithm to a RFCavity.
Define the position of a misaligned element.
Definition: AlignWrapper.h:39
Interface for RF cavity.
Definition: ParallelPlate.h:36
virtual void visitComponent(const Component &)
Apply the algorithm to an arbitrary component.
virtual void visitMultipole(const Multipole &)
Apply the algorithm to a Multipole.
Particle reference data.
Definition: PartData.h:38
virtual void visitFlexibleCollimator(const FlexibleCollimator &)
Apply the algorithm to a flexible collimator.
Interface for general corrector.
Definition: Corrector.h:35
Abstract collimator.
Definition: RBend.h:73
Interface for beam diagnostics.
Definition: Diagnostic.h:32
Interface for a marker.
Definition: Marker.h:32
virtual void visitSeparator(const Separator &)
Apply the algorithm to a Separator.
Interface for drift space.
Definition: Drift.h:33
Build a map using a linear map for each element.
Definition: LinearMapper.h:68
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.
Definition: Multipole.h:46
virtual void visitMonitor(const Monitor &)
Apply the algorithm to a Monitor.
LinearMap< double, 6 > itsMap
Definition: LinearMapper.h:213
void applyTransform(const Euclid3D &, double refLength)
Apply transform.
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.
Interface for probe.
Definition: Probe.h:16
FTps< double, 2 > buildSBendVectorPotential(const BMultipoleField &, double h)
Construct the vector potential for a SBend.
virtual void visitSolenoid(const Solenoid &)
Apply the algorithm to a Solenoid.
virtual void visitCorrector(const Corrector &)
Apply the algorithm to a Corrector.
constexpr double c
The velocity of light in m/s.
Definition: Physics.h:52
Interface for cyclotron collimator.
Definition: CCollimator.h:13
virtual void visitProbe(const Probe &prob)
Apply the algorithm to a probe.
Displacement and rotation in space.
Definition: Euclid3D.h:68
Abstract beam-beam interaction.
Definition: BeamBeam.h:37
Definition: SBend.h:68
virtual void visitBeamStripping(const BeamStripping &)
Apply the algorithm to a beam stripping.
virtual void visitDegrader(const Degrader &)
Apply the algorithm to a drift.
Interface for cyclotron valley.
virtual void visitDrift(const Drift &)
Apply the algorithm to a Drift.
virtual void visitSBend(const SBend &)
Apply the algorithm to a SBend.
Interface for solenoids.
Definition: Solenoid.h:36
static void makeFocus(double k, double L, double &c, double &s, double &d, double &f)
Helper function for finding first-order coefficients.
An abstract sequence of beam line components.
Definition: Beamline.h:37
virtual void visitRFQuadrupole(const RFQuadrupole &)
Apply the algorithm to a RFQuadrupole.
virtual void visitCyclotronValley(const CyclotronValley &)
Apply the algorithm to a CyclotronValley.
virtual void visitDiagnostic(const Diagnostic &)
Apply the algorithm to a Diagnostic.
void operator=(const LinearMapper &)
virtual void visitParallelPlate(const ParallelPlate &)
Apply the algorithm to a ParallelPlate.
The magnetic field of a multipole.
Interface for RF cavity.
Definition: RFCavity.h:37
void applyEntranceFringe(double edge, const BMultipoleField &field, double scale)
Transforms fringing fields.
Abstract collimator.
Definition: Degrader.h:37
virtual void visitMarker(const Marker &)
Apply the algorithm to a Marker.
virtual void visitBeamBeam(const BeamBeam &)
Apply the algorithm to a BeamBeam.
virtual void visitRBend(const RBend &)
Apply the algorithm to a rectangular bend.
virtual void visitMapIntegrator(const MapIntegrator &)
Apply the algorithm to an integrator capable of mapping.
Truncated power series in N variables of type T.
Interface for a geometric patch.
Definition: Patch.h:34
Interface for a single beam element.
Definition: Component.h:51
virtual void visitCCollimator(const CCollimator &)
Apply the algorithm to a collimator.
void applyThinMultipole(const BMultipoleField &field, double factor)
Thin multipole kick.
Vector truncated power series in n variables.
virtual void setMap(const LinearMap< double, 6 > &)
Reset the linear part of the accumulated map for restart.
void applyDrift(double length)
Apply drift length.
Interface for a Lambertson septum.
Definition: Lambertson.h:33
Integrate a map.
Definition: MapIntegrator.h:41