The MIGALE solver’s predicting capabilities are extended with three real gas models: the pressure-explicit CEoSs of van der Waals [
1] and Peng–Robinson [
2] (
Section 3.1) and the Helmholtz-explicit MEoS of Span–Wagner [
3] (
Section 3.2). MEoSs generally require more coefficients with respect to CEoSs and their computational cost is, therefore, much higher. On the other hand, they also guarantee superior accuracy for thermodynamic quantities whose values are crucial during a fluid dynamic simulation, such as the speed of sound. The implementation of all models is discussed, also describing modifications needed by other algorithms of the solver, such as the numerical flux computation and boundary conditions (
Section 3.3 and
Section 3.4).
3.1. Peng–Robinson and van der Waals Models
The pressure-explicit CEoSs of van der Waals [
1] and Peng–Robinson [
2] can be obtained from the general formulation [
28] as
where
p is the fluid pressure,
the density,
T the temperature,
the mass-specific gas constant,
the universal gas constant, and
the fluid’s molecular weight. Equation (
20) shows also the term
, which accounts for intermolecular attractions, and the terms
B,
C, and
D that account for molecular volume. The term
A is usually written as
, where the function
(if not null) contains the dependence of
from the molecular shape, whereas
a is a constant. For all models that can be obtained from Equation (
20),
A,
B,
C, and
D assume different values, depending on the working fluid. In fact, they depend from some input parameters, which are the critical pressure
and temperature
, the molecular weight, and the acentric factor
, which is an estimation of the non-sphericity of the molecules defined as
, where
,
, and
is the saturation pressure.
Table 1 summarizes the expressions that must be used for
A,
B,
C, and
D to obtain the van der Waals and the Peng–Robinson gas models, which are given by
If the ideal gas law is recovered.
Starting from these equations, a complete characterization of a pure single-phase substance comes from the determination of at least one caloric EoS for each model [
29]. A general procedure for any thermal pressure-explicit EoS like the one in Equation (
20) is given by Reynolds [
30]. The expression for the mass-specific internal energy takes the form
whereas the mass-specific entropy is
where
and
are used as symbolic substitutes of
and
T in the integral functions and
identifies an arbitrary reference state. The last terms in both Equations (
22) and (
23) represent departure functions from the non-polytropic ideal gas behavior since they vanish for sufficiently rarefied thermodynamic states, i.e.,
. The remaining two integrals require instead an expression for the ideal gas contribution to the isochoric specific heat
, which is by definition the limit of
as
. In this work, a polynomial function of the absolute temperature in the form
is employed for each considered fluid, where
is the ideal gas contribution to the isobaric specific heat. Coefficients
for
can be determined theoretically from chemical group contribution methods such as the one in [
31], or from given polynomial fittings of experimental data available in the literature.
Once the expressions for
and
are known, all the other relevant thermodynamic properties can be determined using a combination of them and of their derivatives. For example, by definition the mass-specific enthalpy and real gas isochoric specific heat are obtained as
As reported in [
32], the real gas isobaric specific heat and the speed of sound are obtained from
Another important quantity that must be determined is the fundamental derivative of gas dynamics
, that following the work of Cramer [
33] can be again expressed as a function of temperature and density only, as
This derivative is crucial in real gas dynamics, since with negative values of
some non-classical phenomena may arise, such as expansion shocks or compression fans [
34].
Lastly, since the solver works with
p and
T as independent variables, the computation of the inverse problem is needed, as
The fluid density is determined from the equation for the pressure. When the models are derived by Equation (
20), the thermal EoS can be reformulated as a third-degree polynomial in the density, whose coefficients are a function of temperature and pressure, i.e.,
, with
for
. The analytical resolution method of Cardano is employed in this work, whereas the physical meaning and validity of each root have been determined using the considerations in [
35]. For temperature, some Newton’s iterations are employed on the functions
and
, since their derivatives are known and the resulting formulation is more complicated. Initial guesses are calculated using the polytropic ideal gas model with
.
3.2. Span–Wagner Model
The Helmholtz-explicit MEoS of Span–Wagner [
3] is formulated in terms of an optimized functional fit of experimental measurements, which can be derived for any fluid having a sufficiently wide and precise range of data [
36]. The derived EoS is formulated for the free Helmholtz energy state function
, described in a non-dimensional form with the summation of an ideal gas contribution and a real gas residual as
where
is the reduced density and
is the inverse of the reduced temperature. In Equation (
28), the dimensional ideal gas part is defined as
since for the ideal gas
. So, once a suitable approximation of
is provided,
can be completely determined by computing two integrals. In this work, four different functional forms can be activated by the user, since
is implemented as
where each term represents an approximation of a statistical mechanical behavior of the ideal gas heat capacity as suggested by Aly and Lee [
37]. In Equation (
30), coefficients
are considered as user parameter, since many functional fittings can be found in the literature. The non-dimensional residual part of Equation (
28) is similarly provided as a summation of various activatable terms as
with
and where the last Gaussian bell-shaped sums are generally used to improve the fluid description near the critical point [
36].
Thanks to the Helmholtz energy definition, all the other relevant thermodynamic properties can be computed with Maxwell’s relations, such as
whereas Equations (
24)–(
26) still hold for the calculation of the enthalpy, specific heats, speed of sound, and fundamental derivative. The inverse problem of Equation (
27) is here treated with Newton’s iterations also for the density, but since the number of roots may be higher than the CEoS case, some efficient initial guesses are chosen as suggested by Span [
36]. In particular, the initial guess for the density is provided by the Peng–Robinson model, whose coefficients are calculated and stored once. For the temperature, a simplified version of the van der Waals model with a power law ideal gas-specific heat is analytically inverted. The adopted expression is
, where
and
as suggested by [
33]. Furthermore, the van der Waals coefficients are calculated and stored before computations.
3.3. Derivatives
The first and second derivatives of the thermodynamic properties are needed for the Jacobian matrix of the implicit time integration scheme, the shock-capturing term, the permutation matrix, and the convective fluxes. In particular, the following derivatives must be provided:
where
can represent
e,
h,
c,
s,
,
. Since all the properties are formulated as functions of
and
T, the exact expressions of their first and second derivatives with respect to these variables are obtained with the AD tool Tapenade [
15]. Then, using the relations from [
38], which involve just the derivatives of
, the values of
are calculated. Thanks to the chain rule on
, and considering that
, where
y can be either
p or
T, the last five derivatives in Equation (
33) can be rewritten as
The first two derivatives in Equation (
33) are determined as suggested by Cinnella [
39]. However, despite Equations (
35)–(
39) being valid for all the chosen EoSs, the Span–Wagner model requires a further step, i.e., the computation of all the pure and mixed derivatives, from the first to the third order of the non-dimensional Helmholtz energy state function. This task is here performed with the AD tool Tapenade [
15].
3.4. Numerical Fluxes and Boundary Conditions
The first thermodynamic generalization required by the solver is the adoption of a consistent numerical flux for real gas computations. In this work, the generalization of the approximate Riemann solver of Roe [
8] proposed by Vinokur-Montagné [
9] is used for the convective part. This procedure differs from the original Roe version since in the real gas regime the description of the Roe averaged state must be enriched with the definition of averaged values of the pressure derivatives
and
between the two sides of every mesh interface. These values are here obtained following the procedure proposed by Glaister [
10] and then used to generalize the Roe averaged a speed of sound for the determination of convective eigenvalues.
For the viscous part, the generalized multiparameter correlation of Chung et al. [
7] for the determination of transport properties in real gas regime is applied. In particular, the procedure allows for estimating reliable values of the molecular dynamic viscosity and thermal conductivity of polar and non-polar fluids as functions of
and
T. The required additional input data are the critical density
, the dipole moment of the fluid molecules, and the equilibrium dissociation constant of the substance.
The contribution of the new flux to the global Jacobian matrix is computed with the AD tool Tapenade [
15], an open source algorithm developed by the Institut National de Recherche en Sciences et Technologies du Numérique (INRIA). AD guarantees that every derivative will be mathematically exact and will not suffer any truncation error, which is typical of the finite differences (FD) approach [
40]. In fact, every derivative is obtained with a symbolic optimized differentiation of all the lines of a source code, to generate a new program that will contain the calculations for both the original outputs and their derivatives. This is made possible by an iterative application of the chain rule of differentiation since the whole source code is interpreted as a composite function of all its lines. The chain can be traveled from top to bottom with the tangent (or direct) differentiation mode or from bottom to top with the adjoint (or reverse) mode (see [
15] for further details). In this work, the tangent mode has been used, since it is best suited for large amounts of inputs and is easy to use. In particular, the focus is on the term
in Equation (
11), where
and
are the unknown variables at the inner and outer side of an element face. The Jacobian matrix of
is generated column by column, differentiating
one time in tangent mode for every component of
and
. Every column is then wrapped with the others to assemble the Jacobian matrix. This often results in an increment of the computational cost with respect to manually derived analytical procedures, which are often difficult to obtain. In this work, an ad hoc automated strategy for the use of Tapenade has been derived, that is able to scan and modify the generated routines to avoid or regroup redundant computations. The new Jacobian matrix is thus characterized by a lower computational cost with respect to FD, especially when the thermodynamic or physical complexity is high.
Table 2 reports the time required to perform
calls to the routines to build the Jacobian matrix of an inviscid two-dimensional convective flux and a three-dimensional turbulent diffusive flux. AD is always less expansive than the FD counterpart, and shows a maximum reduction in the computing time
.
The second generalization concerns inflow and outflow boundary conditions, which are implemented following the work of Colonna and Rebay [
11]. The approach relies on the determination of a linearized form of the Riemann invariants, that allows the imposition of the proper set of physical quantities at every boundary face in both subsonic and supersonic regimes, for both incoming and outgoing flows. The contribution to the global Jacobian matrix of the residual is also here derived with Tapenade [
15], following the same approach described for the convective and viscous fluxes.