OPALX (Object Oriented Parallel Accelerator Library for Exascal) MINIorX
OPALX
VerticalFFAMagnet.h
Go to the documentation of this file.
1//
2// Header file for VerticalFFAMagnet Component
3//
4// Copyright (c) 2019 Chris Rogers
5// All rights reserved.
6//
7// OPAL is licensed under GNU GPL version 3.
8//
9
13#include "PartBunch/PartBunch.h"
14
15#ifndef ABSBEAMLINE_VerticalFFAMagnet_H
16#define ABSBEAMLINE_VerticalFFAMagnet_H
17
18namespace endfieldmodel {
19 class EndFieldModel;
20}
21
27
29public:
34 explicit VerticalFFAMagnet(const std::string& name);
35
38
40 ElementBase* clone() const;
41
51 inline bool apply(
52 const size_t& i, const double& t, Vector_t<double, 3>& E, Vector_t<double, 3>& B);
53
63 inline bool apply(
64 const Vector_t<double, 3>& R, const Vector_t<double, 3>& P, const double& t,
66
75
82 void initialise(PartBunch_t* bunch, double& startField, double& endField);
83
89 void initialise();
90
92 void finalise();
93
99 inline bool bends() const {
100 return false;
101 }
102
104 void getDimensions(double& /*zBegin*/, double& /*zEnd*/) const {
105 }
106
109
111 const BGeometryBase& getGeometry() const;
112
114 EMField& getField();
115
117 const EMField& getField() const;
118
120 void accept(BeamlineVisitor& visitor) const;
121
128 return endField_m.get();
129 }
130
137
140 size_t getMaxOrder() const {
141 return maxOrder_m;
142 }
143
146 void setMaxOrder(size_t maxOrder);
147
149 double getB0() const {
150 return Bz_m / Tesla;
151 }
152
154 void setB0(double Bz) {
155 Bz_m = Bz * Tesla;
156 }
157
159 double getFieldIndex() const {
160 return k_m * mm;
161 } // units are [m^{-1}]
162
164 void setFieldIndex(double index) {
165 k_m = index / mm;
166 }
167
170 return zNegExtent_m / mm;
171 }
172
174 inline void setNegativeVerticalExtent(double negativeExtent);
175
178 return zPosExtent_m / mm;
179 }
180
182 inline void setPositiveVerticalExtent(double positiveExtent);
183
185 double getBBLength() const {
186 return bbLength_m / mm;
187 }
188
190 void setBBLength(double bbLength) {
191 bbLength_m = bbLength * mm;
192 }
193
195 double getWidth() const {
196 return halfWidth_m / mm * 2.;
197 }
198
200 void setWidth(double width) {
201 halfWidth_m = width / 2 * mm;
202 }
203
214 inline std::vector<std::vector<double> > getDfCoefficients() const;
215
216private:
218
221
225
226 size_t maxOrder_m = 0;
227 double k_m = 0.;
228 double Bz_m = 0.;
229 double zNegExtent_m = 0.; // extent downwards from the midplane
230 double zPosExtent_m = 0.; // extent upwards from the midplane
231 double halfWidth_m = 0.; // extent in either +x or -x
232 double bbLength_m = 0.;
233 std::unique_ptr<endfieldmodel::EndFieldModel> endField_m;
234 std::vector<std::vector<double> > dfCoefficients_m;
235
236 const double mm = 1000.;
237 const double Tesla = 10.;
238};
239
241 zNegExtent_m = negativeExtent * mm;
242}
243
245 zPosExtent_m = positiveExtent * mm;
246}
247
249 const size_t& i, const double& t, Vector_t<double, 3>& E, Vector_t<double, 3>& B) {
250 std::shared_ptr<ParticleContainer_t> pc = RefPartBunch_m->getParticleContainer();
251 auto Rview = pc->R.getView();
252 auto Pview = pc->P.getView();
253 const Vector_t<double, 3> R = Rview(i);
254 const Vector_t<double, 3> P = Pview(i);
255 return apply(R, P, t, E, B);
256}
257
259 const Vector_t<double, 3>& R, const Vector_t<double, 3>& /*P*/, const double&,
261 return getFieldValue(R, B);
262}
263
264std::vector<std::vector<double> > VerticalFFAMagnet::getDfCoefficients() const {
265 return dfCoefficients_m;
266}
267
268#endif
PartBunch< PLayout_t< double, 3 >, double, 3 > PartBunch_t
ippl::Vector< T, Dim > Vector_t
Component(const std::string &name)
Constructor with given name.
Definition Component.cpp:44
PartBunch_t * RefPartBunch_m
Definition Component.h:185
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)
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
bool apply(const size_t &i, const double &t, Vector_t< double, 3 > &E, Vector_t< double, 3 > &B)
void setB0(double Bz)
double getBBLength() const
VerticalFFAMagnet(const std::string &name)
void setNegativeVerticalExtent(double negativeExtent)
void setFieldIndex(double index)
bool getFieldValue(const Vector_t< double, 3 > &R, Vector_t< double, 3 > &B) const
void getDimensions(double &, double &) const
double getWidth() const
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