OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
OPAL
BendBase.h
Go to the documentation of this file.
1 #ifndef CLASSIC_BENDBASE_H
2 #define CLASSIC_BENDBASE_H
3 
5 
6 #include <vector>
7 #include <string>
8 
9 class Fieldmap;
10 
11 class BendBase: public Component {
12 public:
13  BendBase();
14  BendBase(const BendBase &);
15  BendBase(const std::string &);
16 
18  virtual bool bends() const;
19 
20  double getChordLength() const;
21  virtual void setBendAngle(double angle);
22  double getBendAngle() const;
23  virtual void setEntranceAngle(double entranceAngle);
24  double getEntranceAngle() const;
25  virtual double getExitAngle() const = 0;
26  void setFullGap(double);
27  double getFullGap() const;
28 
29  virtual void setDesignEnergy(const double& energy, bool changeable = true);
30  double getDesignEnergy() const;
31  std::vector<Vector_t> getDesignPath() const;
32 
33  void setFieldAmplitude(double k0, double k0s);
34  double getFieldAmplitude() const;
35 
36  void setFieldMapFN(std::string fileName);
37  std::string getFieldMapFN() const;
38 protected:
40  double calcDesignRadius(double fieldAmplitude) const;
42  double calcFieldAmplitude(double radius) const;
44  double calcBendAngle(double chordLength, double radius) const;
46  double calcDesignRadius(double chordLength, double angle) const;
48  double calcGamma() const;
50  double calcBetaGamma() const;
51 
52  double chordLength_m;
53  double angle_m;
54  double entranceAngle_m;
57  const bool fast_m = false;
58 
59  double gap_m;
60 
61  double designEnergy_m;
64  std::vector<Vector_t> refTrajMap_m;
65 
70 
72 
73  std::string fileName_m;
74 };
75 
76 inline
77 bool BendBase::bends() const {
78  return true;
79 }
80 
81 inline
82 double BendBase::getChordLength() const {
83  return chordLength_m;
84 }
85 
86 inline
87 void BendBase::setBendAngle(double angle) {
88  angle_m = angle;
89 }
90 
91 inline
92 double BendBase::getBendAngle() const {
93  return angle_m;
94 }
95 
96 inline
97 void BendBase::setEntranceAngle(double angle)
98 {
99  entranceAngle_m = angle;
100 }
101 
102 inline
104  return entranceAngle_m;
105 }
106 
107 inline
108 void BendBase::setFullGap(double gap) {
109  gap_m = std::abs(gap);
110 }
111 
112 inline
113 double BendBase::getFullGap() const {
114  return gap_m;
115 }
116 
117 inline
118 void BendBase::setDesignEnergy(const double& energy, bool changeable) {
120  designEnergy_m = std::abs(energy) * 1e6;
121  designEnergyChangeable_m = changeable;
122  }
123 }
124 
125 inline
127  return designEnergy_m;
128 }
129 
130 inline
132 {
133  return fieldAmplitude_m;
134 }
135 
136 inline
137 void BendBase::setFieldMapFN(std::string fileName) {
138  fileName_m = fileName;
139 }
140 
141 inline
142 std::string BendBase::getFieldMapFN() const {
143  return fileName_m;
144 }
145 
146 
147 #endif
PETE_TUTree< FnAbs, typename T::PETE_Expr_t > abs(const PETE_Expr< T > &l)
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
const bool fast_m
Flag to turn on fast field calculation.
Definition: BendBase.h:57
void setFieldMapFN(std::string fileName)
Definition: BendBase.h:137
double calcBendAngle(double chordLength, double radius) const
Calculate bend angle from chord length and design radius.
Definition: BendBase.cpp:79
virtual void setDesignEnergy(const double &energy, bool changeable=true)
Definition: BendBase.h:118
double fieldAmplitude_m
Field amplitude.
Definition: BendBase.h:71
double calcBetaGamma() const
Calculate beta*gamma from design energy.
Definition: BendBase.cpp:95
double getChordLength() const
Definition: BendBase.h:82
double designEnergy_m
Bend design energy (eV).
Definition: BendBase.h:61
virtual void setEntranceAngle(double entranceAngle)
Definition: BendBase.h:97
double entranceAngle_m
Definition: BendBase.h:54
void setFullGap(double)
Definition: BendBase.h:108
double getBendAngle() const
Definition: BendBase.h:92
double getFieldAmplitude() const
Definition: BendBase.h:131
double getDesignEnergy() const
Definition: BendBase.h:126
double gap_m
Full vertical gap of the magnets.
Definition: BendBase.h:59
double fieldAmplitudeY_m
Definition: BendBase.h:68
virtual double getExitAngle() const =0
virtual void setBendAngle(double angle)
Definition: BendBase.h:87
Fieldmap * fieldmap_m
Magnet field map.
Definition: BendBase.h:56
std::string fileName_m
Definition: BendBase.h:73
double chordLength_m
Definition: BendBase.h:52
double getEntranceAngle() const
Definition: BendBase.h:103
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
virtual bool bends() const
Indicates that element bends the beam.
Definition: BendBase.h:77
std::string getFieldMapFN() const
Definition: BendBase.h:142
double fieldAmplitudeX_m
Definition: BendBase.h:66
double getFullGap() const
Definition: BendBase.h:113
double angle_m
Bend angle.
Definition: BendBase.h:53
Interface for a single beam element.
Definition: Component.h:50