Skip to content

Commit

Permalink
more updates
Browse files Browse the repository at this point in the history
  • Loading branch information
zingale committed Jan 4, 2025
1 parent e891dda commit 6bc407a
Show file tree
Hide file tree
Showing 20 changed files with 131 additions and 74 deletions.
75 changes: 42 additions & 33 deletions Docs/source/one_zone_tests.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,22 @@ with density held constant and the temperature found via the equation of state,
$T = T(\rho, X_k, e)$.


.. note::

Since the energy evolves due to the heat release (or loss)
from reactions, the temperature will change during the burn.


Getting Started
---------------

The ``burn_cell`` code are located in
The ``burn_cell`` code is located in
``Microphysics/unit_test/burn_cell``. An inputs file which sets the
default parameters for your choice of network is needed to run the
test. There are a number of inputs file in the unit test directory
already with a name list ``inputs_burn_network``, where network
is the network you wish to use for your testing.
test. There are a number of inputs files in the unit test directory
already with a name list ``inputs_network``, where ``network``
is the network you wish to use for your testing. These can be
used as a starting point for any explorations.


Setting the thermodynamics
Expand All @@ -53,7 +60,8 @@ The parameters that affect the thermodynamics are:

* ``unit_test.small_dens`` : the low density cutoff used in the equation of state

The composition can be set either by setting each mass fraction explicitly,
The composition can be set either by setting each mass fraction explicitly via the
parameters, ``unit_test.X1``, ``unit_test.X2``, ...,
e.g.:

::
Expand Down Expand Up @@ -126,47 +134,48 @@ Microphysics build system parameters, e.g.,

make NETWORK_DIR=aprox19 INTEGRATOR_DIR=rkc

The build process will automatically create links in the build
directory to the EOS table and any reaction rate tables needed by your
choice of network.


.. important::

You need to do a ``make clean`` before rebuilding with a different
network or integrator.


To run the code, enter the burn_cell directory and run::

./main3d.gnu.ex inputs

where ``inputs`` is the name of your inputs file.

For each of the ``numsteps`` steps defined in the inputs
file, the code will output a files into a new directory titled
``run_prefix_output`` where ``run_prefix`` is the run prefix defined in the
inputs file. Each output file will be named using the run prefix
defined in the inputs file and the corresponding timestep.

Next, run ``burn_cell.py`` using python 3.x, giving the defined run prefix as an argument.
For example::
Working with Output
-------------------

python3 burn_cell.py react_aprox13
.. note::

The ``burn_cell.py`` code will gather information from all of the
output files and compile them into three graphs explained below.
For this part, we'll assume that the default ``aprox13`` and
``VODE`` options were used for the network and integrator, and the
test was run with ``inputs.aprox13``.

Graphs Output by ``burn_cell.py``
---------------------------------
As the code runs, it will output to ``stdout`` details of the initial
and final state and the number of integration steps taken (along with whether
the burn was successful). The full history of the thermodynamic state will also be output to a file,
``state_over_time.txt``, with each line corresponding to one of the
``nsteps`` requested in the time integration.

The file ``run-prefix_logX.png`` and ``run-prefix_logX.eps`` will display a
graph of the chemical abundances as a function of the time, both on
logarithmic scales, for all species involved in the simulation. An
example of this graph is shown below.
The script ``plot_burn_cell.py`` can be used to visualize the evolution:

.. figure:: react_aprox13_logX.png
:alt: An example of a plot output by the burn_cell unit test. This is the logX output corresponding to the network aprox13.
:width: 4.5in

An example of a plot output by the burn_cell unit test. This is the
logX output corresponding to the network aprox13.
.. prompt:: bash

python plot_burn_cell.py state_over_time.txt

This will generate the following figure:

The file ``run-prefix_ydot.png`` and ``run-prefix_ydot.eps`` will display the
molar fraction (mass fraction / atomic weight) as a function of time,
both on logarithmic scales, for all species involved in the code.
.. figure:: state.png
:alt: An example of a plot output by the burn_cell unit test.

