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

Fixes for #4424 #4547

Merged
merged 3 commits into from
Feb 27, 2025
Merged

Fixes for #4424 #4547

merged 3 commits into from
Feb 27, 2025

Conversation

casella
Copy link
Contributor

@casella casella commented Feb 25, 2025

Added small pressure losses to avoid index reduction with fixed pressure boundaries. Changed to explicit steady state initialization to avoid unspecified initial conditions.

Fixes #4424

… avoid index reduction with the fixed pressure boundary.

Changed to explicit steady state initialization to avoid unspecified initial conditions
Fixes modelica#4424
@casella
Copy link
Contributor Author

casella commented Feb 25, 2025

This works in Dymola but not in OpenModelica 😢

@casella
Copy link
Contributor Author

casella commented Feb 25, 2025

There is something fishy in the way the pressure loss models work, I'm getting much smaller pressure losse than I expected, which makes the model ill-posed. I'll investigate more.

@casella
Copy link
Contributor Author

casella commented Feb 25, 2025

I think I accidentally found a bug in Fluid.Dissipation:

M_FLOW := IN_var.rho*(if a>0 and b<=0 then
Modelica.Fluid.Dissipation.Utilities.Functions.General.SmoothPower(
(1/a)*dp,
(1/a)*dp_min,
0.5)
elseif a>0 and b>0 then
sign(dp)*(-b/(2*a) + sqrt((b/(2*a))^2 + (1/a)*abs(dp)))
else b*dp);

I guess the last line (the else case) should be 1/b*dp, not dp. Probably nobody has ever used this option, so it went unnoticed until now. I'm checking with Stefan and I'm going to fix this ASAP.

@casella
Copy link
Contributor Author

casella commented Feb 25, 2025

In the meantime, I changed the parametrization of the pressure losses to use a quadratic model and get about 0.1 bar pressure loss. I also switched to FixedInitial to avoid convergence problems. This works both in Dymola and OMC.

@maltelenz could you please check if it also works in WSM?

@maltelenz
Copy link
Contributor

ModelicaTest.Fluid.TestComponents.Pipes.DynamicPipeEnergyConservationCheck2 simulates to completion in WSM.

The new results do not match the previously suggested reference (I assume this is expected).

There are still transients in the beginning, I don't know if this is expected.

@casella
Copy link
Contributor Author

casella commented Feb 26, 2025

ModelicaTest.Fluid.TestComponents.Pipes.DynamicPipeEnergyConservationCheck2 simulates to completion in WSM.

Good.

The new results do not match the previously suggested reference (I assume this is expected).

Yes, since I added some pressure losses the pressures are different. But that doesn't matter, since the point of this model is to run the asserts. I'll ask LTX to re-generate the reference results in #4424.

There are still transients in the beginning, I don't know if this is expected.

Yes, it is. I tried steady-state initialization but I got into numerical trouble with OMC, so I though we could keep the same default behaviour we had previously with Dymola (i.e., fix all the states to their initial values), only make it explicit. There is a relaxation transient, then the asserts are only applied at the end. This is also improved by PR #4555.

So, you can approve this without problem. Thanks!

@casella casella enabled auto-merge (squash) February 26, 2025 19:32
Copy link
Contributor

@maltelenz maltelenz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works in System Modeler, and the results seem as expected per previous comment.

@casella casella merged commit afba9aa into modelica:master Feb 27, 2025
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants