OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
ScalingFFAMagnet.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2017, Chris Rogers
3 * All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * 1. Redistributions of source code must retain the above copyright notice,
7 * this list of conditions and the following disclaimer.
8 * 2. Redistributions in binary form must reproduce the above copyright notice,
9 * this list of conditions and the following disclaimer in the documentation
10 * and/or other materials provided with the distribution.
11 * 3. Neither the name of STFC nor the names of its contributors may be used to
12 * endorse or promote products derived from this software without specific
13 * prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 * POSSIBILITY OF SUCH DAMAGE.
26 */
27
32
33#ifndef ABSBEAMLINE_ScalingFFAMagnet_H
34#define ABSBEAMLINE_ScalingFFAMagnet_H
35
48 public:
53 explicit ScalingFFAMagnet(const std::string &name);
54
57
59 ScalingFFAMagnet* clone() const override;
60
70 bool apply(const size_t &i, const double &t, Vector_t &E, Vector_t &B) override;
71
81 bool apply(const Vector_t &R, const Vector_t &P, const double &t,
82 Vector_t &E, Vector_t &B) override;
83
91 bool getFieldValue(const Vector_t &R, Vector_t &B) const;
92
100 bool getFieldValueCylindrical(const Vector_t &R, Vector_t &B) const;
101
108 void initialise(PartBunchBase<double, 3> *bunch, double &startField, double &endField) override;
109
115 void initialise();
116
118 void finalise() override;
119
121 inline bool bends() const override;
122
124 void getDimensions(double &/*zBegin*/, double &/*zEnd*/) const override {}
125
127 BGeometryBase& getGeometry() override;
128
130 const BGeometryBase& getGeometry() const override;
131
133 EMField &getField() override;
134
136 const EMField &getField() const override;
137
139 void accept(BeamlineVisitor& visitor) const override;
140
142 double getTanDelta() const {return tanDelta_m;}
143
145 void setTanDelta(double tanDelta) {tanDelta_m = tanDelta;}
146
148 double getFieldIndex() const {return k_m;}
149
151 void setFieldIndex(double k) {k_m = k;}
152
154 double getDipoleConstant() const {return Bz_m;}
155
157 void setDipoleConstant(double Bz) {Bz_m = Bz;}
158
160 double getR0() const {return r0_m;}
161
163 void setR0(double r0) {r0_m = r0;}
164
166 Vector_t getCentre() const {return centre_m;}
167
169 void setCentre(Vector_t centre) {centre_m = centre;}
170
177
184
187 size_t getMaxOrder() const {return maxOrder_m;}
188
191 void setMaxOrder(size_t maxOrder) {maxOrder_m = maxOrder;}
192
195 double getPhiStart() const {return phiStart_m;}
196
199 void setPhiStart(double phiStart) {phiStart_m = phiStart;}
200
203 double getPhiEnd() const {return phiEnd_m;}
204
207 void setPhiEnd(double phiEnd) {phiEnd_m = phiEnd;}
208
211 double getRMin() const {return rMin_m;}
212
215 void setRMin(double rMin) {rMin_m = rMin;}
216
219 double getRMax() const {return rMax_m;}
220
223 void setRMax(double rMax) {rMax_m = rMax;}
224
227 double getAzimuthalExtent() const {return azimuthalExtent_m;}
228
231 void setAzimuthalExtent(double azimuthalExtent) {azimuthalExtent_m = azimuthalExtent;}
232
235 double getVerticalExtent() const {return verticalExtent_m;}
236
239 void setVerticalExtent(double verticalExtent) {verticalExtent_m = verticalExtent;}
240
242 std::vector<std::vector<double> > getDfCoefficients() {return dfCoefficients_m;}
243
252 void setupEndField();
253
260
262 std::string getEndFieldName() const {return endFieldName_m;}
263 private:
270
273
277
278 size_t maxOrder_m = 0;
279 double tanDelta_m = 0.;
280 double k_m = 0.;
281 double Bz_m = 0.;
282 double r0_m = 0.;
283 double rMin_m = 0.; // minimum radius
284 double rMax_m = 0.; // maximum radius
285 double phiStart_m = 0.; // offsets this element
286 double phiEnd_m = 0.; // used for placement of next element
287 double azimuthalExtent_m = 0.; // maximum distance used for field calculation
288 double verticalExtent_m = 0.; // maximum allowed distance from the midplane
291 std::string endFieldName_m = "";
292 const double fp_tolerance = 1e-18;
293 std::vector<std::vector<double> > dfCoefficients_m;
294};
295
296#endif
297
const std::string name
constexpr double e
The value of.
Definition: Physics.h:39
Interface for a single beam element.
Definition: Component.h:50
bool getFieldValue(const Vector_t &R, Vector_t &B) const
double getVerticalExtent() const
std::string endFieldName_m
bool apply(const size_t &i, const double &t, Vector_t &E, Vector_t &B) override
void accept(BeamlineVisitor &visitor) const override
void setAzimuthalExtent(double azimuthalExtent)
void setRMin(double rMin)
void finalise() override
void setCentre(Vector_t centre)
void setR0(double r0)
endfieldmodel::EndFieldModel * endField_m
double getDipoleConstant() const
void setVerticalExtent(double verticalExtent)
std::vector< std::vector< double > > getDfCoefficients()
ScalingFFAMagnet * clone() const override
ScalingFFAMagnet(const std::string &name)
void setTanDelta(double tanDelta)
double getAzimuthalExtent() const
std::string getEndFieldName() const
void setDipoleConstant(double Bz)
void getDimensions(double &, double &) const override
bool getFieldValueCylindrical(const Vector_t &R, Vector_t &B) const
void setPhiStart(double phiStart)
const double fp_tolerance
double getRMin() const
double getPhiEnd() const
EMField & getField() override
size_t getMaxOrder() const
Vector_t getCentre() const
void setEndField(endfieldmodel::EndFieldModel *endField)
void setMaxOrder(size_t maxOrder)
BMultipoleField dummy
double getFieldIndex() const
void setFieldIndex(double k)
void setRMax(double rMax)
void setEndFieldName(std::string name)
void setPhiEnd(double phiEnd)
endfieldmodel::EndFieldModel * getEndField() const
double getR0() const
double getRMax() const
std::vector< std::vector< double > > dfCoefficients_m
double getTanDelta() const
double getPhiStart() const
BGeometryBase & getGeometry() override
bool bends() const override
ScalingFFAMagnet & operator=(const ScalingFFAMagnet &rhs)
PlanarArcGeometry planarArcGeometry_m
Abstract base class for accelerator geometry classes.
Definition: Geometry.h:43
A simple arc in the XZ plane.
The magnetic field of a multipole.
Abstract base class for electromagnetic fields.
Definition: EMField.h:188