Incorrect definition of isentropicExponent for moist air near saturation
Modelica.Media.Air.MoistAir.isentropicExponent (MSL 4.1.0) is currently defined as
gamma := specificHeatCapacityCp(state) / specificHeatCapacityCv(state);
This definition is only valid for ideal gases.
For real media, the correct thermodynamic definition is
where rho is the density, p the pressure, and a the speed of sound.
Unfortunately, in Modelica.Media.Air.MoistAir, this dependency is circular: the speed of sound is itself computed based on the isentropic exponent. As a result, the formulation becomes invalid close to saturation.
Observed behavior
Model: MoistAirIsentropicExponent.zip
Tested with MSL 4.0.0 (as far as i know, no change in 4.1.0)
Figure 1a (top left) shows the isentropic exponent kappa (gamma) for "humidity" values from 99.8% to 100.2% (phi = p_H2O/p_H2O_sat = relative humidity, psi = x/x_sat = normalized humidity ratio; see Fig. 1c bottom left). In this narrow range, kappa changes dramatically from approximately 1.4 to 4.5.
Figure 1b illustrates the effect on an exemplary isentropic compression from 1 bar to 2 bar, with an inlet temperature of 20 °C:
T_is: outlet temperature computed using Medium.specificEntropy
T_kappa: outlet temperature computed using the isentropic exponent from
Fig. 1a
The resulting outlet temperature varies from roughly 80 °C to 230 °C.
Practical impact
In climate and HVAC system modeling, it is common to set ambient conditions to saturated air ( phi = psi = 1). With the current implementation, this can lead to severe modeling errors.
Possible solutions
-
Documentation update
Clearly state that isentropicExponent() is only valid for approximately
phi, psi < 0.999.
-
Runtime warning
Trigger a warning in isentropicExponent() for phi, psi > 0.999.
-
Use unsaturated kappa beyond saturation
Apply the unsaturated isentropic exponent also for kappa >= 1.
While not physically exact, this is far more accurate than the current
behavior. The isentropic exponent changes only slightly for oversaturated
air. The model would still be incorrect for large amount of liquid or solid water, but MoistAir
does not properly support Xi = 1 anyway.
-
Full model correction
Update the model formulation to be valid for psi, phi >= 1.
Recommendation
From a cost–benefit perspective, (3) + (1) appears to be the most practical solution to me.
Option (2) would also be useful, provided it does not generate an excessive number of warnings.
Remark
The definition of specificEntropy() does likewise not take liquid water and solid water into account, which is also noted in the documentation. Its defintion is however likely to cause only minor errors for slightly oversaturated air, comparably with option (3).

Incorrect definition of
isentropicExponentfor moist air near saturationModelica.Media.Air.MoistAir.isentropicExponent(MSL 4.1.0) is currently defined asThis definition is only valid for ideal gases.
For real media, the correct thermodynamic definition is
where
rhois the density,pthe pressure, andathe speed of sound.Unfortunately, in
Modelica.Media.Air.MoistAir, this dependency is circular: the speed of sound is itself computed based on the isentropic exponent. As a result, the formulation becomes invalid close to saturation.Observed behavior
Model: MoistAirIsentropicExponent.zip
Tested with MSL 4.0.0 (as far as i know, no change in 4.1.0)
Figure 1a (top left) shows the isentropic exponent
kappa(gamma)for "humidity" values from 99.8% to 100.2%(phi = p_H2O/p_H2O_sat= relative humidity,psi = x/x_sat= normalized humidity ratio; see Fig. 1c bottom left). In this narrow range,kappachanges dramatically from approximately 1.4 to 4.5.Figure 1b illustrates the effect on an exemplary isentropic compression from 1 bar to 2 bar, with an inlet temperature of 20 °C:
T_is: outlet temperature computed usingMedium.specificEntropyT_kappa: outlet temperature computed using the isentropic exponent fromFig. 1a
The resulting outlet temperature varies from roughly 80 °C to 230 °C.
Practical impact
In climate and HVAC system modeling, it is common to set ambient conditions to saturated air (
phi = psi = 1). With the current implementation, this can lead to severe modeling errors.Possible solutions
Documentation update
Clearly state that
isentropicExponent()is only valid for approximatelyphi, psi < 0.999.Runtime warning
Trigger a warning in
isentropicExponent()forphi, psi > 0.999.Use unsaturated
kappabeyond saturationApply the unsaturated isentropic exponent also for
kappa >= 1.While not physically exact, this is far more accurate than the current
behavior. The isentropic exponent changes only slightly for oversaturated
air. The model would still be incorrect for large amount of liquid or solid water, but
MoistAirdoes not properly support
Xi = 1anyway.Full model correction
Update the model formulation to be valid for
psi, phi >= 1.Recommendation
From a cost–benefit perspective, (3) + (1) appears to be the most practical solution to me.
Option (2) would also be useful, provided it does not generate an excessive number of warnings.
Remark
The definition of
specificEntropy()does likewise not take liquid water and solid water into account, which is also noted in the documentation. Its defintion is however likely to cause only minor errors for slightly oversaturated air, comparably with option (3).