pynucastro.rates.reaclib_rate module#
- class pynucastro.rates.reaclib_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 from the ReacLib library, which can be composed of multiple sets.
- Parameters:
rfile (str, pathlib.Path, io.StringIO) – the data file or string containing the rate in ReacLib format.
chapter (int) – the ReacLib chapter describing the number of reactants and products
original_source (str) – the original source. This is usually set automatically when reading
rfile
, but can be manually provided when adding rates together.reactants (list(str), list(Nucleus)) – the reactants for the reaction
products (list(str), list(Nucleus)) – the products for the reaction
labelprops (str) – a collection of flags that classify a ReacLib rate
Q (float) – the energy release (in MeV)
- Raises:
RateFileError – If the rate file is not correctly formatted.
UnsupportedNucleus – If the nucleus is unknown to pynucastro
- eval(T, *, rho=None, comp=None)[source]#
Evaluate the reaction rate for temperature T
- Parameters:
T (float) – the temperature to evaluate the rate at
rho (float) – the density to evaluate the rate at (not needed for ReacLib rates).
comp (float) – the composition (of type
Composition
) to evaluate the rate with (not needed for ReacLib rates).
- Return type:
- eval_deriv(T, *, rho=None, comp=None)[source]#
Evaluate the derivative of reaction rate with respect to T
- Parameters:
T (float) – the temperature to evaluate the rate at
rho (float) – the density to evaluate the rate at (not needed for ReacLib rates).
comp (float) – the composition (of type
Composition
) to evaluate the rate with (not needed for ReacLib rates).
- Return type:
- function_string_cxx(dtype='double', specifiers='inline', leave_open=False, extra_args=None)[source]#
Return a string containing the C++ function that computes the rate
- Parameters:
dtype (str) – The C++ datatype to use for all declarations
specifiers (str) – C++ specifiers to add before each function declaration (i.e. “inline”)
leave_open (bool) – If
true
, then we leave the function unclosed (no “}” at the end). This can allow additional functions to add to this output.extra_args (list, tuple) – A list of strings representing additional arguments that should be appended to the argument list when defining the function interface.
- Return type:
- function_string_py()[source]#
Return a string containing the python function that computes the rate.
- Return type:
- 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.
- Return type:
- plot(Tmin=100000000.0, Tmax=1600000000.0, rhoYmin=390000000.0, rhoYmax=2000000000.0, figsize=(10, 10))[source]#
Plot the rate’s temperature sensitivity vs temperature
- Parameters:
- Return type:
- class pynucastro.rates.reaclib_rate.SingleSet(a, labelprops)[source]#
Bases:
object
A single ReacLib set for a reaction in the form:
λ = 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 (list, numpy.ndarray) – the coefficients of the exponential fit
labelprops (str) – a collection of flags that classify a ReacLib rate
- dfdT()[source]#
Return a function for the temperature derivative of the set,
dratedT(tf)
, wheretf
is aTfactors
object
- dln_set_string_dT9_cxx(*, prefix='dset_dT', plus_equal=False)[source]#
Generate the C++ code to evaluate d/dT9 ln(set).