OPAL (Object Oriented Parallel Accelerator Library) 2022.1
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
14
15#ifndef ABSBEAMLINE_VerticalFFAMagnet_H
16#define ABSBEAMLINE_VerticalFFAMagnet_H
17
18namespace endfieldmodel {
19 class EndFieldModel;
20}
21
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);
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
153
155 inline void setNegativeVerticalExtent(double negativeExtent);
156
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;
186private:
188
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
211 zNegExtent_m = negativeExtent*mm;
212}
213
215 zPosExtent_m = positiveExtent*mm;
216}
217
218bool 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
223bool VerticalFFAMagnet::apply(const Vector_t &R, const Vector_t &/*P*/,
224 const double &, Vector_t &/*E*/, Vector_t &B) {
225 return getFieldValue(R, B);
226}
227
228std::vector<std::vector<double> > VerticalFFAMagnet::getDfCoefficients() const {
229 return dfCoefficients_m;
230}
231
232#endif
233
const std::string name
ParticlePos_t & R
ParticleAttrib< Vector_t > P
Interface for a single beam element.
Definition: Component.h:50
PartBunchBase< double, 3 > * RefPartBunch_m
Definition: Component.h:191
void setBBLength(double bbLength)
ElementBase * clone() const
endfieldmodel::EndFieldModel * getEndField() const
void accept(BeamlineVisitor &visitor) const
VerticalFFAMagnet & operator=(const VerticalFFAMagnet &rhs)
bool getFieldValue(const Vector_t &R, Vector_t &B) const
void setWidth(double width)
double getFieldIndex() const
size_t getMaxOrder() const
std::vector< std::vector< double > > getDfCoefficients() const
std::unique_ptr< endfieldmodel::EndFieldModel > endField_m
BGeometryBase & getGeometry()
BMultipoleField dummy
void setMaxOrder(size_t maxOrder)
std::vector< std::vector< double > > dfCoefficients_m
double getPositiveVerticalExtent() const
double getNegativeVerticalExtent() const
StraightGeometry straightGeometry_m
void setB0(double Bz)
double getBBLength() const
double getB0() const
VerticalFFAMagnet(const std::string &name)
void setNegativeVerticalExtent(double negativeExtent)
void setFieldIndex(double index)
void getDimensions(double &, double &) const
double getWidth() const
bool apply(const size_t &i, const double &t, Vector_t &E, Vector_t &B)
void setEndField(endfieldmodel::EndFieldModel *endField)
void setPositiveVerticalExtent(double positiveExtent)
Abstract base class for accelerator geometry classes.
Definition: Geometry.h:43
A geometry representing a straight line.
The magnetic field of a multipole.
Abstract base class for electromagnetic fields.
Definition: EMField.h:188