Opened 7 years ago
Last modified 3 years ago
#4526 new enhancement
Propagate displayUnits on simple equations
Reported by: | Francesco Casella | Owned by: | Mahder Alemseged Gebremedhin |
---|---|---|---|
Priority: | high | Milestone: | |
Component: | New Instantiation | Version: | |
Keywords: | Cc: |
Description
After the ban on replaceable base classes in Modelica 3.0, input & output connectors are Real and no longer have units. When building components the typical pattern is the following:
model M Modelica.SIunits.Temperature T; Modelica.Blocks.Interfaces.RealOutput T_out; ... equation ... T_out = T; ... end M;
It would be great if in this case the unit and displayUnit information was automatically propagated from T to T_out, so that I can see the temperature in degrees Celsius when I'm looking into the connector variable.
This can be trivially implemented by checking all the equations in the form:
a = b; a + b = 0;
where one of the variables (e.g., a
) has a non-empty unit string, while the other (e.g., b
) has an empty unit string. In this case, b
takes the unit and displayUnit attributes of a
.
When implementing this feature, please pay attention to efficiency, see #4362
Change History (13)
follow-up: 3 comment:1 by , 7 years ago
comment:2 by , 7 years ago
Component: | NF - New FrontEnd → New Instantiation |
---|
Move all tickets from NF - New Frontend to New Instantiation so we don't have two different categories for the same thing.
follow-up: 6 comment:3 by , 7 years ago
Replying to casella:
@mahge930 reports:
Can you try it with the flags -d=frontEndUnitCheck -d=dumpUnits
-d=frontEndUnitCheck enables the new front end unit check.
This only dumps information to stdout. I believe this ticket is requesting to actually update the DAE structure so that OMEdit would show the correct units in the plotting. Possibly we should even output the propagated units in the flat Modelica?
Anyway, this should not be all that difficult to implement; when performing unit checking we have the list of variables with propagated units, so we only need to traverse the DAE structure (only the elements?) and update the units.
comment:4 by , 7 years ago
Actually, I guess the displayUnit would not be propagated since the unit checking does not consider it.
comment:5 by , 7 years ago
https://github.com/OpenModelica/OMCompiler/pull/2104 updates the DAE with the propagated units (which was already calculated but not returned); displayUnit is not considered though.
comment:6 by , 7 years ago
Replying to sjoelund.se:
This only dumps information to stdout. I believe this ticket is requesting to actually update the DAE structure so that OMEdit would show the correct units in the plotting.
Yes.
Possibly we should even output the propagated units in the flat Modelica?
Yes.
Replying to sjoelund.se:
displayUnit is not considered though
It is already better to have unit information rather than no unit information at all. However, the best user experience is obtained if also displayUnit is propagated, otherwise in the above example I would see T in Celsius and T_out in Kelvin, which would be quite puzzling and has no rationale behind it.
comment:7 by , 7 years ago
Summary: | Propagate units on simple equations → Propagate units and displayUnits on simple equations |
---|
comment:8 by , 6 years ago
Summary: | Propagate units and displayUnits on simple equations → Propagate displayUnits on simple equations |
---|
Changed the name to better reflect the currently standing issue
comment:10 by , 5 years ago
Milestone: | 1.14.0 → 1.16.0 |
---|
Releasing 1.14.0 which is stable and has many improvements w.r.t. 1.13.2. This issue is rescheduled to 1.16.0
comment:12 by , 4 years ago
Milestone: | 1.17.0 → 1.18.0 |
---|
Retargeted to 1.18.0 because of 1.17.0 timed release.
@mahge930 reports:
We'll try this out and report. See also #4531.