-
Notifications
You must be signed in to change notification settings - Fork 167
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
Issue in Fluid.Dissipation function #1350
Comments
Comment by wischhusen on 14 Feb 2014 12:04 UTC For simplicity, assume that b=3000, and a=1e-5 (and c=1), then computation at hardware precision gives v_lam = 0.166666666667e-9, while the accurate value for this expression is 0.167347025126e-9. I could not follow here. How did you calculate the correct solution? I receive the solution of 0.167347025126e-9 for b=30000 (and MIN=1e-15) using Dymola and Matlab. The expansion you suggest is certainly correct but we could not determine any significant improvement w.r.t the current formular. Perhaps we need the capability to produce the right solution for the case you selected. Could you give us hints how to determine the failure? |
Comment by awittkop on 14 Feb 2014 16:50 UTC In Maple I receive the following:
The latter (accres) being the more correct answer computed using 30 Digits in floating point. In Matlab I perform the same computation as above in hardware precision as follows:
ans = 1.6735e-10 The appears to be in complete agreement with the Maple hardware precision result (at least out to the digits that Matlab displays). The error then, as computed in Maple is:
or 0.4%, meaning we only obtain 2 digits of accuracy for the actual computation. In terms of a,b,c, and given that for large b, max(MIN/4,b2)=b2, the asymptotic expansion of the formula for a<<b is given by:
which one can see by eye gives a much more accurate result. This is also easily confirmed in Matlab via:
ans = 1.6667e-10 which is fully accurate to the displayed digits. |
Modified by beutlich on 21 May 2014 20:45 UTC |
Comment by wischhusen on 26 Jun 2014 13:24 UTC
because the simplified solution does not match the exact solution (the rel. difference in your case is about 1e-9), such that the integrator will see another step here. From the practical point of view we are talking about pressure differences of 1e-5 Pa (for liquid water) at the transition point between simplified and exact solution, which is not even close to the usual operating conditions (>> 1 Pa). To investigate the impact of the proposed procedure on calculations with zero mass flow rates I would like to test it on a complexer, realistic application. The testing requires some more time. Therefore I propose to change the Milestone to 3.2.2. The current model, although it might be not numerically optimized, works well for existing applications. |
Comment by wischhusen on 2 Dec 2014 08:27 UTC
|
Changelog modified by wischhusen on 2 Dec 2014 08:27 UTC |
Modified by beutlich on 2 Dec 2014 08:38 UTC |
Modified by beutlich on 19 Mar 2015 11:37 UTC |
Changelog removed by beutlich on 19 Mar 2015 11:37 UTC |
Modified by wischhusen on 27 Mar 2015 10:06 UTC |
Changelog modified by wischhusen on 27 Mar 2015 10:06 UTC |
Reported by allanwittkopf on 11 Nov 2013 18:15 UTC
In the function dp_curvedOverall_MFLOW, there are two computations:
that have serious computational difficulties when A2/2*IN_var.eta >> 8*zeta_LOC_sharp_turb*abs(dp)*IN_var.rho*d_hyd^2
Setting
the first computation simplifies to:
The issue is that if b is large, and a is small, the sum in the numerator suffers from severe catastrophic cancellation.
For simplicity, assume that b=3000, and a=1e-5 (and c=1), then computation at hardware precision gives v_lam = 0.166666666667e-9, while the accurate value for this expression is 0.167347025126e-9.
A modest increase of the value of b to 30000 results in v_lam=0.
Round-off errors of this type can wreak havoc with integrator error control.
As a workaround, I recoded the expressions for v_lam and v_tra to use a 1-term asymptotic expansion whenever abs(a)<2e-8*abs(b) as follows:
and this repaired the behavior, giving 8 digits of accuracy overall, instead of 0 digits of accuracy when b>>a.
This might normally not be much of a concern, but when this component is used in a model, the sign of v_lam and v_tra are relevant to other conditionals, and having them jump to zero when they should still be a small positive value can present problems.
For a formal fix, it may be advisable to carry the expansion out to more than just 1 term, and increase the usage region, which could be used to attain ~ 11 digits of accuracy overall (for a 2 term expansion) or ~ 13 digits (for a 3-term expansion).
Migrated-From: https://trac.modelica.org/Modelica/ticket/1350
The text was updated successfully, but these errors were encountered: