OPAL (Object Oriented Parallel Accelerator Library) 2024.2
OPAL
BendBase.cpp
Go to the documentation of this file.
2
4
5#include <cmath>
6
10
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),
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}
const std::string name
constexpr double c
The velocity of light in m/s.
Definition Physics.h:45
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
double calcBendAngle(double chordLength, double radius) const
Calculate bend angle from chord length and design radius.
Definition BendBase.cpp:79
double fieldAmplitude_m
Field amplitude.
Definition BendBase.h:71
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 entranceAngle_m
Definition BendBase.h:54
Fieldmap fieldmap_m
Magnet field map.
Definition BendBase.h:56
double gap_m
Full vertical gap of the magnets.
Definition BendBase.h:59
double fieldAmplitudeY_m
Definition BendBase.h:68
std::string fileName_m
Definition BendBase.h:73
double chordLength_m
Definition BendBase.h:52
bool designEnergyChangeable_m
Definition BendBase.h:62
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
double angle_m
Bend angle.
Definition BendBase.h:53
Component(const std::string &name)
Constructor with given name.
Definition Component.cpp:53
PartBunchBase< double, 3 > * RefPartBunch_m
Definition Component.h:191
Vektor< double, 3 > Vector_t