|
| 1 | +.. _sec:jac_cell: |
| 2 | + |
| 3 | +************ |
| 4 | +``jac_cell`` |
| 5 | +************ |
| 6 | + |
| 7 | +.. index:: jac_cell, numerical_jacobian.H |
| 8 | + |
| 9 | +``jac_cell`` is used to test the accuracy of an analytic Jacobian |
| 10 | +provided by a network, but comparing to a finite-difference |
| 11 | +approximation. Given a thermodynamic state, ``jac_cell`` evaluates |
| 12 | +the analytic Jacobian as well as a numerical approximation to it, and |
| 13 | +then outputs (to ``stdout``) the Jacobian elements side-by-side for |
| 14 | +each method of computing the Jacobian. |
| 15 | + |
| 16 | +.. note:: |
| 17 | + |
| 18 | + Some integrators, like VODE, have their own numerical Jacobian |
| 19 | + routines. This test uses the implementation in |
| 20 | + ``integration/util/numerical_jacobian.H``, which closely follows the ideas |
| 21 | + of the VODE numerical approximation, as described in :cite:`lsode`. |
| 22 | + |
| 23 | + |
| 24 | +Getting Started |
| 25 | +=============== |
| 26 | + |
| 27 | +The ``jac_cell`` code is located in |
| 28 | +``Microphysics/unit_test/jac_cell``. An inputs file which sets the |
| 29 | +default parameters for your thermodynamic state is needed to run the |
| 30 | +test. |
| 31 | + |
| 32 | +Setting the thermodynamics |
| 33 | +-------------------------- |
| 34 | + |
| 35 | +The parameters that affect the thermodynamics are: |
| 36 | + |
| 37 | +* ``unit_test.density`` : the initial density |
| 38 | + |
| 39 | +* ``unit_test.temperature`` : the initial temperature |
| 40 | + |
| 41 | +* ``unit_test.small_temp`` : the low temperature cutoff used in the equation of state |
| 42 | + |
| 43 | +* ``unit_test.small_dens`` : the low density cutoff used in the equation of state |
| 44 | + |
| 45 | +While the mass fractions can be set individually (using |
| 46 | +``unit_test.X1``, ``unit_test.X2``, ...), it is recommended to use |
| 47 | +``unit_test.uniform_xn=1`` to initialize all the mass fractions to be |
| 48 | +equal. |
| 49 | + |
| 50 | + |
| 51 | +Building and Running the Code |
| 52 | +============================= |
| 53 | + |
| 54 | +The code can be built simply as: |
| 55 | + |
| 56 | +.. prompt:: bash |
| 57 | + |
| 58 | + make |
| 59 | + |
| 60 | +.. note:: |
| 61 | + |
| 62 | + By default, this will build with the ``aprox13`` network, which |
| 63 | + uses the C++ templating method (:ref:`sec:templated_rhs`) of |
| 64 | + building the analytic Jacobian at compile-time. The network can be |
| 65 | + changed via the build parameter ``NETWORK_DIR``. |
| 66 | + |
| 67 | +.. important:: |
| 68 | + |
| 69 | + The screening routines provided by Microphysics do not return the |
| 70 | + derivative of the screening factor with respect to composition. This |
| 71 | + means that the analytic Jacobian provided by the network will ignore |
| 72 | + this contribution, but the numerical Jacobian will implicitly include |
| 73 | + it. |
| 74 | + |
| 75 | + To compare just the network Jacobian elements, it is suggested that |
| 76 | + you build with ``SCREEN_METHOD=null``. |
| 77 | + |
| 78 | + |
| 79 | +The build process will automatically create links in the build |
| 80 | +directory to any required EOS table. |
| 81 | + |
| 82 | +To run the code, in the ``jac_cell`` directory run:: |
| 83 | + |
| 84 | + ./main3d.gnu.ex inputs |
| 85 | + |
| 86 | +where ``inputs`` is the provided inputs file. You may edit the |
| 87 | +thermodynamic state in that file prior to running. |
| 88 | + |
| 89 | + |
| 90 | +Output |
| 91 | +====== |
| 92 | + |
| 93 | +All output is directed to ``stdout``. Example output is shown below |
| 94 | +(this output includes screening, highlighting the difference that the |
| 95 | +screening composition derivatives make): |
| 96 | + |
| 97 | + |
| 98 | +.. literalinclude:: ../../unit_test/jac_cell/ci-benchmarks/jac_cell_aprox13.out |
0 commit comments