pynucastro.rates package
The core routines needed to read and interpret nuclear reaction rates
Submodules
pynucastro.rates.known_duplicates module
pynucastro.rates.library module
- class pynucastro.rates.library.LangankeLibrary[source]
Bases:
TabularLibrary
Load all of the tabular rates inside /library/tabular/langanke/ and return a Library.
- lib_path = '/opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/site-packages/pynucastro/rates/../library/tabular/langanke'
- class pynucastro.rates.library.Library(libfile=None, rates=None)[source]
Bases:
object
A Library is a Rate container that reads a single file containing one or many Reaclib rates, possibly containing multiple sets per rate.
The Library class also implements searching based on rules specified by RateFilter objects.
- derived_backward(compute_Q=False, use_pf=False)[source]
This library contains the detailed balance reverse reactions over the selected .derived_forward(), computed by hand.
- derived_forward()[source]
In this library, we exclude the weak and tabular rates from the .forward() library which includes all the ReacLib forward reactions.
In a future PR, we will classify forward reactions as exothermic (Q>0), and reverse by endothermic (Q<0). However, ReacLib does not follow this path. If a reaction is measured experimentally (independent of Q), they use detailed balance to get the opposite direction. Eventually, I want to classify forward and reverse by positive Q and negative Q; however, for testing purposes, making this classification may eventually lead to computing the detailed balance twice.
The idea of derived_forward is to eliminate the reverse and weak, and see if our job gives the same Reaclib predictions, checking the NSE convergence with the pf functions. In the future, I want to move this function in a unit test.
- diff(other_library)[source]
Return a Library containing the rates in this library that are not contained in other_library
- filter(filter_spec)[source]
filter_specs should be an iterable of RateFilter objects or a single RateFilter object. Library.filter yields all rates matching any RateFilter in filter_specs. If RateFilter.exact, then return rates with exactly the reactants or products passed in as arguments.
- find_duplicate_links()[source]
report on an rates where another rate exists that has the same reactants and products. These may not be the same Rate object (e.g., one could be tabular the other a simple decay), but they will present themselves in the network as the same link.
We return a list, where each entry is a list of all the rates that share the same link
- forward()[source]
Select only the forward rates, discarding the inverse rates obtained by detailed balance.
- get_rate_by_name(name)[source]
Given a string representing a rate in the form ‘A(x,y)B’ (or a list of strings for multiple rates) return the Rate objects that match from the Library. If there are multiple inputs, then a list of Rate objects is returned.
- get_rate_by_nuclei(reactants, products)[source]
given a list of reactants and products, return any matching rates
- linking_nuclei(nuclist, with_reverse=True, print_warning=True)[source]
Return a Library object containing the rates linking the nuclei provided in the list of Nucleus objects or nucleus abbreviations ‘nuclist’.
If with_reverse is True, then include reverse rates. Otherwise include only forward rates.
If print_warning is True, then print out a warning if one of the input nuclei is not linked.
- class pynucastro.rates.library.RateFilter(reactants=None, products=None, exact=True, reverse=None, min_reactants=None, max_reactants=None, min_products=None, max_products=None, filter_function=None)[source]
Bases:
object
RateFilter filters out a specified rate or set of rates A RateFilter stores selection rules specifying a rate or group of rates to assist in searching for rates stored in a Library.
- class pynucastro.rates.library.ReacLibLibrary[source]
Bases:
Library
Load the latest stored version of the ReacLib library and return a Library
- class pynucastro.rates.library.SuzukiLibrary[source]
Bases:
TabularLibrary
Load all of the tabular rates inside /library/tabular/suzuki/ and return a Library.
- lib_path = '/opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/site-packages/pynucastro/rates/../library/tabular/suzuki'
pynucastro.rates.rate module
Classes and methods to interface with files storing rate data.
- class pynucastro.rates.rate.ApproximateRate(primary_rate, secondary_rates, primary_reverse, secondary_reverse, is_reverse=False, approx_type='ap_pg')[source]
Bases:
ReacLibRate
- function_string_cxx(dtype='double', specifiers='inline', leave_open=False, extra_args=())[source]
Return a string containing C++ function that computes the approximate rate
- class pynucastro.rates.rate.DerivedRate(rate, compute_Q=False, use_pf=False)[source]
Bases:
ReacLibRate
This class is a derived class from Rate with the purpose of computing the inverse rate by the application of detailed balance to the forward reactions.
- counter_factors()[source]
This function returns the nucr! = nucr_1! * … * nucr_r! for each repeated nucr reactant and nucp! = nucp_1! * … * nucp_p! for each reactant nucp product in a ordered pair (nucr!, nucp!). The factors nucr! and nucp! avoid overcounting when more than one nuclei is involve in the reaction, otherwise it will return 1.0.
- class pynucastro.rates.rate.Rate(reactants=None, products=None, Q=None, weak_type='', label='generic')[source]
Bases:
object
The base reaction rate class. Most rate types will subclass this and extend to their particular format.
- eval_jacobian_term(T, rho, comp, y_i)[source]
Evaluate drate/d(y_i), y_i is a Nucleus object. This rate term has the full composition and density dependence, i.e.:
rate = rho**n Y1**a Y2**b … N_A <sigma v>
The derivative is only non-zero if this term depends on nucleus y_i.
- heaviest()[source]
Return the heaviest nuclide in this Rate.
If two nuclei are tied in mass number, return the one with the lowest atomic number.
- jacobian_string_py(y_i)[source]
Return a string containing the term in a jacobian matrix in a reaction network corresponding to this rate differentiated with respect to y_i
y_i is an object of the class
Nucleus
.
- exception pynucastro.rates.rate.RateFileError[source]
Bases:
Exception
An error occurred while trying to read a Rate from a file.
- class pynucastro.rates.rate.RatePair(forward=None, reverse=None)[source]
Bases:
object
the forward and reverse rates for a single reaction sequence. Forward rates are those with Q >= 0.
- Variables:
forward – the forward reaction Rate object
reverse – the reverse reaction Rate object
- class pynucastro.rates.rate.ReacLibRate(rfile=None, chapter=None, original_source=None, reactants=None, products=None, sets=None, labelprops=None, Q=None)[source]
Bases:
Rate
A single reaction rate. Currently, this is a ReacLib rate, which can be composed of multiple sets, or a tabulated electron capture rate.
- Raises:
- function_string_cxx(dtype='double', specifiers='inline', leave_open=False, extra_args=())[source]
Return a string containing C++ function that computes the rate
- get_rate_exponent(T0)[source]
for a rate written as a power law, r = r_0 (T/T0)**nu, return nu corresponding to T0
- get_rate_id()[source]
Get an identifying string for this rate. Don’t include resonance state since we combine resonant and non-resonant versions of reactions.
- class pynucastro.rates.rate.SingleSet(a, labelprops)[source]
Bases:
object
a set in Reaclib is one piece of a rate, in the form
lambda = exp[ a_0 + sum_{i=1}^5 a_i T_9**(2i-5)/3 + a_6 log T_9]
A single rate in Reaclib can be composed of multiple sets
- Parameters:
a – the coefficients of the exponential fit
labelprops – a collection of flags that classify a ReacLib rate
- dln_set_string_dT9_cxx(prefix='dset_dT', plus_equal=False)[source]
return a string containing the C++ code for d/dT9 ln(set)
- class pynucastro.rates.rate.TableIndex(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
Enum
a simple enum-like container for indexing the electron-capture tables
- DQ = 3
- GAMMA = 7
- MU = 2
- NU = 6
- RATE = 5
- RHOY = 0
- T = 1
- VS = 4
- class pynucastro.rates.rate.TableInterpolator(*args, **kwargs)[source]
Bases:
TableInterpolator
A simple class that holds a pointer to the table data and methods that allow us to interpolate a variable
- class_type = jitclass.TableInterpolator#7fcacc4da090<data:array(float64, 2d, A),table_rhoy_lines:int32,table_temp_lines:int32,rhoy:array(float64, 1d, A),temp:array(float64, 1d, A)>
- class pynucastro.rates.rate.TabularRate(rfile=None)[source]
Bases:
Rate
A tabular rate.
- Raises:
- get_rate_id()[source]
Get an identifying string for this rate. Don’t include resonance state since we combine resonant and non-resonant versions of reactions.
- class pynucastro.rates.rate.Tfactors(*args, **kwargs)[source]
Bases:
Tfactors
precompute temperature factors for speed
- Parameters:
T (float) – input temperature (Kelvin)
- Variables:
T9 – T / 1.e9 K
T9i – 1.0 / T9
T913i – 1.0 / T9 ** (1/3)
T913 – T9 ** (1/3)
T953 – T9 ** (5/3)
lnT9 – log(T9)
- class_type = jitclass.Tfactors#7fcacc4be250<T9:float64,T9i:float64,T913:float64,T913i:float64,T953:float64,lnT9:float64>