Opened 9 years ago
Last modified 7 years ago
#3778 closed defect
noEvent(x>0) fails to guard against sqrt(x) for x<0 — at Version 1
Reported by: | Michael Wetter | Owned by: | somebody |
---|---|---|---|
Priority: | high | Milestone: | Future |
Component: | *unknown* | Version: | |
Keywords: | Cc: |
Description (last modified by )
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.
This fix makes the following tests work:
simulate(Buildings.Fluid.Examples.Performance.Example1v1); simulate(Buildings.Fluid.Examples.Performance.Example1v2); simulate(Buildings.Fluid.Examples.Performance.Example2); simulate(Buildings.Fluid.HeatExchangers.Examples.DryCoilCounterFlowPControl); simulate(Buildings.Fluid.FixedResistances.Examples.FixedResistancesExplicit); simulate(Buildings.Fluid.Examples.ResistanceVolumeFlowReversal);
Note:
See TracTickets
for help on using tickets.