RelativisticChargeInMagneticFieldODE.h
Go to the documentation of this file.
1 #ifndef _gal_RelativisticChargeInMagneticFieldODE_h_
2 #define _gal_RelativisticChargeInMagneticFieldODE_h_
3 
4 #include <GalacticUnits.h>
5 
6 
7 namespace galactic {
8 
22  template<class MagneticFieldFunctor>
24  public:
26  const double energy,
27  MagneticFieldFunctor& mag)
28  : fQcE(charge * lightspeed / energy), fMagField(mag) { }
29 
31  template<typename Vector6>
32  void
33  operator()(const double /*x*/, const Vector6& y, Vector6& dYdX)
34  const
35  {
36  double b[3];
37  fMagField(y, b);
38  dYdX[0] = y[3]; // u_x
39  dYdX[1] = y[4]; // u_y
40  dYdX[2] = y[5]; // u_z
41  dYdX[3] = fQcE * (y[4]*b[2] - y[5]*b[1]);
42  dYdX[4] = fQcE * (y[5]*b[0] - y[3]*b[2]);
43  dYdX[5] = fQcE * (y[3]*b[1] - y[4]*b[0]);
44  }
45 
47  operator unsigned int() const
48  { return 6; }
49 
50  private:
51  const double fQcE;
52  MagneticFieldFunctor& fMagField;
53  };
54 
55 
56 }
57 
58 
59 #endif
void operator()(const double, const Vector6 &y, Vector6 &dYdX) const
calculate derivatives
RelativisticChargeInMagneticFieldODE(const double charge, const double energy, MagneticFieldFunctor &mag)
double Vector6[6]
const double lightspeed
Definition: GalacticUnits.h:27

, generated on Tue Sep 26 2023.