OPAL (Object Oriented Parallel Accelerator Library) 2024.2
OPAL
VariableRFCavity.h
Go to the documentation of this file.
1//
2// Class VariableRFCavity
3// Defines the abstract interface for a RF Cavity
4// with Time Dependent Parameters.
5//
6// Copyright (c) 2014 - 2023, Chris Rogers, STFC Rutherford Appleton Laboratory, Didcot, UK
7// All rights reserved
8//
9// This file is part of OPAL.
10//
11// OPAL is free software: you can redistribute it and/or modify
12// it under the terms of the GNU General Public License as published by
13// the Free Software Foundation, either version 3 of the License, or
14// (at your option) any later version.
15//
16// You should have received a copy of the GNU General Public License
17// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
18//
19#ifndef CLASSIC_ABSBEAMLINE_VariableRFCavity_HH
20#define CLASSIC_ABSBEAMLINE_VariableRFCavity_HH
21
26#include "Fields/Definitions.h"
27#include "Fields/EMField.h"
28
41
42public:
44 explicit VariableRFCavity(const std::string& name);
55 virtual ~VariableRFCavity();
56
62 virtual void accept(BeamlineVisitor&) const override;
63
65 virtual ElementBase* clone() const override;
66
76 virtual bool apply(const size_t& i, const double& t,
77 Vector_t& E, Vector_t& B) override;
78
89 virtual bool apply(const Vector_t& R, const Vector_t& P,
90 const double& t, Vector_t& E, Vector_t& B) override;
91
92
103 virtual bool applyToReferenceParticle(const Vector_t& R, const Vector_t& P,
104 const double& t, Vector_t& E, Vector_t& B) override;
105
110 virtual void initialise(PartBunchBase<double, 3>* bunch, double& startField, double& endField) override;
111
116 virtual void finalise() override;
117
119 virtual bool bends() const override {return false;}
120
122 virtual void getDimensions(double& /*zBegin*/, double& /*zEnd*/) const override {}
123
130 virtual inline double getAmplitude(double time) const;
131
138 virtual inline double getFrequency(double time) const;
139
146 virtual inline double getPhase(double time) const;
147
149 virtual inline double getHeight() const;
151 virtual inline double getWidth() const;
153 virtual inline double getLength() const;
155 virtual inline void setHeight(double fullHeight);
157 virtual inline void setWidth(double fullWidth);
159 virtual void setLength(double length);
160
162 virtual std::shared_ptr<AbstractTimeDependence> getAmplitudeModel() const;
164 virtual std::shared_ptr<AbstractTimeDependence> getPhaseModel() const;
166 virtual std::shared_ptr<AbstractTimeDependence> getFrequencyModel() const;
167
169 virtual void setAmplitudeModel(std::shared_ptr<AbstractTimeDependence> time_dep);
171 virtual void setPhaseModel(std::shared_ptr<AbstractTimeDependence> time_dep);
173 virtual void setFrequencyModel(std::shared_ptr<AbstractTimeDependence> time_dep);
174
179 virtual void setAmplitudeName(const std::string& amplitude) { amplitudeName_m = amplitude; }
180
185 virtual void setPhaseName(const std::string& phase) { phaseName_m = phase; }
186
191 virtual void setFrequencyName(const std::string& frequency) { frequencyName_m = frequency; }
192
194 virtual StraightGeometry& getGeometry() override;
196 virtual const StraightGeometry& getGeometry() const override;
197
203 void initialise() const;
204
206 virtual EMField& getField() override;
208 virtual const EMField& getField() const override;
209
210protected:
211 void initNull();
212 std::shared_ptr<AbstractTimeDependence> phaseTD_m;
213 std::shared_ptr<AbstractTimeDependence> amplitudeTD_m;
214 std::shared_ptr<AbstractTimeDependence> frequencyTD_m;
215 std::string phaseName_m;
216 std::string amplitudeName_m;
217 std::string frequencyName_m;
220 double length_m;
222
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;
243}
244
246 return halfWidth_m * 2;
247}
248
250 return length_m;
251}
252
253void VariableRFCavity::setHeight(double fullHeight) {
254 halfHeight_m = fullHeight / 2;
255}
256
257void VariableRFCavity::setWidth(double fullWidth) {
258 halfWidth_m = fullWidth / 2;
259}
260
261#endif // CLASSIC_VirtualRFCavity_HH
const std::string name
Interface for a single beam element.
Definition: Component.h:50
Generates a field like E = a(t) * sin{2*pi * integral(f(tau),0,t) + q(t)} B = 0 where E0,...
std::shared_ptr< AbstractTimeDependence > frequencyTD_m
void initialise() const
Lookup the time dependencies and update.
StraightGeometry geometry
The cavity's geometry.
virtual void setHeight(double fullHeight)
Set the full height of the cavity.
virtual double getAmplitude(double time) const
Get the amplitude at a given time.
virtual void finalise() override
Finalise following tracking.
std::string amplitudeName_m
virtual void getDimensions(double &, double &) const override
Not used (does nothing)
virtual void setPhaseName(const std::string &phase)
Set the phase time dependence name.
virtual double getFrequency(double time) const
Get the frequency at a given time.
std::string phaseName_m
std::string frequencyName_m
virtual bool bends() const override
virtual double getWidth() const
virtual std::shared_ptr< AbstractTimeDependence > getFrequencyModel() const
VariableRFCavity()
Default constructor.
virtual double getLength() const
virtual void setAmplitudeName(const std::string &amplitude)
Set the amplitude time dependence name.
virtual bool apply(const size_t &i, const double &t, Vector_t &E, Vector_t &B) override
Calculate the field at the position of the i^th particle.
virtual void setPhaseModel(std::shared_ptr< AbstractTimeDependence > time_dep)
Set the phase time dependence.
virtual ~VariableRFCavity()
Destructor does nothing.
virtual std::shared_ptr< AbstractTimeDependence > getAmplitudeModel() const
TimeDependenceCache frequencyCache_m
virtual double getHeight() const
virtual void setFrequencyModel(std::shared_ptr< AbstractTimeDependence > time_dep)
Set the frequency time dependence.
virtual void setLength(double length)
Set the length of the cavity.
virtual bool applyToReferenceParticle(const Vector_t &R, const Vector_t &P, const double &t, Vector_t &E, Vector_t &B) override
Calculate the field at a given position.
std::shared_ptr< AbstractTimeDependence > amplitudeTD_m
virtual double getPhase(double time) const
Get the phase at a given time.
virtual void accept(BeamlineVisitor &) const override
Apply visitor to RFCavity.
virtual void setFrequencyName(const std::string &frequency)
Set the frequency time dependence name.
virtual void setWidth(double fullWidth)
Set the full width of the cavity.
virtual std::shared_ptr< AbstractTimeDependence > getPhaseModel() const
virtual ElementBase * clone() const override
Inheritable deepcopy method.
virtual EMField & getField() override
Not implemented.
std::shared_ptr< AbstractTimeDependence > phaseTD_m
virtual StraightGeometry & getGeometry() override
Set the cavity geometry.
VariableRFCavity & operator=(const VariableRFCavity &)
Assignment operator; performs deepcopy on time-dependence models.
virtual void setAmplitudeModel(std::shared_ptr< AbstractTimeDependence > time_dep)
Set the amplitude (field gradient) time dependence.
A geometry representing a straight line.
Abstract base class for electromagnetic fields.
Definition: EMField.h:188