Skip to content

Commit

Permalink
Merge branch 'master' into issue3616_openmodelica_1_22_1
Browse files Browse the repository at this point in the history
  • Loading branch information
mwetter committed Jan 9, 2024
2 parents 8f300a6 + 259f6a4 commit 710c17d
Show file tree
Hide file tree
Showing 121 changed files with 6,067 additions and 1,223 deletions.
37 changes: 18 additions & 19 deletions Buildings/Controls/OBC/ASHRAE/G36/Generic/TimeSuppression.mo
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ block TimeSuppression
Buildings.Controls.OBC.CDL.Reals.Min supTim
"Calculated suppression time due to the setpoint change"
annotation (Placement(transformation(extent={{80,0},{100,20}})));

protected
Buildings.Controls.OBC.CDL.Discrete.Sampler samSet(
final samplePeriod=samplePeriod)
Expand Down Expand Up @@ -70,28 +69,18 @@ protected
Buildings.Controls.OBC.CDL.Logical.Timer tim
"Time when the setpoint is being changed"
annotation (Placement(transformation(extent={{-40,-160},{-20,-140}})));
Buildings.Controls.OBC.CDL.Reals.Greater gre1
"Check if current model time is greater than the initial period equaling the sample time"
annotation (Placement(transformation(extent={{-80,100},{-60,120}})));
Buildings.Controls.OBC.CDL.Reals.GreaterThreshold greThr(
final t=dTHys,
final h=0.5*dTHys)
"Check if there is setpoint change"
annotation (Placement(transformation(extent={{-120,-160},{-100,-140}})));
Buildings.Controls.OBC.CDL.Reals.Sources.ModelTime modTim
"Time of the model"
annotation (Placement(transformation(extent={{-140,100},{-120,120}})));
Buildings.Controls.OBC.CDL.Reals.MultiplyByParameter gai(
final k=chaRat)
"Setpoint change rate"
annotation (Placement(transformation(extent={{20,20},{40,40}})));
Buildings.Controls.OBC.CDL.Reals.Subtract sub1
"Calculate difference of previous and current setpoints"
annotation (Placement(transformation(extent={{-20,130},{0,150}})));
Buildings.Controls.OBC.CDL.Reals.Sources.Constant con(
final k=samplePeriod)
"Sample period time"
annotation (Placement(transformation(extent={{-140,70},{-120,90}})));
Buildings.Controls.OBC.CDL.Reals.Sources.Constant conZer(
final k=0)
"Constant zero"
Expand Down Expand Up @@ -125,6 +114,14 @@ protected
Buildings.Controls.OBC.CDL.Reals.Abs abs2
"Absolute temperature difference"
annotation (Placement(transformation(extent={{-20,20},{0,40}})));
Buildings.Controls.OBC.CDL.Logical.TrueDelay truDel(
final delayTime=samplePeriod,
final delayOnInit=true)
"Ignore the first sampling period"
annotation (Placement(transformation(extent={{-80,100},{-60,120}})));
Buildings.Controls.OBC.CDL.Logical.Sources.Constant con1(
final k=true) "Constant true"
annotation (Placement(transformation(extent={{-140,100},{-120,120}})));

equation
connect(TSet, samSet.u)
Expand All @@ -141,13 +138,6 @@ equation
connect(edg.y,lat1. clr)
annotation (Line(points={{-18,-120},{40,-120},{40,-86},{78,-86}},
color={255,0,255}));
connect(modTim.y,gre1. u1)
annotation (Line(points={{-118,110},{-82,110}}, color={0,0,127}));
connect(con.y,gre1. u2)
annotation (Line(points={{-118,80},{-100,80},{-100,102},{-82,102}},
color={0,0,127}));
connect(gre1.y,swi. u2)
annotation (Line(points={{-58,110},{38,110}}, color={255,0,255}));
connect(sub1.y,swi. u1)
annotation (Line(points={{2,140},{20,140},{20,118},{38,118}},
color={0,0,127}));
Expand Down Expand Up @@ -200,7 +190,10 @@ equation
146},{-22,146}}, color={0,0,127}));
connect(triSam1.y, temDif.u2) annotation (Line(points={{-98,-20},{-70,-20},{-70,
24},{-62,24}}, color={0,0,127}));

