OPAL (Object Oriented Parallel Accelerator Library)  2024.1
OPAL
Component.h
Go to the documentation of this file.
1 #ifndef CLASSIC_Component_HH
2 #define CLASSIC_Component_HH
3 
4 // ------------------------------------------------------------------------
5 // $RCSfile: Component.h,v $
6 // ------------------------------------------------------------------------
7 // $Revision: 1.1.1.1 $
8 // ------------------------------------------------------------------------
9 // Copyright: see Copyright.readme
10 // ------------------------------------------------------------------------
11 //
12 // Class: Component
13 // An abstract base class which defines the common interface for all
14 // CLASSIC components, i.e. beam line members which are not themselves
15 // beam lines.
16 //
17 // ------------------------------------------------------------------------
18 // Class category: AbsBeamline
19 // ------------------------------------------------------------------------
20 //
21 // $Date: 2000/03/27 09:32:31 $
22 // $Author: fci $
23 //
24 // ------------------------------------------------------------------------
25 
27 #include "Fields/EMField.h"
28 
29 class PartData;
30 
31 template <class T, unsigned Dim>
32 class PartBunchBase;
33 
34 template <class T, int N> class FVps;
35 
36 struct Point
37 {
38  double x;
39  double y;
40 };
41 
42 // Class Component
43 // ------------------------------------------------------------------------
45 // Class Component defines the abstract interface for an arbitrary single
46 // component in a beam line. A component is the basic element in the
47 // accelerator model, like a dipole, a quadrupole, etc. It is normally
48 // associated with an electro-magnetic field, which may be null.
49 
50 class Component: public ElementBase {
51 
52 public:
53 
55  explicit Component(const std::string &name);
56 
57  Component();
58  Component(const Component &right);
59  virtual ~Component();
60 
62  // The representation of the electro-magnetic field of the component
63  // (version for non-constant object).
64  virtual EMField &getField() = 0;
65 
67  // The representation of the electro-magnetic field of the component
68  // (version for constant object).
69  virtual const EMField &getField() const = 0;
70 
72  // Return the value of the time-independent part of the electric
73  // field at point [b]P[/b].
74  EVector Efield(const Point3D &P) const;
75 
77  // Return the value of the time-independent part of the magnetic
78  // field at point [b]P[/b].
79  BVector Bfield(const Point3D &P) const;
80 
82  // Return the value of the time-dependent part of the electric
83  // field at point [b]P[/b] for time [b]t[/b].
84  EVector Efield(const Point3D &P, double t) const;
85 
87  // Return the value of the time-dependent part of the magnetic
88  // field at point [b]P[/b] for time [b]t[/b].
89  BVector Bfield(const Point3D &P, double t) const;
90 
92  // Return the value of the time-independent part of both electric
93  // and magnetic fields at point [b]P[/b].
94  EBVectors EBfield(const Point3D &P) const;
95 
97  // Return the value of the time-dependent part of both electric
98  // and magnetic fields at point [b]P[/b] for time [b]t[/b].
99  EBVectors EBfield(const Point3D &P, double t) const;
100 
101  virtual bool apply(const size_t &i,
102  const double &t,
103  Vector_t &E,
104  Vector_t &B);
105 
106  virtual bool apply(const Vector_t &R,
107  const Vector_t &P,
108  const double &t,
109  Vector_t &E,
110  Vector_t &B);
111 
112  virtual bool applyToReferenceParticle(const Vector_t &R,
113  const Vector_t &P,
114  const double &t,
115  Vector_t &E,
116  Vector_t &B);
117 
130  virtual bool getPotential(const Vector_t &/*R*/,
131  const double &/*t*/,
132  Vector_t &/*A*/,
133  double &/*phi*/) {return false;}
134 
135  virtual double getDesignEnergy() const;
136  virtual void setDesignEnergy(const double& energy, bool changeable = true);
137 
138  virtual void initialise(PartBunchBase<double, 3> *bunch, double &startField, double &endField) = 0;
139 
140  virtual void finalise() = 0;
141 
142  virtual bool bends() const = 0;
143 
144  // virtual bool determineEntryPoint(const double &kineticEnergy, const double &tolerance) = 0;
145 
146  virtual void goOnline(const double &kineticEnergy);
147 
148  virtual void goOffline();
149 
150  virtual bool Online();
151 
152  // void getOrientation(Vector_t &, double &) const; // first component is alpha, second is beta. the third component is always neglected.
153  // // alpha is defined as the angle between projection of the normal of the face of the element onto
154  // // the s-u plane and the s vector. for beta the following is valid:
155  // // beta = arccos(|n_{parallel}|) where n_{parallel} is the projection of the normal onto the s-u
156  // // plane
157 
158  // void setOrientation(const Vector_t &direction);
159 
160  virtual void getDimensions(double &zBegin, double &zEnd) const = 0;
161 
162  virtual ElementType getType() const override;
163 
165  // If this method returns a pointer to this component.
166  // The default version returns ``this''.
167  virtual const ElementBase &getDesign() const;
168 
170  // This catch-all method implements a hook for tracking a particle
171  // bunch through a non-standard component.
172  // The default version throws a LogicalError.
173  virtual void trackBunch(PartBunchBase<double, 3> *bunch, const PartData &,
174  bool revBeam, bool revTrack) const;
175 
177  // This catch-all method implements a hook for tracking a transfer
178  // map through a non-standard component.
179  // The default version throws a LogicalError.
180  virtual void trackMap(FVps<double, 6> &map, const PartData &,
181  bool revBeam, bool revTrack) const;
182 
183  void setExitFaceSlope(const double &);
184 
185 protected:
186 
187  static const std::vector<double> defaultAperture_m;
188  // Vector_t Orientation_m;
190 
192  bool online_m;
193 };
194 
195 
196 // Inline access functions to fields.
197 // ------------------------------------------------------------------------
198 
199 inline EVector Component::Efield(const Point3D &P) const
200 { return getField().Efield(P); }
201 
202 inline BVector Component::Bfield(const Point3D &P) const
203 { return getField().Bfield(P); }
204 
205 inline EVector Component::Efield(const Point3D &P, double t) const
206 { return getField().Efield(P, t); }
207 
208 inline BVector Component::Bfield(const Point3D &P, double t) const
209 { return getField().Bfield(P, t); }
210 
211 inline EBVectors Component::EBfield(const Point3D &P) const
212 { return getField().EBfield(P); }
213 
214 inline EBVectors Component::EBfield(const Point3D &P, double t) const
215 { return getField().EBfield(P, t); }
216 
217 // inline void Component::getOrientation(Vector_t &ori, double &m) const {
218 // ori = Orientation_m;
219 // m = exit_face_slope_m;
220 // }
221 
222 // inline void Component::setOrientation(const Vector_t &direction)
223 // { Orientation_m = direction; }
224 
225 inline void Component::setExitFaceSlope(const double &m)
226 { exit_face_slope_m = m; }
227 
228 inline void Component::setDesignEnergy(const double &/*energy*/, bool /*changeable*/)
229 { }
230 
231 inline double Component::getDesignEnergy() const
232 {
233  return -1.0;
234 }
235 
236 #endif // CLASSIC_Component_HH
virtual ElementType getType() const override
Get element type std::string.
Definition: Component.cpp:95
virtual void goOffline()
Definition: Component.cpp:87
BVector Bfield(const Point3D &P) const
Return the field in a point.
Definition: Component.h:202
virtual bool Online()
Definition: Component.cpp:91
virtual void initialise(PartBunchBase< double, 3 > *bunch, double &startField, double &endField)=0
virtual EBVectors EBfield(const Point3D &P) const
Get field.
Definition: EMField.cpp:183
Abstract base class for electromagnetic fields.
Definition: EMField.h:188
virtual EVector Efield(const Point3D &P) const
Get field.
Definition: EMField.cpp:163
EBVectors EBfield(const Point3D &P) const
Return the field in a point.
Definition: Component.h:211
double y
Definition: Component.h:39
An electric field vector.
Definition: EMField.h:63
double exit_face_slope_m
Definition: Component.h:189
virtual void getDimensions(double &zBegin, double &zEnd) const =0
PartBunchBase< double, 3 > * RefPartBunch_m
Definition: Component.h:191
A point in 3 dimensions.
Definition: EMField.h:33
virtual void trackMap(FVps< double, 6 > &map, const PartData &, bool revBeam, bool revTrack) const
Track a map.
Definition: Component.cpp:78
virtual bool getPotential(const Vector_t &, const double &, Vector_t &, double &)
Definition: Component.h:130
A magnetic field vector.
Definition: EMField.h:97
void setExitFaceSlope(const double &)
Definition: Component.h:225
virtual ~Component()
Definition: Component.cpp:63
virtual BVector Bfield(const Point3D &P) const
Get field.
Definition: EMField.cpp:168
virtual bool bends() const =0
virtual void finalise()=0
virtual bool apply(const size_t &i, const double &t, Vector_t &E, Vector_t &B)
Definition: Component.cpp:99
EVector Efield(const Point3D &P) const
Return the field in a point.
Definition: Component.h:199
static const std::vector< double > defaultAperture_m
Definition: Component.h:187
virtual bool applyToReferenceParticle(const Vector_t &R, const Vector_t &P, const double &t, Vector_t &E, Vector_t &B)
Definition: Component.cpp:121
bool online_m
Definition: Component.h:192
double x
Definition: Component.h:38
virtual const ElementBase & getDesign() const
Return design element.
Definition: Component.cpp:67
virtual double getDesignEnergy() const
Definition: Component.h:231
ElementType
Definition: ElementBase.h:88
virtual void goOnline(const double &kineticEnergy)
Definition: Component.cpp:83
Vector truncated power series in n variables.
Definition: Component.h:34
const std::string name
virtual EMField & getField()=0
Return field.
virtual void setDesignEnergy(const double &energy, bool changeable=true)
Definition: Component.h:228
A representation of an electromagnetic field.
Definition: EMField.h:133
Interface for a single beam element.
Definition: Component.h:50
virtual void trackBunch(PartBunchBase< double, 3 > *bunch, const PartData &, bool revBeam, bool revTrack) const
Track particle bunch.
Definition: Component.cpp:71