OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
BendBase.cpp
Go to the documentation of this file.
2
4
5#include <cmath>
6
8 BendBase("")
9{}
10
12 Component(right),
13 chordLength_m(right.chordLength_m),
14 angle_m(right.angle_m),
15 entranceAngle_m(right.entranceAngle_m),
16 fieldmap_m(right.fieldmap_m),
17 gap_m(right.gap_m),
18 designEnergy_m(right.designEnergy_m),
19 designEnergyChangeable_m(true),
20 refTrajMap_m(right.refTrajMap_m),
21 fieldAmplitudeX_m(right.fieldAmplitudeX_m),
22 fieldAmplitudeY_m(right.fieldAmplitudeY_m),
23 fieldAmplitude_m(right.fieldAmplitude_m),
24 fileName_m(right.fileName_m)
25{}
26
27BendBase::BendBase(const std::string &name):
29 chordLength_m(0.0),
30 angle_m(0.0),
31 entranceAngle_m(0.0),
32 fieldmap_m(nullptr),
33 gap_m(0.0),
34 designEnergy_m(0.0),
35 designEnergyChangeable_m(true),
36 fieldAmplitudeX_m(0.0),
37 fieldAmplitudeY_m(0.0),
38 fieldAmplitude_m(0.0),
39 fileName_m("")
40{}
41
42
43std::vector<Vector_t> BendBase::getDesignPath() const {
44 unsigned int size = refTrajMap_m.size();
45 std::vector<Vector_t> designPath(size);
46 // double angleZ = getRotationAboutZ();
47 // Quaternion rotationAboutZ(cos(angleZ / 2), sin(angleZ / 2) * Vector_t(0, 0, 1));
48 for (unsigned int i = 0; i < size; ++ i) {
49 Vector_t currentPosition = refTrajMap_m[i];
50 designPath[i] = currentPosition;//rotationAboutZ.rotate(currentPosition);
51 }
52
53 return designPath;
54}
55
56void BendBase::setFieldAmplitude(double k0, double k0s) {
59}
60
61double BendBase::calcDesignRadius(double fieldAmplitude) const
62{
63 double mass = RefPartBunch_m->getM();
64 double betaGamma = calcBetaGamma();
65 double charge = RefPartBunch_m->getQ();
66 // Lorentz force: condition for a circular orbit
67 return std::abs(betaGamma * mass / (Physics::c * fieldAmplitude * charge));
68}
69
70double BendBase::calcFieldAmplitude(double radius) const
71{
72 double mass = RefPartBunch_m->getM();
73 double betaGamma = calcBetaGamma();
74 double charge = RefPartBunch_m->getQ();
75 // Lorentz force: condition for a circular orbit
76 return betaGamma * mass / (Physics::c * radius * charge);
77}
78
79double BendBase::calcBendAngle(double chordLength, double radius) const
80{
81 return 2.0 * std::asin(chordLength / (2.0 * radius));
82}
83
84double BendBase::calcDesignRadius(double chordLength, double angle) const
85{
86 return chordLength / (2.0 * std::sin(angle / 2.0));
87}
88
89double BendBase::calcGamma() const
90{
91 double mass = RefPartBunch_m->getM();
92 return designEnergy_m / mass + 1.0;
93}
94
96{
97 double gamma = calcGamma();
98 return std::sqrt(std::pow(gamma, 2.0) - 1.0);
99}
Tps< T > pow(const Tps< T > &x, int y)
Integer power.
Definition: TpsMath.h:76
Tps< T > sin(const Tps< T > &x)
Sine.
Definition: TpsMath.h:111
Tps< T > sqrt(const Tps< T > &x)
Square root.
Definition: TpsMath.h:91
PETE_TUTree< FnArcSin, typename T::PETE_Expr_t > asin(const PETE_Expr< T > &l)
Definition: PETE.h:726
PETE_TUTree< FnAbs, typename T::PETE_Expr_t > abs(const PETE_Expr< T > &l)
const std::string name
constexpr double c
The velocity of light in m/s.
Definition: Physics.h:45
double getQ() const
Access to reference data.
double getM() const
double calcGamma() const
Calculate gamma from design energy.
Definition: BendBase.cpp:89
std::vector< Vector_t > getDesignPath() const
Definition: BendBase.cpp:43
std::vector< Vector_t > refTrajMap_m
Map of reference particle trajectory.
Definition: BendBase.h:64
BendBase()
Definition: BendBase.cpp:7
double calcBendAngle(double chordLength, double radius) const
Calculate bend angle from chord length and design radius.
Definition: BendBase.cpp:79
double calcBetaGamma() const
Calculate beta*gamma from design energy.
Definition: BendBase.cpp:95
double designEnergy_m
Bend design energy (eV).
Definition: BendBase.h:61
double fieldAmplitudeY_m
Definition: BendBase.h:68
double calcFieldAmplitude(double radius) const
Calculate field amplitude from design energy and radius.
Definition: BendBase.cpp:70
double calcDesignRadius(double fieldAmplitude) const
Calculate design radius from design energy and field amplitude.
Definition: BendBase.cpp:61
void setFieldAmplitude(double k0, double k0s)
Definition: BendBase.cpp:56
double fieldAmplitudeX_m
Definition: BendBase.h:66
Interface for a single beam element.
Definition: Component.h:50
PartBunchBase< double, 3 > * RefPartBunch_m
Definition: Component.h:191