#2250 closed enhancement (fixed)
Support DisplayUnit and unit conversion for parameter input in OMEdit
Reported by: | Francesco Casella | Owned by: | Adeel Asghar |
---|---|---|---|
Priority: | blocker | Milestone: | 1.11.0 |
Component: | OMEdit | Version: | trunk |
Keywords: | Cc: | kofranek@…, bernt.lie@… |
Description
The new MSL uses only SI units in the model, and assumes the GUI can handle DisplayUnits, as well as unit conversions for parameter input. This feature should be implemented in OMEdit in the next release.
Attachments (2)
Change History (43)
comment:1 by , 11 years ago
Milestone: | Future → 2.0.0 |
---|
comment:2 by , 11 years ago
comment:3 by , 11 years ago
Priority: | high → critical |
---|
comment:4 by , 11 years ago
Milestone: | 2.0.0 → 1.9.2 |
---|
comment:5 by , 10 years ago
Milestone: | 1.9.2 → 1.9.3 |
---|
Milestone changed to 1.9.3 since 1.9.2 was released.
comment:10 by , 9 years ago
Cc: | added |
---|
follow-up: 16 comment:11 by , 9 years ago
@adeas31: The commit message says "The plot data is now based on the display unit.", but something must have gone wrong. The code
model Test_displayunit Modelica.SIunits.Pressure p_test(displayUnit="bar"); equation p_test = 5e5; end Test_displayunit;
gives me the attached screenshot. Notice how the legend says [bar], but the data is still 5e5 (i.e. Pascal), not 5 (bar) as expected.
comment:12 by , 9 years ago
Forgot to add, this is on OMEdit v1.10.0-dev-53-g45d32fb. I guess this needs to be reopened?
follow-up: 14 comment:13 by , 9 years ago
Also, the variable in the Variables Browser is also still in Pascal, so does not heed the displayUnits, although one might discuss which one it should be.
Personally, I think it should follow displayUnit, as that allows one to scale all the parameters of a model to look at them in one plot, e.g. a valve pressure [O(1e5-1e7)] plus a valve opening [0..1].
comment:14 by , 9 years ago
Replying to Christoph <buchner@…>:
Also, the variable in the Variables Browser is also still in Pascal
That's correct, since the unit is listed there (not the displayUnit).
so does not heed the displayUnits, although one might discuss which one it should be.
Personally, I think it should follow displayUnit, as that allows one to scale all the parameters of a model to look at them in one plot, e.g. a valve pressure [O(1e5-1e7)] plus a valve opening [0..1].
I don't think it is really necessary to list the displayUnits, only to handle them correctly when actually displaying something. I am not sure I understand what you mean with your comment regading the scaling of all parameters in one plot.
BTW, it should also be possible to change the displayUnit on the fly if one needs so, without changing the Modelica source and re-running the simulation.
comment:15 by , 9 years ago
I am not sure I understand what you mean with your comment regading the scaling of all parameters in one plot.
Let's say you want to analyse the behaviour of a valve when varying the opening, and plot the upstream and downstream pressure, plus the opening. The pressures will typically be O(1e5-1e7), i.e. 1-100 bar, while the opening goes from 0..1. To meaningfully show this information together in one plot, you would set the displayUnit of the pressure to bar, so both quantities attain similar order of magnitude when analyzing.
As the plotting functionality currently does not honor displayUnit, all you see from the opening is a flat line on the bottom.
Alternatively, you can look at the variables browser, but when looking at the pressures you have to count zeros, which is error prone -- quick! is p=100000 or p=1000000 the value you expect? Again, it would be useful to honor the displayUnit the user set, to attain more similar magnitude for the quantities analyzed.
This gets worse the more quantities you plot, e.g. for the above valve you want to compare pressures (1e5-1e7 -> scale to bar), opening (0-1), and mass flow rates (1e-4 - 1e-2 -> scale to g/s).
comment:16 by , 9 years ago
Replying to Christoph <buchner@…>:
@adeas31: The commit message says "The plot data is now based on the display unit.", but something must have gone wrong. The code
model Test_displayunit Modelica.SIunits.Pressure p_test(displayUnit="bar"); equation p_test = 5e5; end Test_displayunit;gives me the attached screenshot. Notice how the legend says [bar], but the data is still 5e5 (i.e. Pascal), not 5 (bar) as expected.
Because we don't have bar
as unit in our system. I have added it now in 4759770/OMCompiler/. However, OMEdit should display error if we don't support the display unit and should fallback to the original unit. I have fixed this in efb215b/OMEdit.
comment:17 by , 9 years ago
Ah great, I will try this with the next nightly that has it.
Btw, regarding the quantity name, bar does not necessarily have to be "gauge pressure", it can be any kind of pressure (gauge, absolute,...), so it might be better to just say "pressure" to avoid confusion/misunderstandings. (Gauge pressure is commonly zero-referenced pressure against ambient air pressure)
follow-up: 21 comment:20 by , 9 years ago
I just would like to inquire,
1) how to add units conversions - i.e. physiolibrary uses units common in medicine and comes with conversion scripts for dymola - see https://goo.gl/oQoNBj
2) adding the possibility to set the parameters in any compatible displayUnit would be a big up! (as it is in dymola). This enables to effectively approach the model in common units, although it is modeled (and thus compatible) in convenient SI units. Is it planned in this ticket, or in future one?
comment:21 by , 9 years ago
Replying to Filip Jezek:
I just would like to inquire,
1) how to add units conversions - i.e. physiolibrary uses units common in medicine and comes with conversion scripts for dymola - see https://goo.gl/oQoNBj
Right now we don't have anyway to add units. We have some basic units and derived units defined in OpenModelica.
2) adding the possibility to set the parameters in any compatible displayUnit would be a big up! (as it is in dymola). This enables to effectively approach the model in common units, although it is modeled (and thus compatible) in convenient SI units. Is it planned in this ticket, or in future one?
This is already done as part of this ticket. Try for example Temperature
. You should be able to convert it from Kelvin to Celsius and vice versa.
follow-up: 27 comment:22 by , 9 years ago
Cc: | added |
---|
Adeel, could you please add the units "hour" and "day" to the list of time units, and make sure it is also used for the plot scaling if set as displayUnit?
This requirement comes from Bernt Lie, which often needs multi-day simulations, where it is much better to see 1 day or 24 hrs rather than 8.4e6 seconds.
comment:23 by , 9 years ago
We should really be able to have this configurable so that anybody can add units to OpenModelica if they specify conversions wrt SI units.
comment:24 by , 9 years ago
That would be nice. A simple text file where each line contains a unit string, an SI unit string, the ratio and the offset w.r.t. SI unit should be enough.
comment:25 by , 9 years ago
It is basically like that in the C++ file:
https://github.com/OpenModelica/OMCompiler/blob/master/Compiler/runtime/unitparser.cpp#L1068
but we should be able to read additional ones in there.
follow-up: 28 comment:26 by , 9 years ago
Just found a small unrelated error in the file linked from the above comment: the megawatt radiant flux has a unit symbol of MA, not MW: https://github.com/OpenModelica/OMCompiler/blob/7c597ec8b277cbc6446344aefcfa9fb9e5fda848/Compiler/runtime/unitparser.cpp#L1128
follow-up: 29 comment:27 by , 9 years ago
Replying to casella:
Adeel, could you please add the units "hour" and "day" to the list of time units, and make sure it is also used for the plot scaling if set as displayUnit?
This requirement comes from Bernt Lie, which often needs multi-day simulations, where it is much better to see 1 day or 24 hrs rather than 8.4e6 seconds.
Done in 58a8915/OMCompiler.
Note that plot can only display values accroding to the displayUnit. I still haven't implemented a way inside the plotting which allows you to choose from different units like in parameters window.
comment:28 by , 9 years ago
Replying to Christoph <buchner@…>:
Just found a small unrelated error in the file linked from the above comment: the megawatt radiant flux has a unit symbol of MA, not MW: https://github.com/OpenModelica/OMCompiler/blob/7c597ec8b277cbc6446344aefcfa9fb9e5fda848/Compiler/runtime/unitparser.cpp#L1128
Fixed in 58a8915/OMCompiler.
comment:29 by , 9 years ago
Replying to adeas31:
Note that plot can only display values accroding to the displayUnit. I still haven't implemented a way inside the plotting which allows you to choose from different units like in parameters window.
In fact, what Bernt was looking for was changing the time unit, i.e. the unit on the abscissa of the graph. When you allow to choose from different units for the Y axis, please remember to also make it possible for the X axis.
follow-up: 31 comment:30 by , 9 years ago
As far as I know, OpenModelica has still no unit information for built-in variable time. At least there is nothing in the variable browser of OMEdit.
follow-up: 32 comment:31 by , 9 years ago
Replying to lochel:
As far as I know, OpenModelica has still no unit information for built-in variable time. At least there is nothing in the variable browser of OMEdit.
According to the Modelica specification, section 3.6.7, the built-in variable time
has unit "s", so this needs to be fixed.
Unfortunately, I see no way to declare a displayUnit for time in a model, because time
is only implicitly defined. However, OMEdit could give the option of setting the displayUnit of this built-in variable.
comment:32 by , 9 years ago
Replying to casella:
Unfortunately, I see no way to declare a displayUnit for time in a model, because
time
is only implicitly defined. However, OMEdit could give the option of setting the displayUnit of this built-in variable.
OMEdit could give the option to change the displayUnit for any variable that is plotted, regardless if it was defined with a displayUnit or not :)
follow-up: 35 comment:34 by , 9 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
I added convert units support in plotting view as well a2b889d/OMEdit.
The variables browser now has display unit column which contains a drop down list with possible units.
comment:35 by , 8 years ago
Replying to adeas31:
I added convert units support in plotting view as well a2b889d/OMEdit.
The variables browser now has display unit column which contains a drop down list with possible units.
Great work. This really enhances the usability of OMEdit for the evaluation of simulation results. But the data is plotted with wrong units after re-simulation (please see screenshots attached):
- Selecting the temperature variables after initial simulation will plot them correctly in degC
- After re-simulation (without changing anything on the plot) one of the temperature curves will change to values in Kelvin. The display unit entry in the appropriate column in the Variable Browser remain unchanged
- Changing the display unit setting to K for this variable gives totally wrong results in the plot, as 273.15 is added to the values that are already in K
- Only solution to get the plot right again, is unchecking and re-checking this variable for plotting
comment:36 by , 8 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
Reopened, as the issue described above is closely related to the added units support in plotting view.
comment:38 by , 8 years ago
Milestone: | 1.10.0 → 2.0.0 |
---|---|
Priority: | critical → blocker |
follow-up: 40 comment:39 by , 8 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
Fixed in e4abcb5/OMEdit.
comment:40 by , 8 years ago
Many thanks to Adeel for the fix. The use case described in the screenshot in comment:36 now works as expected.
r18156 added an API call that can convert between units (returns the scale factor and offset). Should be easy to add a displayUnit column to OMEdit (user editable, combo box that remembers the xml-file unit and displayUnit).