The file ``run-prefix_T-edot.png`` and ``run-prefix_T-edot.eps`` will display
the temperature and the energy generation rate as a function of time.
Only the most abundant species are plotted. The number of species to plot and the
limits of $X$ can be set via runtime parameters (see ``python plot_burn_cell.py -h``).
26 changes: 24 additions & 2 deletions Docs/source/runtime_parameters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,30 @@ namespace: ``network``



**NETWORK_DIR=he-burn.bak/he-burn-18a:**

+---------------------------------------+---------------------------------------------------------+------------------------------+
| parameter | description | default value |
+=======================================+=========================================================+==============================+
| ``disable_p_C12_to_N13`` | | 0 |
+---------------------------------------+---------------------------------------------------------+------------------------------+
| ``disable_He4_N13_to_p_O16`` | | 0 |
+---------------------------------------+---------------------------------------------------------+------------------------------+



**NETWORK_DIR=he-burn.bak/he-burn-22a:**

+---------------------------------------+---------------------------------------------------------+------------------------------+
| parameter | description | default value |
+=======================================+=========================================================+==============================+
| ``disable_p_C12_to_N13`` | | 0 |
+---------------------------------------+---------------------------------------------------------+------------------------------+
| ``disable_He4_N13_to_p_O16`` | | 0 |
+---------------------------------------+---------------------------------------------------------+------------------------------+



**NETWORK_DIR=metal_chem:**

+---------------------------------------+---------------------------------------------------------+------------------------------+
Expand Down Expand Up @@ -1089,8 +1113,6 @@ namespace: ``unit_test``
+---------------------------------------+---------------------------------------------------------+------------------------------+
| parameter | description | default value |
+=======================================+=========================================================+==============================+
| ``run_prefix`` | | "" |
+---------------------------------------+---------------------------------------------------------+------------------------------+
| ``small_temp`` | | 1.e5 |
+---------------------------------------+---------------------------------------------------------+------------------------------+
| ``small_dens`` | | 1.e5 |
Expand Down
2 changes: 0 additions & 2 deletions unit_test/burn_cell/_parameters
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
@namespace: unit_test

run_prefix string ""

small_temp real 1.e5
small_dens real 1.e5

Expand Down
2 changes: 0 additions & 2 deletions unit_test/burn_cell/inputs_aprox13
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
unit_test.run_prefix = "react_aprox13_"

unit_test.small_temp = 1.e5
unit_test.small_dens = 1.e5

Expand Down
2 changes: 0 additions & 2 deletions unit_test/burn_cell/inputs_aprox13_mott
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
unit_test.run_prefix = "react_aprox13_mott_"

unit_test.small_temp = 1e5
unit_test.small_dens = 1e5

Expand Down
2 changes: 0 additions & 2 deletions unit_test/burn_cell/inputs_aprox19
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
unit_test.run_prefix = "react_aprox19_"

unit_test.small_temp = 1.e5
unit_test.small_dens = 1.e5

Expand Down
2 changes: 0 additions & 2 deletions unit_test/burn_cell/inputs_aprox19.nse
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
unit_test.run_prefix = "react_aprox19_nse_"

unit_test.small_temp = 1.e5
unit_test.small_dens = 1.e5

Expand Down
2 changes: 0 additions & 2 deletions unit_test/burn_cell/inputs_aprox21
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
unit_test.run_prefix = "react_aprox21_"

unit_test.small_temp = 1e5
unit_test.small_dens = 1e5

Expand Down
2 changes: 0 additions & 2 deletions unit_test/burn_cell/inputs_aprox21_rot1
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
unit_test.run_prefix = "react_aprox21_rot1_"

unit_test.small_temp = 1e5
unit_test.small_dens = 1e5

Expand Down
2 changes: 0 additions & 2 deletions unit_test/burn_cell/inputs_aprox21_rot2
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
unit_test.run_prefix = "react_aprox21_rot2_"

unit_test.small_temp = 1e5
unit_test.small_dens = 1e5

