From a7d8f3da5e4bae86b2fd1c93fc1a5f4c25424d88 Mon Sep 17 00:00:00 2001 From: Michael Wetter Date: Mon, 10 Feb 2025 14:04:16 -0800 Subject: [PATCH] Ported changes from Buildings, for #1966 --- .../Controls/OBC/CDL/Logical/TrueFalseHold.mo | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/IBPSA/Controls/OBC/CDL/Logical/TrueFalseHold.mo b/IBPSA/Controls/OBC/CDL/Logical/TrueFalseHold.mo index 5365adb62d..2f1d576285 100644 --- a/IBPSA/Controls/OBC/CDL/Logical/TrueFalseHold.mo +++ b/IBPSA/Controls/OBC/CDL/Logical/TrueFalseHold.mo @@ -22,7 +22,7 @@ block TrueFalseHold protected /* The following parameter is required solely as a warkaround for a bug in OCT [Modelon - 1263]. Both Dymola and OMC can handle the initial equation pre(u)=u, which complies with MLS. */ - parameter Boolean pre_u_start=false + parameter Boolean pre_u_start=false "Value of pre(u) at initial time" annotation (Evaluate=true); Boolean not_u = not u @@ -49,21 +49,15 @@ equation y = u; entryTimeTrue = if y then time else pre(entryTimeTrue); entryTimeFalse = if not y then time else pre(entryTimeFalse); - /* - The two elsewhen clauses below are kept separate to address an issue - with event handling in the CVODE solver. - */ - elsewhen {edge(u), edge(not_u)} then - y = if time >= pre(entryTimeFalse) + falseHoldDuration and - time >= pre(entryTimeTrue) + trueHoldDuration then u + elsewhen {edge(u), + edge(not_u), + time >= pre(entryTimeFalse) + falseHoldDuration and + time >= pre(entryTimeTrue) + trueHoldDuration} then + y=if time >= pre(entryTimeFalse) + falseHoldDuration and + time >= pre(entryTimeTrue) + trueHoldDuration then u else pre(y); entryTimeTrue = if edge(y) then time else pre(entryTimeTrue); entryTimeFalse = if edge(not_y) then time else pre(entryTimeFalse); - elsewhen time >= pre(entryTimeFalse) + falseHoldDuration and - time >= pre(entryTimeTrue) + trueHoldDuration then - y = u; - entryTimeTrue = if edge(y) then time else pre(entryTimeTrue); - entryTimeFalse = if edge(not_y) then time else pre(entryTimeFalse); end when; annotation ( defaultComponentName="truFalHol", @@ -145,6 +139,12 @@ alt=\"Input and output of the block\"/> revisions="