.. include:: ../../../definitions.rst

Eulerian01: athermal, constant density
--------------------------------------

Description
~~~~~~~~~~~

Consider a system with a fluid comprised of two chemical species, :math:`A` and :math:`B`, with the transfer of species given by the reversible homogeneous reaction,

.. math::
   :label: chem_eulerian01_eq01

   A(g) \leftrightarrow B(g)

If both species have the same molecular weight, specific heat, and enthalpy of formation, then the mixture molecular weight, system temperature, and density are constant.
The evolution of species mass in the absence of convection and diffusion is given by

.. math::
   :label: chem_eulerian01_eq02

   \rho\frac{\partial X_{A}}{\partial t} = \dot{\omega}_{A}

where :math:`\rho` is density;
:math:`X_A` is the mass fraction of species :math:`A`; and
:math:`\dot{\omega}_{A}` is the net rate of production (consumption if negative) of species :math:`A`.

A manufactured solution for species :math:`A` is

.. math::
   :label: chem_eulerian01_eq03

   X_A(t) = X_A^0 - \sin(6\pi t)/4

where :math:`X_A^0 = X_A(t=0)` is the initial mass fraction of species :math:`A`. Taking the derivative with respect to time, and substituting the result into :eq:`chem_eulerian01_eq02` gives

.. math::
   :label: chem_eulerian01_eq04

   \dot{\omega}_A = -\rho 3\pi \cos(6\pi t)/2

which has units of kg\ |cdot|\ m\ :math:`^{-3}`\ |cdot| sec\ :math:`^{-1}`. Two modifications are required to implement this Eulerian reaction rate into MFIX-Exa:

- Eq. :eq:`chem_eulerian01_eq04` needs to be divided by the molecular weight of species A because Eulerian reaction rates in MFIX-Exa are provided in units of mol\ |cdot|\ m\ :math:`^{-3}`\ |cdot| sec\ :math:`^{-1}`.
- The negative sign is omitted because species :math:`A` is a reactant. Specifically, by inspection of chemical equation :eq:`chem_eulerian01_eq01`, species :math:`A` is a reactant when the rate is positive (forward reaction), and a product when the rate is negative (backward reaction).

The resulting Eulerian reaction rate is

.. math::
   :label: chem_eulerian01_eq54

   R_A = \frac{\rho 3\pi \cos(6\pi t)}{2 M_A}

Setup
~~~~~

The domain is a single cuboid cell with 0.0025 m edge length and convection and diffusion terms are set to zero for all governing equations. The fluid has a constant temperature of 300 K at 60,795 Pa, and the initial composition is :math:`X_A=X_B=0.5`. The density is chosen to be 2 kg\ |cdot|\ m\ :math:`^{-3}`; therefore, the component and mixture molecular weights are computed from the ideal gas law :math:`M=\rho RT / p_{therm} \approx 0.0821` kg\ |cdot|\ mol\ :math:`^{-1}`.


Results
~~~~~~~

The test is run at five fixed time-step sizes with a refinement factor of 2: 0.2, 0.1, 0.05, 0.025, 0.0125 milliseconds. The :math:`L_1`\ -norm is computed by dividing the sum of the absolute difference between the analytical and numerical solution over all time steps by the total number of time steps.

.. math::

   L_1 = \frac{\sum_n \| X_A(t_n) - X_A^{\mathrm{\texttt{MFIX-Exa}}}\|}{n}


Forward Euler
'''''''''''''

The analytical solution and absolute error with dt = 0.2 msec are shown in :numref:`fig_chem_eulerian01_ForwardEuler_sol`. The :math:`L_1` norm is used to compute the observed order of accuracy shown in :numref:`fig_chem_eulerian01_ForwardEuler_ooa`.


.. _fig_chem_eulerian01_ForwardEuler_sol:

.. figure:: ./images/eulerian01_ForwardEuler_solution.png
   :width: 85%
   :align: center
   :alt: Eulerian01 test numerical solution and absolute error

   Numerical solution for species mass fraction and absolute error.


.. _fig_chem_eulerian01_ForwardEuler_ooa:

.. figure:: ./images/eulerian01_ForwardEuler_accuracy.png
   :width: 45%
   :align: center
   :alt: Eulerian01 test observed order

   Observed order of species mass fraction.
