pynucastro.networks.base_cxx_network module#

The generated C++ Jacobian includes explicit composition derivatives of rate coefficients for species listed in Rate.rate_comp_dependence. For a reaction contribution \(f_j = C_j(Y, \rho)\lambda(Y)\), it uses the product rule, \(\partial f_j/\partial Y_i = \lambda\,\partial C_j/\partial Y_i + C_j\,\partial\lambda/\partial Y_i\). The coefficient derivatives are read from rate_derivs_t; for example, the effective Fe52(nn, gamma)Fe54 rate contributes a term using drate_Fe52_n_n_to_Fe54_approx_dYN.

Support for a pure C++ reaction network. These functions will write the C++ code necessary to integrate a reaction network comprised of the rates that are passed in.

class pynucastro.networks.base_cxx_network.BaseCxxNetwork(*args, **kwargs)[source]#

Bases: ABC, RateCollection

Base class for a C++ network. This takes the same arguments as RateCollection and interprets the collection of rates and nuclei to produce the C++ code needed to integrate the network.

compose_jacobian()[source]#

Create the Jacobian matrix, df/dY, where f is a dY/dt and Y is a molar fraction

The Jacobian is stored as a list with each entry representing a Jacobian element in row-major order: i is the Ydot row and j is the abundance column we differentiate with respect to. We also store whether the entry is null.

compose_ydot()[source]#

Create the expressions for dY/dt for each nucleus, where Y is the molar fraction.

This stores the result in a dict where the key is a Nucleus, and the value is a list of tuples, with the forward-reverse pairs of a rate

get_indent_amt(l, k)[source]#

Determine the amount of spaces to indent a line. This looks for a string of the form “<key>(#)”, where # is the a number that is the amount of indent.

Parameters:
  • l (str) – a line from a template file to check for an indent

  • k (str) – a keyword of the form “<key>” that appears in the line

Return type:

int

write_screen_var(n_indent, of, rate, do_T_derivatives=True)[source]#

Return the string that composes the screening variable for a rate.