%-------------------------------------------------------------------------------

% This file is part of Code_Saturne, a general-purpose CFD tool.
%
% Copyright (C) 1998-2013 EDF S.A.
%
% This program is free software; you can redistribute it and/or modify it under
% the terms of the GNU General Public License as published by the Free Software
% Foundation; either version 2 of the License, or (at your option) any later
% version.
%
% This program is distributed in the hope that it will be useful, but WITHOUT
% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
% FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
% details.
%
% You should have received a copy of the GNU General Public License along with
% this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
% Street, Fifth Floor, Boston, MA 02110-1301, USA.

%-------------------------------------------------------------------------------

%-------------------------------------------------------------------------------
\section{Continuous mass and momentum equations}
%-------------------------------------------------------------------------------

This section presents the continuous equations. It is no substitute for the
specific sub-sections of this documentation: the purpose here is mainly to
provide an overview before more detailed reading.

\paragraph{Balance methodology:}
The continuous equations can be obtained applying budget on the mass,
momentum, or again on mass of a scalar. A useful theorem, the so-called
Leibniz theorem, states that the variation of the integral of a given field $A$ 
over a moving domain $\Omega$ reads:

 \begin{equation}\label{eq:goveq:leibnitz_th}
\begin{array}{r c l}
\displaystyle \DP{} \left( \int_{\vol{} } A \dd \vol{} \right) &=& 
\displaystyle \int_{\vol{} }\der{A}{t} \dd \vol{} + \int_{\partial \vol{}} A  \variav \cdot  \dd \vect{S},
\end{array}
 \end{equation}
 where $\variav$ is the velocity of the boundary of $\Omega$ and $\partial \Omega$ is the boundary of $\Omega$ with a outward surface element $\dd \vect{S}$. 

%-----------------------------------------------
\subsection{Laminar flows}
\paragraph{Mass equation:}
Let now apply \eqref{eq:goveq:leibnitz_th} to a fluid volume\footnote{%
A fluid volume consists of fluid particles, that is to say it moves with the fluid velocity.
},
so $\partial \Omega$ moves with the fluid velocity denoted by $\vect{u}$, and to the field
$A= \rho$, where $\rho$ denotes the density:
%
 \begin{equation}\label{eq:goveq:leibnitz_th_mass}
\begin{array}{r c l}
\displaystyle \DP{} \left( \int_{\vol{}} \rho \dd \vol{}\right) &=& 
\displaystyle \int_{\vol{}} \der{\rho}{t} \dd \vol{} + \int_{\partial \vol{}} \rho  \vect{u} \cdot  \dd \vect{S}, \\
\displaystyle &=&
\displaystyle \int_{\vol{ }} \left( \der{\rho}{t} + \dive \left( \rho \vect{u} \right) \right) \dd \vol{},
\end{array}
 \end{equation}
the second line is obtained using Green relation. In \eqref{eq:goveq:leibnitz_th_mass}, the term
$\DP{} \left( \int_{\vol{} }\rho \dd \vol{}\right) $ is zero because\footnote{
it can be non-zero in some rare cases when fluid is created by a chemical reaction for instance.
}
 it is the variation of the mass of a fluid volume. This equality is true for any fluid volume, so
 if the density field and the velocity field are sufficiently regular then the \textbf{continuity} equation holds:
 
\begin{equation}\label{eq:mass0}
\dfrac{\partial \rho}{\partial t} + \dive(\rho \vect{u})=0.
\end{equation}

Equation \eqref{eq:mass0} could be slightly generalized to cases where a mass source term $\Gamma$ 
exists:
\begin{equation}\label{eq:mass}
\dfrac{\partial \rho}{\partial t} + \dive(\rho \vect{u})=\Gamma,
\end{equation}
but $\Gamma$ is generally taken to $0$.
\nomenclature[grho]{$\rho$}{density field \nomunit{$kg.m^{-3}$}}
\nomenclature[rut1]{$\vect{u}$}{velocity field \nomunit{$m.s^{-1}$}}
\nomenclature[ggamma ]{$\Gamma$}{mass source term}

