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
Generate events in functions; to avoid non-discrete booleans. #4263
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
model Model1b
replaceable package Medium = Modelica.Media.R134a.R134a_ph "Medium model"
annotation (choicesAllMatching=true);
Medium.ThermodynamicState state_a;
Modelica.Units.SI.AbsolutePressure p=Medium.p_default;
Modelica.Units.SI.SpecificEnthalpy h=Medium.h_default;
equation
//state_a = Medium.setState_phX(Medium.p_default, Medium.h_default);
state_a = Medium.setState_phX(p, h);
end Model1b;
still fails in Dymola 2024x - even with the proposed changes. Would be good to have this model as test model.
Are other functions affected as well?
No, but it seems that I messed up the annotations a bit, it should now be resolved. |
I added a test-model, but made it similar to an existing one instead. |
Fix annotations. Co-authored-by: Thomas Beutlich <modelica@tbeu.de>
Co-authored-by: Thomas Beutlich <modelica@tbeu.de>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I confirm that Model1b now runs in Dymola 2024x (and still in SimulationX 4.4).
For me it seems like a MSL bug. What's the opinion of the Media officers? |
Unfortunately, the new test model ModelicaTest.Media.TestOnly.R134a_setState_phX raises a AssignmentFromNonDiscreteToDiscrete warning in SimulationX 4.4 and fails to simulate with all tested solvers due to a singular system of equations. It does not matter if this PR is applied or not. |
Ok, that is problematic. I assume the failure to simulate and assignment-error are related; indicating that the current version of the function doesn't work, and not some unrelated error in the example model. I don't know the exact reason - is it related to calling GenerateEvents indirectly (i.e., one function with GenerateEvents calling another one)? If so it might be possible to rewrite it as:
(I cannot test that in SimulationX.) So what to do:
|
I would be in favor to add the rewrite proposed by Hans. It makes the event generation explicit. Could you add it to the PR? |
Should be done now. Please re-test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gkurzbach The new test model ModelicaTest.Media.TestOnly.R134a_setState_phX still fails in SimulationX 4.4. Can you please elaborate. Thanks.
Closes #4209
I don't know if significant enough to push for release.