criptic v1
Cosmic Ray Interstellar Propagation Tool using Itô Calculus
Loading...
Searching...
No Matches
SR.H
Go to the documentation of this file.
1
16#ifndef _SR_H_
17#define _SR_H_
18
19#include <cmath>
20#include "Types.H"
21#include "PartTypes.H"
22
23namespace criptic {
24
28 namespace sr {
29
36 static inline Real gamma_from_p(const Real m, const Real p) {
37 Real pm = p/m;
38 return pm < 1.0e-6 ? 1.0 + pm*pm / 2.0 : std::sqrt(1.0 + pm*pm);
39 }
40
47 static inline Real gamma_from_T(const Real m, const Real T) {
48 return 1.0 + T/m;
49 }
50
57 static inline Real gamma_from_E(const Real m, const Real E) {
58 return E/m;
59 }
60
67 static inline Real p_from_gamma(const Real m, const Real gamma) {
68 Real g = gamma-1.0;
69 if (g < 1.0e-6)
70 return m * (std::sqrt(2.0)*g + (g/2.0)*std::sqrt(g/2.0));
71 else
72 return m * std::sqrt(gamma*gamma - 1.0);
73 }
74
81 static inline Real p_from_T(const Real m, const Real T) {
82 Real Tm = T/m;
83 if (Tm < 1.0e-6)
84 return std::sqrt(2.0*Tm) + m * (Tm/2.0) * std::sqrt(Tm/2.0);
85 else
86 return m * std::sqrt(Tm * (2.0+Tm));
87 }
88
95 static inline Real p_from_E(const Real m, const Real E) {
96 Real Tm = E / m - 1.0;
97 if (Tm < 1.0e-6)
98 return std::sqrt(2.0*Tm) + m * (Tm/2.0) * std::sqrt(Tm/2.0);
99 else
100 return m * std::sqrt(Tm * (2.0+Tm));
101 }
102
109 static inline Real T_from_gamma(const Real m, const Real gamma) {
110 return m * (gamma-1.0);
111 }
112
119 static inline Real T_from_p(const Real m, const Real p) {
120 Real pm = p / m;
121 if (pm < 1.0e-6)
122 return p*p / (2.0*m) * (1.0 - pm*pm/4.0);
123 else
124 return m * (std::sqrt(1.0 + pm*pm) - 1.0);
125 }
126
133 static inline Real E_from_gamma(const Real m, const Real gamma) {
134 return m * gamma;
135 }
136
143 static inline Real E_from_p(const Real m, const Real p) {
144 Real pm = p / m;
145 if (pm < 1.0e-6)
146 return m + p*p / (2.0*m) * (1.0 - pm*pm/4.0);
147 else
148 return m * std::sqrt(1.0 + pm*pm);
149 }
150
158 static inline Real dT_dp(const Real m, const Real p) {
159 Real pm = p / m;
160 if (pm < 1.0e-6)
161 return pm * (1.0 - pm*pm/2.0);
162 else
163 return pm / std::sqrt(1.0 + pm*pm);
164 }
165
172 static inline Real v_from_p(const Real m, const Real p) {
173 Real pm = p / m;
174 if (pm < 1.0e-6)
175 return pm - 0.5 / (pm*pm*pm);
176 else
177 return 1.0 / std::sqrt(1.0 + 1.0/(pm*pm));
178 }
179
186 static inline Real gamma_from_p(const partTypes::pType pt,
187 const Real p) {
188 return gamma_from_p(partTypes::mass[pt], p);
189 }
190
197 static inline Real gamma_from_T(const partTypes::pType pt, const Real T) {
198 return gamma_from_T(partTypes::mass[pt], T);
199 }
200
207 static inline Real p_from_gamma(const partTypes::pType pt,
208 const Real gamma) {
209 return p_from_gamma(partTypes::mass[pt], gamma);
210 }
211
218 static inline Real p_from_T(const partTypes::pType pt, const Real T) {
219 return p_from_T(partTypes::mass[pt], T);
220 }
221
228 static inline Real T_from_gamma(const partTypes::pType pt,
229 const Real gamma) {
230 return T_from_gamma(partTypes::mass[pt], gamma);
231 }
232
239 static inline Real T_from_p(const partTypes::pType pt, const Real p) {
240 return T_from_p(partTypes::mass[pt], p);
241 }
242
250 static inline Real dT_dp(const partTypes::pType pt, const Real p) {
251 return dT_dp(partTypes::mass[pt], p);
252 }
253
260 static inline Real v_from_p(const partTypes::pType pt, const Real p) {
261 return v_from_p(partTypes::mass[pt], p);
262 }
263
270 static inline Real ECM(const Real mt, const Real mp, const Real T) {
271 return std::sqrt( mt*mt + mp*mp + 2*mt*(mp*mp+T) );
272 }
273
280 static inline Real ECM(const partTypes::pType ptt,
281 const partTypes::pType ptp,
282 const Real T) {
283 return ECM(partTypes::mass[ptt], partTypes::mass[ptp], T);
284 }
285 }
286}
287
288#endif
289// _SR_H_
Data file of elementary particle properties.
Basic integer and real types.
constexpr Real mass[nPartType]
Definition PartTypes.H:44
pType
Enum of particle types.
Definition PartTypes.H:32
static Real ECM(const Real mt, const Real mp, const Real T)
Compute center of mass energy for collision with fixed target.
Definition SR.H:270
static Real v_from_p(const Real m, const Real p)
Compute velocity from momentum.
Definition SR.H:172
static Real T_from_p(const Real m, const Real p)
Compute kinetic energy from rest mass and momentum.
Definition SR.H:119
static Real E_from_p(const Real m, const Real p)
Compute total energy from rest mass and momentum.
Definition SR.H:143
static Real p_from_E(const Real m, const Real E)
Compute momentum from rest mass and total energy.
Definition SR.H:95
static Real E_from_gamma(const Real m, const Real gamma)
Compute total energy from rest mass and Lorentz factor.
Definition SR.H:133
static Real p_from_gamma(const Real m, const Real gamma)
Compute momentum from rest mass and Lorentz factor.
Definition SR.H:67
static Real gamma_from_T(const Real m, const Real T)
Compute Lorentz factor from rest mass and kinetic energy.
Definition SR.H:47
static Real T_from_gamma(const Real m, const Real gamma)
Compute kinetic energy from rest mass and Lorentz factor.
Definition SR.H:109
static Real gamma_from_E(const Real m, const Real E)
Compute Lorentz factor from rest mass and total energy.
Definition SR.H:57
static Real dT_dp(const Real m, const Real p)
Compute derivative of kinetic energy with respect to momentum.
Definition SR.H:158
static Real p_from_T(const Real m, const Real T)
Compute momentum from rest mass and kinetic energy.
Definition SR.H:81
static Real gamma_from_p(const Real m, const Real p)
Compute Lorentz factor from rest mass and momentum.
Definition SR.H:36
The primary namespace for criptic objects.
Definition AdvancePacket.H:25
double Real
Definition Types.H:38