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)

comment:1 by Francesco Casella, 7 years ago

@mahge930 reports:

I think this is already supported.

Can you try it with the flags -d=frontEndUnitCheck -d=dumpUnits
-d=frontEndUnitCheck enables the new front end unit check.

-d=dumpUnits notifies you about the units calculated, i.e, exactly what you are looking for.

I know this doesn't work with with -d=newInst right now. That is only because the unit checking is not enabled for NF.

The old front end was used to test this out during the implementation because it had a complete support for many more things. I think we can enable it for the NF whenever needed.

We'll try this out and report. See also #4531.

comment:2 by Per Östlund, 7 years ago

Component: NF - New FrontEndNew Instantiation

Move all tickets from NF - New Frontend to New Instantiation so we don't have two different categories for the same thing.

in reply to:  1 ; comment:3 by Martin Sjölund, 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 Martin Sjölund, 7 years ago

Actually, I guess the displayUnit would not be propagated since the unit checking does not consider it.

comment:5 by Martin Sjölund, 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.

in reply to:  3 comment:6 by Francesco Casella, 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 Francesco Casella, 7 years ago

Summary: Propagate units on simple equationsPropagate units and displayUnits on simple equations

comment:8 by Francesco Casella, 6 years ago

Summary: Propagate units and displayUnits on simple equationsPropagate displayUnits on simple equations

Changed the name to better reflect the currently standing issue

comment:9 by Francesco Casella, 6 years ago

Milestone: 1.13.01.14.0

Rescheduled to 1.14.0 after 1.13.0 releasee

comment:10 by Francesco Casella, 5 years ago

Milestone: 1.14.01.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:11 by Francesco Casella, 4 years ago

Milestone: 1.16.01.17.0

Retargeted to 1.17.0 after 1.16.0 release

comment:12 by Francesco Casella, 4 years ago

Milestone: 1.17.01.18.0

Retargeted to 1.18.0 because of 1.17.0 timed release.

comment:13 by Francesco Casella, 3 years ago

Milestone: 1.18.0

Ticket retargeted after milestone closed

Note: See TracTickets for help on using tickets.