OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
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 #include "Algorithms/Vektor.h"
29 
30 class PartData;
31 
32 template <class T, unsigned Dim>
33 class PartBunchBase;
34 
35 template <class T, int N> class FVps;
36 
37 struct Point
38 {
39  double x;
40  double y;
41 };
42 
43 // Class Component
44 // ------------------------------------------------------------------------
46 // Class Component defines the abstract interface for an arbitrary single
47 // component in a beam line. A component is the basic element in the
48 // accelerator model, like a dipole, a quadrupole, etc. It is normally
49 // associated with an electro-magnetic field, which may be null.
50 
51 class Component: public ElementBase {
52 
53 public:
54 
56  explicit Component(const std::string &name);
57 
58  Component();
59  Component(const Component &right);
60  virtual ~Component();
61 
63  // The representation of the electro-magnetic field of the component
64  // (version for non-constant object).
65  virtual EMField &getField() = 0;
66 
68  // The representation of the electro-magnetic field of the component
69  // (version for constant object).
70  virtual const EMField &getField() const = 0;
71 
73  // Return the value of the time-independent part of the electric
74  // field at point [b]P[/b].
75  EVector Efield(const Point3D &P) const;
76 
78  // Return the value of the time-independent part of the magnetic
79  // field at point [b]P[/b].
80  BVector Bfield(const Point3D &P) const;
81 
83  // Return the value of the time-dependent part of the electric
84  // field at point [b]P[/b] for time [b]t[/b].
85  EVector Efield(const Point3D &P, double t) const;
86 
88  // Return the value of the time-dependent part of the magnetic
89  // field at point [b]P[/b] for time [b]t[/b].
90  BVector Bfield(const Point3D &P, double t) const;
91 
93  // Return the value of the time-independent part of both electric
94  // and magnetic fields at point [b]P[/b].
95  EBVectors EBfield(const Point3D &P) const;
96 
98  // Return the value of the time-dependent part of both electric
99  // and magnetic fields at point [b]P[/b] for time [b]t[/b].
100  EBVectors EBfield(const Point3D &P, double t) const;
101 
102  virtual void addKR(int i, double t, Vector_t &K) {};
103 
104  virtual void addKT(int i, double t, Vector_t &K) {};
105 
106  virtual bool apply(const size_t &i,
107  const double &t,
108  Vector_t &E,
109  Vector_t &B);
110 
111  virtual bool apply(const Vector_t &R,
112  const Vector_t &P,
113  const double &t,
114  Vector_t &E,
115  Vector_t &B);
116 
117  virtual bool applyToReferenceParticle(const Vector_t &R,
118  const Vector_t &P,
119  const double &t,
120  Vector_t &E,
121  Vector_t &B);
122 
135  virtual bool getPotential(const Vector_t &R,
136  const double &t,
137  Vector_t &A,
138  double &phi) {return false;}
139 
140  virtual double getDesignEnergy() const;
141  virtual void setDesignEnergy(const double& energy, bool changeable);
142 
143  virtual void initialise(PartBunchBase<double, 3> *bunch, double &startField, double &endField) = 0;
144 
145  virtual void finalise() = 0;
146 
147  virtual bool bends() const = 0;
148 
149  // virtual bool determineEntryPoint(const double &kineticEnergy, const double &tolerance) = 0;
150 
151  virtual void goOnline(const double &kineticEnergy);
152 
153  virtual void goOffline();
154 
155  virtual bool Online();
156 
157  // void getOrientation(Vector_t &, double &) const; // first component is alpha, second is beta. the third component is always neglected.
158  // // alpha is defined as the angle between projection of the normal of the face of the element onto
159  // // the s-u plane and the s vector. for beta the following is valid:
160  // // beta = arccos(|n_{parallel}|) where n_{parallel} is the projection of the normal onto the s-u
161  // // plane
162 
163  // void setOrientation(const Vector_t &direction);
164 
165  virtual void getDimensions(double &zBegin, double &zEnd) const = 0;
166 
167  virtual ElementBase::ElementType getType() const;
168 
169  virtual void setComponentType(std::string /*name*/) { };
170  virtual std::string getComponentType() const { return ""; };
171 
173  // If a component is a wrapper, this method returns a pointer to
174  // its underlying design element, otherwise a pointer to this component.
175  // The default version returns ``this''.
176  virtual const ElementBase &getDesign() const;
177 
179  // This catch-all method implements a hook for tracking a particle
180  // bunch through a non-standard component.
181  // The default version throws a LogicalError.
182  virtual void trackBunch(PartBunchBase<double, 3> *bunch, const PartData &,
183  bool revBeam, bool revTrack) const;
184 
186  // This catch-all method implements a hook for tracking a transfer
187  // map through a non-standard component.
188  // The default version throws a LogicalError.
189  virtual void trackMap(FVps<double, 6> &map, const PartData &,
190  bool revBeam, bool revTrack) const;
191 
192  void setExitFaceSlope(const double &);
193 
194 protected:
195 
196  static const std::vector<double> defaultAperture_m;
197  // Vector_t Orientation_m;
199 
201  bool online_m;
202 };
203 
204 
205 // Inline access functions to fields.
206 // ------------------------------------------------------------------------
207 
208 inline EVector Component::Efield(const Point3D &P) const
209 { return getField().Efield(P); }
210 
211 inline BVector Component::Bfield(const Point3D &P) const
212 { return getField().Bfield(P); }
213 
214 inline EVector Component::Efield(const Point3D &P, double t) const
215 { return getField().Efield(P, t); }
216 
217 inline BVector Component::Bfield(const Point3D &P, double t) const
218 { return getField().Bfield(P, t); }
219 
220 inline EBVectors Component::EBfield(const Point3D &P) const
221 { return getField().EBfield(P); }
222 
223 inline EBVectors Component::EBfield(const Point3D &P, double t) const
224 { return getField().EBfield(P, t); }
225 
226 // inline void Component::getOrientation(Vector_t &ori, double &m) const {
227 // ori = Orientation_m;
228 // m = exit_face_slope_m;
229 // }
230 
231 // inline void Component::setOrientation(const Vector_t &direction)
232 // { Orientation_m = direction; }
233 
234 inline void Component::setExitFaceSlope(const double &m)
235 { exit_face_slope_m = m; }
236 
237 inline void Component::setDesignEnergy(const double& energy, bool changeable = true )
238 { }
239 
240 inline double Component::getDesignEnergy() const
241 {
242  return -1.0;
243 }
244 
245 #endif // CLASSIC_Component_HH
virtual bool apply(const size_t &i, const double &t, Vector_t &E, Vector_t &B)
Definition: Component.cpp:99
A magnetic field vector.
Definition: EMField.h:97
virtual BVector Bfield(const Point3D &P) const
Get field.
Definition: EMField.cpp:168
Interface for basic beam line object.
Definition: ElementBase.h:128
virtual void getDimensions(double &zBegin, double &zEnd) const =0
virtual void trackMap(FVps< double, 6 > &map, const PartData &, bool revBeam, bool revTrack) const
Track a map.
Definition: Component.cpp:78
An electric field vector.
Definition: EMField.h:63
double x
Definition: Component.h:39
virtual EBVectors EBfield(const Point3D &P) const
Get field.
Definition: EMField.cpp:183
virtual void goOffline()
Definition: Component.cpp:87
Particle reference data.
Definition: PartData.h:38
virtual EMField & getField()=0
Return field.
bool online_m
Definition: Component.h:201
virtual bool Online()
Definition: Component.cpp:91
A point in 3 dimensions.
Definition: EMField.h:33
virtual void setDesignEnergy(const double &energy, bool changeable)
Definition: Component.h:237
Class: DataSink.
Definition: OpalData.h:29
EBVectors EBfield(const Point3D &P) const
Return the field in a point.
Definition: Component.h:220
virtual void trackBunch(PartBunchBase< double, 3 > *bunch, const PartData &, bool revBeam, bool revTrack) const
Track particle bunch.
Definition: Component.cpp:71
double y
Definition: Component.h:40
PartBunchBase< double, 3 > * RefPartBunch_m
Definition: Component.h:200
virtual EVector Efield(const Point3D &P) const
Get field.
Definition: EMField.cpp:163
Abstract base class for electromagnetic fields.
Definition: EMField.h:188
virtual void addKT(int i, double t, Vector_t &K)
Definition: Component.h:104
BVector Bfield(const Point3D &P) const
Return the field in a point.
Definition: Component.h:211
virtual void finalise()=0
static const std::vector< double > defaultAperture_m
Definition: Component.h:196
virtual void initialise(PartBunchBase< double, 3 > *bunch, double &startField, double &endField)=0
virtual double getDesignEnergy() const
Definition: Component.h:240
virtual void setComponentType(std::string)
Definition: Component.h:169
const std::string name
virtual void goOnline(const double &kineticEnergy)
Definition: Component.cpp:83
void setExitFaceSlope(const double &)
Definition: Component.h:234
virtual bool applyToReferenceParticle(const Vector_t &R, const Vector_t &P, const double &t, Vector_t &E, Vector_t &B)
Definition: Component.cpp:121
Interface for a single beam element.
Definition: Component.h:51
virtual void addKR(int i, double t, Vector_t &K)
Definition: Component.h:102
virtual const ElementBase & getDesign() const
Return design element.
Definition: Component.cpp:67
double exit_face_slope_m
Definition: Component.h:198
#define K
Definition: integrate.cpp:118
virtual bool bends() const =0
virtual ElementBase::ElementType getType() const
Get element type std::string.
Definition: Component.cpp:95
Vector truncated power series in n variables.
virtual ~Component()
Definition: Component.cpp:63
EVector Efield(const Point3D &P) const
Return the field in a point.
Definition: Component.h:208
virtual std::string getComponentType() const
Definition: Component.h:170
virtual bool getPotential(const Vector_t &R, const double &t, Vector_t &A, double &phi)
Definition: Component.h:135
A representation of an electromagnetic field.
Definition: EMField.h:133