AMReX Astro Microphysics Networks#
pynucastro can generate a C++ network that works in the
AMReX-Astro Microphysics. This is done through
the AmrexAstroCxxNetwork class. A simple
C++ 3-alpha network that works with Microphysics can be created via:
import pynucastro as pyna
reaclib_library = pyna.ReacLibLibrary()
mylib = reaclib_library.linking_nuclei(["he4", "c12", "o16"])
net = pyna.AmrexAstroCxxNetwork(libraries=[mylib], rate_params=[r])
net.write_network()
The C++ network uses a set of template files in
pynucastro/templates/amrexastro-cxx-microphysics/ which have
placeholders of the form <func>(num). Here,
funcis a tag that corresponds to a function that will be called to write the output in this locationnumis the number of indentations for that line of code
In BaseCxxNetwork, there is a dictionary of function tags and the corresponding function
called ftags. Any network class that derives from this can add to this list to specialize
the output.
When the network is written, each template file is read and output line by line, injecting the code output by a function if the line has a function tag in it.
For the generation of the righthand side of the network itself, we use
SymPy to build up an expression for each term and then use SymPy’s
cxxcode function to translate it into C++ code. This is managed by the SympyRates class.
This will directly write out the C++ code into a collection of headers and source files. These are:
actual_network.HThis header simply stores the number of rates, and separately the number of ReacLib and tabular rates, as well as defines the arrays that hold the rate data.
actual_rhs.HThis defines the function to compute the energy release from the network as well as evaluate the rates and construct the “ydot” and Jacobian terms. Function tags are used to compute the screening factors, compute the tabular rates, and build the ydot and Jacobian, and include any plasma neutrino losses.
derived_rates.HThis computes any rates that are derived via detailed balance, with a function provided for each rate.
interp_tools.HThis contains interpolation functions used by tabulated rates.
partition_functions.HThis holds the partition function data (inline) and the functions to interpolate it.
reaclib_rates.HThis computes the ReacLib reaction rates, with a function provided for each rate.
table_rates.HThis manages
TabularRaterates and interpolating the data. The rate data itself is stored inline in the header file.Warning
We do not check if the thermodynamic conditions for evaluating the rate fall outside of the tabulation. Instead we simply extrapolate from the edge of the table. See Tabulated weak nuclear reaction rates for the bounds of the data.
temperature_table_ratesThis manages
TemperatureTabularRaterates and interpolating their data. The rate data itself is stored inline in the header file.tfactors.HThis stores the
structthat holds the different temperature factors used in the reaction rates.
Finally, there are a few meta-data files:
pynucastro.netThis lists the nuclei in the network and their properties in a format that Microphysics requires.
Make.packageThis is a stub for the build system that list the files needed to build the network.
_parametersThis lists the runtime parameters that affect the network.
Using the network#
To use the network, there are 2 options.
You can use the unit tests in
Microphysics/unit_test/, for example,burn_cellwill do a single-zone burn.You can add the argument
standalone_build=Trueto thewrite_network()function to output a basicmain.cppandGNUmakefile. This still requires a copy ofMicrophysics, and expect the environment variableMICROPHYSICS_HOMEto point to its root directory. You can then build simply as:makeand run as:
./main3d.gnu.ex testing.density=1.e6 testing.temperature=1.e9where the density and temperature are set via runtime parameters as shown. To control the screening, use the
SCREEN_METHODbuild parameter from Microphysics. For example, to disable screening, we can do:make SCREEN_METHOD=null