connect(con1.y, truDel.u)
annotation (Line(points={{-118,110},{-82,110}}, color={255,0,255}));
connect(truDel.y, swi.u2)
annotation (Line(points={{-58,110},{38,110}}, color={255,0,255}));
annotation (defaultComponentName="timSup",
Icon(coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},{100,100}}),
graphics={
Expand Down Expand Up @@ -291,6 +284,12 @@ of difference (<code>chaRat</code>) but no longer than 30 minutes (<code>1800</c
</html>", revisions="<html>
<ul>
<li>
December 12, 2023, by Jianjun Hu:<br/>
Reimplemented the check of ignoring the first sampling period.
This is for
<a href=\"https://github.com/lbl-srg/modelica-buildings/issues/3596\">issue 3596</a>.
</li>
<li>
August 1, 2020, by Jianjun Hu:<br/>
First implementation.
</li>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
within Buildings.Controls.OBC.ASHRAE.G36.Generic.Validation;
model TimeSuppressionNegativeStartTime
"Model validates the block for suppresing changes due to the setpoint change with a negative start time
"

Buildings.Controls.OBC.ASHRAE.G36.Generic.TimeSuppression timSupCooReq
"Time suppression for generating cooling request"
annotation (Placement(transformation(extent={{40,70},{60,90}})));
Buildings.Controls.OBC.ASHRAE.G36.Generic.TimeSuppression timSupAla(
final chaRat=1080,
final maxTim=7200) "Time suppression for temperature alarm"
annotation (Placement(transformation(extent={{40,-90},{60,-70}})));
Buildings.Controls.OBC.CDL.Reals.Sources.Sin zonTem(
final amplitude=2,
final freqHz=1/7200,
final offset=298.15)
"Zone temperature"
annotation (Placement(transformation(extent={{-60,-40},{-40,-20}})));
Buildings.Controls.OBC.CDL.Reals.Sources.Ramp cooSet(
final height=5,
final duration=600,
final offset=295.15,
final startTime=900) "Cooling setpoint"
annotation (Placement(transformation(extent={{-60,10},{-40,30}})));

equation
connect(cooSet.y, timSupCooReq.TSet) annotation (Line(points={{-38,20},{-20,20},
{-20,84},{38,84}}, color={0,0,127}));
connect(cooSet.y, timSupAla.TSet) annotation (Line(points={{-38,20},{-20,20},{
-20,-76},{38,-76}}, color={0,0,127}));
connect(zonTem.y, timSupCooReq.TZon) annotation (Line(points={{-38,-30},{0,-30},
{0,76},{38,76}}, color={0,0,127}));
connect(zonTem.y, timSupAla.TZon) annotation (Line(points={{-38,-30},{0,-30},{
0,-84},{38,-84}}, color={0,0,127}));

annotation (experiment(
StartTime=-360,
StopTime=7200,
Tolerance=1e-06),
__Dymola_Commands(file="modelica://Buildings/Resources/Scripts/Dymola/Controls/OBC/ASHRAE/G36/Generic/Validation/TimeSuppressionNegativeStartTime.mos"
"Simulate and plot"),
Documentation(info="<html>
<p>
This example validates
<a href=\"modelica://Buildings.Controls.OBC.ASHRAE.G36.Generic.TimeSuppression\">
Buildings.Controls.OBC.ASHRAE.G36.Generic.TimeSuppression</a>.
</p>
</html>", revisions="<html>
<ul>
<li>
December 12, 2023, by Jianjun Hu:<br/>
First implementation.
</li>
</ul>
</html>"),
Icon(coordinateSystem(extent={{-100,-100},{100,100}}),
graphics={
Ellipse(lineColor = {75,138,73},
fillColor={255,255,255},
fillPattern = FillPattern.Solid,
extent = {{-100,-100},{100,100}}),
Polygon(lineColor = {0,0,255},
fillColor = {75,138,73},
pattern = LinePattern.None,
fillPattern = FillPattern.Solid,
points = {{-36,60},{64,0},{-36,-60},{-36,60}})}),
Diagram(coordinateSystem(extent={{-100,-120},{100,120}})));
end TimeSuppressionNegativeStartTime;
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
within Buildings.Controls.OBC.ASHRAE.G36.Generic.Validation;
model TimeSuppression
"Model validates the block for suppresing changes due to the setpoint change"
model TimeSuppressionPositiveStartTime
"Model validates the block for suppresing changes due to the setpoint change with a positive start time"

Buildings.Controls.OBC.ASHRAE.G36.Generic.TimeSuppression timSupCooReq
"Time suppression for generating cooling request"
Expand Down Expand Up @@ -33,7 +33,7 @@ equation
0,-84},{38,-84}}, color={0,0,127}));