\paragraph{Momentum equation:}
The same procedure on the momentum gives:
\begin{equation}\label{eq:goveq:leibnitz_th_momentum}
\begin{array}{r c l}
\displaystyle \DP{} \left( \int_{\vol{} }\rho \vect{u} \dd \vol{}\right) &=& 
\displaystyle \int_{\vol{} }\der{\left( \rho \vect{u} \right) }{t} \dd \vol{} + \int_{\partial \vol{}}  \vect{u}\otimes \left( \rho \vect{u} \right) \cdot  \dd \vect{S}, \\
\displaystyle &=&
\displaystyle \int_{\vol{ }} \der{\left( \rho \vect{u} \right) }{t} + \divv \left( \vect{u} \otimes \rho \vect{u} \right)  \dd \vol{},
\end{array}
 \end{equation} 
once again, the Green relation has been used to obtain the second line. One then invokes Newton's second law
stating that the variation of momentum is equal to the external forces:
\begin{equation}\label{eq:goveq:leibnitz_th_momentum2}
\begin{array}{r c l}
\displaystyle \DP{} \left( \int_{\vol{}} \rho \vect{u} \dd \vol{}\right) &=& 
\displaystyle 
\underbrace{
\int_{\partial \vol{}}  \tens{\sigma} \cdot  \dd \vect{S}
}_{
\text{ boundary force }
}
+
\underbrace{
\int_{\vol{} }\rho \vect{g} \dd \vol{}
}_{
\text{ volume force }
}
, \\
\displaystyle &=&
\displaystyle \int_{\vol{ }} \divv \left( \tens{\sigma} \right) + \rho \vect{g}  \dd \vol{},
\end{array}
 \end{equation} 
where $\tens{\sigma}$ is the Cauchy stress tensor\footnote{
$\tens{\sigma} \cdot \dd \vect{S}$ represents the forces exerted on the surface element
$ \dd \vect{S} $ by the exterior of the domain $\Omega$.
}, $\vect{g}$ is the gravity field. Other source of momentum can be added in particular case, such 
as head losses or Coriolis forces for instance.

Finally, bringing \eqref{eq:goveq:leibnitz_th_momentum} and \eqref{eq:goveq:leibnitz_th_momentum2} all together 
the \textbf{momentum} equation is obtained:
\begin{equation}\label{eq:momentum}
\dfrac{\partial }{\partial t}(\rho \vect{u})
+\divv \left( \vect{u}\otimes \rho \vect{u} \right)
=\divv \left( \tens{\sigma} \right) +\rho \vect{g} +\vect{ST}_{\vect{u}}-\tens{K}\,\vect{u} + \Gamma \vect{u}^{in},
\end{equation}
%
where $\vect{ST}_{\vect{u}}$ and $\tens{K}\,\vect{u}$ stand for explicit and implicit additional 
momentum Source Terms
\nomenclature[rstut1]{$\vect{ST}_{\vect{u}}$}{explicit additional momemtum source terms \nomunit{$kg.m^{-2}.s^{-2}$}}
\nomenclature[rkt2]{$\tens{K}$}{tensor of the velocity head loss \nomunit{$kg.m^{-3}.s^{-1}$}}
\nomenclature[gsigmat2]{$\tens{\sigma}$}{total stress tensor \nomunit{$Pa$}}
 which may be prescribed by the user (head loss, $\Gamma \vect{u}^{in}$ 
contribution associated with a user-prescribed mass source term...).
Note that $\tens{K}$ is a symmetric positive tensor, by definition. 

