OpenModelica icon indicating copy to clipboard operation
OpenModelica copied to clipboard

Bug: Multiple display unit changes in plotting with prefix unit

Open abuntrock opened this issue 1 year ago • 1 comments

Description

When a display unit is changed multiple times in the plotting window the value is in a prefix unit (e.g. krpm) but the legend displays the base unit (e.g. rpm). Soryy for duplicate if this is already part of another plot unit related issue but I could not find an issue directly addressing this bug.

Steps to Reproduce

  1. Simulate the following model with the Prefix Unit option activated:
model PlotUnitError
  Modelica.Mechanics.Rotational.Components.Inertia inertia annotation(
    Placement(transformation(origin = {10, 10}, extent = {{-10, -10}, {10, 10}})));
  Modelica.Mechanics.Rotational.Sources.Speed speed annotation(
    Placement(transformation(origin = {-30, 10}, extent = {{-10, -10}, {10, 10}})));
  Modelica.Blocks.Sources.Ramp ramp(height = 1000, duration = 1)  annotation(
    Placement(transformation(origin = {-70, 10}, extent = {{-10, -10}, {10, 10}})));
equation
  connect(speed.flange, inertia.flange_a) annotation(Line(points = {{-20, 10}, {0, 10}}));
  connect(ramp.y, speed.w_ref) annotation(Line(points = {{-58, 10}, {-42, 10}}, color = {0, 0, 127}));

annotation(uses(Modelica(version = "4.0.0")));
end PlotUnitError;
  1. Change the display unit of inertia.w to rpm and plot it. The plot looks as shown in the first screenshot (unit in legend = krpm and a ramp from 0 to around 9.5, which is correct)
  2. Change to display unit to rad/s and then back to rpm. The plot looks as shown in the second screenshot. The value range is the same but the unit listed in the legend is now rpm instead of krpm, which does not fit to the displayed values.

Expected Behavior

The unit in the plot legend and the value in the plot always match.

Screenshots

My colleague @niklwors will add the two mentioned screenshots as a comment.

Version and OS

  • OpenModelica Version: 1.23.0
  • OS: Windows 11, 64 bit
  • MSL 4.0.0

Thanks for looking into this Aaron Buntrock - Bosch Rexroth

abuntrock avatar Jul 02 '24 07:07 abuntrock

image001

image002

niklwors avatar Jul 02 '24 07:07 niklwors

Looks perfect with todays nightly. Thanks a lot.

abuntrock avatar Sep 09 '24 08:09 abuntrock

Will be available in the forthcoming 1.24.0 release.

casella avatar Sep 13 '24 11:09 casella