You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a unit checking topic affecting #3266 and #3257.
What is the desired unit inference behavior in the following model?
model LiteralTimesInferredUnit
Real power(unit = "W") = 10;
constant Real i1(unit = "A") = 5;
Real i3 = 5;
Real u1;
Real u2;
Real u3;
equation
power = u1 * i1;
power = u2 * 5; /* "5" is a literal meant to represent a constant current equal to i1. */
power = u3 * i3; /* Not getting a unit for u3 seems better than getting "W". */
end LiteralTimesInferredUnit;
To clarify the problem, wouldn't it be unfortunate if we ended up assigning the unit "1" to the literal 5, and then infer that u2 has the same unit as power?
The above example has no declared units in the expression u2 * 5, but the example can also be generalized to efficiency * u2 * 5 or u2 * 5 * efficiency, where efficiency has unit W/W, showing that the problem isn't unique to expressions without any declared units.
The problem makes me ready to give up on the pure bottom-up approach operating on the Modelica expression tree, making me ready to take a more global approach to multiplicative expressions. It would then be possible to say that we can't even infer the unit of a factor subexpression with empty unit as long as the whole multiplicative expression also contains variables whose units still remain to be inferred. That is, unit inference shouldn't be able to make any progress on u2 * 5, meaning that the unit of u2 cannot be inferred. However, if the unit of u2 would be inferred to V from some other equation, there wouldn't be any more variables with units remaining to be inferred in the product, and then the factor 5 with empty unit could safely be assigned the unit "1" to avoid the wildcard effect.
Edit: For comparison, I think we all agree that the expected behavior for u3 and i3 is that none of them get an inferred unit, as the splitting of "W" into two factors would be completely arbitrary.
The text was updated successfully, but these errors were encountered:
This is a unit checking topic affecting #3266 and #3257.
What is the desired unit inference behavior in the following model?
To clarify the problem, wouldn't it be unfortunate if we ended up assigning the unit
"1"
to the literal5
, and then infer thatu2
has the same unit aspower
?The above example has no declared units in the expression
u2 * 5
, but the example can also be generalized toefficiency * u2 * 5
oru2 * 5 * efficiency
, whereefficiency
has unitW/W
, showing that the problem isn't unique to expressions without any declared units.The problem makes me ready to give up on the pure bottom-up approach operating on the Modelica expression tree, making me ready to take a more global approach to multiplicative expressions. It would then be possible to say that we can't even infer the unit of a factor subexpression with empty unit as long as the whole multiplicative expression also contains variables whose units still remain to be inferred. That is, unit inference shouldn't be able to make any progress on
u2 * 5
, meaning that the unit ofu2
cannot be inferred. However, if the unit ofu2
would be inferred toV
from some other equation, there wouldn't be any more variables with units remaining to be inferred in the product, and then the factor5
with empty unit could safely be assigned the unit"1"
to avoid the wildcard effect.Edit: For comparison, I think we all agree that the expected behavior for
u3
andi3
is that none of them get an inferred unit, as the splitting of"W"
into two factors would be completely arbitrary.The text was updated successfully, but these errors were encountered: