GMF_HMR.h
Go to the documentation of this file.
1 #ifndef _gal_GMF_HMR_ASS_A_h
2 #define _gal_GMF_HMR_ASS_A_h
3 
4 #include <cmath>
5 
6 #include <GalacticUnits.h>
7 
8 
9 namespace galactic {
10 
11  namespace gmf {
12 
13 
14  namespace HMRConstants {
15 
16  const double kRange = 20 * kiloparsec;
17  const double kL = 8.5 * kiloparsec;
18  const double kRho1 = 2 * kiloparsec;
19  const double kD = -0.5 * kiloparsec;
20  const double kZ1 = 0.3 * kiloparsec;
21  const double kZ2 = 4 * kiloparsec;
22  const double kZ3 = 20 * parsec;
23  const double kPitch = -170 * degree;
24  const double kPsi = 10.55 * kiloparsec;
25  const double kB0 = 3 * microgauss;
26 
27  }
28 
29 
31 
32  class HMR_ASS_A {
33  public:
34  template<typename PositionVector, typename FieldVector>
35  void
36  operator()(const PositionVector& position, FieldVector& b)
37  {
38  using namespace std;
39  using namespace HMRConstants;
40 
41  const double& x = position[0];
42  const double& y = position[1];
43  const double& z = position[2];
44 
45  const double rho2 = x*x + y*y;
46  const double r = sqrt(rho2 + z*z);
47 
48  b[2] = 0;
49 
50  // return with zero field if out of range
51  if (r > kRange || !rho2) {
52  b[0] = b[1] = 0;
53  return;
54  }
55 
56  const double rho = sqrt(rho2);
57 
58  const double b_rho =
59  kB0 * kL *
60  pow(tanh(rho / kRho1), 3) / rho2 *
61  pow(cos(atan2(y, x) - log(rho / kPsi)/tan(kPitch) - M_PI), 2) *
62  (0.5 / cosh(z / kZ1) + 0.5 / cosh(z / kZ2)) * tanh(z / kZ3);
63 
64  const double sinp = sin(kPitch);
65  const double cosp = cos(kPitch);
66  b[0] = b_rho * (sinp * x - cosp * y);
67  b[1] = b_rho * (sinp * y + cosp * x);
68 
69  /*cout << "GMF " << b[0] << ' ' << b[1] << ' ' << b[2] << ' '
70  << r/kiloparsec << ' ' << rho/kiloparsec << ' '
71  << b_rho << endl;*/
72  }
73 
74  };
75 
76 
77  class HMR_BSS_S {
78  public:
79  template<typename PositionVector, typename FieldVector>
80  void
81  operator()(const PositionVector& position, FieldVector& b)
82  {
83  using namespace std;
84  using namespace HMRConstants;
85 
86  const double& x = position[0];
87  const double& y = position[1];
88  const double& z = position[2];
89 
90  const double rho2 = x*x + y*y;
91  const double r = sqrt(rho2 + z*z);
92 
93  b[2] = 0;
94 
95  // return with zero field if out of range
96  if (r > kRange || !rho2) {
97  b[0] = b[1] = 0;
98  return;
99  }
100 
101  const double rho = sqrt(rho2);
102 
103  const double b_rho =
104  kB0 * kL *
105  pow(tanh(rho / kRho1), 3) / rho2 *
106  cos(atan2(y, x) - log(rho / kPsi)/tan(kPitch) - M_PI) *
107  (0.5 / cosh(z / kZ1) + 0.5 / cosh(z / kZ2));
108 
109  const double sinp = sin(kPitch);
110  const double cosp = cos(kPitch);
111  b[0] = b_rho * (sinp * x - cosp * y);
112  b[1] = b_rho * (sinp * y + cosp * x);
113  }
114 
115  };
116 
117  }
118 
119 }
120 
121 
122 #endif
const double kiloparsec
Definition: GalacticUnits.h:25
const double degree
Definition: GalacticUnits.h:44
HMR-model (ASS-A)
Definition: GMF_HMR.h:32
double pow(const double x, const unsigned int i)
void operator()(const PositionVector &position, FieldVector &b)
Definition: GMF_HMR.h:81
const double parsec
Definition: GalacticUnits.h:24
void operator()(const PositionVector &position, FieldVector &b)
Definition: GMF_HMR.h:36
const double microgauss
Definition: GalacticUnits.h:42

, generated on Tue Sep 26 2023.