-
Notifications
You must be signed in to change notification settings - Fork 164
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 mass flow rate calculation in Modelica.Fluid.Fittings.GenericResistances.VolumeFlowRate #2770
Comments
@wischhusen can you take care of this? Thanks! |
Thanks for reporting this issue! I resolved the problem by allowing positive (incl. zero) numbers for a and b. One factor has to be greater zero to allow a proper inversion of the function. |
# Conflicts: # Modelica/Fluid/Dissipation.mo
Hi, V_FLOW = c/a * 1/(b/(2*a) + sqrt(...)) |
# Conflicts: # Modelica/Fluid/Dissipation.mo
I would propose the following solution. We do not need regularization since the argument of sqrt contains the constant term (b/(2*a))^2:
|
Hm, we already have a PR #2782 addressing this issue. 😕 |
Hm, but there is a flaw in that pull request. Shall I put the code there as well? |
It really is hard to tell or reproduce for outsiders without a SSCCE (Short, Self Contained, Correct (Compilable), Example).
You still can update this PR by pushing to the issue2770 branch. |
The mass flow rate of volumeFlowRate is always zero if the pressure drop is a linear function of volume flow rate.
The volume flow of is calculated by solving the quadric equation dp=aV_flow^2+bV_flow. This fails if a is zero. The actual problem is in Modelica.Fluid.Dissipation.PressureLoss.General.dp_volumeFlowRate_MFLOW:
The point is, for small a the right term sqrt(X^2 + eps) --> X, and this leads to V_flow=0 if b>0.
Proposed solution:
x1= (-b/(2a) - ((b/(2a))^2 + dp/a)^0.5
The second root should be calculated by Vieta's formula
x2 = c/a/x1
In the common case b>0 the second solution x2 is the physically meaningful.
I removed the regularized power function SmoothPower here only for simplicity of presentation. It should be kept in the actual code.
The text was updated successfully, but these errors were encountered: