{"action":"created","issue":{"url":"https://api.github.com/repos/tbeu/Modelica/issues/1350","repository_url":"https://api.github.com/repos/tbeu/Modelica","labels_url":"https://api.github.com/repos/tbeu/Modelica/issues/1350/labels{/name}","comments_url":"https://api.github.com/repos/tbeu/Modelica/issues/1350/comments","events_url":"https://api.github.com/repos/tbeu/Modelica/issues/1350/events","html_url":"https://github.com/tbeu/Modelica/issues/1350","id":200221402,"number":1350,"title":"Issue in Fluid.Dissipation function","user":{"login":"modelica-trac-importer","id":22202507,"avatar_url":"https://avatars.githubusercontent.com/u/22202507?v=3","gravatar_id":"","url":"https://api.github.com/users/modelica-trac-importer","html_url":"https://github.com/modelica-trac-importer","followers_url":"https://api.github.com/users/modelica-trac-importer/followers","following_url":"https://api.github.com/users/modelica-trac-importer/following{/other_user}","gists_url":"https://api.github.com/users/modelica-trac-importer/gists{/gist_id}","starred_url":"https://api.github.com/users/modelica-trac-importer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/modelica-trac-importer/subscriptions","organizations_url":"https://api.github.com/users/modelica-trac-importer/orgs","repos_url":"https://api.github.com/users/modelica-trac-importer/repos","events_url":"https://api.github.com/users/modelica-trac-importer/events{/privacy}","received_events_url":"https://api.github.com/users/modelica-trac-importer/received_events","type":"User","site_admin":false},"labels":[{"id":515527754,"url":"https://api.github.com/repos/tbeu/Modelica/labels/bug","name":"bug","color":"ee0701","default":true},{"id":515538514,"url":"https://api.github.com/repos/tbeu/Modelica/labels/L:%20Fluid.Dissipation","name":"L: Fluid.Dissipation","color":"0000aa","default":false}],"state":"open","locked":false,"assignee":{"login":"beutlich","id":14896695,"avatar_url":"https://avatars.githubusercontent.com/u/14896695?v=3","gravatar_id":"","url":"https://api.github.com/users/beutlich","html_url":"https://github.com/beutlich","followers_url":"https://api.github.com/users/beutlich/followers","following_url":"https://api.github.com/users/beutlich/following{/other_user}","gists_url":"https://api.github.com/users/beutlich/gists{/gist_id}","starred_url":"https://api.github.com/users/beutlich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/beutlich/subscriptions","organizations_url":"https://api.github.com/users/beutlich/orgs","repos_url":"https://api.github.com/users/beutlich/repos","events_url":"https://api.github.com/users/beutlich/events{/privacy}","received_events_url":"https://api.github.com/users/beutlich/received_events","type":"User","site_admin":false},"assignees":[{"login":"beutlich","id":14896695,"avatar_url":"https://avatars.githubusercontent.com/u/14896695?v=3","gravatar_id":"","url":"https://api.github.com/users/beutlich","html_url":"https://github.com/beutlich","followers_url":"https://api.github.com/users/beutlich/followers","following_url":"https://api.github.com/users/beutlich/following{/other_user}","gists_url":"https://api.github.com/users/beutlich/gists{/gist_id}","starred_url":"https://api.github.com/users/beutlich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/beutlich/subscriptions","organizations_url":"https://api.github.com/users/beutlich/orgs","repos_url":"https://api.github.com/users/beutlich/repos","events_url":"https://api.github.com/users/beutlich/events{/privacy}","received_events_url":"https://api.github.com/users/beutlich/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/tbeu/Modelica/milestones/52","html_url":"https://github.com/tbeu/Modelica/milestone/52","labels_url":"https://api.github.com/repos/tbeu/Modelica/milestones/52/labels","id":2241922,"number":52,"title":"MSL3.2.1+build.3","description":"Plan as of 84th Modelica Design Meeting:\n 1. Freeze date for maintenance build: Dec 22, 2014\n 2. Leo will run regression testing an fill a ticket for all models with non-obvious differences by Jan 2, 2015 (check \n    wiki:HowTo/MAP-LIB/ModelicaStandardLibrary/RegressionTesting for instructions how to replicate regression tests)\n 3. All library officers should react within one week, until Jan 9, 2015 (either explain the difference or fix the bug)\n 4. A web meeting is scheduled shortly after Jan 9, 2015 for a quick review and then build `v3.2.1+build.3-beta.2`\n\n","creator":{"login":"modelica-trac-importer","id":22202507,"avatar_url":"https://avatars.githubusercontent.com/u/22202507?v=3","gravatar_id":"","url":"https://api.github.com/users/modelica-trac-importer","html_url":"https://github.com/modelica-trac-importer","followers_url":"https://api.github.com/users/modelica-trac-importer/followers","following_url":"https://api.github.com/users/modelica-trac-importer/following{/other_user}","gists_url":"https://api.github.com/users/modelica-trac-importer/gists{/gist_id}","starred_url":"https://api.github.com/users/modelica-trac-importer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/modelica-trac-importer/subscriptions","organizations_url":"https://api.github.com/users/modelica-trac-importer/orgs","repos_url":"https://api.github.com/users/modelica-trac-importer/repos","events_url":"https://api.github.com/users/modelica-trac-importer/events{/privacy}","received_events_url":"https://api.github.com/users/modelica-trac-importer/received_events","type":"User","site_admin":false},"open_issues":1,"closed_issues":23,"state":"closed","created_at":"2017-01-10T20:31:11Z","updated_at":"2017-01-11T22:05:30Z","due_on":"2014-03-15T07:00:00Z","closed_at":"2017-01-10T20:31:11Z"},"comments":3,"created_at":"2017-01-11T22:04:50Z","updated_at":"2017-01-11T22:05:40Z","closed_at":null,"body":"**Reported by allanwittkopf on 11 Nov 2013 18:15 UTC**\nIn the function dp_curvedOverall_MFLOW, there are two computations:\n\n```mo\nSI.Velocity v_lam=(-A2/2*IN_var.eta + 0.5*sqrt(max(MIN, (A2*IN_var.eta)^2 + 8   \n          *zeta_LOC_sharp_turb*abs(dp)*IN_var.rho*d_hyd^2)))/zeta_LOC_sharp_turb/         \n            IN_var.rho/d_hyd\n\nSI.Velocity v_tra=(-A2/2*IN_var.eta + 0.5*sqrt(max(MIN, (A2*IN_var.eta)^2 + 8       \n            *zeta_LOC_sharp_turb*abs(dp_lam_max)*IN_var.rho*d_hyd^2)))/\n            zeta_LOC_sharp_turb/IN_var.rho/d_hyd\n```\n\nthat have serious computational difficulties when A2/2\\*IN_var.eta >> 8\\*zeta_LOC_sharp_turb\\*abs(dp)\\*IN_var.rho\\*d_hyd^2\n\nSetting\n\n```mo\na=2*zeta_LOC_sharp_turb*abs(dp)*IN_var.rho*d_hyd^2\nb=A2/2*IN_var.eta\nc=zeta_LOC_sharp_turb*IN_var.rho*d_hyd\n```\nthe first computation simplifies to:\n\n```mo\nv_lam = (-b+sqrt(max(MIN/4,b^2)+a)/c\n```\n\nThe issue is that if b is large, and a is small, the sum in the numerator suffers from severe catastrophic cancellation.\n\nFor 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.\nA modest increase of the value of b to 30000 results in v_lam=0.\n\nRound-off errors of this type can wreak havoc with integrator error control.\n\nAs 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:\n\n```mo\n   SI.Velocity v_lam=if 8e8*abs(zeta_LOC_sharp_turb*abs(dp)*IN_var_rho*d_hyd^2)\n   < abs(A2*IN_var_eta) then\n      2*abs(dp)*d_hyd/A2/IN_var_eta\n   else\n      (-A2/2*IN_var_eta+1/2*sqrt(max(MIN,(A2*IN_var_eta)^2) +\n      8*zeta_LOC_sharp_turb*abs(dp)*IN_var_rho*d_hyd^2))\n      /zeta_LOC_sharp_turb/IN_var_rho/d_hyd\n\nSI.Velocity v_tra=if 8e8*abs(zeta_LOC_sharp_turb*abs(dp_lam_max)*IN_var_rho\n   *d_hyd^2) < abs(A2*IN_var_eta) then\n      2*abs(dp_lam_max)*d_hyd/A2/IN_var_eta\n   else\n      (-A2/2*IN_var_eta+1/2*sqrt(max(MIN,(A2*IN_var_eta)^2 +\n      8*zeta_LOC_sharp_turb*abs(dp_lam_max)*IN_var_rho*d_hyd^2)))\n      /zeta_LOC_sharp_turb/IN_var_rho/d_hyd\n```\n\nand this repaired the behavior, giving 8 digits of accuracy overall, instead of 0 digits of accuracy when b>>a.\n\nThis 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.\n\nFor 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).\n\n\n----\n\nMigrated-From: https://trac.modelica.org/Modelica/ticket/1350"},"comment":{"url":"https://api.github.com/repos/tbeu/Modelica/issues/comments/272010460","html_url":"https://github.com/tbeu/Modelica/issues/1350#issuecomment-272010460","issue_url":"https://api.github.com/repos/tbeu/Modelica/issues/1350","id":272010460,"user":{"login":"modelica-trac-importer","id":22202507,"avatar_url":"https://avatars.githubusercontent.com/u/22202507?v=3","gravatar_id":"","url":"https://api.github.com/users/modelica-trac-importer","html_url":"https://github.com/modelica-trac-importer","followers_url":"https://api.github.com/users/modelica-trac-importer/followers","following_url":"https://api.github.com/users/modelica-trac-importer/following{/other_user}","gists_url":"https://api.github.com/users/modelica-trac-importer/gists{/gist_id}","starred_url":"https://api.github.com/users/modelica-trac-importer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/modelica-trac-importer/subscriptions","organizations_url":"https://api.github.com/users/modelica-trac-importer/orgs","repos_url":"https://api.github.com/users/modelica-trac-importer/repos","events_url":"https://api.github.com/users/modelica-trac-importer/events{/privacy}","received_events_url":"https://api.github.com/users/modelica-trac-importer/received_events","type":"User","site_admin":false},"created_at":"2017-01-11T22:05:40Z","updated_at":"2017-01-11T22:05:40Z","body":"**Comment by wischhusen on 26 Jun 2014 13:24 UTC**\nThe proposed procedure is plausible from the numerical point of view. Nevertheless, I believe that there are some issues which are not resolved completely:\n\n1. We move the accuracy step from 1e-8 to 1e-18 since dp in factor a is usually calculated by two integrator state variables (say p1 and p2) which are substracted. The maximum accuracy for substracting two almost identical non-zero pressures defines the location of the new step. At least there will be one at a much lower pressure difference.\n\n2. There is a new step at\n\n```\n8e8*abs(zeta_LOC_sharp_turb*abs(dp)*IN_var_rho*d_hyd^2)\n   < abs(A2*IN_var_eta)\n```\n\nbecause 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.\n\nFrom 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).\n\nTo 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.  "}}
{"actor":{"display_login":"modelica-trac-importer"}}