pynucastro.networks.sympy_network_support module#

Support functions for interpreting the rates, ydots, and Jacobian through SymPy.

class pynucastro.networks.sympy_network_support.SympyRates[source]#

Bases: object

A collection of rates stored as SymPy objects.

cxxify(s)[source]#

Given string s, generated from a SymPy expression, replace the placeholder symbols with the values maintained in the symbol_ludict dictionary.

Parameters:

s (str) – the input string

Return type:

str

jacobian_term_symbol(rate, ydot_j, y_i)[source]#

Construct a SymPy expression containing a single rate’s contribution to the Jacobian matrix element d(dY_j/dt)/dY_i. We return both the SymPy expression and a bool indicating whether the term is null.

Parameters:
  • rate (Rate) – the rate we are considering

  • ydot_j (Nucleus) – the evolution equation, dY_j/dt we are working on

  • y_i (Nucleus) – the nucleus we are differentiating with respect to.

Return type:

tuple(sympy.core.expr.Expr, bool)

specific_rate_symbol(rate)[source]#

Construct a SymPy expression containing this rate’s term in a dY/dt equation, e.g. ρ Y(A)Y(B) <σv> / (1 + ẟ_AB) for a rate A + B

Also enter the symbol and substitution in the lookup table.

Parameters:

rate (Rate) – the reaction rate to consider

Return type:

sympy.core.expr.Expr

ydot_term_symbol(rate, y_i)[source]#

Construct a sympy expression containing this rate’s contribution to the ydot term for nuclide y_i.

Parameters:
  • rate (Rate) – the reaction rate we are working with

  • y_i (Nucleus) – the nucleus for which we want to construct the dY/dt term corresponding to rate.

Return type:

sympy.core.expr.Expr