Skip to content

Inconsistencies found in the Modelica Standard Library 4.1.0

English | Japanese

« One-dimensional models

OpenRheo's 1D tier ports the Modelica Standard Library (MSL) 4.1.0 (BSD-3) to C++. While checking the port against MSL 4.1.0 run in OpenModelica 1.27.1, we found six places where the MSL code disagrees with its own documentation, the cited literature, or the IAPWS standard. This page records them (2026-11-20).

  • Reference: MSL tag v4.1.0 (commit 8ae3d35); line numbers refer to that tag.
  • None of these is a porting error. With the port switched to MSL behaviour it matches OpenModelica to ≤ 3e-14 relative (fluid) and ≤ 1.5e-12 (water).
  • OpenRheo's default is the corrected behaviour (documentation / literature / standard). A switch reproduces MSL 4.1.0 exactly.
  • Not yet reported upstream. Feel free to use this page for reports or checks.

Summary

ID Where What Effect
Q1 Fluid.Dissipation, curved bend laminar loss coefficient doubled laminar bend Δp ×2
Q2 Fluid.Dissipation, both bends relative roughness divided by the diameter (in m) again turbulent Δp up to +17 % (curved), +24.7 % (edged); similar bends differ with size
Q3 Fluid.Dissipation, valve geometries two different Cv→Av factors default Av→Cv→Av round trip off by 2.4 %
D1 Media.Water.IF97_Utilities, region 2 ideal-gas coefficients lose their 9th digit h up to 4.1e-8, cp up to 3.4e-7; 30 of 36 IAPWS check values fail
D2 Media.Water.IF97_Utilities, region 5 1997 equation, not R7-97(2012) 1e-6 to 4e-6 relative; range limited to 10 MPa
D3 Media.Water.IF97_Utilities, waterBaseProp_dT region 5 calls g2 instead of g5 every (d, T) state above 1073.15 K stops with an assert

Fluid (Modelica/Fluid/Dissipation.mo)

Q1: laminar doubling in the curved bend

  • Where: PressureLoss.Bend.dp_curvedOverall_DP lines 3043–3049 (CF_fri), dp_curvedOverall_MFLOW lines 3219–3225 (CF_3).
  • Code: CF_fri = 1 + SMOOTH(Re_lam_max, Re_lam_leave, Re)*min(1.4, …) + SMOOTH(Re_lam_leave, Re_lam_max, Re).
  • Disagreement: the second SMOOTH term is 1 for Re ≤ Re_lam_leave, so CF_fri = 2 and ζ doubles in the laminar regime. The documentation (line 7985) says "There is no correction due to roughness in the laminar regime up to Re ≤ 6.5e3" (Idelchik 2006, p.336).
  • Evidence: for Re < 1e3 MSL's Δp is exactly twice the corrected value.
  • OpenRheo default: the term is dropped; ζ = A2/Re + A1·B1.

Q2: roughness divided by the diameter twice in both bends

  • Where: dp_curvedOverall_DP line 3038, dp_curvedOverall_MFLOW line 3211, dp_edgedOverall_DP line 3360, dp_edgedOverall_MFLOW lines 3496, 3507, 3513, 3561.
  • Code: lambda_FRI_rough = 0.25/(log10(k/(3.7*d_hyd) + 5.74/Re^0.9))^2 with k = K/d_hyd already relative.
  • Disagreement: the documented formula (line 7953) uses the absolute roughness K: 0.25*(lg(K/(3.7*d_hyd) + 5.74/Re^0.9))^-2 (Miller 1984, eq. 8.4). The code divides the relative roughness again by the diameter in metres, which is not dimensionally consistent: roughness is amplified for d < 1 m and suppressed for d > 1 m.
  • Example: k/d = 1e-2, R0/d = 2, Re = 1e6 gives ζ = 0.356 at d = 0.05 m and 0.268 at d = 1 m; geometrically similar bends should give the same value.
  • Evidence: at Re > 1e5 MSL's Δp is up to 17 % (curved) and 24.7 % (edged) above the corrected value (d = 0.1 m, K = 5e-5 m).
  • OpenRheo default: k/3.7, so ζ depends only on K/d.

Q3: two Cv→Av factors in the valve geometries

  • Where: PressureLoss.Valve.dp_severalGeometryOverall_DP line 5911 and _MFLOW line 6020 use Av = Cv*24e-6; the record default dp_severalGeometryOverall_IN_con.Cv = Av/24.6e-6 (line 6111) uses another factor.
  • Effect: the default Av → Cv → Av round trip loses 2.4 %. (Fluid.Valves.BaseClasses.PartialValve.Cv2Av = 24.0e-6, Valves.mo line 544, is self-consistent.)
  • OpenRheo default: one factor in both places, the IEC 60534 value 2.4027e-5 m² per US gal/min.

