OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
BendBase.h
Go to the documentation of this file.
1#ifndef OPALX_BendBase_HH
2#define OPALX_BendBase_HH
3
6
7#include <cstddef>
8#include <string>
9#include <vector>
10
32class BendBase : public Component {
33public:
34 BendBase();
35 explicit BendBase(const std::string& name);
36 BendBase(const BendBase&);
37 ~BendBase() override;
38
39 bool bends() const override;
40
41 void initialise(PartBunch_t* bunch, double& startField, double& endField) override;
42 void finalise() override;
43
44 bool apply(const std::shared_ptr<ParticleContainer_t>& pc) override;
45 bool apply(const size_t& i, const double& t, Vector_t<double, 3>& E, Vector_t<double, 3>& B)
46 override;
47 bool apply(
48 const Vector_t<double, 3>& R, const Vector_t<double, 3>& P, const double& t,
51 const Vector_t<double, 3>& R, const Vector_t<double, 3>& P, const double& t,
53
54 void getFieldExtend(double& zBegin, double& zEnd) const override;
55 bool isInside(const Vector_t<double, 3>& r) const override;
56
58 CoordinateSystemTrafo getEdgeToEnd() const override;
59
67 void setLength(double length);
68 double getLength() const;
69
76 double getChordLength() const;
77
78 virtual void setBendAngle(double angle);
79 double getBendAngle() const;
80
81 virtual void setEntranceAngle(double entranceAngle);
82 double getEntranceAngle() const;
83
84 virtual void setExitAngle(double exitAngle);
85 virtual double getExitAngle() const = 0;
86
87 void setFullGap(double gap);
88 double getFullGap() const;
89
90 void setDesignEnergy(const double& energy, bool changeable = true) override;
91 double getDesignEnergy() const override;
92
100 std::vector<Vector_t<double, 3>> getDesignPath(std::size_t minSamples = 32) const;
101
111 void setFieldAmplitude(double k0, double k0s);
112 double getFieldAmplitude() const;
113
114 void setFieldMapFN(std::string fileName);
115 std::string getFieldMapFN() const;
116
117 double getB() const;
118 void setB(double B);
119
120 void setEntryFaceRotation(double rotation);
121 double getEntryFaceRotation() const;
122
123 void setExitFaceRotation(double rotation);
124 double getExitFaceRotation() const;
125
126 void setEntryFaceCurvature(double curvature);
127 double getEntryFaceCurvature() const;
128
129 void setExitFaceCurvature(double curvature);
130 double getExitFaceCurvature() const;
131
132 void setSlices(double slices);
133 double getSlices() const;
134
135 void setStepsize(double stepSize);
136 double getStepsize() const;
137
138 void setNSlices(const std::size_t& nSlices);
139 std::size_t getNSlices() const;
140
141 void setK1(double k1);
142 double getK1() const;
143
144 int getRequiredNumberOfTimeSteps() const override;
145
146 virtual BMultipoleField& getField() override = 0;
147 virtual const BMultipoleField& getField() const override = 0;
148
149protected:
150 double calcDesignRadius(double fieldAmplitude) const;
151 double calcFieldAmplitude(double radius) const;
152 double calcBendAngle(double chordLength, double radius) const;
153 double calcDesignRadius(double chordLength, double angle) const;
154 double calcGamma() const;
155 double calcBetaGamma() const;
156 double getStoredExitAngle() const;
157
158private:
159 static void computeFieldHost(
160 const Vector_t<double, 3>& R, const BMultipoleField& field, Vector_t<double, 3>& B);
161
164 double angle_m;
167 double gap_m;
173 std::string fileName_m;
178 double slices_m;
180 std::size_t nSlices_m;
181 double k1_m;
182};
183
184inline bool BendBase::bends() const { return true; }
185
186inline void BendBase::setLength(double length) { setElementLength(std::abs(length)); }
187
188inline double BendBase::getLength() const { return getElementLength(); }
189
190inline void BendBase::setBendAngle(double angle) { angle_m = angle; }
191
192inline double BendBase::getBendAngle() const { return angle_m; }
193
194inline void BendBase::setEntranceAngle(double entranceAngle) { entranceAngle_m = entranceAngle; }
195
196inline double BendBase::getEntranceAngle() const { return entranceAngle_m; }
197
198inline void BendBase::setExitAngle(double exitAngle) { exitAngle_m = exitAngle; }
199
200inline void BendBase::setFullGap(double gap) { gap_m = std::abs(gap); }
201
202inline double BendBase::getFullGap() const { return gap_m; }
203
204inline void BendBase::setDesignEnergy(const double& energy, bool changeable) {
206 designEnergy_m = std::abs(energy) * 1e6;
207 designEnergyChangeable_m = changeable;
208 }
209}
210
211inline double BendBase::getDesignEnergy() const { return designEnergy_m; }
212
213inline void BendBase::setFieldAmplitude(double k0, double k0s) {
215 fieldAmplitudeX_m = k0s;
216 fieldAmplitude_m = std::hypot(k0, k0s);
217}
218
219inline double BendBase::getFieldAmplitude() const { return fieldAmplitude_m; }
220
221inline void BendBase::setFieldMapFN(std::string fileName) { fileName_m = std::move(fileName); }
222
223inline std::string BendBase::getFieldMapFN() const { return fileName_m; }
224
225inline double BendBase::getB() const { return getField().getNormalComponent(0); }
226
227inline void BendBase::setB(double B) { getField().setNormalComponent(0, B); }
228
229inline void BendBase::setEntryFaceRotation(double rotation) { entryFaceRotation_m = rotation; }
230
232
233inline void BendBase::setExitFaceRotation(double rotation) { exitFaceRotation_m = rotation; }
234
235inline double BendBase::getExitFaceRotation() const { return exitFaceRotation_m; }
236
237inline void BendBase::setEntryFaceCurvature(double curvature) { entryFaceCurvature_m = curvature; }
238
240
241inline void BendBase::setExitFaceCurvature(double curvature) { exitFaceCurvature_m = curvature; }
242
244
245inline void BendBase::setSlices(double slices) { slices_m = slices; }
246
247inline double BendBase::getSlices() const { return slices_m; }
248
249inline void BendBase::setStepsize(double stepSize) { stepSize_m = stepSize; }
250
251inline double BendBase::getStepsize() const { return stepSize_m; }
252
253inline void BendBase::setNSlices(const std::size_t& nSlices) { nSlices_m = nSlices; }
254
255inline std::size_t BendBase::getNSlices() const { return nSlices_m; }
256
257inline void BendBase::setK1(double k1) { k1_m = k1; }
258
259inline double BendBase::getK1() const { return k1_m; }
260
261inline int BendBase::getRequiredNumberOfTimeSteps() const { return 10; }
262
263inline double BendBase::getStoredExitAngle() const { return exitAngle_m; }
264
265#endif // OPALX_BendBase_HH
Defines the abstract interface for a single beamline component in the accelerator model.
ippl::Vector< T, Dim > Vector_t
The magnetic field of a multipole.
double getNormalComponent(int n) const
Get component.
void setNormalComponent(int n, double Bn)
Set component.
Common OPALX interface for analytic horizontal bending magnets.
Definition BendBase.h:32
double endField_m
Definition BendBase.h:163
bool apply(const std::shared_ptr< ParticleContainer_t > &pc) override
Apply to all particles. Kernel launch moved inside the function.
Definition BendBase.cpp:92
double calcGamma() const
Definition BendBase.cpp:264
virtual BMultipoleField & getField() override=0
Return field.
double getEntryFaceCurvature() const
Definition BendBase.h:239
double startField_m
Definition BendBase.h:162
std::vector< Vector_t< double, 3 > > getDesignPath(std::size_t minSamples=32) const
Sample the local curved reference path of the bend body.
Definition BendBase.cpp:220
virtual const BMultipoleField & getField() const override=0
Return field.
std::size_t getNSlices() const
Definition BendBase.h:255
void setFieldMapFN(std::string fileName)
Definition BendBase.h:221
double calcBendAngle(double chordLength, double radius) const
Definition BendBase.cpp:256
void setB(double B)
Definition BendBase.h:227
void setExitFaceCurvature(double curvature)
Definition BendBase.h:241
void setLength(double length)
Set the nominal body length.
Definition BendBase.h:186
double fieldAmplitude_m
Definition BendBase.h:172
bool applyToReferenceParticle(const Vector_t< double, 3 > &R, const Vector_t< double, 3 > &P, const double &t, Vector_t< double, 3 > &E, Vector_t< double, 3 > &B) override
Apply to reference particle with position R and momemtum P.
Definition BendBase.cpp:179
double calcBetaGamma() const
Definition BendBase.cpp:270
double exitFaceRotation_m
Definition BendBase.h:175
double getChordLength() const
Return the geometric chord between entrance and exit frames.
Definition BendBase.cpp:211
double getEntryFaceRotation() const
Definition BendBase.h:231
double designEnergy_m
Definition BendBase.h:168
virtual void setExitAngle(double exitAngle)
Definition BendBase.h:198
void finalise() override
Definition BendBase.cpp:90
virtual void setEntranceAngle(double entranceAngle)
Definition BendBase.h:194
double entryFaceRotation_m
Definition BendBase.h:174
double entranceAngle_m
Definition BendBase.h:165
double getBendAngle() const
Definition BendBase.h:192
double getFieldAmplitude() const
Definition BendBase.h:219
double getDesignEnergy() const override
Definition BendBase.h:211
void setK1(double k1)
Definition BendBase.h:257
CoordinateSystemTrafo getEdgeToBegin() const override
Definition BendBase.cpp:203
double exitAngle_m
Definition BendBase.h:166
double getExitFaceRotation() const
Definition BendBase.h:235
double stepSize_m
Definition BendBase.h:179
double gap_m
Definition BendBase.h:167
double k1_m
Definition BendBase.h:181
double entryFaceCurvature_m
Definition BendBase.h:176
double fieldAmplitudeY_m
Definition BendBase.h:171
void initialise(PartBunch_t *bunch, double &startField, double &endField) override
Definition BendBase.cpp:82
CoordinateSystemTrafo getEdgeToEnd() const override
Definition BendBase.cpp:207
virtual double getExitAngle() const =0
virtual void setBendAngle(double angle)
Definition BendBase.h:190
double exitFaceCurvature_m
Definition BendBase.h:177
~BendBase() override
void setFullGap(double gap)
Definition BendBase.h:200
double getB() const
Definition BendBase.h:225
void setSlices(double slices)
Definition BendBase.h:245
void setExitFaceRotation(double rotation)
Definition BendBase.h:233
void setDesignEnergy(const double &energy, bool changeable=true) override
Definition BendBase.h:204
std::string fileName_m
Definition BendBase.h:173
double getStepsize() const
Definition BendBase.h:251
double getExitFaceCurvature() const
Definition BendBase.h:243
double getK1() const
Definition BendBase.h:259
double getSlices() const
Definition BendBase.h:247
std::size_t nSlices_m
Definition BendBase.h:180
double getEntranceAngle() const
Definition BendBase.h:196
void setEntryFaceCurvature(double curvature)
Definition BendBase.h:237
bool designEnergyChangeable_m
Definition BendBase.h:169
void setStepsize(double stepSize)
Definition BendBase.h:249
void getFieldExtend(double &zBegin, double &zEnd) const override
Return the field-support extent of the component.
Definition BendBase.cpp:194
void setNSlices(const std::size_t &nSlices)
Definition BendBase.h:253
double calcFieldAmplitude(double radius) const
Definition BendBase.cpp:248
int getRequiredNumberOfTimeSteps() const override
Definition BendBase.h:261
double calcDesignRadius(double fieldAmplitude) const
Definition BendBase.cpp:240
double getStoredExitAngle() const
Definition BendBase.h:263
void setFieldAmplitude(double k0, double k0s)
Store the dipole design amplitudes used by the analytic field.
Definition BendBase.h:213
static void computeFieldHost(const Vector_t< double, 3 > &R, const BMultipoleField &field, Vector_t< double, 3 > &B)
Definition BendBase.cpp:275
double slices_m
Definition BendBase.h:178
double getLength() const
Definition BendBase.h:188
std::string getFieldMapFN() const
Definition BendBase.h:223
bool bends() const override
Definition BendBase.h:184
double fieldAmplitudeX_m
Definition BendBase.h:170
void setEntryFaceRotation(double rotation)
Definition BendBase.h:229
double getFullGap() const
Definition BendBase.h:202
double angle_m
Definition BendBase.h:164
bool isInside(const Vector_t< double, 3 > &r) const override
Definition BendBase.cpp:199
Rigid spatial transform between a parent frame and a local frame.
virtual double getElementLength() const
Get design length.
virtual void setElementLength(double length)
Set design length.