criptic v1
Cosmic Ray Interstellar Propagation Tool using Itô Calculus
Loading...
Searching...
No Matches
CRPacket.H
Go to the documentation of this file.
1
10#ifndef _CRPACKET_H_
11#define _CRPACKET_H_
12
13#include "../Utils/PartTypes.H"
14#include "../Utils/SR.H"
15#include "../Utils/Types.H"
16
17namespace criptic {
18
28 class CRPacket {
29
30 public:
31
32 // Flag values for bitmasking sources. Binary representations are:
33 // noSrc = 111111...
34 // secondaryFlag = 100000...
35 static constexpr
37 static constexpr
41 // Data
50#ifdef TRACK_PITCH_ANGLE
51 Real mu;
52#endif
53
54 // Pass-throughs for particle properties
55
60 constexpr Real Z() const {
61 return partTypes::charge[type];
62 }
63
68 constexpr Real m() const {
69 return partTypes::mass[type];
70 }
71
76 constexpr bool isSecondary() const {
77 return src & secondaryFlag;
78 }
79
80 // Special relativistic transformations
81
86 Real gamma() const {
87 return sr::gamma_from_p(type, p);
88 }
89
94 Real T() const {
95 return sr::T_from_p(type, p);
96 }
97
102 void set_T(const Real T) {
103 p = sr::p_from_T(type, T);
104 }
105
110 Real E() const {
111 return sr::E_from_p(type, p);
112 }
113
118 Real v() const {
119 return sr::v_from_p(type, p);
120 }
121
126 Real R() const {
127 return p / std::abs(Z());
128 }
129
134 Real dT_dp() const {
135 return sr::dT_dp(type, p);
136 }
137
144 Real wG(const Real B) const {
145#ifdef CRIPTIC_UNITS_CGS
146 return constants::e * std::abs(Z()) * B / (gamma() * m() * constants::mp_c);
147#else
148 return constants::e * std::abs(Z()) * B / (gamma() * m() * constants::mp);
149#endif
150 }
151
161 Real rG(const Real B) const {
162 // Perpendicular momentum in *physical* instead of code units
163#ifdef TRACK_PITCH_ANGLE
164 // Pitch angle tracking case
165 const Real p_perp = p * constants::mp_c * std::sqrt(1 - mu*mu);
166#else
167 // Pitch angle averaged case
168 const Real p_perp = p * constants::mp_c * M_PI_4;
169#endif
170#ifdef CRIPTIC_UNITS_CGS
171 return p_perp * constants::c / (std::abs(Z()) * constants::e * B);
172#else
173 return p_perp / (std::abs(Z()) * constants::e * B);
174#endif
175 }
176 };
177
178}
179
180#endif
181// _CRPACKET_H_
182
A class that holds data to describe a CR packet.
Definition CRPacket.H:28
constexpr Real m() const
Particle mass.
Definition CRPacket.H:68
void set_T(const Real T)
Set the momentum of the packet by specifying its kinetic energy.
Definition CRPacket.H:102
constexpr bool isSecondary() const
Is this a secondary packet?
Definition CRPacket.H:76
Real gamma() const
Lorentz factor of packet.
Definition CRPacket.H:86
Real rG(const Real B) const
Compute gyroradius of packet.
Definition CRPacket.H:161
Real tInj
Definition CRPacket.H:45
Real gr
Definition CRPacket.H:49
Real v() const
Velocity of packet.
Definition CRPacket.H:118
Real wInj
Definition CRPacket.H:46
Real T() const
Kinetic energy of packet.
Definition CRPacket.H:94
Real wG(const Real B) const
Compute gyrofrequency of packet.
Definition CRPacket.H:144
Real R() const
Rigidity of packet.
Definition CRPacket.H:126
constexpr Real Z() const
Particle charge.
Definition CRPacket.H:60
static constexpr IdxType noSrc
Definition CRPacket.H:36
IdxType src
Definition CRPacket.H:43
static constexpr IdxType secondaryFlag
Definition CRPacket.H:38
Real w
Definition CRPacket.H:48
Real E() const
Total energy of packet.
Definition CRPacket.H:110
Real dT_dp() const
Derivative of kinetic energy with respect to momentum.
Definition CRPacket.H:134
partTypes::pType type
Definition CRPacket.H:42
IdxType uniqueID
Definition CRPacket.H:44
Real p
Definition CRPacket.H:47
static constexpr Real c
Definition Constants.H:34
static constexpr Real mp
Definition Constants.H:36
static constexpr Real mp_c
Definition Constants.H:117
static constexpr Real e
Definition Constants.H:47
constexpr Real mass[nPartType]
Definition PartTypes.H:44
constexpr int charge[nPartType]
Definition PartTypes.H:55
pType
Enum of particle types.
Definition PartTypes.H:32
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 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
constexpr IdxType maxIdx
Definition Types.H:55
std::vector< Real >::size_type IdxType
Definition Types.H:45
double Real
Definition Types.H:38