-
Notifications
You must be signed in to change notification settings - Fork 300
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
Wrong flat Modelica output of records with start attributes #11792
Comments
#11812 fixes the second issue, that the record declaration itself is wrong. The issue was that the frontend does not have unmodified instances of records, only record instances with modifiers applied (e.g. Regarding the first issue the problem is that the variables in the flat model do not have modifiers, only binding equations and type attributes. But it should be possible to reconstruct the modifiers from the instance tree when dumping record components. |
Good.
I see. So, if I flatten model M3
Real x(start = 3);
equation
der(x) = 1;
end M3; I get class M3
Real x(start = 3.0);
equation
der(x) = 1.0;
end M3; but then
I guess that is necessary, if we want to support records in BaseModelica output |
Yes, each variable has a flat list of type attributes (just a list of name/binding tuples). There's never been any need to be able to represent nested binding equations before since those are normally resolved during flattening. |
OK, now after #11812 I get
@perost, getting the record member modifiers is essential if we want to get power grids models to run in MARCO. Do you think you can fix this before the summer break? Thanks! |
#12453 improves the handling of records in Base Modelica, the output is now: package 'M'
record 'R'
Real 'x';
Real 'y';
end 'R';
model 'M'
'R' 'r1'('x'(start = 1.0), 'y'(start = 2.0));
'R' 'r2'('x'(start = 3.0), 'y'(start = 4.0));
equation
'r1' = 'M.R'(0.0, 0.0);
'r2' = 'M.R'(0.0, 0.0);
end 'M';
end 'M'; There's still an issue here, However, I'm not sure if we actually want this fix, because it changes the flattening to do the same as for the new backend and not split record instances instead of having to reconstruct them when dumping Base Modelica. I realized after implementing the fix that the complicated and error-prone way we previously did it was to try to avoid having the With this fix that's no longer the case, since using |
#12453 has now been replaced by #12454, which achieves the same result but without changing the flattening behaviour. It turned out that the current code only needed some very slight modification to work with the new code I wrote to dump record modifiers. The reconstruction of record instances still has issues, like probably not working with nested records, but that's a different issue. |
#12455 fixes the issue I mentioned earlier that record expressions use the wrong name for the record type. |
That is not really necessary for the time being. We just need to be able to handle Complex numbers. |
I checked with the latest nightly, All fine, thanks @perost! |
Steps to Reproduce
Consider the following MWE:
When I instantiate it with the default options, I get
However, if I turn on the -f translation flag, I get
This is wrong for two reasons:
@perost I hope this is a quick fix
Keeping @mscuttari in the loop
The text was updated successfully, but these errors were encountered: