OPAL (Object Oriented Parallel Accelerator Library) 2024.2
OPAL
VariableRFCavityFringeField.h
Go to the documentation of this file.
1//
2// Class VariableRFCavityFringeField
3// Defines the abstract interface for a soft-edged 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_VariableRFCavityFringeField_HH
20#define CLASSIC_ABSBEAMLINE_VariableRFCavityFringeField_HH
21
23#include "Fields/Definitions.h"
24
25#include <iostream>
26
27namespace endfieldmodel {
28 class EndFieldModel;
29}
30
51
52public:
54 explicit VariableRFCavityFringeField(const std::string& name);
66
72 virtual void accept(BeamlineVisitor&) const override;
73
79 inline void initialise() const;
80
82 virtual ElementBase* clone() const override;
83
93 virtual bool apply(const size_t& i, const double& t,
94 Vector_t& E, Vector_t& B) override;
95
106 virtual bool apply(const Vector_t& R, const Vector_t& P,
107 const double& t, Vector_t& E, Vector_t& B) override;
108
119 virtual bool applyToReferenceParticle(const Vector_t& R, const Vector_t& P,
120 const double& t, Vector_t& E, Vector_t& B) override;
121
127 virtual void setEndField
128 (std::shared_ptr<endfieldmodel::EndFieldModel> endField);
129
135 virtual inline std::shared_ptr<endfieldmodel::EndFieldModel>
136 getEndField() const;
137
142 virtual void initialise(PartBunchBase<double, 3>* bunch,
143 double& startField, double& endField) override;
144
146 virtual inline void setCavityCentre(double zCentre);
148 virtual inline double getCavityCentre() const;
150 virtual inline void setMaxOrder(size_t maxOrder);
152 virtual inline size_t getMaxOrder() const;
156 void printCoefficients(std::ostream& out) const;
158 inline std::vector<std::vector<double> > getEzCoefficients() const;
160 inline std::vector<std::vector<double> > getEyCoefficients() const;
162 inline std::vector<std::vector<double> > getBxCoefficients() const;
163
164protected:
165 double zCentre_m; // offsets this element
167 std::shared_ptr<endfieldmodel::EndFieldModel> endField_m;
168 std::vector<std::vector<double> > f_m;
169 std::vector<std::vector<double> > g_m;
170 std::vector<std::vector<double> > h_m;
171
172private:
173 void initNull();
174};
175
177 zCentre_m = zCentre;
178}
179
181 return zCentre_m;
182}
183
185 maxOrder_m = maxOrder;
187}
188
191}
192
194 return maxOrder_m;
195}
196
197std::shared_ptr<endfieldmodel::EndFieldModel> VariableRFCavityFringeField::getEndField() const {
198 return endField_m;
199}
200
201std::vector<std::vector<double> > VariableRFCavityFringeField::getEzCoefficients() const {
202 return f_m;
203}
204
205std::vector<std::vector<double> > VariableRFCavityFringeField::getEyCoefficients() const {
206 return g_m;
207}
208
209std::vector<std::vector<double> > VariableRFCavityFringeField::getBxCoefficients() const {
210 return h_m;
211}
212
213#endif // #ifdef CLASSIC_VirtualRFCavityFringeField_HH
const std::string name
Generates a field like E = a(t) * sin{2*pi * integral(f(tau),0,t) + q(t)} B = 0 where E0,...
void initialise() const
Lookup the time dependencies and update.
Generates a field like Ey = E0*a(t)*y^{2n+1} g_n(z) sin{f(t)*t-q(t)} Ez = E0*a(t)*y^{2n} f_n(z) sin{f...
std::shared_ptr< endfieldmodel::EndFieldModel > endField_m
virtual ~VariableRFCavityFringeField()
Destructor does nothing.
std::vector< std::vector< double > > getBxCoefficients() const
Get the coefficients for Bx.
std::vector< std::vector< double > > f_m
VariableRFCavityFringeField & operator=(const VariableRFCavityFringeField &)
Assignment operator; performs deepcopy on time-dependence models.
virtual double getCavityCentre() const
Set the offset of centre of the cavity field from the element start in metres.
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.
std::vector< std::vector< double > > getEzCoefficients() const
Get the coefficients for Ez.
VariableRFCavityFringeField()
Default constructor.
virtual void setMaxOrder(size_t maxOrder)
Set the maximum y power.
std::vector< std::vector< double > > getEyCoefficients() const
Get the coefficients for Ey.
virtual std::shared_ptr< endfieldmodel::EndFieldModel > getEndField() const
Get the endFieldModel.
std::vector< std::vector< double > > h_m
void initialiseCoefficients()
Set the coefficients for calculating the field expansion.
std::vector< std::vector< double > > g_m
void printCoefficients(std::ostream &out) const
Print the coefficients to ostream out.
virtual size_t getMaxOrder() const
Get the maximum y power that will be used in field calculations.
virtual void accept(BeamlineVisitor &) const override
Apply visitor to RFCavity.
virtual ElementBase * clone() const override
Inheritable deepcopy method.
virtual void setCavityCentre(double zCentre)
Get the offset of centre of the cavity field from the element start in metres.
void initialise() const
Lookup the time dependencies and update.
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.
virtual void setEndField(std::shared_ptr< endfieldmodel::EndFieldModel > endField)
Set the endFieldModel.