In order to make the set of Equations \eqref{eq:mass} and \eqref{eq:momentum} closed, the Newtonian state law
linking the deviatoric part of the stress tensor $\tens{\sigma}$ to the velocity field (more precisely to the rate of strain tensor $\tens{S}$)
is introduced: 
%
\begin{equation}\label{eq:goveqn:newtonian_fluid}
\tens{\tau}=2 \mu \deviator{\tens{S}} = 2 \mu  \tens{S}-\frac{2}{3}\mu  \trace \left(\tens{S} \right) \tens{1},
\end{equation}
%
where $\mu =\mu_l $ is called  the dynamic molecular viscosity, 
\nomenclature[gmu]{$\mu$}{dynamic viscosity \nomunit{$kg.m^{-1}.s^{-1}$}}
\nomenclature[gmul]{$\mu_l$}{dynamic molecular viscosity \nomunit{$kg.m^{-1}.s^{-1}$}}
whereas $\tens{\tau}$ is the viscous stress tensor and the pressure field are defined as:
%
\begin{equation}
\left\lbrace
\begin{array}{r c l}
P &=& -\dfrac{1}{3} \trace \left( \tens{\sigma} \right), \\
\tens{\sigma} & = & \tens{\tau}-P\tens{1}.
\end{array}
\right.
\end{equation}
%
\nomenclature[rp ]{$P$}{pressure field \nomunit{$Pa$}}
\nomenclature[gtaut2]{$\tens{\tau}$}{viscous stress tensor, which is the deviatoric part of the stress tensor \nomunit{$Pa$}}
and $\tens{S}$ , the strain rate tensor, as:
\begin{equation}\label{eq:base_introd_strainrate}
 \tens{S}=\frac{1}{2} \left( \gradt \, \vect{u}+ \transpose{\gradt \, \vect{u}} \right).
\end{equation}
%
\nomenclature[rst2]{$\tens{S}$}{strain rate tensor \nomunit{$s^{-1}$}}
%
\nomenclature[odeviator]{$\deviator{ \left(\tens{.} \right)}$}{deviatoric part of a tensor}
\nomenclature[otrace]{$\trace{ \left(\tens{.}\right)}$}{trace of a tensor}
%
Note that a fluid for which \eqref{eq:goveqn:newtonian_fluid} holds isS called a Newtonian fluid, it is generally the case
for water, air, but not the case of a paint because the stresses do not depend linearly on the strain rate.

\paragraph{Navier-Stokes equations:}
Injecting Equation \eqref{eq:goveqn:newtonian_fluid} into the momentum Equation \eqref{eq:momentum} and combining 
it with the continuity Equation \eqref{eq:mass} give the Navier-Stokes equations:
%
\begin{equation}\label{eq:navier_stokes_conservative}
\left\lbrace
\begin{array}{r c l}
\dfrac{\partial \rho}{\partial t} + \dive \left( \rho \vect{u} \right) &=& \Gamma, \\
\dfrac{\partial }{\partial t}(\rho \vect{u})
+\divv \left( \vect{u}\otimes \rho \vect{u} \right)
&=& - \grad P 
+ \divv \left( \mu  \left[ \gradt \, \vect{u} + \transpose{\gradt \, \vect{u}} - \dfrac{2}{3} \trace \left(\gradt \, \vect{u} \right) \tens{Id} \right]   \right) 
+\rho \vect{g}
 +\vect{ST}_{\vect{u}}-\tens{K}\,\vect{u} + \Gamma \vect{u}^{in},
\end{array}
\right.
\end{equation}

The left hand side of the momentum part of  Equation \eqref{eq:navier_stokes_conservative} can be rewritten using the continuity Equation \eqref{eq:mass}:
\begin{equation}\label{eq:goveqn:conservative_non_conservative}
\dfrac{\partial }{\partial t}(\rho \vect{u}) +\divv \left( \vect{u}\otimes \rho \vect{u} \right)
 = 
\rho \der{\vect{u}}{t} + 
\underbrace{
\der{\rho}{t} \vect{u}  
}_{
\left[ \Gamma  -  \dive \left(\rho \vect{u} \right) \right]  \vect{u} 
}
+ \dive \left(\rho \vect{u} \right) \vect{u} 
+ 
\underbrace{
\gradt \, \vect{u} \cdot \left( \rho \vect{u} \right)
}_{
\text{convection}
} .
\end{equation}

Then the Navier-Stokes equations read in non-conservative form:
\begin{equation}\label{eq:navier_stokes_laminar}
\left\lbrace
\begin{array}{r c l}
\dfrac{\partial \rho}{\partial t} + \dive \left( \rho \vect{u} \right) &=& \Gamma, \\
\rho \der{\vect{u} }{t} 
+
\gradt \, \vect{u} \cdot \left( \rho \vect{u}\right)
&=& - \grad P 
+ \divv \left( \mu  \left[ \gradt \, \vect{u} + \transpose{\gradt \, \vect{u}} - \dfrac{2}{3} \trace \left(\gradt \, \vect{u} \right) \tens{Id} \right]   \right) 
+ \rho \vect{g}
 +\vect{ST}_{\vect{u}}-\tens{K}\,\vect{u} + \Gamma \left( \vect{u}^{in} - \vect{u} \right),
