Skip to content
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

Ported changes from Buildings for CDL.Logica.TrueFalseHold #1967

Merged
merged 1 commit into from
Feb 14, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions IBPSA/Controls/OBC/CDL/Logical/TrueFalseHold.mo
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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",
Expand Down Expand Up @@ -145,6 +139,12 @@ alt=\"Input and output of the block\"/>
revisions="<html>
<ul>
<li>
January 13, 2025, by Antoine Gautier:<br/>
Merge <code>elsewhen</code> clauses.<br/>
This is for
<a href=\"https://github.com/lbl-srg/modelica-buildings/issues/4082\">Buildings, issue 4082</a>.
</li>
<li>
August 26, 2024, by Antoine Gautier:<br/>
Resolved an issue with unit impulse signals.<br/>
This is for
Expand Down