ModelicaStandardLibrary icon indicating copy to clipboard operation
ModelicaStandardLibrary copied to clipboard

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

Open HansOlsson opened this issue 10 months ago • 0 comments

Issues listed below:

  • [ ] Using bww as temporary in function?
  • [ ] Rewrite division to be clearer?
  • [ ] Or?

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:

  • Incorrect units for something.
  • Incorrect formula.
  • A missing conversion that happen to have the value 1 for some reason.
  • A coincidence that the values look similar.

HansOlsson avatar Mar 27 '24 10:03 HansOlsson