OPALX (Object Oriented Parallel Accelerator Library for Exascal) MINIorX
OPALX
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 "OPALTypes.h"
29
31
32class PartData;
33
34template <class T, int N>
35class FVps;
36
37struct Point {
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
50class Component : public ElementBase {
51public:
53 explicit Component(const std::string& name);
54
55 Component();
56 Component(const Component& right);
57 virtual ~Component();
58
60 // The representation of the electro-magnetic field of the component
61 // (version for non-constant object).
62 virtual EMField& getField() = 0;
63
65 // The representation of the electro-magnetic field of the component
66 // (version for constant object).
67 virtual const EMField& getField() const = 0;
68
70 // Return the value of the time-independent part of the electric
71 // field at point [b]P[/b].
72 EVector Efield(const Point3D& P) const;
73
75 // Return the value of the time-independent part of the magnetic
76 // field at point [b]P[/b].
77 BVector Bfield(const Point3D& P) const;
78
80 // Return the value of the time-dependent part of the electric
81 // field at point [b]P[/b] for time [b]t[/b].
82 EVector Efield(const Point3D& P, double t) const;
83
85 // Return the value of the time-dependent part of the magnetic
86 // field at point [b]P[/b] for time [b]t[/b].
87 BVector Bfield(const Point3D& P, double t) const;
88
90 // Return the value of the time-independent part of both electric
91 // and magnetic fields at point [b]P[/b].
92 EBVectors EBfield(const Point3D& P) const;
93
95 // Return the value of the time-dependent part of both electric
96 // and magnetic fields at point [b]P[/b] for time [b]t[/b].
97 EBVectors EBfield(const Point3D& P, double t) const;
98
99 virtual bool apply(
100 const size_t& i, const double& t, Vector_t<double, 3>& E, Vector_t<double, 3>& B);
101
102 virtual bool apply(
103 const Vector_t<double, 3>& R, const Vector_t<double, 3>& P, const double& t,
105
106 virtual bool applyToReferenceParticle(
107 const Vector_t<double, 3>& R, const Vector_t<double, 3>& P, const double& t,
109
122 virtual bool getPotential(
123 const Vector_t<double, 3>& /*R*/, const double& /*t*/, Vector_t<double, 3>& /*A*/,
124 double& /*phi*/) {
125 return false;
126 }
127
128 virtual double getDesignEnergy() const;
129 virtual void setDesignEnergy(const double& energy, bool changeable = true);
130
131 virtual void initialise(PartBunch_t* bunch, double& startField, double& endField) = 0;
132
133 virtual void finalise() = 0;
134
135 virtual bool bends() const = 0;
136
137 // virtual bool determineEntryPoint(const double &kineticEnergy, const double &tolerance) =
138 // 0;
139
140 virtual void goOnline(const double& kineticEnergy);
141
142 virtual void goOffline();
143
144 virtual bool Online();
145
146 // void getOrientation(Vector_t<double, 3> &, double &) const; // first component is alpha,
147 // second is beta. the third component is always neglected.
148 // // alpha is defined as the angle between projection of the normal of the face of the element
149 // onto
150 // // the s-u plane and the s vector. for beta the following is valid:
151 // // beta = arccos(|n_{parallel}|) where n_{parallel} is the projection of the normal onto the
152 // s-u
153 // // plane
154
155 // void setOrientation(const Vector_t<double, 3> &direction);
156
157 virtual void getDimensions(double& zBegin, double& zEnd) const = 0;
158
159 virtual ElementType getType() const;
160
162 // If this method returns a pointer to this component.
163 // The default version returns ``this''.
164 virtual const ElementBase& getDesign() const;
165
167 // This catch-all method implements a hook for tracking a particle
168 // bunch through a non-standard component.
169 // The default version throws a LogicalError.
170 virtual void trackBunch(PartBunch_t* bunch, const PartData&, bool revBeam, bool revTrack) const;
171
173 // This catch-all method implements a hook for tracking a transfer
174 // map through a non-standard component.
175 // The default version throws a LogicalError.
176 virtual void trackMap(FVps<double, 6>& map, const PartData&, bool revBeam, bool revTrack) const;
177
178 void setExitFaceSlope(const double&);
179
180protected:
181 static const std::vector<double> defaultAperture_m;
182 // Vector_t<double, 3> Orientation_m;
184
187};
188
189// Inline access functions to fields.
190// ------------------------------------------------------------------------
191
192inline EVector Component::Efield(const Point3D& P) const {
193 return getField().Efield(P);
194}
195
196inline BVector Component::Bfield(const Point3D& P) const {
197 return getField().Bfield(P);
198}
199
200inline EVector Component::Efield(const Point3D& P, double t) const {
201 return getField().Efield(P, t);
202}
203
204inline BVector Component::Bfield(const Point3D& P, double t) const {
205 return getField().Bfield(P, t);
206}
207
208inline EBVectors Component::EBfield(const Point3D& P) const {
209 return getField().EBfield(P);
210}
211
212inline EBVectors Component::EBfield(const Point3D& P, double t) const {
213 return getField().EBfield(P, t);
214}
215
216// inline void Component::getOrientation(Vector_t<double, 3> &ori, double &m) const {
217// ori = Orientation_m;
218// m = exit_face_slope_m;
219// }
220
221// inline void Component::setOrientation(const Vector_t<double, 3> &direction)
222// { Orientation_m = direction; }
223
224inline void Component::setExitFaceSlope(const double& m) {
226}
227
228inline void Component::setDesignEnergy(const double& /*energy*/, bool /*changeable*/) {
229}
230
231inline double Component::getDesignEnergy() const {
232 return -1.0;
233}
234
235#endif // CLASSIC_Component_HH
double x
Definition Component.h:38
ParticleContainer< double, 3 > ParticleContainer_t
Definition Component.h:30
double y
Definition Component.h:39
ElementType
Definition ElementBase.h:88
PartBunch< PLayout_t< double, 3 >, double, 3 > PartBunch_t
ippl::Vector< T, Dim > Vector_t
BVector Bfield(const Point3D &P) const
Return the field in a point.
Definition Component.h:196
virtual ElementType getType() const
Get element type std::string.
Definition Component.cpp:76
virtual bool applyToReferenceParticle(const Vector_t< double, 3 > &R, const Vector_t< double, 3 > &P, const double &t, Vector_t< double, 3 > &E, Vector_t< double, 3 > &B)
virtual void finalise()=0
virtual const EMField & getField() const =0
Return field.
virtual bool getPotential(const Vector_t< double, 3 > &, const double &, Vector_t< double, 3 > &, double &)
Definition Component.h:122
virtual double getDesignEnergy() const
Definition Component.h:231
bool online_m
Definition Component.h:186
virtual void initialise(PartBunch_t *bunch, double &startField, double &endField)=0
virtual void goOnline(const double &kineticEnergy)
Definition Component.cpp:64
virtual void goOffline()
Definition Component.cpp:68
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:60
Component(const std::string &name)
Constructor with given name.
Definition Component.cpp:44
virtual EMField & getField()=0
Return field.
virtual bool bends() const =0
PartBunch_t * RefPartBunch_m
Definition Component.h:185
virtual ~Component()
Definition Component.cpp:49
virtual void setDesignEnergy(const double &energy, bool changeable=true)
Definition Component.h:228
static const std::vector< double > defaultAperture_m
Definition Component.h:181
virtual void trackBunch(PartBunch_t *bunch, const PartData &, bool revBeam, bool revTrack) const
Track particle bunch.
Definition Component.cpp:56
virtual bool Online()
Definition Component.cpp:72
EBVectors EBfield(const Point3D &P) const
Return the field in a point.
Definition Component.h:208
double exit_face_slope_m
Definition Component.h:183
virtual const ElementBase & getDesign() const
Return design element.
Definition Component.cpp:52
virtual bool apply(const size_t &i, const double &t, Vector_t< double, 3 > &E, Vector_t< double, 3 > &B)
Definition Component.cpp:80
EVector Efield(const Point3D &P) const
Return the field in a point.
Definition Component.h:192
void setExitFaceSlope(const double &)
Definition Component.h:224
ElementBase(const std::string &name)
Constructor with given name.
Particle reference data.
Definition PartData.h:37
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