OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
OPAL
EMField.h
Go to the documentation of this file.
1 #ifndef CLASSIC_EMField_HH
2 #define CLASSIC_EMField_HH
3 
4 // ------------------------------------------------------------------------
5 // $RCSfile: EMField.h,v $
6 // ------------------------------------------------------------------------
7 // $Revision: 1.1.1.1 $
8 // ------------------------------------------------------------------------
9 // Copyright: see Copyright.readme
10 // ------------------------------------------------------------------------
11 //
12 // Classes:
13 // Point3D: a point in 3-dimensional space.
14 // EVector: an electric field vector.
15 // BVector: a magnetic field vector.
16 // EBVectors: an electromagnetic field, containing E and B.
17 // EMField: a virtual base class for electromagnetic fields.
18 //
19 // ------------------------------------------------------------------------
20 // Class category: Fields
21 // ------------------------------------------------------------------------
22 //
23 // $Date: 2000/03/27 09:32:36 $
24 // $Author: fci $
25 //
26 // ------------------------------------------------------------------------
27 
28 
29 // Class Point3D
30 // ------------------------------------------------------------------------
32 
33 class Point3D {
34 
35 public:
36 
38  // Construct the point from its coordinates (x,y,z) in m.
39  Point3D(double x, double y, double z);
40 
42  // Return the x-coordinate for the point in m.
43  double getX() const;
44 
46  // Return the y-coordinate for the point in m.
47  double getY() const;
48 
50  // Return the z-coordinate for the point in m.
51  double getZ() const;
52 
53 private:
54 
55  double x, y, z;
56 };
57 
58 
59 // Class EVector
60 // ------------------------------------------------------------------------
62 
63 class EVector {
64 
65 public:
66 
68  // Construct the field vector from is components (Ex,Ey,Ez) in A/m.
69  EVector(double, double, double);
70 
72  // Multiply the field vector by [b]scalar[/b].
73  EVector operator*(double scalar) const;
74 
76  // Return the x-component of the field in A/m.
77  double getEx() const;
78 
80  // Return the y-component of the field in A/m.
81  double getEy() const;
82 
84  // Return the z-component of the field in A/m.
85  double getEz() const;
86 
87 private:
88 
89  double Ex, Ey, Ez;
90 };
91 
92 
93 // Class BVector
94 // ------------------------------------------------------------------------
96 
97 class BVector {
98 
99 public:
100 
102  // Construct the field vector from its components (Bx,By,Bz) in T.
103  BVector(double, double, double);
104 
106  // Multiply the field vector by [b]scalar[/b].
107  BVector operator*(double scalar) const;
108 
110  // Return the x-component of the field in T.
111  double getBx() const;
112 
114  // Return the y-component of the field in T.
115  double getBy() const;
116 
118  // Return the z-component of the field in T.
119  double getBz() const;
120 
121 private:
122 
123  double Bx, By, Bz;
124 };
125 
126 
127 // Class EBVectors
128 // ------------------------------------------------------------------------
130 // Contains both an electric and a magnetic field vector.
131 // These represent the instantaneous electromagnetic field in a given point.
132 
133 class EBVectors {
134 
135 public:
136 
138  // Construct the field from the two field vectors [b]E[/b] (in A/m)
139  // and [b]B[/b] (in T).
140  EBVectors(const EVector &E, const BVector &B);
141 
143  // Return the electric field vector in A/m.
144  EVector getE() const;
145 
147  // Return the x-component of the electric field in A/m.
148  double getEx() const;
149 
151  // Return the y-component of the electric field in A/m.
152  double getEy() const;
153 
155  // Return the z-component of the electric field in A/m.
156  double getEz() const;
157 
159  // Return the magnetic field vector in T.
160  BVector getB() const;
161 
163  // Return the x-component of the magnetic field in T.
164  double getBx() const;
165 
167  // Return the y-component of the magnetic field in T.
168  double getBy() const;
169 
171  // Return the z-component of the magnetic field in T.
172  double getBz() const;
173 
174 private:
175 
178 };
179 
180 
181 // Class EMField
182 // ------------------------------------------------------------------------
184 // This class represent a time-varying position dependent electromagnetic
185 // field. Derived classes include time-constant fields as well as
186 // spatially homogeneous fields.
187 
188 class EMField {
189 
190 public:
191 
193  // Construct zero field.
194  EMField();
195 
196  EMField(const EMField &right);
197  virtual ~EMField();
198  const EMField &operator=(const EMField &right);
199 
201  // Return the time-independent part of the electric field in point [b]P[/b].
202  // This default action returns a zero field.
203  virtual EVector Efield(const Point3D &P) const;
204 
206  // Return the time-independent part of the magnetic field in point [b]P[/b].
207  // This default action returns a zero field.
208  virtual BVector Bfield(const Point3D &P) const;
209 
211  // Return the electric field at time [b]t[/b] in point [b]P[/b].
212  // This default action returns the static part EField(P).
213  virtual EVector Efield(const Point3D &P, double t) const;
214 
216  // Return the magnetic field at time [b]t[/b] in point [b]P[/b].
217  // This default action returns the static part BField(P).
218  virtual BVector Bfield(const Point3D &P, double t) const;
219 
221  // Return the static part of the field pair (E,B) in point [b]P[/b].
222  // This default action returns EBVectors(EField(P), BField(P)).
223  virtual EBVectors EBfield(const Point3D &P) const;
224 
226  // Return the field pair (E,B) at time [b]t[/b] in point [b]P[/b].
227  // This default action returns the static part EBfield(P).
228  virtual EBVectors EBfield(const Point3D &P, double t) const;
229 
231  // Multiply the field by [b]scalar[/b].
232  // This method must be defined for each derived class.
233  virtual void scale(double scalar) = 0;
234 
236  static const EVector ZeroEfield;
237 
239  static const BVector ZeroBfield;
240 
242  static const EBVectors ZeroEBfield;
243 };
244 
245 #endif // CLASSIC_EMField_HH
A point in 3 dimensions.
Definition: EMField.h:33
Point3D(double x, double y, double z)
Constructor.
Definition: EMField.cpp:31
double getZ() const
Return coordinate.
Definition: EMField.cpp:40
double getX() const
Return coordinate.
Definition: EMField.cpp:34
double z
Definition: EMField.h:55
double y
Definition: EMField.h:55
double x
Definition: EMField.h:55
double getY() const
Return coordinate.
Definition: EMField.cpp:37
An electric field vector.
Definition: EMField.h:63
double Ex
Definition: EMField.h:89
double Ez
Definition: EMField.h:89
EVector operator*(double scalar) const
Scale.
Definition: EMField.cpp:51
double getEz() const
Get component.
Definition: EMField.cpp:63
EVector(double, double, double)
Constructor.
Definition: EMField.cpp:47
double getEx() const
Get component.
Definition: EMField.cpp:55
double getEy() const
Get component.
Definition: EMField.cpp:59
double Ey
Definition: EMField.h:89
A magnetic field vector.
Definition: EMField.h:97
BVector operator*(double scalar) const
Scale.
Definition: EMField.cpp:74
double getBz() const
Get component.
Definition: EMField.cpp:86
double Bx
Definition: EMField.h:123
double getBy() const
Get component.
Definition: EMField.cpp:82
double getBx() const
Get component.
Definition: EMField.cpp:78
double Bz
Definition: EMField.h:123
BVector(double, double, double)
Constructor.
Definition: EMField.cpp:70
double By
Definition: EMField.h:123
A representation of an electromagnetic field.
Definition: EMField.h:133
double getEz() const
Get component.
Definition: EMField.cpp:110
EVector E
Definition: EMField.h:176
double getBz() const
Get component.
Definition: EMField.cpp:126
double getEx() const
Get component.
Definition: EMField.cpp:102
double getBy() const
Get component.
Definition: EMField.cpp:122
BVector getB() const
Get field.
Definition: EMField.cpp:114
double getBx() const
Get component.
Definition: EMField.cpp:118
BVector B
Definition: EMField.h:177
EBVectors(const EVector &E, const BVector &B)
Constructor.
Definition: EMField.cpp:93
EVector getE() const
Get component.
Definition: EMField.cpp:98
double getEy() const
Get component.
Definition: EMField.cpp:106
Abstract base class for electromagnetic fields.
Definition: EMField.h:188
EMField()
Default constructor.
Definition: EMField.cpp:146
const EMField & operator=(const EMField &right)
Definition: EMField.cpp:158
static const BVector ZeroBfield
The constant representing a zero magnetic field.
Definition: EMField.h:239
static const EVector ZeroEfield
The constant representing a zero electric field.
Definition: EMField.h:236
virtual BVector Bfield(const Point3D &P) const
Get field.
Definition: EMField.cpp:168
virtual ~EMField()
Definition: EMField.cpp:154
virtual void scale(double scalar)=0
Scale the field.
static const EBVectors ZeroEBfield
The constant representing a zero electromagnetic field.
Definition: EMField.h:242
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