Closed gwr69 closed 3 months ago
Your question actually touches upon a bigger limitation. Given two unit expressions a and b, it is surprisingly difficult to create the unit expression for their product. It isn't even allowed to work around the problem by putting an exponent on a parenthesized expression, as in "a/(b)-1"
.
But a/(b-1)
and even a/b-1
should work, shouldn’t it?
Only if b
is a unit-operand
. For something like "m/s"
it isn't allowed.
Indeed, you are of course right. That is what I meant with a more relaxed “input form” (which then might accept “m/s” or even “1” as factor) that a tool shout bring into a more strict “normal form”, e.g., as specified by section 19.1.
Considering the current role of units, I think it is right that the specification only specifies the valid input forms, and leave it up to tools to normalize or use other forms. Even if we would have had a less strict form of unit expressions in the Modelica specification, I don't think we would have benefited from using a more strict form in the tool – except from the completely canonicalized base unit factorizations we use to determine unit equivalence and convertibility.
Just a short clarification for section 19.1: Is there a good reason for allowing
J.kg-1.K-1
but not1.s-1
?Edit: Ok, I guess it makes sense to already restrict unit expressions before parsing instead of putting them into some kind of “normal form” afterwards.