OPALX (Object Oriented Parallel Accelerator Library for Exascale) MINIorX
OPALX
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<double, 3> &E, Vector_t<double, 3> &B) override;
71
81 bool apply(const Vector_t<double, 3> &R, const Vector_t<double, 3> &P, const double &t,
83
92
101
108 void initialise(PartBunch_t *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
167
169 void setCentre(Vector_t<double, 3> 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
259 void setEndFieldName(std::string name) {endFieldName_m = name;}
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
constexpr double e
The value of.
Definition: Physics.h:39
Interface for a single beam element.
Definition: Component.h:50
Sector bending magnet with an FFA-style field index and spiral end shape.
double getVerticalExtent() const
Get the maximum vertical displacement from the midplane.
std::string endFieldName_m
void setupEndField()
setupEndField does some end field and geometry set-up
void accept(BeamlineVisitor &visitor) const override
Accept a beamline visitor.
void setAzimuthalExtent(double azimuthalExtent)
Set the maximum azimuthal displacement from \psi=0.
void setRMin(double rMin)
Set the maximum radius.
void finalise() override
Finalise the ScalingFFAMagnet - sets bunch to nullptr.
void setR0(double r0)
Set the radius constant R_0.
void setCentre(Vector_t< double, 3 > centre)
Set the centre of the sector.
endfieldmodel::EndFieldModel * endField_m
double getDipoleConstant() const
Get the dipole constant B_0.
void setVerticalExtent(double verticalExtent)
Set the maximum vertical displacement from the midplane.
Vector_t< double, 3 > getCentre() const
Get the centre of the sector.
void initialise()
Initialise the ScalingFFAMagnet.
std::vector< std::vector< double > > getDfCoefficients()
Return the calculated df coefficients.
ScalingFFAMagnet * clone() const override
Inheritable copy constructor.
ScalingFFAMagnet(const std::string &name)
Construct a new ScalingFFAMagnet.
void setTanDelta(double tanDelta)
Set tan delta - delta is the spiral angle.
double getAzimuthalExtent() const
Get the maximum azimuthal displacement from \psi=0.
std::string getEndFieldName() const
Return the end field name.
void setDipoleConstant(double Bz)
Set the dipole constant B_0.
void getDimensions(double &, double &) const override
Not implemented.
void calculateDfCoefficients()
Calculate the df coefficients, ready for field generation.
void setPhiStart(double phiStart)
Set the offset of the magnet centre from the start.
const double fp_tolerance
double getRMin() const
Get the maximum radius.
double getPhiEnd() const
Get the offset of the magnet end from the start.
EMField & getField() override
Return a dummy (0.) field value (what is this for?)
size_t getMaxOrder() const
Get the maximum power of y modelled in the off-midplane expansion;.
~ScalingFFAMagnet()
Destructor - deletes map.
void setEndField(endfieldmodel::EndFieldModel *endField)
Set the fringe field.
void setMaxOrder(size_t maxOrder)
Set the maximum power of y modelled in the off-midplane expansion;.
bool apply(const size_t &i, const double &t, Vector_t< double, 3 > &E, Vector_t< double, 3 > &B) override
Calculate the field at the position of the ith particle.
BMultipoleField dummy
double getFieldIndex() const
Get the field index k.
void setFieldIndex(double k)
Set the field index k.
void setRMax(double rMax)
Set the maximum radius.
void setEndFieldName(std::string name)
Set the end field name.
void setPhiEnd(double phiEnd)
Set the offset of the magnet end from the start.
bool getFieldValue(const Vector_t< double, 3 > &R, Vector_t< double, 3 > &B) const
Calculate the field at some arbitrary position in cartesian coordinates.
endfieldmodel::EndFieldModel * getEndField() const
Get the fringe field.
Vector_t< double, 3 > centre_m
double getR0() const
Get the radius constant R_0.
double getRMax() const
Get the maximum radius.
std::vector< std::vector< double > > dfCoefficients_m
double getTanDelta() const
Get tan delta - delta is the spiral angle.
bool getFieldValueCylindrical(const Vector_t< double, 3 > &R, Vector_t< double, 3 > &B) const
Calculate the field at some arbitrary position in cylindrical coordinates.
double getPhiStart() const
Get the offset of the magnet centre from the start.
BGeometryBase & getGeometry() override
Return the cell geometry.
bool bends() const override
Return true - ScalingFFAMagnet always bends the reference particle.
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