OPAL (Object Oriented Parallel Accelerator Library)  2024.1
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 
27 namespace endfieldmodel {
28  class EndFieldModel;
29 }
30 
51 
52 public:
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;
154  void initialiseCoefficients();
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 
164 protected:
165  double zCentre_m; // offsets this element
166  size_t maxOrder_m;
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 
172 private:
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 
197 std::shared_ptr<endfieldmodel::EndFieldModel> VariableRFCavityFringeField::getEndField() const {
198  return endField_m;
199 }
200 
201 std::vector<std::vector<double> > VariableRFCavityFringeField::getEzCoefficients() const {
202  return f_m;
203 }
204 
205 std::vector<std::vector<double> > VariableRFCavityFringeField::getEyCoefficients() const {
206  return g_m;
207 }
208 
209 std::vector<std::vector<double> > VariableRFCavityFringeField::getBxCoefficients() const {
210  return h_m;
211 }
212 
213 #endif // #ifdef CLASSIC_VirtualRFCavityFringeField_HH
virtual bool applyToReferenceParticle(const Vector_t &R, const Vector_t &P, const double &t, Vector_t &E, Vector_t &B) override
virtual void setEndField(std::shared_ptr< endfieldmodel::EndFieldModel > endField)
std::vector< std::vector< double > > h_m
virtual bool apply(const size_t &i, const double &t, Vector_t &E, Vector_t &B) override
virtual std::shared_ptr< endfieldmodel::EndFieldModel > getEndField() const
virtual void setCavityCentre(double zCentre)
std::vector< std::vector< double > > f_m
std::vector< std::vector< double > > g_m
std::shared_ptr< endfieldmodel::EndFieldModel > endField_m
void printCoefficients(std::ostream &out) const
virtual void accept(BeamlineVisitor &) const override
void initialise() const
std::vector< std::vector< double > > getBxCoefficients() const
const std::string name
VariableRFCavityFringeField & operator=(const VariableRFCavityFringeField &)
virtual ElementBase * clone() const override
std::vector< std::vector< double > > getEyCoefficients() const
std::vector< std::vector< double > > getEzCoefficients() const
virtual void setMaxOrder(size_t maxOrder)