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
470 stars 168 forks source link

Issue with uninitialized record fields #1910

Open modelica-trac-importer opened 7 years ago

modelica-trac-importer commented 7 years ago

Reported by awittkop on 16 Feb 2016 16:33 UTC In the MSL file Media/Water/IF97_Utilities.mo on lines 894 and 931 in the functions boilingcurve_p and dewcurve_p respectively, a property record (Common.IF97PhaseBoundaryProperties) is populated.

For both these functions, in the else clauses of the contained if statement, the cp, vt, and vp fields are left uninitialized.

Isn't it necessary that (all parts of) declared outputs be set before returning?


Migrated-From: https://trac.modelica.org/Modelica/ticket/1910

modelica-trac-importer commented 7 years ago

Modified by dietmarw on 17 Feb 2016 07:31 UTC

thorade commented 4 years ago

Here is direct link to the code: https://github.com/modelica/ModelicaStandardLibrary/blob/master/Modelica/Media/Water/IF97_Utilities.mo#L894-L966

The Modelica path is Modelica.Media.Water.IF97_Utilities.BaseIF97.Regions.boilingcurve_p Modelica.Media.Water.IF97_Utilities.BaseIF97.Regions.dewcurve_p

thorade commented 4 years ago

These records are to my understanding only used for some iterations, not to be used by end users (these functions are not part of the interface). Thetwo branches of the if-else are different, because in the two different regions different iterations are used. Calculating values that are not used later on, might be a waste of time, but we could of course do it.

If we just want to comply with the language specification, we could just explicitly set each missing value to 0.