modelica / ModelicaStandardLibrary

Free (standard conforming) library to model mechanical (1D/3D), electrical (analog, digital, machines), magnetic, thermal, fluid, control systems and hierarchical state machines. Also numerical functions and functions for strings, files and streams are included.
https://doc.modelica.org
BSD 3-Clause "New" or "Revised" License
452 stars 165 forks source link

Incorrect units, confusing style, and probably more in Modelica.Media.Air.ReferenceMoistAir #4368

Open HansOlsson opened 3 months ago

HansOlsson commented 3 months ago

Issues listed below:

It started from unit-checking MSL which detected something odd in: Modelica.Media.Air.ReferenceMoistAir.Utilities.VirialCoefficients.Bww_dT specifically the line:

bww := (bww + N[55]*Delta55^b[55]*psi55 + N[56]*Delta56^b[56]*psi56)/
    Modelica.Media.Air.ReferenceMoistAir.Utilities.Water95_Utilities.Constants.rhored
    *Modelica.Media.Air.ReferenceMoistAir.Utilities.Water95_Utilities.Constants.MM;

It might be that bww on the line before is a "temporary" with a different unit, which could explain the unit-error.

However, regardless of that the style of ..../rhored*MM is a bit confusing to me (I have to spend a few second to remember the precedence). I would write ...*MM/rhored - to clarify the meaning. The same issue occurs in Modelica.Media.Air.ReferenceMoistAir.Utilities.Water95_Utilities - where criticalMolarVolume=1/322.0*0.018015268 (using identical literal values instead of constants - thus bypassing any unit-check).

But, that made me think once more: MM/rhored has unit [kg/mol]/[mol/m3]=[kg.m3.mol-2] whereas MolarVolume used for criticalMolarVolume has unit [m3.mol-1]. Is it just coincidence that it is the same values - or is there some additional issue? I know a factor of 1kg/m3 or 1000kg/m3 is easy to slip by for air or water; but that wouldn't explain it.

It could be: