OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
CavityAutophaser.h
Go to the documentation of this file.
1 #ifndef CAVITYAUTOPHASER
2 #define CAVITYAUTOPHASER
3 
5 #include "Algorithms/PartData.h"
6 
8 public:
10  std::shared_ptr<Component> cavity);
11 
13 
14  double getPhaseAtMaxEnergy(const Vector_t &R,
15  const Vector_t &P,
16  double t,
17  double dt);
18 
19 private:
20  double guessCavityPhase(double t);
21  std::pair<double, double> optimizeCavityPhase(double initialGuess,
22  double t,
23  double dt);
24 
25  double track(Vector_t R,
26  Vector_t P,
27  double t,
28  const double dt,
29  const double phase,
30  std::ofstream *out = NULL) const;
31  double getEnergyMeV(const Vector_t &P);
32  double getMomentum(double kineticEnergyMeV);
33 
35  std::shared_ptr<Component> itsCavity_m;
36 
39 
40 };
41 
42 inline
44  return itsReference_m.getM() * 1e-6 * (sqrt(dot(P,P) + 1) - 1);
45 }
46 
47 inline
48 double CavityAutophaser::getMomentum(double kineticEnergyMeV) {
49  return sqrt(std::pow(kineticEnergyMeV / (itsReference_m.getM() * 1e-6) + 1, 2) - 1);
50 }
51 
52 #endif
constexpr double e
The value of .
Definition: Physics.h:40
Particle reference data.
Definition: PartData.h:38
double getPhaseAtMaxEnergy(const Vector_t &R, const Vector_t &P, double t, double dt)
double dot(const Vector3D &lhs, const Vector3D &rhs)
Vector dot product.
Definition: Vector3D.cpp:118
std::shared_ptr< Component > itsCavity_m
double track(Vector_t R, Vector_t P, double t, const double dt, const double phase, std::ofstream *out=NULL) const
double getMomentum(double kineticEnergyMeV)
double getEnergyMeV(const Vector_t &P)
const PartData & itsReference_m
Tps< T > pow(const Tps< T > &x, int y)
Integer power.
Definition: TpsMath.h:76
double guessCavityPhase(double t)
Tps< T > sqrt(const Tps< T > &x)
Square root.
Definition: TpsMath.h:91
double getM() const
The constant mass per particle.
Definition: PartData.h:112
std::pair< double, double > optimizeCavityPhase(double initialGuess, double t, double dt)
CavityAutophaser(const PartData &ref, std::shared_ptr< Component > cavity)