\end{array}
\right.
\end{equation}
This formulation will be used in the following. Note that the convective term is nothing else but 
$ \gradt \, \vect{u} \cdot \left( \rho \vect{u}\right) = \divv \left( \vect{u}\otimes \rho \vect{u} \right) -\dive \left(  \rho \vect{u} \right) \vect{u} $,
this relationship should be conserved by the space-discretized scheme (see \chaptername~\ref{chapter:spadis}).

%-------------------------------------------------------------------------
\subsection{Turbulent flows with a Reynolds-Averaged Navier-Stokes approach (\emph{RANS}):}
When the flow becomes turbulent, the \emph{RANS} approach is to consider the 
velocity field $\vect{u}$ as stochastic and then splat into a mean field denoted by $\overline{\vect{u}}$ and
a fluctuating field $\vect{u}^\prime$:
\begin{equation}
\vect{u} = \overline{\vect{u}} + \vect{u}^\prime . 
\end{equation} 
The Reynolds average operator $\overline{\left( \cdot\right)}$ is applied to Navier-Stokes Equation \eqref{eq:navier_stokes_conservative}:
%
\begin{equation}\label{eq:reynolds}
\left\lbrace
\begin{array}{r c l}
\dfrac{\partial \rho}{\partial t} + \dive \left( \rho \overline{\vect{u}} \right) &=& \Gamma, \\
\rho \der{ \overline{\vect{u}} }{t} 
+
\gradt \, \overline{\vect{u}} \cdot \left( \rho \overline{\vect{u}}\right)
&=& - \grad \overline{P} 
+ \divv \left( \mu  \left[ \gradt \, \overline{\vect{u}} + \transpose{\gradt \, \overline{\vect{u}}} - \dfrac{2}{3} \trace \left(\gradt \, \overline{\vect{u}} \right) \tens{Id} \right]   \right) 
+ \rho \vect{g}
- \divv \left(\rho \tens{R} \right) \\
&+& 
\displaystyle
\vect{ST}_{\vect{u}}-\tens{K}\,\overline{\vect{u}} + \Gamma \left( \overline{\vect{u}}^{in} - \overline{\vect{u}} \right),
\end{array}
\right.
\end{equation}
%
Only the mean fields $\overline{\vect{u}}$ and $\overline{P}$ are computed. 
An additional term $\tens{R}$ appears in the Reynolds Equations \eqref{eq:reynolds} which is by definition the covariance tensor of the fluctuating
velocity field and called the Reynolds stress tensor:
%
\begin{equation}\label{eq:def_reynolds_stress-tensor}
\tens{R} \equiv \overline{\vect{u}^\prime \otimes \vect{u}^ \prime}.
\end{equation}
the latter requires a closure modelling which depends the turbulence model adopted. Two major types of modelling exist:

\begin{enumerate}[ label=\roman{*}/, ref=(\roman{*})]
\item Eddy Viscosity Models (\emph{EVM}) which assume that the Reynolds stress tensor is aligned with
the strain rate tensor of the mean flow ($\overline{\tens{S}} \equiv \frac{1}{2} \left( \gradt \, \vect{u}+ \transpose{\gradt \, \vect{u}} \right)$):
%
\begin{equation}\label{eq:goveqn:evm_hypothesis}
\rho \tens{R} = \dfrac{2}{3}\rho  k \tens{1} - 2 \mu_T \deviator{\overline{\tens{S}}},
\end{equation}
where the turbulent kinetic energy $k$ is defined by:
%
\begin{equation}\label{eq:goveqn:tke_def}
k \equiv \dfrac{1}{2} \trace \left( \tens{R}\right),
\end{equation}
and $\mu_T$ is called the dynamic turbulent viscosity and must be modelled.
Note that the viscous part $\mu_T\deviator{\overline{\tens{S}}}$ of the Reynolds stresses is simply added to the viscous part of the
stress tensor $\mu_l\deviator{\overline{\tens{S}}}$ so that the momentum equation for the mean velocity is similar to the one of a laminar
flow with a variable viscosity $\mu = \mu_l +\mu_T$. 
 Five \emph{EVM} are available in \CS:
