OPAL (Object Oriented Parallel Accelerator Library) 2022.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
37template < class Field > class OscillatingField: public Field {
38
39public:
40
42 // Constructs a null field.
44
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
75private:
76
77 // The frequency, and phase.
78 double frequency;
79 double phase;
80};
81
82
83// Implementation of template class OscillatingField
84// ------------------------------------------------------------------------
85
86template < class Field >
88{}
89
90
91template < class Field >
93{}
94
95
96template < class Field > inline
98{ return frequency; }
99
100
101template < class Field > inline
103{ return phase; }
104
105
106template < class Field > inline
108{ frequency = freq; }
109
110
111template < class Field > inline
113{ phase = phi; }
114
115
116template < class Field >
118{ return Field::Efield(p); }
119
120
121template < class Field >
123{ return Field::Efield(p) * cos(t * frequency - phase); }
124
125
126template < class Field >
128{ return Field::Bfield(p); }
129
130
131template < class Field >
133{ return Field::Bfield(p) * cos(t * frequency - phase); }
134
135#endif // CLASSIC_OscillatingField_HH
Tps< T > cos(const Tps< T > &x)
Cosine.
Definition: TpsMath.h:129
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
An oscillating electromagnetic field.
virtual EVector Efield(const Point3D &point) const
Get field.
virtual void setFrequency(double f)
Assign the RF frequency in Hz.
virtual double getFrequency() const
Return the RF frequency in Hz.
virtual BVector Bfield(const Point3D &point) const
Get field.
virtual EVector Efield(const Point3D &point, double time) const
Get field.
virtual void setPhase(double phi)
Assign the RF phase in rad.
virtual BVector Bfield(const Point3D &point, double time) const
Get field.
virtual double getPhase() const
Return the RF phase in rad.
OscillatingField()
Default constructor.
virtual ~OscillatingField()
Definition: Field.h:33