Advanced documentation¶
The “advanced documentation” is the almost complete documentation of all modules.
prince_cr.config
– default configuration optionsprince_cr.core
– Core moduleprince_cr.data
– (particle) Species managementprince_cr.solvers
– PDE solver implementationsprince_cr.cross_sections
– Cross section data managementprince_cr.interaction_rates
– Computation of Interaction Matricesprince_cr.photonfields
– EBL and CMB photon fieldsprince_cr.cr_sources
– UHECR source class definitions
prince_cr.config
– default configuration options¶
The module contains all static options of PriNCe that are not meant to be changed in run time.
PriNCe configuration module.
-
prince_cr.config.
E_CMB
= 2.34823e-13¶ CMB energy kB*T0 [GeV]
-
prince_cr.config.
H_0
= 70.5¶ Hubble constant
-
prince_cr.config.
Omega_Lambda
= 0.73¶ Omega_Lambda
-
prince_cr.config.
Omega_m
= 0.27¶ Omega_m
-
prince_cr.config.
cosmic_ray_grid
= (3, 14, 8)¶ Cosmic ray energy grid (defines system size for solver) Number of bins in multiples of 4 recommended for maximal vectorization efficiency for 256 bit AVX or similar Format (log10(E_min), log10(E_max), nbins/decade of energy)
-
prince_cr.config.
data_dir
= '/home/docs/checkouts/readthedocs.org/user_builds/prince/checkouts/latest/prince_cr/data'¶ Directory where the data files for the calculation are stored
-
prince_cr.config.
db_fname
= 'prince_db_05.h5'¶ PrinceDB file name
-
prince_cr.config.
debug_level
= 1¶ Debug flag for verbose printing, 0 silences PriNCe entirely
-
prince_cr.config.
grid_scale
= 'E'¶ Scale of the energy grid ‘E’: logarithmic in energy E_i = E_min * (Delta)^i ‘logE’: linear grid in x = log_10(E): x_i = x_min + i * Delta
-
prince_cr.config.
override_debug_fcn
= []¶ Printout debug info only for functions in this list (just give the name, “get_solution” for instance) Warning, this option slows down initialization by a lot. Use only when needed.
-
prince_cr.config.
override_max_level
= 10¶ Override debug printout for debug levels < value for the functions above
-
prince_cr.config.
pf
= 'Linux-5.19.0-1028-aws-x86_64-with-debian-buster-sid'¶ determine shared library extension and MKL path
-
prince_cr.config.
photon_grid
= (-15, -6, 8)¶ Photon grid of target field, only for calculation of rates
-
prince_cr.config.
print_module
= False¶ Print module name in debug output
-
prince_cr.config.
redist_fname
= 'sophia_redistribution_logbins.npy'¶ Model file for redistribution functions (from SOPHIA or similar)
-
prince_cr.config.
redist_threshold_ID
= 101¶ Particle ID for which redistribution functions are needed to be taken into account. The default value is 101 (proton). All particles with smaller IDs, i.e. neutrinos, pions, muons etc., will have energy redistributions. For larger IDs (nuclei) the boost conservation is employed.
-
prince_cr.config.
semi_lagr_method
= '5th_order'¶ Order of semi-lagrangian for energy derivative
-
prince_cr.config.
tau_dec_threshold
= inf¶ Threshold lifetime value for explicit transport of particles of this type. It means that if a particle is unstable with lifetime smaller than this threshold, it will be decayed until all final state particles of this chain are stable. In other words: short intermediate states will be integrated out
-
prince_cr.config.
x_cut
= 0.0001¶ Cut on energy redistribution functions Resitribution below this x value are set to 0. “x_cut” : 0., “x_cut_proton” : 0.,
-
prince_cr.config.
y_cut
= inf¶ cut on photon energy, cross section above y = E_cr e_ph / m_cr does not contribute
prince_cr.core
– Core module¶
This module contains the main program features. Instantiating prince_cr.core.PriNCeRun
will initialize the data structures and particle tables, create and fill the
interaction and decay matrix and check if all information for the calculation
of inclusive fluxes in the atmosphere is available.
Provides user interface and runtime management.
-
class
prince_cr.core.
PriNCeRun
(*args, **kwargs)[source]¶ This is a draft of the main class.
This class is supposed to interprete the config options and initialize all necessary stuff in order. This class is meant to keep all separate ingredients together in one place, and it is inteded to be passed to further classes via self.
prince_cr.data
– (particle) Species management¶
The prince_cr.data.SpeciesManager
handles the bookkeeping of :class:`prince_cr.data.PrinceSpecies`s.
Module inteded to contain some prince-specific data structures.
-
class
prince_cr.data.
EnergyGrid
(lower, upper, bins_dec)[source]¶ Class for constructing a grid for discrete distributions.
Since we discretize everything in energy, the name seems appropriate. All grids are log spaced.
Parameters:
-
class
prince_cr.data.
PrinceDB
[source]¶ Provides access to data stored in an HDF5 file.
The file contains all tables for runnin PriNCe. Currently the only still required file is the particle database. The tools to generate this database are publicly available in PriNCe-data-utils.
-
class
prince_cr.data.
PrinceSpecies
(ncoid, princeidx, d)[source]¶ Bundles different particle properties for simplified availability of particle properties in
prince_cr.core.PriNCeRun
.Parameters: -
indices
(grid_tag='default')[source]¶ Returns a list of all indices in the state vector.
Returns: array of indices in state vector PrinceRun.phi
Return type: (numpy.array)
-
lbin
(grid_tag='default')[source]¶ Returns lower bin of particle range in state vector.
Returns: lower bin in state vector PrinceRun.phi
Return type: (int)
-
lidx
(grid_tag='default')[source]¶ Returns lower index of particle range in state vector.
Returns: lower index in state vector PrinceRun.phi
Return type: (int)
-
ubin
(grid_tag='default')[source]¶ Returns upper bin of particle range in state vector.
Returns: upper bin in state vector PrinceRun.phi
Return type: (int)
-
uidx
(grid_tag='default')[source]¶ Returns upper index of particle range in state vector.
Returns: upper index in state vector PrinceRun.phi
Return type: (int)
-
A
= None¶ Mass, charge, neutron number
-
N
= None¶ Mass, charge, neutron number
-
Z
= None¶ Mass, charge, neutron number
-
decay_channels
= None¶ decay channels if any
-
has_redist
= None¶ (bool) particle has an energy redistribution
-
is_alias
= None¶ (bool) particle is an alias (PDG ID encodes special scoring behavior)
-
is_baryon
= None¶ (bool) particle is a baryon
-
is_charged
= None¶ (bool) particle is a lepton
-
is_em
= None¶ (bool) if it’s an electromagnetic particle
-
is_hadron
= None¶ (bool) particle is a hadron (meson or baryon)
-
is_lepton
= None¶ (bool) particle is a lepton
-
is_meson
= None¶ (bool) particle is a meson
-
is_nucleus
= None¶ (bool) particle is a nucleus
-
is_stable
= None¶ (bool) particle is stable
-
lifetime
= None¶ (float) lifetime
-
mass
= None¶ Mass in atomic units or GeV
-
ncoid
= None¶ Neucosma ID of particle
-
princeidx
= None¶ (int) Prince index (in state vector)
-
sl
¶ - Return the slice for this species on the grid
- can be used as spec[s.sl]
Returns: a slice object pointing to the species in the state vecgtor Return type: (slice)
-
sname
= None¶ (str) species name in string representation
-
-
class
prince_cr.data.
SpeciesManager
(ncoid_list, ed)[source]¶ Provides a database with particle and species.
-
add_grid
(grid_tag, dimension)[source]¶ Defines additional grid dimensions under a certain tag.
Propagates changes to this variable to all known species.
-
ncoid2princeidx
= None¶ (dict) Converts Neucosma ID to index in state vector
-
nspec
= None¶ (int) Total number of species
-
princeidx2ncoid
= None¶ (dict) Converts index in state vector to Neucosma ID
-
princeidx2sref
= None¶ (dict) Converts prince index to reference of class:data.PrinceSpecies
-
sname2princeidx
= None¶ (dict) Converts particle name to index in state vector
-
sname2sref
= None¶ (dict) Converts particle name to reference of class:data.PrinceSpecies
-
-
prince_cr.data.
db_handler
= <prince_cr.data.PrinceDB object>¶ db_handler is the HDF file interface
prince_cr.solvers
– PDE solver implementations¶
Contains solvers to solve the coupled differential equation system
The steps performed by the solver are:
Contains solvers, i.e. integrators, kernels, steppers, for PriNCe.
-
class
prince_cr.solvers.propagation.
UHECRPropagationResult
(state, egrid, spec_man)[source]¶ Reduced version of solver class, that only holds the result vector and defined add and multiply
-
get_lnA
(nco_ids, egrid=None)[source]¶ Return the average ln(A) as a function of total energy for all elements in the range
-
-
class
prince_cr.solvers.partial_diff.
SemiLagrangianSolver
(cr_grid)[source]¶ Contains routines to project spectra from shifted grids back to old grid
-
interpolate_4thorder_weights
(conloss, state)[source]¶ Uses quadratic interpolation with lagrange polynomials
-
interpolate_5thorder_weights
(conloss, state)[source]¶ Uses cubic interpolation with lagrange polynomials
-
interpolate_cubic_weights
(conloss, state)[source]¶ Uses cubic interpolation with lagrange polynomials
-
interpolate_gradient
(conloss, state)[source]¶ Uses a linear approximation arround x_i to find the new state old grid
-
prince_cr.cross_sections
– Cross section data management¶
Contains function to load and combined cross section models
prince_cr.interaction_rates
– Computation of Interaction Matrices¶
Contains function to precompute the sparse Interaction matrices efficiently
The module contains classes for computations of interaction rates
-
class
prince_cr.interaction_rates.
ContinuousAdiabaticLossRate
(prince_run, energy='grid', *args, **kwargs)[source]¶ Implementation of continuous pair production loss rates.
-
single_loss_length
(pid, z)[source]¶ Returns energy loss length in cm (convenience function for plotting)
-
spec_man
= None¶ Reference to species manager
-
-
class
prince_cr.interaction_rates.
ContinuousPairProductionLossRate
(prince_run, energy='grid', *args, **kwargs)[source]¶ Implementation of continuous pair production loss rates.
-
photon_vector
(z)[source]¶ Returns photon vector at redshift z on photon grid.
This vector is in fact a matrix of vectors of the interpolated photon field with dimensions (dim_cr, xi_steps).
Parameters: z (float) – redshift Return value from cache if redshift value didn’t change since last call.
-
single_loss_length
(pid, z, pfield=None)[source]¶ Returns energy loss length in cm (convenience function for plotting)
-
photon_field
= None¶ Reference to PhotonField object
-
spec_man
= None¶ Reference to species manager
-
-
class
prince_cr.interaction_rates.
PhotoNuclearInteractionRate
(prince_run=None, with_dense_jac=True, *args, **kwargs)[source]¶ Implementation of photo-hadronic/nuclear interaction rates. This Version directly writes the data into a CSC-matrix and only updates the data each time.
-
get_hadr_jacobian
(z, scale_fac=1.0, force_update=False)[source]¶ Returns the nonel rate vector and coupling matrix.
-
photon_vector
(z)[source]¶ Returns photon vector at redshift z on photon grid.
This vector is in fact a matrix of vectors of the interpolated photon field with dimensions (dim_cr, xi_steps).
Parameters: z (float) – redshift Return value from cache if redshift value didn’t change since last call.
-
single_interaction_length
(pid, z, pfield=None)[source]¶ Returns energy loss length in cm (convenience function for plotting)
-
cross_sections
= None¶ Reference to CrossSection object
-
photon_field
= None¶ Reference to PhotonField object
-
spec_man
= None¶ Reference to species manager
-
prince_cr.photonfields
– EBL and CMB photon fields¶
Contains different EBL models as a function of redshift
Created on Feb 22, 2017
@author: Anatoli Fedynitch
-
class
prince_cr.photonfields.
CIBDominguez2D
(model='base', simple_scaling=False)[source]¶ CIB model “3” by Gilmore et al.
CIB photon distribution for z = 0…2. Requires availability of an scipy.interp2d object file data/CIB_dominguez_int2D.ppo.
- Note: The class contains an interpolators for the upper and lower limits,
- which are not yet accessable through a function
- Ref.:
- R.C. Gilmore et al., MNRAS 410, 2556 (2011) [arXiv:1104.0671]
-
class
prince_cr.photonfields.
CIBFranceschini2D
(simple_scaling=False)[source]¶ CIB model “1” by Fraceschini et al.
CIB photon distribution for z = 0…2. Requires availability of an scipy.interp2d object file data/CIB_franceschini_int2D.ppo.
- Ref.:
- Franceschini et al., Astron. Astrphys. 487, 837 (2008) [arXiv:0805.1841]
-
class
prince_cr.photonfields.
CIBFranceschiniZ0
[source]¶ CIB model “1” by Fraceschini et al.
CIB photon distribution at z=0.
- Ref.:
- Franceschini et al., Astron. Astrphys. 487, 837 (2008) [arXiv:0805.1841]
-
class
prince_cr.photonfields.
CIBGilmore2D
(model='fiducial', simple_scaling=False)[source]¶ CIB model “3” by Gilmore et al.
CIB photon distribution for z = 0…7. Requires availability of an scipy.interp2d object file data/CIB_gilmore_int2D.ppo.
- Note: Currently uses the fixed model from the reference as standard,
- for the fiducial model, change the ‘model’ keyword
- Ref.:
- R.C. Gilmore et al., MNRAS Soc. 422, 3189 (2012) [arXiv:1104.0671]
-
class
prince_cr.photonfields.
CIBInoue2D
(model='base', simple_scaling=False)[source]¶ CIB model “2” by Inoue et al.
CIB photon distribution for z = 0…10. Requires availability of an scipy.interp2d object file data/CIB_inoue_int2D.ppo. A low and high variation of the “third-population” component are also available, by passing
- Ref.:
- Inoue et al. [arXiv:1212.1683]
-
class
prince_cr.photonfields.
CIBSteckerZ0
[source]¶ CIB model “1” by Stecker et al.
CIB photon distribution at z=0.
- Ref.:
- F.W. Stecker et al., Astrophys. J. 648, 774 (2006) [astro-ph/0510449]
-
class
prince_cr.photonfields.
CMBPhotonSpectrum
[source]¶ Redshift-scaled number density of CMB photons
In the CMB frame (equivalent to the observer’s frame). Normalisation from Planck’s spectrum. The scaling goes as . The CMB spectrum is a blackbody spectrum with the present-day temperature T0 = 2.725 K.
- Ref.:
- Ahlers, L.A. Anchordoqui, and S. Sarkar, Phys. Rev. D 79, 083009 (2009) [0902.3993]
-
class
prince_cr.photonfields.
CombinedPhotonField
(list_of_classes_and_args)[source]¶ Class to combine (sum) several models, which inherit from
PhotonField
.This class is useful when constructing a realistic photon spectrum, which is typically a superposition of CMB and CIB. The list of models can be passed to the constructor or each model can be added separately using the
add_model()
.Parameters: list_of_classes_and_args – Can be either list of classes or list of tuples (class, args)
prince_cr.cr_sources
– UHECR source class definitions¶
Defines the (simple) source injection for the extragalactic propagation
Defines source models for cosmic ray propagation
The standard interface requires to UHECRSolvers requires that each source defines a methods injection_rate(self, z)
-
class
prince_cr.cr_sources.
AugerFitSource
(prince_run, ncoids=None, params=None, norm=1.0, m='flat', *args, **kwargs)[source]¶ Simple source class with spectral index and rigidity dependent cutoff Defined to be parrallel for all species below the cutoff as in Auger Combined Fit paper
- if E < Z * Rcut:
- inj(E) = norm * E**-gamma
- else:
- inj(E) = norm * E**-gamma * exp(- E / Z * Rcut)
params defined as {pid: gamma, Rcut, norm}
-
class
prince_cr.cr_sources.
RigdityCutoffSource
(prince_run, ncoids=None, params=None, norm=1.0, m='flat', *args, **kwargs)[source]¶ Simple source class with spectral index and rigidity dependent cutoff
inj(E) = norm * E**-gamma * exp(- E / Z * Rcut)
params defined as {pid: gamma, Rcut, norm}
-
class
prince_cr.cr_sources.
RigidityFlexSource
(prince_run, ncoids=None, params=None, norm=1.0, m='flat', *args, **kwargs)[source]¶ Simple source class with spectral index and rigidity dependent cutoff Parameter alpha to scaled the rigidity dependence
inj(E) = norm * E**-gamma * exp(- E / Z**alpha * Rcut)
params defined as {pid: gamma, Rcut, alpha, norm}
-
class
prince_cr.cr_sources.
SimpleSource
(prince_run, ncoids=None, params=None, norm=1.0, m='flat', *args, **kwargs)[source]¶ Simple source class with spectral index and cutoff
inj(E) = norm * E**-gamma * exp(- E / Emax)
params defined as {pid: gamma, Emax, norm}