OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
ParallelPlate.cpp
Go to the documentation of this file.
1 // ------------------------------------------------------------------------
2 // $RCSfile: ParallelPlate.cpp,v $
3 // ------------------------------------------------------------------------
4 // $Revision: 1.1.1.1 $
5 // ------------------------------------------------------------------------
6 // Copyright: see Copyright.readme
7 // ------------------------------------------------------------------------
8 //
9 // Class: ParallelPlate
10 // Defines the abstract interface for Parallel Plate. For benchmarking the
11 // Secondary emisssion model
12 //
13 // ------------------------------------------------------------------------
14 // Class category: AbsBeamline
15 // ------------------------------------------------------------------------
16 //
17 // $Date: 2010/10/12 15:32:31 $
18 // $Author: Chuan Wang $
19 //
20 // ------------------------------------------------------------------------
21 
25 #include "Physics/Physics.h"
26 
27 #include <iostream>
28 #include <fstream>
29 
30 extern Inform *gmsg;
31 
32 // Class ParallelPlate
33 // ------------------------------------------------------------------------
34 
36  ParallelPlate("")
37 {}
38 
39 
41  Component(right),
42  filename_m(right.filename_m),
43  scale_m(right.scale_m),
44  phase_m(right.phase_m),
45  frequency_m(right.frequency_m),
46  length_m(right.length_m),
47  ptime_m(0.0) {
48  setElType(isRF);
49 }
50 
51 
52 ParallelPlate::ParallelPlate(const std::string &name):
53  Component(name),
54  filename_m(""),
55  scale_m(1.0),
56  phase_m(0.0),
57  frequency_m(0.0),
58  length_m(0.0),
59  ptime_m(0.0) {
60  setElType(isRF);
61 }
62 
63 
65 
66 
67 }
68 
69 
70 void ParallelPlate::accept(BeamlineVisitor &visitor) const {
71  visitor.visitParallelPlate(*this);
72 }
73 
74 
75 std::string ParallelPlate::getFieldMapFN() const {
76  return "";
77 }
78 
79 void ParallelPlate::setAmplitude(double vPeak) {
80  scale_m = vPeak;
81 }
82 
84  return scale_m ;
85 }
86 
87 void ParallelPlate::setFrequency(double freq) {
88  frequency_m = freq;
89 }
90 
92  return frequency_m;
93 }
94 
95 void ParallelPlate::setPhase(double phase) {
96  phase_m = phase;
97 }
98 
99 double ParallelPlate::getPhase() const {
100  return phase_m;
101 }
102 
103 // void ParallelPlate::setElementLength(double length) {
104 // length_m = length;
105 // }
106 
107 // double ParallelPlate::getElementLength() const {
108 // return length_m;
109 // }
110 
111 
112 bool ParallelPlate::apply(const size_t &i, const double &t, Vector_t &E, Vector_t &B) {
113  return applyToReferenceParticle(RefPartBunch_m->R[i], RefPartBunch_m->P[i], t, E, B);
114 }
115 
116 bool ParallelPlate::apply(const Vector_t &R, const Vector_t &P, const double &t, Vector_t &E, Vector_t &B) {
117  return applyToReferenceParticle(R, P, t, E, B);
118 }
119 
120 bool ParallelPlate::applyToReferenceParticle(const Vector_t &R, const Vector_t &P, const double &t, Vector_t &E, Vector_t &B) {
121  const double phase = frequency_m * t + phase_m;
122  Vector_t tmpE(0.0, 0.0, -1.0), tmpB(0.0, 0.0, 0.0);
123  ptime_m = t;
124 
125  //Here we don't check if the particle is outof bounds, just leave the matter to the particle Boundary collision model in BoundaryGeometry
126  if ((R(2) >= 0.0)
127  && (R(2) < length_m)) {
128  E += scale_m / length_m * sin(phase) * tmpE; //Here scale_m should be Voltage between the parallel plates(V).
129  B = tmpB; //B field is always zero for our parallel plate elements used for benchmarking.
130  return false;
131  }
132  return true;
133 }
134 
135 void ParallelPlate::initialise(PartBunchBase<double, 3> *bunch, double &startField, double &endField) {
136 
138  RefPartBunch_m = bunch;
139  startField = 0.0;
140 
141  endField = length_m;
142 
143 }
144 
145 // In current version ,not implemented yet.
147  using Physics::pi;
148 
149  Inform msg("ParallelPlate initialization for cyclotron tracker ");
150 
151  RefPartBunch_m = bunch;
152  // ElementEdge_m = startField;
153  msg << " Currently parallelplate initialization for cyclotron tracker is empty! " << endl;
154 
155 }
156 
157 
158 
160 {}
161 
162 bool ParallelPlate::bends() const {
163  return false;
164 }
165 
166 void ParallelPlate::getDimensions(double &zBegin, double &zEnd) const {
167  zBegin = 0.0;
168  zEnd = length_m;
169 }
170 
171 
173  return PARALLELPLATE;
174 }
ParticleAttrib< Vector_t > P
void setPhase(double phase)
Tps< T > sin(const Tps< T > &x)
Sine.
Definition: TpsMath.h:111
void setFrequency(double freq)
Interface for RF cavity.
Definition: ParallelPlate.h:36
Inform * gmsg
Definition: Main.cpp:21
void getDimensions(double &zBegin, double &zEnd) const override
void setAmplitude(double vPeak)
virtual ~ParallelPlate()
constexpr double pi
The value of .
Definition: Physics.h:31
void setElType(ElemType elt)
set the element type as enumeration needed in the envelope tracker
Definition: ElementBase.h:591
virtual double getElementLength() const
Get design length.
Definition: ElementBase.h:511
double getPhase() const
PartBunchBase< double, 3 > * RefPartBunch_m
Definition: Component.h:200
virtual bool applyToReferenceParticle(const Vector_t &R, const Vector_t &P, const double &t, Vector_t &E, Vector_t &B) override
virtual bool apply(const size_t &i, const double &t, Vector_t &E, Vector_t &B) override
virtual void accept(BeamlineVisitor &) const override
Apply visitor to ParallelPlate.
virtual bool bends() const override
virtual void initialise(PartBunchBase< double, 3 > *bunch, double &startField, double &endField) override
double getAmplitude() const
const std::string name
ElementBase::ElementType getType() const override
Get element type std::string.
virtual void finalise() override
ParticlePos_t & R
virtual void visitParallelPlate(const ParallelPlate &)=0
Apply the algorithm to an ParallelPlate.
double frequency_m
Definition: ParallelPlate.h:91
Interface for a single beam element.
Definition: Component.h:51
Abstract algorithm.
Definition: Inform.h:41
std::string getFieldMapFN() const
double getFrequency() const
Inform & endl(Inform &inf)
Definition: Inform.cpp:42