OPAL (Object Oriented Parallel Accelerator Library) 2024.2
OPAL
ScalingFFAMagnet.h
Go to the documentation of this file.
1//
2// Class ScalingFFAMagnet
3// Defines the abstract interface for a sector FFA magnet
4// with radially scaling fringe fields.
5//
6// Copyright (c) 2017 - 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 ABSBEAMLINE_ScalingFFAMagnet_H
20#define ABSBEAMLINE_ScalingFFAMagnet_H
21
27
28#include <cmath>
29
40
42
43public:
48 explicit ScalingFFAMagnet(const std::string& name);
49
52
54 ScalingFFAMagnet* clone() const override;
55
65 inline bool apply(const size_t& i, const double& t,
66 Vector_t& E, Vector_t& B) override;
67
77 inline bool apply(const Vector_t& R, const Vector_t& P, const double& t,
78 Vector_t& E, Vector_t& B) override;
79
87 bool getFieldValue(const Vector_t& R, Vector_t& B) const;
88
96 bool getFieldValueCylindrical(const Vector_t& R, Vector_t& B) const;
97
104 void initialise(PartBunchBase<double, 3>* bunch, double& startField, double& endField) override;
105
111 void initialise();
112
114 void finalise() override;
115
117 inline bool bends() const override;
118
120 void getDimensions(double& /*zBegin*/, double& /*zEnd*/) const override {}
121
123 BGeometryBase& getGeometry() override;
124
126 const BGeometryBase& getGeometry() const override;
127
129 EMField& getField() override;
130
132 const EMField& getField() const override;
133
135 void accept(BeamlineVisitor& visitor) const override;
136
138 double getTanDelta() const {return tanDelta_m;}
139
141 void setTanDelta(double tanDelta) {tanDelta_m = tanDelta;}
142
144 double getFieldIndex() const {return k_m;}
145
147 void setFieldIndex(double k) {k_m = k;}
148
150 double getDipoleConstant() const {return Bz_m;}
151
153 void setDipoleConstant(double Bz) {Bz_m = Bz;}
154
156 double getR0() const {return r0_m;}
157
159 void setR0(double r0) {r0_m = r0; r0Sign_m = r0_m / std::abs(r0_m);}
160
162 Vector_t getCentre() const {return centre_m;}
163
165 void setCentre(Vector_t centre) {centre_m = centre;}
166
173
180
183 size_t getMaxOrder() const {return maxOrder_m;}
184
187 void setMaxOrder(size_t maxOrder) {maxOrder_m = maxOrder;}
188
191 double getPhiStart() const {return phiStart_m;}
192
195 void setPhiStart(double phiStart) {phiStart_m = phiStart;}
196
199 double getPhiEnd() const {return phiEnd_m;}
200
203 void setPhiEnd(double phiEnd) {phiEnd_m = phiEnd;}
204
207 double getRMin() const {return rMin_m;}
208
211 void setRMin(double rMin) {rMin_m = rMin;}
212
215 double getRMax() const {return rMax_m;}
216
219 void setRMax(double rMax) {rMax_m = rMax;}
220
223 double getAzimuthalExtent() const {return azimuthalExtent_m;}
224
227 void setAzimuthalExtent(double azimuthalExtent) {azimuthalExtent_m = azimuthalExtent;}
228
231 double getVerticalExtent() const {return verticalExtent_m;}
232
235 void setVerticalExtent(double verticalExtent) {verticalExtent_m = verticalExtent;}
236
238 std::vector<std::vector<double> > getDfCoefficients() {return dfCoefficients_m;}
239
248 void setupEndField();
249
256
258 std::string getEndFieldName() const {return endFieldName_m;}
259
260
261private:
268
271
275
276 size_t maxOrder_m = 0; // maximum order used in the calculation
277 double tanDelta_m = 0.; // tan(spiral angle)
278 double k_m = 0.; // field index
279 double Bz_m = 0.; // nominal field on the radius
280 double r0_m = 0.; // radius; negative for clockwise geometry, else positive
281 double rMin_m = 0.; // minimum radius
282 double rMax_m = 0.; // maximum radius
283 double phiStart_m = 0.; // offsets this element
284 double phiEnd_m = 0.; // used for placement of next element
285 double azimuthalExtent_m = 0.; // maximum distance used for field calculation
286 double verticalExtent_m = 0.; // maximum allowed distance from the midplane
287 double r0Sign_m = 0.0; // -1 for clockwise geometry, else +1
288 Vector_t centre_m; // nominal ring centre
290 std::string endFieldName_m = "";
291 const double fp_tolerance = 1e-18;
292 std::vector<std::vector<double> > dfCoefficients_m;
293};
294
295bool ScalingFFAMagnet::apply(const Vector_t& R, const Vector_t& /*P*/,
296 const double& /*t*/, Vector_t& /*E*/, Vector_t& B) {
297 return getFieldValue(R, B);
298}
299
300bool ScalingFFAMagnet::apply(const size_t& i, const double& t,
301 Vector_t& E, Vector_t& B) {
302 return apply(RefPartBunch_m->R[i], RefPartBunch_m->P[i], t, E, B);
303}
304
305#endif
const std::string name
Component(const std::string &name)
Constructor with given name.
Definition Component.cpp:53
PartBunchBase< double, 3 > * RefPartBunch_m
Definition Component.h:191
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
Vektor< double, 3 > Vector_t