OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
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 ElementBase::ElementType getType() const;
163 
164  virtual void setComponentType(std::string /*name*/) { };
165  virtual std::string getComponentType() const { return ""; };
166 
168  // If this method returns a pointer to this component.
169  // The default version returns ``this''.
170  virtual const ElementBase &getDesign() const;
171 
173  // This catch-all method implements a hook for tracking a particle
174  // bunch through a non-standard component.
175  // The default version throws a LogicalError.
176  virtual void trackBunch(PartBunchBase<double, 3> *bunch, const PartData &,
177  bool revBeam, bool revTrack) const;
178 
180  // This catch-all method implements a hook for tracking a transfer
181  // map through a non-standard component.
182  // The default version throws a LogicalError.
183  virtual void trackMap(FVps<double, 6> &map, const PartData &,
184  bool revBeam, bool revTrack) const;
185 
186  void setExitFaceSlope(const double &);
187 
188 protected:
189 
190  static const std::vector<double> defaultAperture_m;
191  // Vector_t Orientation_m;
193 
195  bool online_m;
196 };
197 
198 
199 // Inline access functions to fields.
200 // ------------------------------------------------------------------------
201 
202 inline EVector Component::Efield(const Point3D &P) const
203 { return getField().Efield(P); }
204 
205 inline BVector Component::Bfield(const Point3D &P) const
206 { return getField().Bfield(P); }
207 
208 inline EVector Component::Efield(const Point3D &P, double t) const
209 { return getField().Efield(P, t); }
210 
211 inline BVector Component::Bfield(const Point3D &P, double t) const
212 { return getField().Bfield(P, t); }
213 
214 inline EBVectors Component::EBfield(const Point3D &P) const
215 { return getField().EBfield(P); }
216 
217 inline EBVectors Component::EBfield(const Point3D &P, double t) const
218 { return getField().EBfield(P, t); }
219 
220 // inline void Component::getOrientation(Vector_t &ori, double &m) const {
221 // ori = Orientation_m;
222 // m = exit_face_slope_m;
223 // }
224 
225 // inline void Component::setOrientation(const Vector_t &direction)
226 // { Orientation_m = direction; }
227 
228 inline void Component::setExitFaceSlope(const double &m)
229 { exit_face_slope_m = m; }
230 
231 inline void Component::setDesignEnergy(const double &/*energy*/, bool /*changeable*/)
232 { }
233 
234 inline double Component::getDesignEnergy() const
235 {
236  return -1.0;
237 }
238 
239 #endif // CLASSIC_Component_HH
const std::string name
Vector truncated power series in n variables.
Definition: FVps.h:39
double x
Definition: Component.h:38
double y
Definition: Component.h:39
Interface for a single beam element.
Definition: Component.h:50
BVector Bfield(const Point3D &P) const
Return the field in a point.
Definition: Component.h:205
virtual void finalise()=0
virtual void initialise(PartBunchBase< double, 3 > *bunch, double &startField, double &endField)=0
virtual double getDesignEnergy() const
Definition: Component.h:234
virtual void setComponentType(std::string)
Definition: Component.h:164
bool online_m
Definition: Component.h:195
virtual bool applyToReferenceParticle(const Vector_t &R, const Vector_t &P, const double &t, Vector_t &E, Vector_t &B)
Definition: Component.cpp:121
virtual void goOnline(const double &kineticEnergy)
Definition: Component.cpp:83
virtual void goOffline()
Definition: Component.cpp:87
virtual void getDimensions(double &zBegin, double &zEnd) const =0
virtual ElementBase::ElementType getType() const
Get element type std::string.
Definition: Component.cpp:95
virtual bool apply(const size_t &i, const double &t, Vector_t &E, Vector_t &B)
Definition: Component.cpp:99
virtual void trackBunch(PartBunchBase< double, 3 > *bunch, const PartData &, bool revBeam, bool revTrack) const
Track particle bunch.
Definition: Component.cpp:71
virtual const EMField & getField() const =0
Return field.
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
PartBunchBase< double, 3 > * RefPartBunch_m
Definition: Component.h:194
virtual bool bends() const =0
virtual ~Component()
Definition: Component.cpp:63
virtual void setDesignEnergy(const double &energy, bool changeable=true)
Definition: Component.h:231
static const std::vector< double > defaultAperture_m
Definition: Component.h:190
virtual bool Online()
Definition: Component.cpp:91
EBVectors EBfield(const Point3D &P) const
Return the field in a point.
Definition: Component.h:214
virtual EMField & getField()=0
Return field.
double exit_face_slope_m
Definition: Component.h:192
virtual std::string getComponentType() const
Definition: Component.h:165
virtual const ElementBase & getDesign() const
Return design element.
Definition: Component.cpp:67
EVector Efield(const Point3D &P) const
Return the field in a point.
Definition: Component.h:202
void setExitFaceSlope(const double &)
Definition: Component.h:228
Particle reference data.
Definition: PartData.h:35
A point in 3 dimensions.
Definition: EMField.h:33
An electric field vector.
Definition: EMField.h:63
A magnetic field vector.
Definition: EMField.h:97
A representation of an electromagnetic field.
Definition: EMField.h:133
Abstract base class for electromagnetic fields.
Definition: EMField.h:188
virtual BVector Bfield(const Point3D &P) const
Get field.
Definition: EMField.cpp:168
virtual EVector Efield(const Point3D &P) const
Get field.
Definition: EMField.cpp:163
virtual EBVectors EBfield(const Point3D &P) const
Get field.
Definition: EMField.cpp:183