ChargeInHMR_ASS_A.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <cmath>
3 #include <cstdlib>
4 
5 #include <utl/RK5ODEIntegrator.h>
6 
7 #include <GalacticUnits.h>
9 using namespace std;
10 #include <GMF_HMR.h>
11 
12 using namespace std;
13 using namespace utl;
14 using namespace galactic;
15 
16 
17 typedef double Vector3[3];
18 typedef double Vector6[6];
19 
20 
21 template<typename Vector>
22 inline
23 double
25 {
26  const double r2 = v[0]*v[0] + v[1]*v[1] + v[2]*v[2];
27  return sqrt(r2);
28 }
29 
30 
31 int
33 {
34  typedef double Vector6[6];
35 
36  typedef gmf::HMR_BSS_S GMFType;
37  //typedef gmf::HMR_ASS_A GMFType;
38  GMFType hmr;
39 
41 
42  for (double energy = 0.01*EeV; energy <= 100*EeV; energy *= 1.3) {
43 
44  ODE chargeMotionODE(1*eplus, energy, hmr);
45 
46  RK5ODEIntegrator<ODE> integrator(chargeMotionODE);
47 
48  const double x0 = 0;
49  const double dxFirst = 0.1*lightyear;
50  // first 3 elements are position, last 3 are (unit) velocity
51  const double sunGCDistance = 8.5*kiloparsec;
52  const Vector6 x0u0 = { -sunGCDistance, 0, 50*parsec, 1, 0, 0 };
53  const double accuracy = 1e-5;
55  integrator.AdaptiveBegin(x0, dxFirst, x0u0, accuracy);
56 
57  while (RadialDistance(it.GetY()) < 40*kiloparsec) {
58 
59  // normalize velocity vector to prevent numerical dissipation
60  // this is optional but should be used for low accuracy runs
61  Vector6& xu = it.GetY();
62  /*const double uNorm =
63  sqrt(xu[3]*xu[3] + xu[4]*xu[4] + xu[5]*xu[5]);
64  xu[3] /= uNorm;
65  xu[4] /= uNorm;
66  xu[5] /= uNorm;*/
67 
68  // output current time (in units of ct = distance)
69  cout << it.GetX() / kiloparsec;
70  // output position (in kiloparsec)
71  for (int j = 0; j < 3; ++j)
72  cout << ' ' << xu[j] / kiloparsec;
73  // output unit velocity
74  for (int j = 3; j < 6; ++j)
75  cout << ' ' << xu[j];
76  cout << '\n';
77 
78  // advance with optimal step for this accuracy
79  ++it;
80  }
81 
82  cout << endl;
83 
84  }
85 
86  return EXIT_SUCCESS;
87 }
const double kiloparsec
Definition: GalacticUnits.h:25
const double eplus
Definition: GalacticUnits.h:37
const double EeV
Definition: GalacticUnits.h:34
int main(int argc, char *argv[])
Definition: DBSync.cc:58
const double lightyear
Definition: GalacticUnits.h:21
double Vector6[6]
AdaptiveRK5Iterator< DerivativeFunctor, VectorType > AdaptiveBegin(const double x, const double dx, const VectorType &y, const double accuracy=1e-5)
const double parsec
Definition: GalacticUnits.h:24
double RadialDistance(const Vector &v)
Vector object.
Definition: Vector.h:30
double Vector3[3]

, generated on Tue Sep 26 2023.