Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with switching units of vector parameters using the GUI of OMEdit #10226

Closed
christiankral opened this issue Feb 16, 2023 · 6 comments
Closed
Assignees
Labels
COMP/GUI/OMEdit Issue and pull request related to OMEdit
Milestone

Comments

@christiankral
Copy link

Description

Polyphase models rely on parameter vectors. Consider the following Modelica model:

model Test
  Modelica.Electrical.QuasiStatic.Polyphase.Basic.Resistor resistor(R_ref = {100, 100, 100})  annotation(
    Placement(visible = true, transformation(origin = {40, 50}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  Modelica.Electrical.QuasiStatic.Polyphase.Basic.Star star annotation(
    Placement(visible = true, transformation(origin = {10, 50}, extent = {{10, -10}, {-10, 10}}, rotation = 0)));
  Modelica.Electrical.QuasiStatic.SinglePhase.Basic.Ground ground annotation(
    Placement(visible = true, transformation(origin = {-10, 10}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
equation
  connect(ground.pin, star.pin_n) annotation(
    Line(points = {{-10, 20}, {-10, 50}, {0, 50}}, color = {85, 170, 255}, pattern = LinePattern.Solid));
  connect(star.plug_p, resistor.plug_p) annotation(
    Line(points = {{20, 50}, {30, 50}}, color = {85, 170, 255}, pattern = LinePattern.Solid));

annotation(
    uses(Modelica(version = "4.0.0")));
end Test;

image

So, for example, the parametes of the quasi stsatic reistor model are R_ref = {100,100,100}

image

If I change the unit of the resistances to kOhm

image

the GUI applies R_ref (displayUnit = "kOhm")= {100, 100, 100} which causes an error when I try to simulate the model, as each is missing for the displayUnit.

Even switching back to the original unit Ohm does note resolve the issue.

Steps to Reproduce

  • Create the model above
  • Simulate the model (everything is OK)
  • Make a double click on the resistor model and change the unit to to kOhm
  • Press OK an simulate the model: it fails
  • Switch to Text View an manually add the keyword each to resistor(R_ref (displayUnit = "kOhm")= {100, 100, 100}), resulting in: resistor(R_ref (each displayUnit = "kOhm")= {100, 100, 100})
  • Simulate the model and it works OK

Expected Behavior

The each shall be included by the GUI automatically when switching to a different unit

Version and OS

Connected to OpenModelica 1.21.0~dev-256-g56379c0
Connected to OMSimulator unknown-linux

So this issue applies to the acutal nightly build version and back to version 19.2 (on Windows)

@christiankral
Copy link
Author

@casella I consider this to be an issue that needs a fix in the next stable version. A user who can not guess what the problem is, will fail working with OpenModelica and possibly discontinue working with it, as it requires sophisticated Modelica knowledge to resolve the issue, even if the translation process drops a clear hint:

[Non-array modification ‘"kOhm"‘ for array component ‘displayUnit‘, possibly due to missing ‘each‘.]
(omeditmessagesbrowser:///Modelica.Electrical.QuasiStatic.Polyphase.Basic.Resistor?lineNumber=4)

@adeas31
Copy link
Member

adeas31 commented Feb 17, 2023

See also #5405, #5737, #7750

@adeas31
Copy link
Member

adeas31 commented Feb 17, 2023

@perost we need to extend the setElementModifierValue.
This is what we have right now setElementModifierValue(name, modifierName, expression) and we should update like this setElementModifierValue(name, modifierName, expression, final, each) where final and each are optional Boolean.

@perost
Copy link
Member

perost commented Mar 20, 2023

@perost we need to extend the setElementModifierValue. This is what we have right now setElementModifierValue(name, modifierName, expression) and we should update like this setElementModifierValue(name, modifierName, expression, final, each) where final and each are optional Boolean.

You can already set final and each with the current API, for example: setElementModifierValue(M, R_ref, $Code((each displayName = "kOhm")={100, 100, 100})). Or do you need something else?

@adeas31
Copy link
Member

adeas31 commented Mar 21, 2023

As I remember it works for the submodifier but not for the actual modifier e.g., how to set each for R_ref?

@perost
Copy link
Member

perost commented Mar 21, 2023

As I remember it works for the submodifier but not for the actual modifier e.g., how to set each for R_ref?

In the example model we have R_ref as a component in resistor, so you would do:

setElementModifierValue(Test, resistor, $Code((each R_ref = 1)))

As you say it only works for submodifiers, but setting each on something that isn't a submodifier doesn't make any sense. I.e. you can't have something like Real R_ref[:] = each 1.

adeas31 added a commit to adeas31/OpenModelica that referenced this issue Nov 2, 2023
Fixes OpenModelica#5395, Fixes OpenModelica#5405, Fixes OpenModelica#5489, Fixes OpenModelica#5737, Fixes OpenModelica#7750 and Fixes OpenModelica#10226

Apply the modifiers with one call of `setElementModifierValue`.
Added a new button for final and each context menu.
Improved the handling of modifiers.
@adeas31 adeas31 closed this as completed in 0281e54 Nov 2, 2023
@casella casella added the COMP/GUI/OMEdit Issue and pull request related to OMEdit label Nov 2, 2023
@casella casella added this to the 1.22.1 milestone Nov 2, 2023
adeas31 added a commit to adeas31/OpenModelica that referenced this issue Nov 14, 2023
…odelica#11019)

Fixes OpenModelica#5395, Fixes OpenModelica#5405, Fixes OpenModelica#5489, Fixes OpenModelica#5737, Fixes OpenModelica#7750 and Fixes OpenModelica#10226

Apply the modifiers with one call of `setElementModifierValue`.
Added a new button for final and each context menu.
Improved the handling of modifiers.
adeas31 added a commit that referenced this issue Nov 14, 2023
Fixes #5395, Fixes #5405, Fixes #5489, Fixes #5737, Fixes #7750 and Fixes #10226

Apply the modifiers with one call of `setElementModifierValue`.
Added a new button for final and each context menu.
Improved the handling of modifiers.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
COMP/GUI/OMEdit Issue and pull request related to OMEdit
Projects
None yet
Development

No branches or pull requests

4 participants