2 Total Energy
3 Internal Energy
4 Total Energy/Enthalpy, local derivatives
5 Energy Equation in OpenFOAM Solvers
6 Total vs Internal Energy
This article provides information on the equation describing conservation of energy relevant to ﬂuid dynamics and computational ﬂuid dynamics (CFD). It ﬁrst assembles an equation for combined mechanical and thermal energy, i.e. total energy, in terms of material derivatives. It then presents an equation for thermal, or internal, energy. The total energy equation is then provided in terms of local (partial) derivatives, both in terms of internal energy and enthalpy. The implementation of the energy equation in solvers in OpenFOAM is then described.
Some of the information in this article is also presented in the book Notes on CFD: General Principles.
The law of conservation of energy states that the total energy of an isolated system remains constant, i.e. it is conserved over time and energy is not created or destroyed but is transformed from one form to another. Here we consider only mechanical and thermodynamic energy, the contributions of which are described in the following sections, using usual notation of tensor algebra and calculus, including representing the material derivative.
The rate of change of mechanical, or kinetic, energy is:
The rate of change of thermal, or internal, energy is
The rate of change of total energy for a particle of material must equal the input of mechanical and thermodynamic power from ﬂuxes and sources acting on the particle. In the limit where particle size is inﬁnitesimally small
An equation for internal energy is produced by simplifying the mechanical contributions which, expressed as
We can express our equations in terms of the local derivative (or partial derivative, spatial derivative, …) , where . Applying conservation of mass, the following relationship holds for any tensor :
Enthalpy is the sum of internal energy and kinematic pressure, i.e. . Combining this with equation 12 gives:
Total energy can be deﬁned as . Combining this with equation 12 gives:
The solution of the energy equation is included in several solvers in OpenFOAM for compressible ﬂow, combustion, heat transfer, multiphase ﬂow and particle tracking. The source code can be found for these solvers within ﬁles in sub-directories of the $FOAM_SOLVERS directory of OpenFOAM (including the compressible, combustion, heatTransfer, multiphase and lagrangian sub-directories).
The energy equation is generally implemented in the form of total energy expressed in equations 12 and 13, without the mechanical sources and . A heat ﬂux is assumed, where the eﬀective thermal diﬀusivity is the sum of laminar and turbulent thermal diﬀusivities. The implementation of each energy equation contains thermal source terms relevant to the particular solver.
For example, the sonicFoam solver contains the following implementation of the energy equation from equation 12.
fvm::ddt(rho, e) + fvm::div(phi, e)
+ fvc::ddt(rho, K) + fvc::div(phi, K)
+ fvc::div(fvc::absolute(phi/fvc::interpolate(rho), U), p, "div(phiv,p)")
- fvm::laplacian(turbulence->alphaEff(), e)
sonicFoam solves equations sequentially, so solves the momentum equation for before updating the speciﬁc kinetic energy ﬁeld for the energy equation above. More commonly, the energy equation is implemented in terms of both internal energy and enthalpy , as both equations 12 and 13, allowing the user to choose the solution variable, or , at run time. For example, the rhoPimpleFoam solver has the following implementation:
fvm::ddt(rho, he) + fvm::div(phi, he)
+ fvc::ddt(rho, K) + fvc::div(phi, K)
he.name() == "e"
- fvm::laplacian(turbulence->alphaEff(), he)
Here, “he” represents either or . The 5th term switches between and depending on the solution variable chosen by the user.
The rhoCentralFoam solver includes an implementation of an energy equation best represented by equation 14 that includes the mechanical source .
The choice of energy equation has a signiﬁcant on some solutions particularly across shocks. In the well known 1D shockTube tutorial example (Sod’s problem), the initial discontinuity causes a shock to propagate into the low pressure region and an expansion wave to propagate upstream. The ﬁgure below shows the temperature after 0.007 s, with simulation results compared with the analytical solution. Using the version of sonicFoam prior to OpenFOAM v2.2.0 that solves a thermal energy equation, the temperature diﬀerence across the shock is badly predicted. Using sonicFoam from v2.2.0 onwards that solves a total energy equation, conservation of total energy ensures the temperature diﬀerence is predicted accurately.