pynucastro.rates.branched_rate module#

Classes and methods for describing rate sequences that have branching endpoints.

class pynucastro.rates.branched_rate.BranchedRate(underlying_rate, *, primary_branch=None, other_branch=None, stoichiometry=None, description=None)[source]#

Bases: Rate

A branched rate represents a sequence that can have different endpoints depending on branching. It takes an underlying_rate which will be used to evaluate the rate, and then takes a primary_branch and other_branches rate(s) that are used to normalize the rate. The products of the rate are set to be the products of the primary_branch.

An example application would be the sequences:

N14(p,γ)O15(,e⁺ν)N15(p,α)C12 N14(p,γ)O15(,e⁺ν)N15(p,γ)O16

These differ only in the last rate. We would set the underlying_rate to be N14(p,γ)O15, the primary_branch to be N15(p,α)C12 and the secondary branch to be N15(p,γ))O16. It would then compute the branching ratio:

f = λ_{N15(p,α)C12} / (λ_{N15(p,α)C12} + λ_{N15(p,γ)O16)

and the final rate evaluation would be

λ = f λ_{N14(p,γ)O15}

Parameters:
  • underlying_rate (Rate) – the underlying rate we are evaluating numerically to get the number of reactions / sec (with suitable volume scalings), reduced by the branching fraction

  • primary_branch (Rate) – the branch we want this sequence to use

  • other_branch (Rate) – an alternate branch used in normalization

  • 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.

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

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

Evaluate the branched 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:

float

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 BranchedRate, this returns the underlying original rate modified by the branching ratio.

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 rate modified by the branching ratio

Return type:

str

get_child_rates()[source]#

Return a list of all of the rates that are used in this approximation.

Return type:

list(Rate)

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

Evaluate the natural log of reaction rate for approximate 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:

float