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

Missing each when setting start values for arrays with dialog #7750

Closed
AnHeuermann opened this issue Aug 10, 2021 · 5 comments
Closed

Missing each when setting start values for arrays with dialog #7750

AnHeuermann opened this issue Aug 10, 2021 · 5 comments
Assignees
Labels

Comments

@AnHeuermann
Copy link
Member

Description

When changing a start value of an array state variable with a dialog in diagram view in OMEdit and setting it to true: start value is used to initialize the resulting model is missing the each key word. Because of that the model can't be simulated.

Steps to Reproduce

Create some model with an array state variable:

model TestComp
  parameter Real a[2]={10,5};
  Real x[2](start={0,0}) annotation (Dialog(tab="Setting",showStartAttribute=true));
equation
  der(x[1]) = a[1]*x[1];
  der(x[2]) = a[2]*x[2];
end TestComp;

Drag the model TestComp into a new model mwe using the diagram view in OMEdit.
image

Then change the start value of x to {1,2} with the Element Parameter dialog and activate true: start-value is used to initialize.
image

The resulting model will look like:

model mwe
  TestComp testComp(x(fixed = true, start = {1, 2}))  annotation(
    Placement(visible = true, transformation(origin = {-2, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
equation
end mwe;

Simulating this will result in an error message:

[2] 16:56:28 Translation Notification
[mwe: 2:23-2:35]: From here:

[3] 16:56:28 Translation Error
[TestComp: 3:3-3:84]: Non-array modification ‘true‘ for array component ‘fixed‘, possibly due to missing ‘each‘.

Expected Behavior

OMC should detect that the variable testComp.x has type array and needs each.
The resulting model should have the each key word in front of fixed=true:

model mwe
  TestComp testComp(x(each fixed = true, start = {1, 2}))  annotation(
    Placement(visible = true, transformation(origin = {-2, 0}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
equation
end mwe;

Version and OS

  • OpenModelica Version: OpenModelica v1.18.0-dev-232-g187041202b (64-bit)
@AnHeuermann AnHeuermann added the COMP/GUI/OMEdit Issue and pull request related to OMEdit label Aug 10, 2021
@AnHeuermann
Copy link
Member Author

@adeas31 I guess ElementProperties.cpp needs to be changed a bit.

@casella
Copy link
Contributor

casella commented Aug 22, 2021

Duplicate of #5405.

There are several such long-standing issues that really need to be resolved - this one is particularly nasty because it generates invalid code that the new front end does not handle.

@adeas31 do you need changes to the interactive environment to fix this?

@casella casella closed this as completed Aug 22, 2021
@AnHeuermann
Copy link
Member Author

Sorry, I don't see why this is a duplicate of #5405. This issue has nothing to do with the check, the by OMEdit generated code is simply wrong for arrays.

@casella
Copy link
Contributor

casella commented Aug 25, 2021

I had provided the wrong link, sorry. Now it points where it should.

@adeas31
Copy link
Member

adeas31 commented Aug 25, 2021

If I remember correctly this is because of updateComponent api. The interactive environment need to be fixed first.

@adeas31 adeas31 self-assigned this Aug 25, 2021
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 added a commit that referenced this issue Nov 2, 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.
@casella casella closed this as not planned Won't fix, can't repro, duplicate, stale 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
Projects
None yet
Development

No branches or pull requests

4 participants