OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
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 
28 #include "Fields/BMultipoleField.h"
31 #include "AbsBeamline/Component.h"
32 
33 #ifndef ABSBEAMLINE_ScalingFFAMagnet_H
34 #define ABSBEAMLINE_ScalingFFAMagnet_H
35 
39 class ScalingFFAMagnet : public Component {
40  public:
45  explicit ScalingFFAMagnet(const std::string &name);
46 
49 
51  ElementBase* clone() const override;
52 
62  bool apply(const size_t &i, const double &t, Vector_t &E, Vector_t &B) override;
63 
73  bool apply(const Vector_t &R, const Vector_t &P, const double &t,
74  Vector_t &E, Vector_t &B) override;
75 
83  bool getFieldValue(const Vector_t &R, Vector_t &B) const;
84 
92  bool getFieldValueCylindrical(const Vector_t &R, Vector_t &B) const;
93 
100  void initialise(PartBunchBase<double, 3> *bunch, double &startField, double &endField) override;
101 
107  void initialise();
108 
110  void finalise() override;
111 
113  inline bool bends() const override;
114 
116  void getDimensions(double &zBegin, double &zEnd) const override {}
117 
119  BGeometryBase& getGeometry() override;
120 
122  const BGeometryBase& getGeometry() const override;
123 
125  EMField &getField() override;
126 
128  const EMField &getField() const override;
129 
131  void accept(BeamlineVisitor& visitor) const override;
132 
134  double getTanDelta() const {return tanDelta_m;}
135 
137  void setTanDelta(double tanDelta) {tanDelta_m = tanDelta;}
138 
140  double getFieldIndex() const {return k_m;}
141 
143  void setFieldIndex(double k) {k_m = k;}
144 
146  double getDipoleConstant() const {return Bz_m;}
147 
149  void setDipoleConstant(double Bz) {Bz_m = Bz;}
150 
152  double getR0() const {return r0_m;}
153 
155  void setR0(double r0) {r0_m = r0;}
156 
158  Vector_t getCentre() const {return centre_m;}
159 
161  void setCentre(Vector_t centre) {centre_m = centre;}
162 
169 
176 
179  size_t getMaxOrder() const {return maxOrder_m;}
180 
183  void setMaxOrder(size_t maxOrder) {maxOrder_m = maxOrder;}
184 
187  double getPhiStart() const {return phiStart_m;}
188 
191  void setPhiStart(double phiStart) {phiStart_m = phiStart;}
192 
195  double getPhiEnd() const {return phiEnd_m;}
196 
199  void setPhiEnd(double phiEnd) {phiEnd_m = phiEnd;}
200 
203  double getRMin() const {return rMin_m;}
204 
207  void setRMin(double rMin) {rMin_m = rMin;}
208 
211  double getRMax() const {return rMax_m;}
212 
215  void setRMax(double rMax) {rMax_m = rMax;}
216 
219  double getAzimuthalExtent() const {return azimuthalExtent_m;}
220 
223  void setAzimuthalExtent(double azimuthalExtent) {azimuthalExtent_m = azimuthalExtent;}
224 
227  double getVerticalExtent() const {return verticalExtent_m;}
228 
231  void setVerticalExtent(double verticalExtent) {verticalExtent_m = verticalExtent;}
232 
234  std::vector<std::vector<double> > getDfCoefficients() {return dfCoefficients_m;}
235 
236  private:
243 
245  ScalingFFAMagnet(const ScalingFFAMagnet &right);
246 
250 
251  size_t maxOrder_m = 0;
252  double tanDelta_m = 0.;
253  double k_m = 0.;
254  double Bz_m = 0.;
255  double r0_m = 0.;
256  double rMin_m = 0.; // minimum radius
257  double rMax_m = 0.; // maximum radius
258  double phiStart_m = 0.; // offsets this element
259  double phiEnd_m = 0.; // used for placement of next element
260  double azimuthalExtent_m = 0.; // maximum distance used for field calculation
261  double verticalExtent_m = 0.; // maximum allowed distance from the midplane
264  const double fp_tolerance = 1e-18;
265  std::vector<std::vector<double> > dfCoefficients_m;
266 };
267 
268 #endif
269 
double getRMax() const
double getPhiStart() const
void setMaxOrder(size_t maxOrder)
constexpr double e
The value of .
Definition: Physics.h:40
Interface for basic beam line object.
Definition: ElementBase.h:128
void setPhiStart(double phiStart)
void setEndField(endfieldmodel::EndFieldModel *endField)
bool getFieldValueCylindrical(const Vector_t &R, Vector_t &B) const
void setFieldIndex(double k)
const double fp_tolerance
A simple arc in the XZ plane.
bool bends() const override
PlanarArcGeometry planarArcGeometry_m
void accept(BeamlineVisitor &visitor) const override
double getTanDelta() const
double getRMin() const
endfieldmodel::EndFieldModel * getEndField() const
void setRMax(double rMax)
ScalingFFAMagnet(const std::string &name)
size_t getMaxOrder() const
double getVerticalExtent() const
Abstract base class for accelerator geometry classes.
Definition: Geometry.h:43
std::vector< std::vector< double > > dfCoefficients_m
std::vector< std::vector< double > > getDfCoefficients()
void setPhiEnd(double phiEnd)
void setTanDelta(double tanDelta)
void setRMin(double rMin)
void setAzimuthalExtent(double azimuthalExtent)
Abstract base class for electromagnetic fields.
Definition: EMField.h:188
ScalingFFAMagnet & operator=(const ScalingFFAMagnet &rhs)
EMField & getField() override
The magnetic field of a multipole.
bool apply(const size_t &i, const double &t, Vector_t &E, Vector_t &B) override
void getDimensions(double &zBegin, double &zEnd) const override
BGeometryBase & getGeometry() override
const std::string name
double getPhiEnd() const
bool getFieldValue(const Vector_t &R, Vector_t &B) const
Vector_t getCentre() const
endfieldmodel::EndFieldModel * endField_m
void setCentre(Vector_t centre)
double getR0() const
Interface for a single beam element.
Definition: Component.h:51
Abstract algorithm.
double getFieldIndex() const
void finalise() override
void setR0(double r0)
double getAzimuthalExtent() const
double getDipoleConstant() const
void setDipoleConstant(double Bz)
ElementBase * clone() const override
BMultipoleField dummy
void setVerticalExtent(double verticalExtent)