%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This file has been autogenerated from the LaTeX part of the   %
% doxygen documentation; DO NOT EDIT IT! Change the model's .hh %
% file instead!!                                                %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

This model assumes a flow of $M \geq 1$ fluid phases $\alpha$, each of which is assumed to be a mixture $N \geq M$ chemical species $\kappa$.

By default, the standard multi-\/phase Darcy approach is used to determine the velocity, i.\-e. \[ \mathbf{v}_\alpha = - \frac{k_{r\alpha}}{\mu_\alpha} \mathbf{K} \left(\text{grad}\, p_\alpha - \varrho_{\alpha} \mathbf{g} \right) \;, \] although the actual approach which is used can be specified via the {\ttfamily Velocity\-Module} property. For example, the velocity model can by changed to the Forchheimer approach by
\begin{lstlisting}[style=eWomsCode]
 SET_TYPE_PROP(MyProblemTypeTag, VelocityModule,
      Ewoms::BoxForchheimerVelocityModule<TypeTag>);
\end{lstlisting}


The core of the model is the conservation mass of each component by means of the equation \[ \sum_\alpha \frac{\partial\;\phi c_\alpha^\kappa S_\alpha }{\partial t} - \sum_\alpha \text{div} \left\{ c_\alpha^\kappa \mathbf{v}_\alpha \right\} - q^\kappa = 0 \;. \]

To close the system mathematically, $M$ model equations are also required. This model uses the primary variable switching assumptions, which are given by\-: \[ 0 \stackrel{!}{=} f_\alpha = \left\{ \begin{array}{cl} S_\alpha & \quad \text{if phase }\alpha\text{ is not present} \\ 1 - \sum_\kappa x_\alpha^\kappa & \quad \text{else} \end{array} \right. \]

To make this approach applicable, a pseudo primary variable {\itshape phase presence} has to be introduced. Its purpose is to specify for each phase whether it is present or not. It is a {\itshape pseudo} primary variable because it is not directly considered when linearizing the system in the Newton method, but after each Newton iteration, it gets updated like the \char`\"{}real\char`\"{} primary variables. The following rules are used for this update procedure\-:


\begin{itemize}
\item If phase $\alpha$ is present according to the pseudo primary variable, but $S_\alpha < 0$ after the Newton update, consider the phase $\alpha$ disappeared for the next iteration and use the set of primary variables which correspond to the new phase presence.


\item If phase $\alpha$ is not present according to the pseudo primary variable, but the sum of the component mole fractions in the phase is larger than 1, i.\-e. $\sum_\kappa x_\alpha^\kappa > 1$, consider the phase $\alpha$ present in the the next iteration and update the set of primary variables to make it consistent with the new phase presence.


\item In all other cases don't modify the phase presence for phase $\alpha$.


\end{itemize}

The model always requires $N$ primary variables, but their interpretation is dependent on the phase presence\-:


\begin{itemize}
\item The first primary variable is always interpreted as the pressure of the phase with the lowest index $PV_0 = p_0$.


\item Then, $M - 1$ \char`\"{}switching primary variables\char`\"{} follow, which are interpreted depending in the presence of the first $M-1$ phases\-: If phase $\alpha$ is present, its saturation $S_\alpha = PV_i$ is used as primary variable; if it is not present, the mole fraction $PV_i = x_{\alpha^\star}^\alpha$ of the component with index $\alpha$ in the phase with the lowest index that is present $\alpha^\star$ is used instead.


\item Finally, the mole fractions of the $N-M$ components with the largest index in the phase with the lowest index that is present $x_{\alpha^\star}^\kappa$ are used as primary variables.


\end{itemize}

This model is then discretized using a fully-\/coupled vertex centered finite volume (box) scheme as spatial and the implicit Euler method as temporal discretization.

