OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
VariableRFCavity.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2014, Chris Rogers
3 * All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * 1. Redistributions of source code must retain the above copyright notice,
7 * this list of conditions and the following disclaimer.
8 * 2. Redistributions in binary form must reproduce the above copyright notice,
9 * this list of conditions and the following disclaimer in the documentation
10 * and/or other materials provided with the distribution.
11 * 3. Neither the name of STFC nor the names of its contributors may be used to
12 * endorse or promote products derived from this software without specific
13 * prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 * POSSIBILITY OF SUCH DAMAGE.
26 */
27
28#ifndef CLASSIC_ABSBEAMLINE_VariableRFCavity_HH
29#define CLASSIC_ABSBEAMLINE_VariableRFCavity_HH
30
32#include "Fields/EMField.h"
35
36class Fieldmap;
37
50 public:
52 explicit VariableRFCavity(const std::string &name);
63 virtual ~VariableRFCavity();
64
70 virtual void accept(BeamlineVisitor &) const override;
71
73 virtual ElementBase* clone() const override;
74
84 virtual bool apply(const size_t &i, const double &t, Vector_t &E, Vector_t &B) override;
85
96 virtual bool apply(const Vector_t &R, const Vector_t &P, const double &t, Vector_t &E, Vector_t &B) override;
97
98
109 virtual bool applyToReferenceParticle(const Vector_t &R, const Vector_t &P, const double &t, Vector_t &E, Vector_t &B) override;
110
115 virtual void initialise(PartBunchBase<double, 3> *bunch, double &startField, double &endField) override;
116
121 virtual void finalise() override;
122
124 virtual bool bends() const override {return false;}
125
127 virtual void getDimensions(double &/*zBegin*/, double &/*zEnd*/) const override {}
128
135 virtual inline double getAmplitude(double time) const;
136
143 virtual inline double getFrequency(double time) const;
144
151 virtual inline double getPhase(double time) const;
152
154 virtual inline double getHeight() const;
156 virtual inline double getWidth() const;
158 virtual inline double getLength() const;
160 virtual inline void setHeight(double fullHeight);
162 virtual inline void setWidth(double fullWidth);
164 virtual void setLength(double length);
165
167 virtual std::shared_ptr<AbstractTimeDependence> getAmplitudeModel() const;
169 virtual std::shared_ptr<AbstractTimeDependence> getPhaseModel() const;
171 virtual std::shared_ptr<AbstractTimeDependence> getFrequencyModel() const;
172
174 virtual void setAmplitudeModel(std::shared_ptr<AbstractTimeDependence> time_dep);
176 virtual void setPhaseModel(std::shared_ptr<AbstractTimeDependence> time_dep);
178 virtual void setFrequencyModel(std::shared_ptr<AbstractTimeDependence> time_dep);
179
184 virtual void setAmplitudeName(std::string amplitude)
185 { amplitudeName_m = amplitude; }
186
191 virtual void setPhaseName(std::string phase)
192 { phaseName_m = phase; }
193
198 virtual void setFrequencyName(std::string frequency)
199 { frequencyName_m = frequency; }
200
202 virtual StraightGeometry& getGeometry() override;
204 virtual const StraightGeometry& getGeometry() const override;
205
207 virtual EMField &getField() override;
209 virtual const EMField &getField() const override;
210 protected:
211 void initNull();
212 void initialise() const;
213 std::shared_ptr<AbstractTimeDependence> phaseTD_m;
214 std::shared_ptr<AbstractTimeDependence> amplitudeTD_m;
215 std::shared_ptr<AbstractTimeDependence> frequencyTD_m;
216 std::string phaseName_m;
217 std::string amplitudeName_m;
218 std::string frequencyName_m;
221 double _length;
224 static constexpr double lengthUnit_m = 1e3;
225
226private:
227};
228
229double VariableRFCavity::getAmplitude(double time) const {
230 return amplitudeTD_m->getValue(time);
231}
232
233double VariableRFCavity::getPhase(double time) const {
234 return phaseTD_m->getValue(time);
235}
236
237double VariableRFCavity::getFrequency(double time) const {
238 return frequencyTD_m->getValue(time);
239}
240
242 return halfHeight_m*2/lengthUnit_m;
243}
244
246 return halfWidth_m*2/lengthUnit_m;
247}
248
250 return _length/lengthUnit_m;
251}
252
253void VariableRFCavity::setHeight(double fullHeight) {
254 halfHeight_m = fullHeight/2*lengthUnit_m;
255}
256
257void VariableRFCavity::setWidth(double fullWidth) {
258 halfWidth_m = fullWidth/2*lengthUnit_m;
259}
260
261
262
263
264#endif // CLASSIC_VirtualRFCavity_HH
const std::string name
Interface for a single beam element.
Definition: Component.h:50
virtual void setPhaseName(std::string phase)
std::shared_ptr< AbstractTimeDependence > frequencyTD_m
void initialise() const
StraightGeometry geometry
The cavity's geometry.
virtual void setHeight(double fullHeight)
virtual double getAmplitude(double time) const
virtual void finalise() override
std::string amplitudeName_m
virtual void getDimensions(double &, double &) const override
virtual void setAmplitudeName(std::string amplitude)
virtual double getFrequency(double time) const
std::string phaseName_m
std::string frequencyName_m
virtual bool bends() const override
virtual double getWidth() const
virtual std::shared_ptr< AbstractTimeDependence > getFrequencyModel() const
virtual double getLength() const
virtual bool apply(const size_t &i, const double &t, Vector_t &E, Vector_t &B) override
virtual void setPhaseModel(std::shared_ptr< AbstractTimeDependence > time_dep)
virtual ~VariableRFCavity()
virtual std::shared_ptr< AbstractTimeDependence > getAmplitudeModel() const
virtual double getHeight() const
virtual void setFrequencyModel(std::shared_ptr< AbstractTimeDependence > time_dep)
virtual void setLength(double length)
virtual bool applyToReferenceParticle(const Vector_t &R, const Vector_t &P, const double &t, Vector_t &E, Vector_t &B) override
std::shared_ptr< AbstractTimeDependence > amplitudeTD_m
virtual double getPhase(double time) const
virtual void accept(BeamlineVisitor &) const override
virtual void setWidth(double fullWidth)
virtual std::shared_ptr< AbstractTimeDependence > getPhaseModel() const
virtual ElementBase * clone() const override
virtual EMField & getField() override
Not implemented.
std::shared_ptr< AbstractTimeDependence > phaseTD_m
static constexpr double lengthUnit_m
virtual StraightGeometry & getGeometry() override
virtual void setFrequencyName(std::string frequency)
VariableRFCavity & operator=(const VariableRFCavity &)
virtual void setAmplitudeModel(std::shared_ptr< AbstractTimeDependence > time_dep)
A geometry representing a straight line.
Abstract base class for electromagnetic fields.
Definition: EMField.h:188