OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
VerticalFFAMagnet.h
Go to the documentation of this file.
1 //
2 // Header file for VerticalFFAMagnet Component
3 //
4 // Copyright (c) 2019 Chris Rogers
5 // All rights reserved.
6 //
7 // OPAL is licensed under GNU GPL version 3.
8 //
9 
10 #include "Fields/BMultipoleField.h"
12 #include "AbsBeamline/Component.h"
13 #include "Algorithms/PartBunch.h"
14 
15 #ifndef ABSBEAMLINE_VerticalFFAMagnet_H
16 #define ABSBEAMLINE_VerticalFFAMagnet_H
17 
18 namespace endfieldmodel {
19  class EndFieldModel;
20 }
21 
28 class VerticalFFAMagnet : public Component {
29  public:
34  explicit VerticalFFAMagnet(const std::string &name);
35 
38 
40  ElementBase* clone() const;
41 
51  inline bool apply(const size_t &i, const double &t, Vector_t &E, Vector_t &B);
52 
62  inline bool apply(const Vector_t &R, const Vector_t &P, const double &t,
63  Vector_t &E, Vector_t &B);
64 
72  bool getFieldValue(const Vector_t &R, Vector_t &B) const;
73 
80  void initialise(PartBunchBase<double, 3> *bunch, double &startField, double &endField);
81 
87  void initialise();
88 
90  void finalise();
91 
97  inline bool bends() const {return false;}
98 
100  void getDimensions(double &zBegin, double &zEnd) const {}
101 
104 
106  const BGeometryBase& getGeometry() const;
107 
109  EMField &getField();
110 
112  const EMField &getField() const;
113 
115  void accept(BeamlineVisitor& visitor) const;
116 
123 
130 
133  size_t getMaxOrder() const {return maxOrder_m;}
134 
137  void setMaxOrder(size_t maxOrder) {maxOrder_m = maxOrder;}
138 
140  double getB0() const {return Bz_m/Tesla;}
141 
143  void setB0(double Bz) {Bz_m = Bz*Tesla;}
144 
146  double getFieldIndex() const {return k_m*mm;} // units are [m^{-1}]
147 
149  void setFieldIndex(double index) {k_m = index/mm;}
150 
152  double getNegativeVerticalExtent() const {return zNegExtent_m/mm;}
153 
155  inline void setNegativeVerticalExtent(double negativeExtent);
156 
158  double getPositiveVerticalExtent() const {return zPosExtent_m/mm;}
159 
161  inline void setPositiveVerticalExtent(double positiveExtent);
162 
164  double getBBLength() const {return bbLength_m/mm;}
165 
167  void setBBLength(double bbLength) {bbLength_m = bbLength*mm;}
168 
170  double getWidth() const {return halfWidth_m/mm*2.;}
171 
173  void setWidth(double width) {halfWidth_m = width/2*mm;}
174 
185  inline std::vector<std::vector<double> > getDfCoefficients() const;
186 private:
188 
190  VerticalFFAMagnet(const VerticalFFAMagnet &right);
191 
195 
196  size_t maxOrder_m = 0;
197  double k_m = 0.;
198  double Bz_m = 0.;
199  double zNegExtent_m = 0.; // extent downwards from the midplane
200  double zPosExtent_m = 0.; // extent upwards from the midplane
201  double halfWidth_m = 0.; // extent in either +x or -x
202  double bbLength_m = 0.;
203  std::unique_ptr<endfieldmodel::EndFieldModel> endField_m;
204  std::vector<std::vector<double> > dfCoefficients_m;
205 
206  const double mm=1000.;
207  const double Tesla=10.;
208 };
209 
210 void VerticalFFAMagnet::setNegativeVerticalExtent(double negativeExtent) {
211  zNegExtent_m = negativeExtent*mm;
212 }
213 
214 void VerticalFFAMagnet::setPositiveVerticalExtent(double positiveExtent) {
215  zPosExtent_m = positiveExtent*mm;
216 }
217 
218 bool VerticalFFAMagnet::apply(const size_t &i, const double &t,
219  Vector_t &E, Vector_t &B) {
220  return apply(RefPartBunch_m->R[i], RefPartBunch_m->P[i], t, E, B);
221 }
222 
224  const double &t, Vector_t &E, Vector_t &B) {
225  return getFieldValue(R, B);
226 }
227 
228 std::vector<std::vector<double> > VerticalFFAMagnet::getDfCoefficients() const {
229  return dfCoefficients_m;
230 }
231 
232 #endif
233 
std::vector< std::vector< double > > getDfCoefficients() const
ParticleAttrib< Vector_t > P
void setWidth(double width)
double getPositiveVerticalExtent() const
Interface for basic beam line object.
Definition: ElementBase.h:128
void setFieldIndex(double index)
bool apply(const size_t &i, const double &t, Vector_t &E, Vector_t &B)
BGeometryBase & getGeometry()
void setEndField(endfieldmodel::EndFieldModel *endField)
double getFieldIndex() const
void setMaxOrder(size_t maxOrder)
bool bends() const
void setBBLength(double bbLength)
size_t getMaxOrder() const
Abstract base class for accelerator geometry classes.
Definition: Geometry.h:43
void getDimensions(double &zBegin, double &zEnd) const
void setPositiveVerticalExtent(double positiveExtent)
double getBBLength() const
VerticalFFAMagnet(const std::string &name)
PartBunchBase< double, 3 > * RefPartBunch_m
Definition: Component.h:200
void setNegativeVerticalExtent(double negativeExtent)
Abstract base class for electromagnetic fields.
Definition: EMField.h:188
double getWidth() const
A geometry representing a straight line.
StraightGeometry straightGeometry_m
The magnetic field of a multipole.
VerticalFFAMagnet & operator=(const VerticalFFAMagnet &rhs)
bool getFieldValue(const Vector_t &R, Vector_t &B) const
const std::string name
void accept(BeamlineVisitor &visitor) const
double getB0() const
std::vector< std::vector< double > > dfCoefficients_m
double getNegativeVerticalExtent() const
ParticlePos_t & R
ElementBase * clone() const
Interface for a single beam element.
Definition: Component.h:51
Abstract algorithm.
void setB0(double Bz)
std::unique_ptr< endfieldmodel::EndFieldModel > endField_m
endfieldmodel::EndFieldModel * getEndField() const
BMultipoleField dummy