$k-\varepsilon$, $k-\varepsilon$ with Linear Production (\emph{LP}), $k-\omega$ \emph{SST}, Spalart Allmaras, and an Elliptic Blending model (\emph{EB-EVM}) $Bl-v^2-k$ (\cite{Billard:2012}).

\item Differential Reynolds Stress Models (\emph{DRSM}) which solve
a transport equation on the components of the Reynolds stress tensor $\tens{R}$ 
during the simulation, and are readily available for the momentum
equation \eqref{eq:reynolds}. Three \emph{DRSM} models are available in \CS: $R_{ij}-\varepsilon$ proposed by Launder Reece and Rodi (\emph{LRR}) in \cite{Launder:1975},
$R_{ij}-\varepsilon$ proposed by Speziale, Sarkar and Gatski (\emph{SSG}) in \cite{Speziale:1991} and an Elliptic Blending version \emph{EB-RSM} (see \cite{Manceau:2002}).
%

\end{enumerate}


%-----------------------------------------------
\subsection{Large Eddy Simulation (\emph{LES}):}
The \emph{LES} approach consists in spatially filtering the $\vect{u}$ field using an operator denoted by $\widetilde{\left(\cdot \right)} $.
Applying the latter filter to the Navier-Stokes Equations \eqref{eq:navier_stokes} gives:
%
\begin{equation}\label{eq:navier_stokes_les}
\left\lbrace
\begin{array}{r c l}
\dfrac{\partial \rho}{\partial t} + \dive \left( \rho \widetilde{\vect{u}} \right) &=& \Gamma, \\
\rho \der{ \widetilde{\vect{u}} }{t} 
+
\gradt \, \widetilde{\vect{u}} \cdot \left( \rho \widetilde{\vect{u}}\right)
&=& - \grad \widetilde{P} 
+ \divv \left( 2 \mu  \deviator{\widetilde{\tens{S}}}   \right) 
+ \rho \vect{g}
- \divv \left( \rho \widetilde{\vect{u}^\prime \otimes \vect{u}^\prime } \right)
 +\vect{ST}_{\vect{u}}-\tens{K}\,\widetilde{\vect{u}} + \Gamma \left( \widetilde{\vect{u}}^{in} - \widetilde{\vect{u}} \right),
\end{array}
\right.
\end{equation}
where $\vect{u}^\prime$ are non-filtered fluctuations. An eddy viscosity hypothesis is made on the additional
resulting tensor:
\begin{equation}
\widetilde{\vect{u}^\prime \otimes \vect{u}^\prime }  = \dfrac{2}{3} k \tens{Id} - 2 \mu_T \deviator{\widetilde{\tens{S}}},
\end{equation}
%
where the above turbulent viscosity $\mu_T$ now accounts only for sub-grid effects.

%-------------------------------------------------------------
\subsection{Formulation for laminar, RANS or LES calculation:}
For the sake of simplicity, in all cases, the computed velocity field will be denoted by $\vect{u}$ even if 
it is about \emph{RANS} velocity field $\overline{\vect{u}}$ or \emph{LES} velocity field $\widetilde{\vect{u}}$.

Moreover, a manipulation on the right hand side of the momentum is  performed to change the meaning
of the pressure field. let $P^\star$ be the dynamic pressure field defined by:
%
\begin{equation}\label{eq:dynamic_pressure_def}
P^\star = P - \rho_0 \vect{g} \cdot \vect{x} + \dfrac{2}{3} \rho k,
\end{equation}
where $\rho_0$ is a reference constant density field. Then the continuity and the momentum equations
read:
 %
 \begin{equation}\label{eq:navier_stokes}