Expand Down
2 changes: 0 additions & 2 deletions unit_test/burn_cell/inputs_ecsn
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
unit_test.run_prefix = "react_ecsn_"

unit_test.small_temp = 1.e5
unit_test.small_dens = 1.e5

Expand Down
2 changes: 0 additions & 2 deletions unit_test/burn_cell/inputs_ignition
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
unit_test.run_prefix = "react_ignition_"

unit_test.small_temp = 1e5
unit_test.small_dens = 1e5

Expand Down
2 changes: 0 additions & 2 deletions unit_test/burn_cell/inputs_ignition_chamulak
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
unit_test.run_prefix = "react_ignition_chamulak_"

unit_test.small_temp = 1e5
unit_test.small_dens = 1e5

Expand Down
2 changes: 0 additions & 2 deletions unit_test/burn_cell/inputs_iso7
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
unit_test.run_prefix = "react_iso7_"

unit_test.small_temp = 1e5
unit_test.small_dens = 1e5

Expand Down
2 changes: 0 additions & 2 deletions unit_test/burn_cell/inputs_rprox
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
unit_test.run_prefix = "react_rprox_"

unit_test.small_temp = 1e5
unit_test.small_dens = 1e5

Expand Down
2 changes: 0 additions & 2 deletions unit_test/burn_cell/inputs_subch_simple
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
unit_test.run_prefix = "react_subch_simple_"

unit_test.small_temp = 1.e5
unit_test.small_dens = 1.e5

Expand Down
2 changes: 0 additions & 2 deletions unit_test/burn_cell/inputs_triple
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
unit_test.run_prefix = "react_triple_"

unit_test.small_temp = 1e5
unit_test.small_dens = 1e5

Expand Down
2 changes: 0 additions & 2 deletions unit_test/burn_cell/inputs_vode_example
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
unit_test.run_prefix = "react_vode_example_"

unit_test.small_temp = 1.e5
unit_test.small_dens = 1e5

Expand Down
7 changes: 0 additions & 7 deletions unit_test/burn_cell/matplotlibrc

This file was deleted.

65 changes: 65 additions & 0 deletions unit_test/burn_cell/plot_burn_cell.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import argparse

import matplotlib.pyplot as plt
from matplotlib import ticker
import numpy as np


def doit(state_file, xmin, n_plot, outfile):

data = np.genfromtxt(state_file, names=True)

# find the keys of the most abundant species
maxX = {}
for k in data.dtype.names:
if k in ["Time", "Temperature"]:
continue
maxX[k] = data[k].max()

abundant = [k for k, v in sorted(maxX.items(), key=lambda item: item[1])][::-1]

fig , (ax1, ax2) = plt.subplots(2, 1, sharex=True)

ax1.plot(data["Time"], data["Temperature"])
ax1.set_xscale("log")
ax1.grid(ls=":")

ax1.set_ylabel("temperature [K]")
ax1.yaxis.set_major_formatter(ticker.ScalarFormatter(useMathText=True))

# now the species
for n in range(n_plot):
ax2.plot(data["Time"], data[abundant[n]], label=abundant[n])

ax2.set_xscale("log")
ax2.set_yscale("log")
ax2.set_ylim(xmin, 1.5)
ax2.grid(ls=":")

ax2.set_xlabel("time (s)")
ax2.set_ylabel("mass fraction")

ax2.legend(fontsize="small")

fig.tight_layout()

fig.set_size_inches(6, 7)

fig.savefig(outfile)


if __name__ == "__main__":

parser = argparse.ArgumentParser()
parser.add_argument("--xmin", type=float, default=1.e-10,
help="cutoff value for mass fractions")
parser.add_argument("-n", type=int, default=5,
help="number of species to plot (most abundant shown)")
parser.add_argument("-o", type=str, default="state.png",
help="name of plot output file")
parser.add_argument("state_file", type=str, nargs=1,
help="burn cell state history file")

args = parser.parse_args()

doit(args.state_file[0], args.xmin, args.n, args.o)

0 comments on commit 6bc407a

Please sign in to comment.