annotation (experiment(StopTime=7200.0, Tolerance=1e-06),
__Dymola_Commands(file="modelica://Buildings/Resources/Scripts/Dymola/Controls/OBC/ASHRAE/G36/Generic/Validation/TimeSuppression.mos"
__Dymola_Commands(file="modelica://Buildings/Resources/Scripts/Dymola/Controls/OBC/ASHRAE/G36/Generic/Validation/TimeSuppressionPositiveStartTime.mos"
"Simulate and plot"),
Documentation(info="<html>
<p>
Expand Down Expand Up @@ -61,4 +61,4 @@ First implementation.
fillPattern = FillPattern.Solid,
points = {{-36,60},{64,0},{-36,-60},{-36,60}})}),
Diagram(coordinateSystem(extent={{-100,-120},{100,120}})));
end TimeSuppression;
end TimeSuppressionPositiveStartTime;
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
AirEconomizerHighLimits
TimeSuppression
TimeSuppressionNegativeStartTime
TimeSuppressionPositiveStartTime
TrimAndRespond
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
within Buildings.Controls.OBC.CDL.Reals.Sources;
block ModelTime
"Standard time"
block CivilTime "Civil time"
Interfaces.RealOutput y(
final unit="s")
"Connector of Real output signal"
"Civil time"
annotation (Placement(transformation(extent={{100,-20},{140,20}})));

equation
y=time;
annotation (
defaultComponentName="modTim",
defaultComponentName="civTim",
Icon(
coordinateSystem(
preserveAspectRatio=true,
Expand Down Expand Up @@ -80,7 +79,7 @@ equation
significantDigits=3)))}),
Documentation(
info="<html>
<p>Block that outputs the standard time.
<p>Block that outputs the civil time.
</p>
<h4>Implementation</h4>
<p>
Expand All @@ -89,18 +88,29 @@ In the case of a building automation system, the
building automation system synchronizes time, and hence
need to assign a value for the output of this block.
Daylight saving time shall not be taken into account,
e.g, the block always outputs standard time rather than
e.g, the block always outputs civil time rather than
daylight savings time.
</p>
<p>
If a simulation starts
at <i>t=-1</i>, then this block outputs first <i>t=-1</i>,
and its output is advanced at the same rate as the simulation time.
</p>
<p>
Note that the block has not been included in the ASHRAE Standard 231p.
However, in the future versions of the ASHRAE 231 Standard, the block should be added.
</p>
</html>",
revisions="<html>
<ul>
<li>
December 12, 2023, by Jianjun Hu:<br/>
Renamed the block from <code>ModelTime</code> to <code>CivilTime</code>.
This is for
<a href=\"https://github.com/lbl-srg/modelica-buildings/issues/3596\">issue 3596</a>.
</li>
<li>
March 2, 2020, by Michael Wetter:<br/>
Changed icon to display dynamically the output value.
</li>
Expand All @@ -125,4 +135,4 @@ First implementation.
</li>
</ul>
</html>"));
end ModelTime;
end CivilTime;
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
within Buildings.Controls.OBC.CDL.Reals.Sources.Validation;
model StandardTime
"Test model for the StandardTime block"
Buildings.Controls.OBC.CDL.Reals.Sources.ModelTime staTim
"Standard time"
model CivilTime "Test model for the CivilTime block"
Buildings.Controls.OBC.CDL.Reals.Sources.CivilTime civTim
"Civil time"
annotation (Placement(transformation(extent={{-10,-10},{10,10}})));
annotation (
experiment(
StartTime=-1,
Tolerance=1e-6,
StopTime=1),
__Dymola_Commands(
file="modelica://Buildings/Resources/Scripts/Dymola/Controls/OBC/CDL/Reals/Sources/Validation/StandardTime.mos" "Simulate and plot"),
file="modelica://Buildings/Resources/Scripts/Dymola/Controls/OBC/CDL/Reals/Sources/Validation/CivilTime.mos" "Simulate and plot"),
Documentation(
info="<html>
<p>
This model tests the implementation of the block that outputs the
model time.
civil time.
</p>
</html>",
revisions="<html>
Expand All @@ -39,4 +38,4 @@ First implementation in CDL.
pattern=LinePattern.None,
fillPattern=FillPattern.Solid,
points={{-36,60},{64,0},{-36,-60},{-36,60}})}));
end StandardTime;
end CivilTime;
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
CalendarTimeMonths
CalendarTimeMonthsMinus
CalendarTimeMonthsPlus
CivilTime
Constant
Pulse
Ramp
Sin
StandardTime
TimeTable
TimeTableNegativeStartTime
2 changes: 1 addition & 1 deletion Buildings/Controls/OBC/CDL/Reals/Sources/package.order
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
CalendarTime
CivilTime
Constant
ModelTime
Pulse
Ramp
Sin
Expand Down
3 changes: 2 additions & 1 deletion Buildings/Controls/OBC/CDL/Reals/Validation/Derivative.mo
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ model Derivative
offset=0.01,
startTime=5) "Ramp for time constant used in approximating derivative"
annotation (Placement(transformation(extent={{-80,40},{-60,60}})));
Reals.Sources.ModelTime modTim "Model time"
Buildings.Controls.OBC.CDL.Reals.Sources.CivilTime modTim
"Civil time"
annotation (Placement(transformation(extent={{-110,0},{-90,20}})));
Buildings.Controls.OBC.CDL.Reals.IntegratorWithReset intWitRes(y_start=1)
"Integration of input"
Expand Down
4 changes: 2 additions & 2 deletions Buildings/Controls/OBC/CDL/Reals/Validation/PIDWithReset.mo
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ model PIDWithReset
Buildings.Controls.OBC.CDL.Conversions.BooleanToReal setPoi
"Set point"
annotation (Placement(transformation(extent={{-20,-40},{0,-20}})));
Buildings.Controls.OBC.CDL.Reals.Sources.ModelTime modTim
"Model time"
Buildings.Controls.OBC.CDL.Reals.Sources.CivilTime modTim
"Civil time"
annotation (Placement(transformation(extent={{-80,-70},{-60,-50}})));
Buildings.Controls.OBC.CDL.Reals.GreaterThreshold greEquThr(
t=1)
Expand Down
20 changes: 11 additions & 9 deletions Buildings/Controls/OBC/Utilities/Validation/PIDWithInputGains.mo
Original file line number Diff line number Diff line change
Expand Up @@ -47,24 +47,26 @@ model PIDWithInputGains
offset=0.1)
"Time constant signal for the derivative term"
annotation (Placement(transformation(extent={{-80,-80},{-60,-60}})));

