Skip to content
Merged
Show file tree
Hide file tree
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
13 changes: 12 additions & 1 deletion Buildings/Controls/OBC/CDL/Logical/Sources/Pulse.mo
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ protected
discrete Modelica.SIunits.Time pulseStart "Start time of pulse";

initial equation
pulseStart = startTime;
if time > startTime then
pulseStart = startTime + period * floor((time - startTime)/period);
else
pulseStart = startTime;
end if;

equation
when sample(startTime, period) then
pulseStart = time;
Expand Down Expand Up @@ -74,6 +79,12 @@ The Boolean output y is a pulse signal:
</html>", revisions="<html>
<ul>
<li>
September 1, 2020, by Milica Grahovac:<br/>
Revised initial equation section to ensure expected simulation results when <code>startTime</code> is before simulation start time.
This is for
<a href=\"https://github.com/lbl-srg/modelica-buildings/issues/2110\">#2110</a>.
</li>
<li>
March 23, 2017, by Jianjun Hu:<br/>
First implementation, based on the implementation of the
Modelica Standard Library.
Expand Down
24 changes: 22 additions & 2 deletions Buildings/Controls/OBC/CDL/Logical/Sources/Validation/Pulse.mo
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,22 @@ model Pulse "Validation model for the Boolean Pulse block"
Buildings.Controls.OBC.CDL.Logical.Sources.Pulse booPul(
width = 0.5,
period = 1)
"Block that generates pulse signal of type Boolean"
annotation (Placement(transformation(extent={{-10,-10},{10,10}})));
"Block that generates pulse signal of type Boolean at simulation start time"
annotation (Placement(transformation(extent={{-10,20},{10,40}})));

Buildings.Controls.OBC.CDL.Logical.Sources.Pulse booPul1(
width=0.5,
period=1,
startTime=1.75)
"Block that generates pulse signal of type Boolean starting from after the simulation start time"
annotation (Placement(transformation(extent={{-10,-20},{10,0}})));

Buildings.Controls.OBC.CDL.Logical.Sources.Pulse booPul2(
width=0.5,
period=1,
startTime=-1.25)
"Block that generates pulse signal of type Boolean starting from before the simulation start time"
annotation (Placement(transformation(extent={{-10,-60},{10,-40}})));

annotation (
experiment(StopTime=5.0, Tolerance=1e-06),
Expand All @@ -20,6 +34,12 @@ Buildings.Controls.OBC.CDL.Logical.Sources.Pulse</a>.
</html>", revisions="<html>
<ul>
<li>
September 1, 2020, by Milica Grahovac:<br/>
Added test cases for simulation time starting before and after the pulse <code>startTime</code>.
This is for
<a href=\"https://github.com/lbl-srg/modelica-buildings/issues/2110\">#2110</a>.
</li>
<li>
July 17, 2017, by Jianjun Hu:<br/>
First implementation.
</li>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
last-generated=2018-06-19
last-generated=2020-09-01
statistics-simulation=
{
"linear": " ",
"nonlinear": " ",
"numerical Jacobians": "0"
}
booPul.y=[1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00]
time=[0e+00, 5e+00]
booPul.y=[1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00]
booPul1.y=[0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00]
booPul2.y=[1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 0e+00, 1e+00, 1e+00, 1e+00, 1e+00, 1e+00]
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
simulateModel("Buildings.Controls.OBC.CDL.Logical.Sources.Validation.Pulse", stopTime=5.0, method="Cvode", tolerance=1e-06, resultFile="BooleanPulse1");
createPlot(id=1, position={15, 10, 590, 420}, y={"booPul.y"}, range={0.0, 5.0, -3.5, 3.5}, grid=true, colors={{28,108,200}});
createPlot(id=1, subPlot=1, position={15, 10, 590, 420}, y={"booPul.y"}, range={0.0, 5.0, -3.5, 3.5}, grid=true, colors={{28,108,200}});
createPlot(id=1, subPlot=2, position={15, 10, 590, 420}, y={"booPul1.y"}, range={0.0, 5.0, -3.5, 3.5}, grid=true, colors={{28,108,200}});
createPlot(id=1, subPlot=3, position={15, 10, 590, 420}, y={"booPul2.y"}, range={0.0, 5.0, -3.5, 3.5}, grid=true, colors={{28,108,200}});
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
compareVars :=
{
"booPul.y"
"booPul.y",
"booPul1.y",
"booPul2.y"
};
17 changes: 15 additions & 2 deletions Buildings/package.mo
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,22 @@ have been <b style=\"color:blue\">improved</b> in a
Buildings.Controls.OBC.CDL.Continuous.LessThreshold
</td>
<td valign=\"top\">Added option to specify a hysteresis, which by default is set to <i>0</i>.
<tr><td colspan=\"2\"><b>Buildings.Fluid.HeatExchangers.RadiantSlabs</b>
</td>
</tr>
<tr><td colspan=\"2\"><b>Buildings.Controls.OBC.CDL.Logical</b>
</td>
</tr>
<tr><td valign=\"top\">Buildings.Controls.OBC.CDL.Logical.Sources.Pulse
</td>
<td valign=\"top\">Revised initial equation section to ensure an output of the block is <code>true</code> when simulation is started
after boolean pulse <code>startTime</code> and the simulation start time is such that it falls within a time period during which the
output is expected to be <code>true</code>.<br/>
This is for <a href=\"https://github.com/lbl-srg/modelica-buildings/issues/2110\">issue 2110</a>.
</td>
</tr>
<tr><td colspan=\"2\"><b>Buildings.Fluid.HeatExchangers.RadiantSlabs</b>
</td>
</tr>
<tr><td valign=\"top\">Buildings.Fluid.HeatExchangers.RadiantSlabs.BaseClasses.Functions.AverageResistance
</td>
<td valign=\"top\">Corrected inequality test on <code>alpha</code>,
Expand Down Expand Up @@ -577,7 +590,7 @@ xxx
from control sequences.<br/>
This is for <a href=\"https://github.com/lbl-srg/modelica-buildings/issues/1709\">#1709</a>.
</td>
</tr>
</tr>
<tr><td valign=\"top\">Buildings.Controls.OBC.CDL.Discrete.TriggeredMovingMean
</td>
<td valign=\"top\">Block that outputs the triggered discrete moving mean of an input signal.
Expand Down