Opened 10 years ago
Last modified 8 years ago
#3778 closed defect
noEvent(x>0) fails to guard against sqrt(x) for x<0 — at Initial Version
| Reported by: | Michael Wetter | Owned by: | somebody |
|---|---|---|---|
| Priority: | high | Milestone: | Future |
| Component: | *unknown* | Version: | |
| Keywords: | Cc: |
Description
Hi
The regression test
Buildings.Fluid.FixedResistances.Examples.FixedResistancesExplicit
fails with "Model error: Argument of sqrt(res22.dp) was -5 should be >= 0"
This is triggered from
m_flow := if noEvent(dp>dp_turbulent) then k*sqrt(dp)
elseif noEvent(dp<-dp_turbulent) then -k*sqrt(-dp)
else (k^2*5/4/m_flow_turbulent)*dp-k/4/(m_flow_turbulent/k)^5*dp^3;
According to the Modelica specification, this is the correct implementation. However, when reformulating as
m_flow := if noEvent(dp>dp_turbulent) then k*sqrt(abs(dp))
elseif noEvent(dp<-dp_turbulent) then -k*sqrt(abs(-dp))
else (k^2*5/4/m_flow_turbulent)*dp-k/4/(m_flow_turbulent/k)^5*dp^3;
the example works. Hence, this looks like the implementation of noEvent is wrong in OpenModelica.
Note:
See TracTickets
for help on using tickets.
