14#include <gsl/gsl_sf.h>
16#include "../Utils/Constants.H"
17#include "../Utils/PartTypes.H"
18#include "../Utils/RngThread.H"
19#include "../Utils/SR.H"
20#include "../Utils/Types.H"
44#ifdef TRACK_PITCH_ANGLE
123 if (
p1 <=
p0)
return k;
124 else if (
q == -1.0)
return k * std::log(
p1/
p0);
125 else return k * (std::pow(
p1,
q+1) - std::pow(
p0,
q+1)) / (
q+1);
137 else if (
q == -2.0)
return k * std::log(
p1/
p0);
138 else return k * (std::pow(
p1,
q+2) - std::pow(
p0,
q+2)) / (
q+2);
158 return k * m * (1/
p1 - 1/
p0) +
159 std::sqrt(1 + m2/p02) - std::sqrt(1 + m2/p12) +
160 std::asinh(
p1/m) - std::asinh(
p0/m);
161 }
else if (
q == 0.0) {
163 Real p1fac = (m2/p12 > 1e-6) ?
164 std::log(
p1 * (std::sqrt(1 + m2/p12) - 1) ) :
165 std::log( m2 / (2 *
p1) - m2*m2 / (8 *
p1 * p12));
166 Real p0fac = (m2/p12 > 1e-6) ?
167 std::log(
p0 * (std::sqrt(1 + m2/p02) - 1) ) :
168 std::log( m2 / (2 *
p0) - m2*m2 / (8 *
p0 * p02));
169 return k * 0.5 * (
p1 * std::sqrt(p12 + m2) -
170 p0 * std::sqrt(p02 + m2) -
172 m2 * (p1fac - p0fac) );
176 Real term1 = m/(
q+1) *
177 (std::pow(
p0,
q+1) - std::pow(
p1,
q+1));
178 Real term2 = 0.5 * std::pow(m,
q+2) * gsl_sf_beta(
a, b) *
179 ( gsl_sf_beta_inc(
a, b, 1/(1+p02/m2) ) -
180 gsl_sf_beta_inc(
a, b, 1/(1+p12/m2) ) );
181 return k * (term1 + term2);
220 return k / std::pow(
p0, qSamp);
221 else if (qSamp == -1.0)
222 return k * std::log(
p1/
p0) / std::pow(
p0, qSamp);
224 return k * (std::pow(
p1, qSamp+1) - std::pow(
p0, qSamp+1)) /
225 ((qSamp+1) * std::pow(
p0, qSamp));
242 if (codeUnits)
k = lum /
TRate();
Class to hold data on a CR packet.
A class to describe a source of CR packets.
Definition CRSource.H:33
void setLum(const Real lum, const bool codeUnits=false)
Set the rate coefficient to produce a specified luminosity.
Definition CRSource.H:240
Real p0
Definition CRSource.H:40
Real nRate() const
Returns total CR injection rate per unit time.
Definition CRSource.H:122
Real T1() const
Returns kinetic energy corresponding to maximum momentum.
Definition CRSource.H:63
Real E1() const
Returns total energy corresponding to maximum momentum.
Definition CRSource.H:95
Real pRate() const
Returns total linear momentum injection rate per time.
Definition CRSource.H:135
RealVec a
Definition CRSource.H:49
Real TRate() const
Returns total kinetic energy injection rate per time.
Definition CRSource.H:150
void set_T0(const Real T0)
Set the momentum lower limit by specifying the kinetic energy.
Definition CRSource.H:71
Real pBar() const
Return mean CR momentum injected.
Definition CRSource.H:193
Real k
Definition CRSource.H:43
Real p1
Definition CRSource.H:41
Real TBar() const
Return mean CR kinetic energy injected.
Definition CRSource.H:204
Real q
Definition CRSource.H:42
RealVec v
Definition CRSource.H:48
Real E0() const
Returns total energy corresponding to minimum momentum.
Definition CRSource.H:87
Real T0() const
Returns kinetic energy corresponding to minimum momentum.
Definition CRSource.H:55
Real wgt(const Real qSamp) const
Return the statistical weight of this source.
Definition CRSource.H:218
IdxType uniqueID
Definition CRSource.H:39
Real R1() const
Returns rigidity correspondning to minimum momentum.
Definition CRSource.H:111
std::vector< CRPacket > draw(const IdxType n, const Real t0, const Real t1, const Real qSamp, const RngThread &rng) const
Draw CR packets.
Definition CRSource.cpp:11
Real R0() const
Returns rigidity correspondning to minimum momentum.
Definition CRSource.H:103
partTypes::pType type
Definition CRSource.H:38
void set_T1(const Real T1)
Set the momentum upper limit by specifying the kinetic energy.
Definition CRSource.H:79
Thread-safe random number generator.
Definition RngThread.H:39
static constexpr Real mp_c2
Definition Constants.H:118
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 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_T(const Real m, const Real T)
Compute momentum from rest mass and kinetic energy.
Definition SR.H:81
The primary namespace for criptic objects.
Definition AdvancePacket.H:25
std::vector< Real >::size_type IdxType
Definition Types.H:45
double Real
Definition Types.H:38