OPAL (Object Oriented Parallel Accelerator Library)  2024.1
OPAL
OscillatingField.h
Go to the documentation of this file.
1 #ifndef CLASSIC_OscillatingField_HH
2 #define CLASSIC_OscillatingField_HH
3 
4 // ------------------------------------------------------------------------
5 // $RCSfile: OscillatingField.h,v $
6 // ------------------------------------------------------------------------
7 // $Revision: 1.2 $
8 // ------------------------------------------------------------------------
9 // Copyright: see Copyright.readme
10 // ------------------------------------------------------------------------
11 //
12 // Template class: OscillatingField
13 //
14 // ------------------------------------------------------------------------
15 // Class category: Fields
16 // ------------------------------------------------------------------------
17 //
18 // $Date: 2000/12/16 19:47:06 $
19 // $Author: mad $
20 //
21 // ------------------------------------------------------------------------
22 
23 #include "Fields/EMField.h"
24 #include <cmath>
25 
26 // Template class OscillatingField<Field>
27 // ------------------------------------------------------------------------
29 // The field is derived from the corresponding static field.
30 // Care must be taken when the static field is not homogeneous,
31 // the oscillating values may be incorrect, as they may not fulfill
32 // Maxwell's equations.
33 // {p}
34 // Note that this class is derived from its template parameter,
35 // it inherits the methods and data from that class as well.
36 
37 template < class Field > class OscillatingField: public Field {
38 
39 public:
40 
42  // Constructs a null field.
44 
45  virtual ~OscillatingField();
46 
48  virtual double getFrequency() const;
49 
51  virtual double getPhase() const;
52 
54  virtual void setFrequency(double f);
55 
57  virtual void setPhase(double phi);
58 
60  // Return the constant part of the electric field in point [b]P[/b].
61  virtual EVector Efield(const Point3D &point) const;
62 
64  // Return the electric field at time [b]t[/b] in point [b]P[/b].
65  virtual EVector Efield(const Point3D &point, double time) const;
66 
68  // Return the constant part of the magnetic field in point [b]P[/b].
69  virtual BVector Bfield(const Point3D &point) const;
70 
72  // Return the magnetic field at time [b]t[/b] in point [b]P[/b].
73  virtual BVector Bfield(const Point3D &point, double time) const;
74 
75 private:
76 
77  // The frequency, and phase.
78  double frequency;
79  double phase;
80 };
81 
82 
83 // Implementation of template class OscillatingField
84 // ------------------------------------------------------------------------
85 
86 template < class Field >
88 {}
89 
90 
91 template < class Field >
93 {}
94 
95 
96 template < class Field > inline
98 { return frequency; }
99 
100 
101 template < class Field > inline
103 { return phase; }
104 
105 
106 template < class Field > inline
108 { frequency = freq; }
109 
110 
111 template < class Field > inline
113 { phase = phi; }
114 
115 
116 template < class Field >
118 { return Field::Efield(p); }
119 
120 
121 template < class Field >
123 { return Field::Efield(p) * cos(t * frequency - phase); }
124 
125 
126 template < class Field >
128 { return Field::Bfield(p); }
129 
130 
131 template < class Field >
133 { return Field::Bfield(p) * cos(t * frequency - phase); }
134 
135 #endif // CLASSIC_OscillatingField_HH
OscillatingField()
Default constructor.
virtual BVector Bfield(const Point3D &point) const
Get field.
An oscillating electromagnetic field.
An electric field vector.
Definition: EMField.h:63
virtual double getPhase() const
Return the RF phase in rad.
A point in 3 dimensions.
Definition: EMField.h:33
A magnetic field vector.
Definition: EMField.h:97
virtual EVector Efield(const Point3D &point) const
Get field.
virtual ~OscillatingField()
Tps< T > cos(const Tps< T > &x)
Cosine.
Definition: TpsMath.h:129
virtual double getFrequency() const
Return the RF frequency in Hz.
virtual void setFrequency(double f)
Assign the RF frequency in Hz.
virtual void setPhase(double phi)
Assign the RF phase in rad.