\left\lbrace
\begin{array}{r c l}
\dfrac{\partial \rho}{\partial t} + \dive \left( \rho \vect{u} \right) &=& \Gamma, \\
\rho \der{\vect{u} }{t} 
+
\gradt \, \vect{u} \cdot \left( \rho \vect{u}\right)
&=& - \grad P^\star 
+ \divv \left( 2\left( \mu_l  +  \mu_T \right) \deviator{\tens{S}}   \right) 
- \divv \left(\rho \tens{R} - 2 \mu_T \deviator{\tens{S}} \right)
+ \left( \rho -\rho_0 \right)\vect{g}
\\
 &+&\vect{ST}_{\vect{u}}-\tens{K}\,\vect{u} + \Gamma \left( \vect{u}^{in} - \vect{u} \right).
\end{array}
\right.
\end{equation}


%-------------------------------------------------------------------------------
\section{Thermal equations}

%-------------------------------------------------------------------------------
\subsection{Energy equation}
The energy equation reads:
\begin{equation}
 \rho \DP{e} = -\divs \left(\underline{q''} \right) +q'''-P \divs \left( \vect{u} \right) + \mu S^2,
\label{eq:energy}
\end{equation}
where $e$ is the specific internal energy,
$\vect{q''}$ is the heat flux vector,
$q'''$ is the dissipation rate or rate of internal heat generation and
$S^2$ is scalar strain rate defined by
\begin{equation}
  S^2  =  2 \deviator{\tens{S}} : \deviator{\tens{S}}.
 \end{equation}

The Fourier law of heat conduction gives:
\begin{equation}
 \displaystyle \vect{q''}=-\lambda \grad T,
\end{equation}
where $\lambda$ is the thermal conductivity and $T$ is the temperature field.

%-------------------------------------------------------------------------------
\subsection{Enthalpy equation}

Thermodynamics definition of enthalpy gives:
\begin{equation}
 h \equiv e+ \dfrac{1}{\rho} P.
\end{equation}

Applying the Lagrangian derivative $\DP{}$ to $h$:
\begin{equation}
 \DP{h}=\DP{e}+\frac{1}{\rho}\DP{P}-\frac{P}{\rho^2}\DP{\rho},
\end{equation}
%
then
\begin{equation}\label{eq:enthalpyT}
\begin{array}{r c l}
  \rho \DP{h} &=& \divs \left( \lambda \grad T \right) +q'''-P\divs \vect{u} + \mu S^2 + \DP{P} -\frac{P}{\rho}\DP{\rho}, \\
   &=& \divs \left( \lambda \grad T \right) +q''' + \mu  S^2 + \DP{P} - \frac{P}{\rho} \left(\underbrace{\DP{\rho} + \rho \divs \underline{u}}_{\displaystyle =0} \right), \\
   &=& \divs \left( \lambda \grad T \right) +q''' + \mu  S^2 + \DP{P}. 
\end{array}
\end{equation}

To express \eqref{eq:enthalpyT} only in terms of $h$ and not $T$, some thermodynamics relationships can be used.
For a pure substance, Maxwell's relations give:
%
\begin{equation}\label{eq:goveqn:dh_dt_dp}
  \dd h=C_p \dd T + \frac{1}{\rho} \left( 1-\beta T \right)\dd P,
\end{equation}
%
where $\beta$ is the thermal expansion coefficient defined by:
\begin{equation}
 \beta= -\frac{1}{\rho}  \left.\der{\rho}{T}\right|_P.
\end{equation}

The equation \eqref{eq:enthalpyT} then becomes:
\begin{equation}\label{eq:enthalpyH}
 \rho \DP{h} = \divs \left( \dfrac{\lambda}{C_p} \left(\grad h -\dfrac{1-\beta T }{\rho}\grad P\right)\right) +q''' + \mu S^2 + \DP{P}.
\end{equation}

\begin{remark}
Note that for incompressible flows, $\beta T$ is negligible compared to $1$. Moreover, for ideal gas, $\beta = 1/T$ so the following relationship holds:
\begin{equation}
 \dd h=C_p \dd T.
\end{equation}
%
\end{remark}

%-------------------------------------------------------------------------------
\subsection{Temperature equation}

