OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
OscillatingField.h
Go to the documentation of this file.
1#ifndef OPALX_OscillatingField_HH
2#define OPALX_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 <cmath>
24#include "Fields/EMField.h"
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>
38class OscillatingField : public Field {
39public:
41 // Constructs a null field.
43
45
47 virtual double getFrequency() const;
48
50 virtual double getPhase() const;
51
53 virtual void setFrequency(double f);
54
56 virtual void setPhase(double phi);
57
59 // Return the constant part of the electric field in point [b]P[/b].
60 virtual EVector Efield(const Point3D& point) const;
61
63 // Return the electric field at time [b]t[/b] in point [b]P[/b].
64 virtual EVector Efield(const Point3D& point, double time) const;
65
67 // Return the constant part of the magnetic field in point [b]P[/b].
68 virtual BVector Bfield(const Point3D& point) const;
69
71 // Return the magnetic field at time [b]t[/b] in point [b]P[/b].
72 virtual BVector Bfield(const Point3D& point, double time) const;
73
74private:
75 // The frequency, and phase.
76 double frequency;
77 double phase;
78};
79
80// Implementation of template class OscillatingField
81// ------------------------------------------------------------------------
82
83template <class Field>
85
86template <class Field>
88
89template <class Field>
91 return frequency;
92}
93
94template <class Field>
95inline double OscillatingField<Field>::getPhase() const {
96 return phase;
97}
98
99template <class Field>
101 frequency = freq;
102}
103
104template <class Field>
105inline void OscillatingField<Field>::setPhase(double phi) {
106 phase = phi;
107}
108
109template <class Field>
111 return Field::Efield(p);
112}
113
114template <class Field>
116 return Field::Efield(p) * cos(t * frequency - phase);
117}
118
119template <class Field>
121 return Field::Bfield(p);
122}
123
124template <class Field>
126 return Field::Bfield(p) * cos(t * frequency - phase);
127}
128
129#endif // OPALX_OscillatingField_HH
ippl::Field< T, Dim, Mesh_t< Dim >, Centering_t< Dim >, ViewArgs... > Field
A magnetic field vector.
Definition EMField.h:88
An electric field vector.
Definition EMField.h:58
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()
A point in 3 dimensions.
Definition EMField.h:32