Skip to content

Commit e668354

Browse files
zingaleaisclark91biboyd
authored
Document the build system (#1760)
Co-authored-by: Alexander Smith <[email protected]> Co-authored-by: Brendan Boyd <[email protected]>
1 parent 4532398 commit e668354

File tree

5 files changed

+231
-0
lines changed

5 files changed

+231
-0
lines changed

Docs/source/build_system.rst

+220
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,220 @@
1+
************
2+
Build System
3+
************
4+
5+
Microphysics leverages the AMReX build system. GNU make is the
6+
primary build system, but CMake is partially supported. Here we focus
7+
on the GNU make build system.
8+
9+
.. tip::
10+
11+
All of the build variables supported by the AMReX build system can
12+
be used with Microphysics, for example:
13+
14+
* ``COMP`` : the compiler system to use
15+
* ``USE_CUDA`` : build for NVIDIA GPUs with CUDA
16+
* ``USE_HIP`` : build for AMD GPUs with HIP/ROCm
17+
18+
See the `AMReX GNU Make Docs
19+
<https://amrex-codes.github.io/amrex/docs_html/BuildingAMReX.html>`_
20+
21+
There are two main makefile stubs:
22+
23+
.. index:: Make.Microphysics, Make.Microphysics_extern
24+
25+
* ``Make.Microphysics`` : this is used by the unit tests within Microphysics and it
26+
defines the variables needed by the AMReX build system, including specifying the
27+
location of the files. It also defines the rules for some files that are created
28+
at build time.
29+
30+
* ``Make.Microphysics_extern`` : this is the core makefile stub for Microphysics
31+
that interprets the build variables that enable / disable different functionality.
32+
This is meant to be included into any application code's build system.
33+
34+
additionally directories have their own ``Make.package`` files that specify
35+
the files needed for the build and some rules for making intermediary files.
36+
37+
38+
Environment variables
39+
=====================
40+
41+
The build system relies on some environment variables to find the source:
42+
43+
.. index:: AMREX_HOME, MICROPHYSICS_HOME
44+
45+
* ``AMREX_HOME`` : this should point to the top-level ``amrex/`` directory
46+
47+
* ``MICROPHYSICS_HOME`` : this is needed by application codes, and
48+
should point to the top level ``Microphysics/`` directory. For
49+
building unit tests within the ``Microphysics/`` directory itself,
50+
this does not need to be explicitly set.
51+
52+
53+
Automatically generated files
54+
=============================
55+
56+
There are a few source files that are created automatically at
57+
compile-time. These are placed in the
58+
``tmp_build_dir/microphysics_sources/`` sub-directory under the
59+
directory you run ``make`` (if building through an application code,
60+
the sub-directory may have a different name).
61+
62+
.. index:: network_properties.H, extern_parameters.H, AMReX_buildInfo.cpp
63+
64+
The main files are:
65+
66+
* ``network_properties.H`` : this defines the properties of the composition that
67+
make up the network (and therefore, used by the equation of state and other
68+
physics).
69+
70+
* ``extern_parameters.H`` : this defines all of the runtime parameters that are
71+
part of the build. At the moment, they are treated as global variables
72+
(using managed memory on GPUs), but a ``struct`` that carries their values
73+
is also available through ``extern_type.H``.
74+
75+
* ``AMReX_buildInfo.cpp`` : this defines functions that return the git hashes,
76+
compilers, compiler flags, and more meta-data about the build. This file
77+
is automatically deleted once it is built to insure it is always up-to-date.
78+
The functions it defines are used when writing the ``job_info`` file
79+
in the plotfiles that some unit tests produce.
80+
81+
Controlling choice of physics
82+
=============================
83+
84+
The choice of physics to include in an application is done at build time, and is
85+
controlled by a number of make variables.
86+
87+
.. tip::
88+
89+
You can query the value of any variable in the Microphysics build system by doing
90+
`make print-<NAME>` where `<NAME>` is the name of the variable.
91+
92+
For example,
93+
94+
.. code:: bash
95+
96+
make print-EOS_DIR
97+
98+
will tell you what EOS is being used.
99+
100+
101+
The following control whether certain physics modules are included in
102+
the build process. Note: an EOS and network are always required.
103+
These can be set to ``TRUE`` to enable and ``FALSE`` to disable specific features.
104+
105+
* ``USE_CONDUCTIVITY`` : determines whether a conductivity routine
106+
should be included in the list of build packages. If enabled, this
107+
also defines the ``CONDUCTIVITY`` preprocessor variable. Default:
108+
``FALSE``.
109+
110+
* ``USE_NEUTRINOS`` : determines whether a neutrino cooling term
111+
should be applied in the reaction network energy generation
112+
equation. See :ref:`neutrino_loss`. The default is set by each
113+
individual network.
114+
115+
* ``USE_NET_NET`` : determines whether the self-consistent NSE
116+
infrastructure is included in the build. See
117+
:ref:`self_consistent_nse`. No default is set.
118+
119+
* ``USE_NSE_TABLE`` : determines whether the tabular NSE
120+
infrastructure is included in the build. See :ref:`tabulated_nse`.
121+
No default is set.
122+
123+
* ``USE_RATES`` : for templated reaction networks (see
124+
:ref:`sec:templated_rhs`) determines whether we include the
125+
``rates/`` set of reaction rates in the build system. Also defines
126+
the ``RATES`` preprocessor variable. The default is set by each of
127+
the templated networks separately.
128+
129+
* ``USE_REACT`` : determines whether we need to include any of the
130+
source related to reaction networks or integrators and sets the
131+
``REACTIONS`` preprocessor variable. Note: even if this is set to
132+
``TRUE``, the ``network_properties.H`` file is still generated. No
133+
default is set.
134+
135+
* ``USE_SCREENING`` : determines whether the screening routines are
136+
included in the list of build packages. If enabled, this also
137+
defines the ``SCREENING`` preprocessor variable which is used in
138+
some networks to disable screening completely. Note: it is also
139+
possible to set the screening routine to ``null`` which would have
140+
the same effect (see :ref:`sec:screening`). The default is set by
141+
each individual network.
142+
143+
144+
The following control the choice of implementation for the different physics modules:
145+
146+
147+
* ``CONDUCTIVITY_DIR`` : the name of the conductivity implementation to use,
148+
relative to ``Microphysics/conductivity/``.
149+
150+
* ``EOS_DIR`` : the name of the EOS to use, relative to ``Microphysics/EOS/``.
151+
152+
* ``INTEGRATOR_DIR`` : the name of the integrator to use, relative to
153+
``Microphysics/integration/``.
154+
155+
* ``NETWORK_DIR`` : the name of the network to use, relative to ``Microphysics/networks/``.
156+
If ``general_null`` is chosen, then the inputs file is determined by
157+
either ``GENERAL_NET_INPUTS`` or ``NETWORK_INPUTS`` (see :ref:`sec:networks:general_null`).
158+
159+
* ``OPACITY_DIR`` : the name of the opacity implementation to use, relative
160+
to ``Microphysics/opacity/``.
161+
162+
* ``SCREEN_METHOD`` : the name of the screening implementation to use. The choices
163+
are listed in :ref:`sec:screening`.
164+
165+
166+
The following control the time-integration method used by the reaction
167+
network integration:
168+
169+
* ``USE_SIMPLIFIED_SDC`` : enable the simplified-SDC coupling of hydro and reactions.
170+
See :ref:`sec:simplified_sdc`.
171+
172+
* ``USE_TRUE_SDC`` : enable the true-SDC coupling of hydro and reactions.
173+
See :ref:`sec:true_sdc`.
174+
175+
.. note::
176+
177+
If neither of these are set to ``TRUE``, then Strang-splitting coupling
178+
will be used.
179+
180+
181+
Targets
182+
=======
183+
184+
For the unit tests, simply doing
185+
186+
.. code:: bash
187+
188+
make
189+
190+
in the test directory will build the test. There are a few other targets defined. The most important
191+
is ``clean``. Doing:
192+
193+
.. code:: bash
194+
195+
make clean
196+
197+
will remove all the build temporary files (including the ``tmp_build_dir/``).
198+
199+
.. important::
200+
201+
If you want to use a different EOS or reaction network (or any other physics), then you
202+
should always do ``make clean`` first in the build directory.
203+
204+
Some other targets include:
205+
206+
* ``nettables`` : create the symlinks for any weak reaction rate tables that are part of the
207+
network.
208+
209+
* ``table`` : create a symlink for the ``helm_table.dat`` EOS table if the ``helmholtz`` EOS is used.
210+
211+
* ``nsetable`` : create a symlink for the NSE table if ``USE_NSE_TABLE=TRUE`` is set.
212+
213+
* ``build_status`` : report the current git versions of Microphysics and AMReX
214+
215+
* ``test_extern_params`` : this will simply parse the runtime parameters and execute the
216+
``write_probin.py`` script that generates the headers and C++ files necessary to use
217+
the parameters. These will be generated under ``tmp_build_dir/microphysics_sources/``.
218+
219+
* ``net_prop_debug`` : this will simply create the ``network_properties.H`` file for the
220+
current network and output it into ``tmp_build_dir/microphysics_sources/``.

Docs/source/index.rst

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ system.
4646
getting_started
4747
design
4848
data_structures
49+
build_system
4950
rp_intro
5051

5152
.. toctree::

Docs/source/networks.rst

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.. _sec:networks:
2+
13
***************************
24
Available Reaction Networks
35
***************************
@@ -25,6 +27,8 @@ Microphysics knows the properties of the fluid.
2527
<https://pynucastro.github.io/>`_ :cite:`pynucastro, pynucastro2` using the ``AmrexAstroCxxNetwork``
2628
class.
2729

30+
.. _sec:networks:general_null:
31+
2832
``general_null``
2933
================
3034

Docs/source/screening.rst

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.. _sec:screening:
2+
13
***************************
24
Screening of Reaction Rates
35
***************************

Docs/source/sdc.rst

+4
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ is the reaction source term.
4444
are supported by the same integrators, and both of these options
4545
will set the ``SDC`` preprocessor flag.
4646

47+
.. _sec:true_sdc:
48+
4749
"True" SDC
4850
----------
4951

@@ -86,6 +88,8 @@ This can be cast as an ODE system as:
8688
8789
\frac{d\Uc}{dt} \approx \frac{\Uc^{m+1} - \Uc^m}{\delta t_m} = \Rbs{\Uc} + {\bf C}
8890
91+
.. _sec:simplified_sdc:
92+
8993
Simplified SDC
9094
--------------
9195

0 commit comments

Comments
 (0)