In order to rearrange the enthalpy Equation (\ref{eq:enthalpyT}) in terms of temperature \eqref{eq:goveqn:dh_dt_dp} is used:
\begin{equation}
 \left.\der{s}{P}\right|_T = -  \left.\der{(1/\rho)}{T}\right|_P = \frac{1}{\rho^2} \left.\der{\rho}{T}\right|_P=-\frac{\beta}{\rho},
\end{equation}
and also:
%
\begin{equation}
\dfrac{\lambda}{C_p} \left(\grad h -\dfrac{1-\beta T }{\rho}\grad P\right) = \lambda \grad T,
\end{equation}
%
 and Equation \eqref{eq:enthalpyH} becomes:
 %
\begin{equation}
  \rho C_p \DP{T}=  \divs \left( \lambda \grad T \right) + \beta T \DP{P} +q''' + \mu S^2.
\label{eq:T_all}
\end{equation}

The Eq. \eqref{eq:T_all} can be reduced using some hypothesis, for example:
\begin{itemize}
 \item If the fluid is an ideal gas, $\beta=\dfrac{1}{T}$ and it becomes:
\begin{equation}
  \rho C_p \DP{T}=  \divs \left( \lambda \grad T \right) + \DP{P} +q''' + \mu S^2.
\end{equation}

 \item If the fluid is incompressible, $\beta=0$, $q'''=0 $ and we generally neglect $\mu S^2$  so that it becomes:
\begin{equation}
  \rho C_p \DP{T}=  \divs \left( \lambda \grad T \right).
\end{equation}
\end{itemize}

%-------------------------------------------------------------------------------
\section{Equations for scalars}

Two types of transport equations are considered: 
%
\begin{enumerate}[ label=\roman{*}/, ref=(\roman{*})]
\item convection of a scalar with additional source terms:
\begin{equation}
\frac{\partial (\rho a)}{\partial t} +
\underbrace{
\dive \left( a \, \rho \underline{u})
\right)
}_{\text{advection}}
-\underbrace{
\dive \left( K\grad a \right) 
}_{
\text{diffusion}} = ST_{a}+\Gamma \,a^{in},
\end{equation}

\item convection of the variance $\widetilde{{a"}^{2}}$ with
additional source terms:
\begin{equation}
\begin{array}{rcl}
\displaystyle\frac{\partial \left(\rho \widetilde{{a"}^{2}}\right)}{\partial t}+
\underbrace{
\dive \left( \widetilde{{a"}^{2}} \, \rho \,\underline{u} \right)
}_{\text{advection}}
-\underbrace{
\dive \left( K\ \grad\widetilde{{a"}^{2}} \right)
}_{\text{diffusion}}
&=&ST_{\widetilde{{a"}^{2}}}+ \ \Gamma \, \widetilde{{a"}^{2}}^{in} 
\\
& &\displaystyle +
\underbrace{
2\,\frac{\mu _{t}}{\sigma _{t}} \left( \grad\widetilde{a} \right)^{2}-
\frac{\rho \,\varepsilon }{R_{f}k}\ \widetilde{{a"}^{2}}
}_{\text{production and dissipation}} ,
\end{array}%
\end{equation}%
\end{enumerate}

The two previous equations can be unified formally as:
\begin{equation}\label{eq:base_introd_depart}
\frac{\partial (\rho \varia)}{\partial t}+\dive \left( \rho \vect{u} \varia \right)
-\dive \left( K\grad \varia \right) = ST_{\varia}+\Gamma \,\varia^{in}+ \mathcal{P}_\varia - \mathcal{\epsilon}_\varia  
\end{equation}%
with:
\begin{equation}
 \mathcal{P}_\varia - \mathcal{\epsilon}_\varia  = 
\left\{
\begin{array}{ll}
 0 & \text{ for $\varia=a$ }, \\
 2 \displaystyle \frac{\mu_t}{\sigma_t}(\grad \widetilde{a})^2 - \displaystyle
\frac{\rho\,\varepsilon}{R_f k}\ \widetilde{{a"}^2} & \text{for
$\varia=\widetilde{{a"}^2}$. }
\end{array}%
\right.
\end{equation}

$ST_\varia$ represents the additional source terms that may be prescribed by the
user.
