|
| 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/``. |
0 commit comments