CDL.Reals.Abs abs1 "Absolute value of controller output"
Buildings.Controls.OBC.CDL.Reals.Abs abs1
"Absolute value of controller output"
annotation (Placement(transformation(extent={{110,-10},{130,10}})));
CDL.Reals.Subtract sub "Difference in controller output"
Buildings.Controls.OBC.CDL.Reals.Subtract sub
"Difference in controller output"
annotation (Placement(transformation(extent={{80,-10},{100,10}})));
CDL.Reals.LessThreshold lesThr(t=1E-5, h=1E-4)
Buildings.Controls.OBC.CDL.Reals.LessThreshold lesThr(t=1E-5, h=1E-4)
"Output true if outputs are bigger than threshold"
annotation (Placement(transformation(extent={{140,-10},{160,10}})));
CDL.Utilities.Assert assMes(message="Control outputs differ more than expected")
Buildings.Controls.OBC.CDL.Utilities.Assert assMes(
message="Control outputs differ more than expected")
"Make sure outputs are within expected tolerance"
annotation (Placement(transformation(extent={{200,20},{220,40}})));
CDL.Reals.Sources.ModelTime modTim
"Model time"
Buildings.Controls.OBC.CDL.Reals.Sources.CivilTime modTim
"Civil time"
annotation (Placement(transformation(extent={{80,40},{100,60}})));
CDL.Reals.GreaterThreshold greThr(t=0.59)
Buildings.Controls.OBC.CDL.Reals.GreaterThreshold greThr(t=0.59)
"Output true if model time is below 0.6"
annotation (Placement(transformation(extent={{140,40},{160,60}})));
CDL.Logical.Or or2
Buildings.Controls.OBC.CDL.Logical.Or or2
"Output true either if time is bigger than 0.59, or if tolerance is maintained"
annotation (Placement(transformation(extent={{170,20},{190,40}})));
equation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ model PartialDirect
"Bandwidth around reference signal for on/off controller"
annotation (Dialog(tab="Advanced"));

Modelica.Blocks.Interfaces.RealInput TSetDisRet(
Modelica.Blocks.Interfaces.RealInput TDisRetSet(
final unit="K",
displayUnit="degC")
"Setpoint for the district return temperature (min for cooling, max for heating)"
Expand Down Expand Up @@ -197,7 +197,7 @@ equation
connect(senTDisSup.T,dTDis. u2)
annotation (Line(points={{-170,-269},{-172,-269},{-172,-184},{60,-184},{60,-110},
{78,-110}}, color={0,0,127}));
connect(TSetDisRet, con.u_s)
connect(TDisRetSet, con.u_s)
annotation (Line(points={{-318,0},{-272,0},{-272,250},{-222,250}},
color={0,0,127}));
connect(senTBuiRet.T, con.u_m)
Expand All @@ -224,7 +224,7 @@ cooling network is at or above the minimum specified value. This configuration
naturally results in a fluctuating building supply tempearture.
</p>
<p align=\"center\">
<img src=\"modelica://Buildings/Resources/Images/Experimental/DHC/EnergyTransferStations/Cooling/Direct.PNG\" alt=\"DC ETS Direct\"/>
<img src=\"modelica://Buildings/Resources/Images/Experimental/DHC/EnergyTransferStations/Cooling/Direct.png\" alt=\"DC ETS Direct\"/>
</p>
<h4>
Reference
Expand Down
Loading

0 comments on commit 710c17d

Please sign in to comment.