Water and steam (Modelica/Media/Water/IF97_Utilities.mo)

D1: region-2 ideal-gas coefficients

The coefficients n_i^o of IAPWS R7-97(2012) Table 10 appear with the 9th significant digit dropped and the remaining digits shifted.

coefficient (J_i^o) MSL 4.1.0 IAPWS R7-97(2012) relative error
n1^o (0) -9.6927686002170 -9.6927686500217 5.1e-9
n2^o (1) 10.0866556801800 10.086655968018 2.8e-9
n3^o (-5) -0.0056087911830200 -0.0056087911283020 9.8e-9
n4^o (-4) 0.071452738814550 0.071452738081455 1.0e-8
n5^o (-3) -0.40710498239280 -0.40710498223928 3.8e-10
n6^o (-2) 1.42408197144400 1.4240819171444 3.8e-8
n7^o (-1) -4.3839511194500 -4.3839511319450 2.9e-9
n8^o (2) -0.284086326077200 -0.28408632460772 5.2e-9
n9^o (3) 0.0212684635330700 0.021268463753307 1.0e-8
  • Where they appear: BaseIF97.Basic.g2 (lines 1994–1998, 2034–2036, 2056), g2metastable (2161–2164, 2177–2178, 2186; the metastable n1^o/n2^o of the footnote are correct), g2pitau (2557–2558), Regions.slowerofp2 (557, 584), Isentropic.hofpT2 (4556–4558), Isentropic.handsofpT2 (4644–4650). With the derivative multiples (J n, J(J-1) n) there are 80 literals.
  • Effect: v is unaffected (only τ-derivatives change). Against IAPWS Tables 15 and 18: h and u off by 1.8e-5 to 1.4e-4 kJ/kg (≤ 4.1e-8 relative), s ≤ 3.3e-8, w ≤ 2.5e-8, cp ≤ 1.3e-7 relative. This exceeds half a unit of the 9th published digit, so 30 of the 36 entries fail. It also reaches ReferenceMoistAir (steam part, ≈ 1e-9).

D2: region-5 basic equation is the 1997 release

  • Where: BaseIF97.Basic.g5 (line 2339) and g5pitau (line 2602): the 1997 release with 5 residual terms, valid to data.PLIMIT5 = 10.0e6 (line 58).
  • Current: IAPWS R7-97(2012) Eqs. (32)–(34) with Tables 37/38 (6 residual terms, valid to 50 MPa).
  • Effect at the Table 42 state (1500 K, 0.5 MPa), MSL relative to IAPWS: v +1.9e-6, h −1.0e-6, s −4.6e-7, cp +3.0e-6, w +3.5e-6. The other two Table 42 states (30 MPa) are outside MSL's range.
  • This is an outdated equation rather than a coding error.

D3: waterBaseProp_dT calls g2 in region 5

  • Where: line 7967, g := BaseIF97.Basic.g2(aux.p, T);, after the region-5 pofdt125 iteration.
  • Effect: g2 asserts T ≤ 1073.15 K, so every (d, T) state in region 5 fails with "IF97 medium function g2: the input temperature … is higher than 1073.15 K". setState_dTX, p_dT, h_dT and the other *_dT functions are unusable above 1073.15 K.
  • OpenRheo default: call g5, consistent with the iteration; p(0.7222559 kg/m³, 1500 K) = 0.5 MPa to 1e-8.

MSL behaviour kept on purpose

  • In regions 1 and 2, T(p,h) and T(p,s) come from the IF97 backward equations without iteration; round trips are exact only to their permitted inconsistency (|ΔT| ≤ 25 mK).
  • The direct and inverse Moody transition splines differ by up to 8.5 % in Re; MSL documents this approximation, so it is kept.

How this was checked

  • The ported functions, switched to MSL behaviour, were compared with MSL 4.1.0 run in OpenModelica 1.27.1: 20 fluid functions over 302 rows, and every water column of the oracle set.
  • The corrected behaviour was then checked against the documentation and literature (Idelchik, Miller, IEC 60534) and against the IAPWS verification tables to all published digits.
  • Switches: fluid msl_quirks (default false); water if97_variant() (default Iapws; Msl_4_1_0 reproduces MSL).