Open casella opened 2 months ago
SimulationX also reports the dimension error
Error in TestFunctionDefault: Wrong argument dimension.
Help: Check.DimCallArg
h=Medium.specificEnthalpy_pT(100000.,300);
The argument 3 (fill(0,0)) in the function call has the wrong dimension ([0]-vector). Expected dimension [1]-vector.
I wonder why OMC deduced type Integer[0]
from fill(0,0)
. Should it be fill(0.0,0)
?
I wonder why OMC deduced type
Integer[0]
fromfill(0,0)
. Should it befill(0.0,0)
?
OMC would normally convert it to fill(0.0, 0)
automatically, but that's done after checking if the types match. So the error message just uses the actual types rather than what the types would've been had they been compatible.
OK, there also is #4393 now which is independent of the dimension error.
This issue is causing regressons in OMC, so I would put it in MSL 4.1.0, I don't see any reason to postpone it to 4.2.0. The proposed modification is actually less restrictive, so there should be no backwards compatibility problems.
We need to cherry pick #4390 to maint/4.1.x so we get this fixed in the forthcoming release.
Consider this simple MWE:
This model compiles in Dymola 2024X and produces the expected result. However, when I try to compile it with OpenModelica, I get this error:
This output looks a bit odd at first sight, what's wrong in calling
specificEnthalpy_pT(1e5, 300)
? I thought it was an OMC bug, but in fact it turns out to be an MSL issue.specificEnthalpy_pT
, as defined in PartialPureSubstance, callsspecificEnthalpy_pTX(p, T, fill(0, 0))
, which is defined in PartialMedium asspecificEnthalpy(setState_pTX(p, T, X))
, so it callssetState_pTX
with a third argumentX = fill(0, 0)
.Unfortunately, setState_pTX for SimpleAir is defined in PartialSimpleIdealGasMedium as:
with input
MassFraction X[nX]
instead ofMassFraction X[:]
. Since by defaultnX = size(substanceNames, 1) = 1
, it then expects an array of dimension one, but instead gets an array of dimension zero, coming fromfill(0,0)
.I'm not sure why Dymola does not complain about this issue, but for sure it needs to be fixed. This holds for functions
specificEnthalpy_pTX
,temperature_phX
, anddensity_phX
in bothPartialSimpleMedium
andPartialSimpleIdealGasMedium
.