OPAL (Object Oriented Parallel Accelerator Library) 2024.2
OPAL
VerticalFFAMagnet.h
Go to the documentation of this file.
1//
2// Class VerticalFFAMagnet
3// Defines the abstract interface for a vertical FFA magnet
4// with vertical scaling fringe fields.
5//
6// Copyright (c) 2019 - 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_VerticalFFAMagnet_H
20#define ABSBEAMLINE_VerticalFFAMagnet_H
21
26#include "Physics/Units.h"
27
28namespace endfieldmodel {
29 class EndFieldModel;
30}
31
37
39
40public:
45 explicit VerticalFFAMagnet(const std::string& name);
46
49
51 ElementBase* clone() const;
52
62 inline bool apply(const size_t& i, const double& t, Vector_t& E, Vector_t& B);
63
73 inline bool apply(const Vector_t& R, const Vector_t& P,
74 const double& t,Vector_t& E, Vector_t& B);
75
83 bool getFieldValue(const Vector_t& R, Vector_t& B) const;
84
91 void initialise(PartBunchBase<double, 3>* bunch, double& startField, double& endField);
92
98 void initialise();
99
101 void finalise();
102
108 inline bool bends() const {return false;}
109
111 void getDimensions(double& /*zBegin*/, double& /*zEnd*/) const {}
112
115
117 const BGeometryBase& getGeometry() const;
118
120 EMField& getField();
121
123 const EMField& getField() const;
124
126 void accept(BeamlineVisitor& visitor) const;
127
134
141
144 size_t getMaxOrder() const {return maxOrder_m;}
145
148 void setMaxOrder(size_t maxOrder);
149
151 double getB0() const {return Bz_m * Units::kG2T;}
152
154 void setB0(double Bz) {Bz_m = Bz * Units::T2kG;}
155
157 double getFieldIndex() const {return k_m;} // units are [m^{-1}]
158
160 void setFieldIndex(double index) {k_m = index;}
161
164
166 inline void setNegativeVerticalExtent(double negativeExtent);
167
170
172 inline void setPositiveVerticalExtent(double positiveExtent);
173
175 double getBBLength() const {return bbLength_m;}
176
178 void setBBLength(double bbLength) {bbLength_m = bbLength;}
179
181 double getWidth() const {return halfWidth_m * 2.;}
182
184 void setWidth(double width) {halfWidth_m = width / 2;}
185
196 inline std::vector<std::vector<double> > getDfCoefficients() const;
197
198private:
200
203
207
208 size_t maxOrder_m = 0;
209 double k_m = 0.;
210 double Bz_m = 0.;
211 double zNegExtent_m = 0.; // extent downwards from the midplane
212 double zPosExtent_m = 0.; // extent upwards from the midplane
213 double halfWidth_m = 0.; // extent in either +x or -x
214 double bbLength_m = 0.;
215 std::unique_ptr<endfieldmodel::EndFieldModel> endField_m;
216 std::vector<std::vector<double> > dfCoefficients_m;
217};
218
220 zNegExtent_m = negativeExtent;
221}
222
224 zPosExtent_m = positiveExtent;
225}
226
227bool VerticalFFAMagnet::apply(const size_t& i, const double& t,
228 Vector_t& E, Vector_t& B) {
229 return apply(RefPartBunch_m->R[i], RefPartBunch_m->P[i], t, E, B);
230}
231
232bool VerticalFFAMagnet::apply(const Vector_t& R, const Vector_t& /*P*/,
233 const double& , Vector_t& /*E*/, Vector_t& B) {
234 return getFieldValue(R, B);
235}
236
237std::vector<std::vector<double> > VerticalFFAMagnet::getDfCoefficients() const {
238 return dfCoefficients_m;
239}
240
241#endif
const std::string name
constexpr double T2kG
Definition Units.h:56
constexpr double kG2T
Definition Units.h:59
Component(const std::string &name)
Constructor with given name.
Definition Component.cpp:53
PartBunchBase< double, 3 > * RefPartBunch_m
Definition Component.h:191
ElementBase(const std::string &name)
Constructor with given name.
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
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
Vektor< double, 3 > Vector_t