pynucastro.rates.modified_rate module#

Classes and methods for describing rates where one or more properties have been modified from the original source.

class pynucastro.rates.modified_rate.ModifiedRate(original_rate, *, stoichiometry=None, new_reactants=None, new_products=None, update_screening=False, not_in_ydot_term=None, description=None, rate_source=None)[source]#

Bases: Rate

A modified rate takes an original rate and changes some properties of it. The evaluation of the original rate will still be used for the actual rate, but the modified rate can have a different products (and therefore Q value) or stoichiometric coefficients

Parameters:
  • original_rate (Rate) – the underlying rate we are evaluating numerically to get the number of reactions / sec (with suitable volume scalings)

  • stoichiometry (dict(Nucleus)) – a custom set of coefficients to be used in the evolution equations dY(Nucleus)/dt. If this is not set, then simply the count of each nucleus in the list of reactants and products will be used.

  • new_reactants (list(Nucleus)) – a list of nuclei that should be used as the reactants of the modified rate, instead of the reactants from the original rate.

  • new_products (list(Nucleus)) – a list of nuclei that should be used as the products of the modified rate, instead of the products from the original rate.

  • update_screening (bool) – do we reset the screening pairs for this rate to reflect any new products or stoichiometry? or do we still screen based on the underlying rate?

  • not_in_ydot_term (list(Nucleus)) – A list of nuclei that appear in reactants but should not contribute to the Y[nuc] scaling in the dY/dt term of the rate equations. As an example, consider the sequence: He4(He3,γ)Be7(e-,ν)Li7(p,α)He4. Here, He4, He3, and p are consumed, but if we want to model this using just the first rate in the sequence, then the dY/dt term is ρY(He3)Y(He4)λ, Even though p doesn’t appear here, we still want to account for its consumption in dY(p)/dt.

  • description (str) – a description of the rate sequence we are approximating. This will be added as a comment to code outputs.

  • rate_source (str) – the key to get the source information for the rate from rate_sources.csv. This information is also used in the unique Rate.id

function_string_cxx(dtype='double', specifiers='inline', leave_open=False, extra_args=())[source]#

Return a string containing the C++ function that computes the rate. For a ModifiedRate, this simply calls the corresponding function for the underlying original 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:

str

function_string_py()[source]#

Return a string containing the python function that computes the rate – in this case it is the underlying original rate.

Return type:

str

log_eval(T, *, rho=None, comp=None, screen_func=None)[source]#

Evaluate natural log of reaction rates for the modified rate. This simply calls the evaluation of the underlying original rate.

Parameters:
  • T (float) – the temperature to evaluate the rate at

  • rho (float) – the density to evaluate screening effects at.

  • comp (float) – the composition (of type Composition) to evaluate screening effects with.

  • screen_func (Callable) – one of the screening functions from pynucastro.screening – if provided, then the rate will include screening correction.

Return type:

numpy.ndarray