pynucastro.networks.python_network module#

Support modules to write a pure python reaction network ODE source

class pynucastro.networks.python_network.PythonNetwork(rate_files=None, libraries=None, rates=None, inert_nuclei=None, symmetric_screening=False, do_screening=True)[source]#

Bases: RateCollection

A pure python reaction network. This can create a python module as a file that contains everything needed to evaluate the reaction rates and construct the righthand side and Jacobian functions.

full_jacobian_element_string(ydot_i_nucleus, y_j_nucleus, indent='')[source]#

Construct a string containing the python code for a single element of the Jacobian, dYdot(ydot_i_nucleus)/dY(y_j_nucleus)

Parameters:
  • ydot_i_nucleus (Nucleus) – The nucleus representing the dY/dt term we are differentiating. This is the row of the Jacobian.

  • ydot_j_nucleus (Nucleus) – The nucleus we are differentiating with respect to. This is the column of the Jacobian.

  • indent (str) – A string that will be prepended to each line of the output, typically consisting of just spaces representing the amount of indent desired.

Return type:

str

full_ydot_string(nucleus, indent='')[source]#

Construct a string containing the python code for dY(nucleus)/dt by considering every reaction that involves nucleus, adding terms that result in its creation and subtracting terms representing its destruction.

Parameters:
  • nucleus (Nucleus) – The nucleus we are constructing the time derivative of.

  • indent (str) – A string that will be prepended to each line of the output, typically consisting of just spaces representing the amount of indent desired.

Return type:

str

rates_string(indent='')[source]#

Create the python code that calls the evaluation function for each rate. Typically this is of the form name(rate_eval, ...), where rate_eval is a container class in the output network that stores the rate values. This also calls screening_string() after the main rates are evaluated but before the approximate rates are constructed.

Parameters:

indent (str) – A string that will be prepended to each line of the output, typically consisting of just spaces representing the amount of indent desired.

Return type:

str

screening_string(indent='')[source]#

Create a string containing the python code that sets up the screening (PlasmaState) and calls the screening function on every set of reactants in our network, and updating the reaction rate values stored in the network.

Parameters:

indent (str) – A string that will be prepended to each line of the output, typically consisting of just spaces representing the amount of indent desired.

Return type:

str