Skip to content

Commit

Permalink
Refactor to ensure passed=u if t=0 (#4022)
Browse files Browse the repository at this point in the history
* Refactor to ensure passed=u if t=0

* Update checksum
  • Loading branch information
AntoineGautier authored Oct 25, 2024
1 parent 9d0f28e commit 4502eec
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
9f5001757d1555f1948b175403b37304
66fd47582d1789884f4a44648f72548a
36 changes: 17 additions & 19 deletions Buildings/Templates/Plants/Controls/Utilities/TimerWithReset.mo
Original file line number Diff line number Diff line change
Expand Up @@ -28,28 +28,20 @@ protected
final unit="s")
"Time instant when u became true";
initial equation
pre(entryTime)=time;
pre(passed)=t <= 0;
entryTime = time;
passed = t <= 0;
equation
when u and not reset then
entryTime=time;
// When u becomes true, and t=0, we want passed to be true
// at the first step (in superdense time).
passed=t <= 0;
elsewhen reset then
entryTime=time;
passed=false;
elsewhen
(u and time >= t + pre(entryTime)) then
passed=true;
entryTime=pre(entryTime);
when {u, reset} then
entryTime = time;
passed = u and t <= 0;
elsewhen u and time >= pre(entryTime) + t then
entryTime = pre(entryTime);
passed = true;
elsewhen not u then
// Set passed to false.
// This is the behavior a timer would have if the threshold test is done with a greater block connected to the output of the timer
passed=false;
entryTime=pre(entryTime);
entryTime = pre(entryTime);
passed = false;
end when;
y=if u then time - entryTime else 0.0;
y = if u then time - entryTime else 0.0;
annotation (
__cdl(
extensionBlock=true),
Expand Down Expand Up @@ -125,6 +117,12 @@ equation
Documentation(revisions="<html>
<ul>
<li>
October 21, 2024, by Antoine Gautier:<br/>
Refactored to ensure <code>passed=u</code> if <code>t=0</code>.
This is for
<a href=\"https://github.com/lbl-srg/modelica-buildings/issues/3952\">#3952</a>.
</li>
<li>
March 29, 2024, by Antoine Gautier:<br/>
First implementation.
</li>
Expand Down
10 changes: 10 additions & 0 deletions Buildings/UsersGuide/ReleaseNotes/Version_12_0_0.mo
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,16 @@ that can lead to wrong simulation results):
<a href=\"https://github.com/lbl-srg/modelica-buildings/issues/3815\">#3815</a>.
</td>
</tr>
<tr><td colspan=\"2\"><b>Buildings.Templates</b>
</td>
</tr>
<tr><td valign=\"top\">Buildings.Templates.Plants.Controls.Utilities.TimerWithReset
</td>
<td valign=\"top\">Refactored to ensure <code>passed=u</code> if <code>t=0</code>.<br/>
This is for
<a href=\"https://github.com/lbl-srg/modelica-buildings/issues/3952\">#3952</a>.
</td>
</tr>
<tr><td colspan=\"2\"><b>xxx</b>
</td>
</tr>
Expand Down

0 comments on commit 4502eec

Please sign in to comment.