Skip to content

Commit

Permalink
Merge pull request #1946 from ibpsa/issue1944_cdl
Browse files Browse the repository at this point in the history
Merge OBC package from Buildings to IBPSA
  • Loading branch information
mwetter authored Jan 6, 2025
2 parents bd96e95 + f7ad86f commit 8797a23
Show file tree
Hide file tree
Showing 737 changed files with 46,628 additions and 3 deletions.
2 changes: 1 addition & 1 deletion IBPSA/Airflow/Multizone/BaseClasses/TwoWayFlowElement.mo
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ This is for
February 24, 2015 by Michael Wetter:<br/>
Changed model to use
<a href=\"modelica://IBPSA.Utilities.Psychrometrics.Functions.density_pTX\">
Buildings.Utilities.Psychrometrics.Functions.density_pTX</a>
IBPSA.Utilities.Psychrometrics.Functions.density_pTX</a>
for the density computation
as
<a href=\"modelica://IBPSA.Media.Air.density\">
Expand Down
68 changes: 68 additions & 0 deletions IBPSA/Controls/OBC/CDL/Constants.mo
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
within IBPSA.Controls.OBC.CDL;
package Constants
"Package with constants"
// Machine dependent constants
final constant Real eps=1E-15
"Biggest number such that 1.0 + eps = 1.0";
final constant Real small=1E-37
"Smallest number such that small and -small are representable on the machine";
final constant Real pi=2*Modelica.Math.asin(1.0)
"Constant number pi, 3.14159265358979";
annotation (
Documentation(
info="<html>
<p>
This package provides often needed constants.
</p>
</html>",
revisions="<html>
<ul>
<li>
March 12, 2024, by Michael Wetter:<br/>
Changed <code>small</code> to <i>1E-37</i>.<br/>
This is for
<a href=\"https://github.com/lbl-srg/modelica-buildings/issues/3695\">Buildings, issue 3695</a>.
</li>
<li>
March 27, 2017, by Michael Wetter:<br/>
First implementation, based on the implementation of the
Modelica Standard Library.
</li>
</ul>
</html>"),
Icon(
coordinateSystem(
extent={{-100.0,-100.0},{100.0,100.0}}),
graphics={
Rectangle(
lineColor={200,200,200},
fillColor={248,248,248},
fillPattern=FillPattern.HorizontalCylinder,
extent={{-100.0,-100.0},{100.0,100.0}},
radius=25.0),
Polygon(
origin={-9.2597,25.6673},
fillColor={102,102,102},
pattern=LinePattern.None,
fillPattern=FillPattern.Solid,
points={{48.017,11.336},{48.017,11.336},{10.766,11.336},{-25.684,10.95},{-34.944,-15.111},{-34.944,-15.111},{-32.298,-15.244},{-32.298,-15.244},{-22.112,0.168},{11.292,0.234},{48.267,-0.097},{48.267,-0.097}},
smooth=Smooth.Bezier),
Polygon(
origin={-19.9923,-8.3993},
fillColor={102,102,102},
pattern=LinePattern.None,
fillPattern=FillPattern.Solid,
points={{3.239,37.343},{3.305,37.343},{-0.399,2.683},{-16.936,-20.071},{-7.808,-28.604},{6.811,-22.519},{9.986,37.145},{9.986,37.145}},
smooth=Smooth.Bezier),
Polygon(
origin={23.753,-11.5422},
fillColor={102,102,102},
pattern=LinePattern.None,
fillPattern=FillPattern.Solid,
points={{-10.873,41.478},{-10.873,41.478},{-14.048,-4.162},{-9.352,-24.8},{7.912,-24.469},{16.247,0.27},{16.247,0.27},{13.336,0.071},{13.336,0.071},{7.515,-9.983},{-3.134,-7.271},{-2.671,41.214},{-2.671,41.214}},
smooth=Smooth.Bezier),
Rectangle(
lineColor={128,128,128},
extent={{-100.0,-100.0},{100.0,100.0}},
radius=25.0)}));
end Constants;
101 changes: 101 additions & 0 deletions IBPSA/Controls/OBC/CDL/Conversions/BooleanToInteger.mo
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
within IBPSA.Controls.OBC.CDL.Conversions;
block BooleanToInteger
"Convert Boolean to Integer signal"
parameter Integer integerTrue=1
"Output signal for true Boolean input";
parameter Integer integerFalse=0
"Output signal for false Boolean input";
IBPSA.Controls.OBC.CDL.Interfaces.BooleanInput u
"Boolean signal to be converted to an Integer signal"
annotation (Placement(transformation(extent={{-140,-20},{-100,20}})));
IBPSA.Controls.OBC.CDL.Interfaces.IntegerOutput y
"Converted input signal as an Integer"
annotation (Placement(transformation(extent={{100,-20},{140,20}})));

equation
y=if u then
integerTrue
else
integerFalse;
annotation (
defaultComponentName="booToInt",
Documentation(
info="<html>
<p>
Block that outputs the <code>Integer</code>
equivalent of the <code>Boolean</code> input.
</p>
<pre>
y = if u then integerTrue else integerFalse;
</pre>
<p>
where <code>u</code> is of <code>Boolean</code> and <code>y</code>
of <code>Integer</code> type,
and <code>integerTrue</code> and <code>integerFalse</code> are parameters.
</p>
</html>",
revisions="<html>
<ul>
<li>
May 17, 2022, by Hongxiang Fu:<br/>
Corrected documentation texts where the variables were described with wrong types.<br/>
This is for
<a href=\"https://github.com/lbl-srg/modelica-buildings/issues/3016\">Buildings, issue 3016</a>.
</li>
<li>
January 3, 2017, by Michael Wetter:<br/>
First implementation, based on the implementation of the
Modelica Standard Library.
</li>
</ul>
</html>"),
Icon(
coordinateSystem(
preserveAspectRatio=true,
extent={{-100,-100},{100,100}}),
graphics={
Rectangle(
extent={{-100,100},{100,-100}},
fillColor={210,210,210},
lineThickness=5.0,
fillPattern=FillPattern.Solid,
borderPattern=BorderPattern.Raised),
Text(
extent={{-86,78},{-34,26}},
textColor={255,0,255},
textString="B"),
Polygon(
points={{28,48},{8,68},{8,58},{-24,58},{-24,38},{8,38},{8,28},{28,48}},
lineColor={255,170,85},
fillColor={255,170,85},
fillPattern=FillPattern.Solid),
Text(
extent={{34,82},{86,24}},
textColor={255,170,85},
textString="I"),
Ellipse(
extent={{-71,7},{-85,-7}},
lineColor=DynamicSelect({235,235,235},
if u then
{0,255,0}
else
{235,235,235}),
fillColor=DynamicSelect({235,235,235},
if u then
{0,255,0}
else
{235,235,235}),
fillPattern=FillPattern.Solid),
Text(
extent={{-150,150},{150,110}},
textString="%name",
textColor={0,0,255}),
Text(
extent={{-74,-28},{64,20}},
textColor={0,0,0},
textString="%integerTrue"),
Text(
extent={{-74,-90},{64,-42}},
textColor={0,0,0},
textString="%integerFalse")}));
end BooleanToInteger;
101 changes: 101 additions & 0 deletions IBPSA/Controls/OBC/CDL/Conversions/BooleanToReal.mo
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
within IBPSA.Controls.OBC.CDL.Conversions;
block BooleanToReal
"Convert Boolean to Real signal"
parameter Real realTrue=1.0
"Output signal for true Boolean input";
parameter Real realFalse=0.0
"Output signal for false Boolean input";
IBPSA.Controls.OBC.CDL.Interfaces.BooleanInput u
"Boolean signal to be converted to a Real signal"
annotation (Placement(transformation(extent={{-140,-20},{-100,20}})));
IBPSA.Controls.OBC.CDL.Interfaces.RealOutput y
"Converted input signal as a Real"
annotation (Placement(transformation(extent={{100,-20},{140,20}})));

equation
y=if u then
realTrue
else
realFalse;
annotation (
defaultComponentName="booToRea",
Documentation(
info="<html>
<p>
Block that outputs the <code>Real</code>
equivalent of the <code>Boolean</code> input.
</p>
<pre>
y = if u then realTrue else realFalse;
</pre>
<p>
where <code>u</code> is of <code>Boolean</code> and <code>y</code>
of <code>Real</code> type,
and <code>realTrue</code> and <code>realFalse</code> are parameters.
</p>
</html>",
revisions="<html>
<ul>
<li>
May 17, 2022, by Hongxiang Fu:<br/>
Corrected documentation texts where the variables were described with wrong types.<br/>
This is for
<a href=\"https://github.com/lbl-srg/modelica-buildings/issues/3016\">Buildings, issue 3016</a>.
</li>
<li>
April 10, 2017, by Jianjun Hu:<br/>
First implementation, based on the implementation of the
Modelica Standard Library.
</li>
</ul>
</html>"),
Icon(
coordinateSystem(
preserveAspectRatio=true,
extent={{-100,-100},{100,100}}),
graphics={
Rectangle(
extent={{-100,100},{100,-100}},
fillColor={210,210,210},
lineThickness=5.0,
fillPattern=FillPattern.Solid,
borderPattern=BorderPattern.Raised),
Ellipse(
extent={{-71,7},{-85,-7}},
lineColor=DynamicSelect({235,235,235},
if u then
{0,255,0}
else
{235,235,235}),
fillColor=DynamicSelect({235,235,235},
if u then
{0,255,0}
else
{235,235,235}),
fillPattern=FillPattern.Solid),
Text(
extent={{-150,150},{150,110}},
textString="%name",
textColor={0,0,255}),
Text(
extent={{-68,-86},{70,-38}},
textColor={0,0,0},
textString="%realFalse"),
Text(
extent={{-68,-26},{70,22}},
textColor={0,0,0},
textString="%realTrue"),
Text(
extent={{-86,78},{-34,26}},
textColor={255,0,255},
textString="B"),
Polygon(
points={{26,48},{6,68},{6,58},{-26,58},{-26,38},{6,38},{6,28},{26,48}},
lineColor={0,0,127},
fillColor={0,0,127},
fillPattern=FillPattern.Solid),
Text(
extent={{34,82},{86,24}},
textColor={0,0,127},
textString="R")}));
end BooleanToReal;
66 changes: 66 additions & 0 deletions IBPSA/Controls/OBC/CDL/Conversions/IntegerToReal.mo
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
within IBPSA.Controls.OBC.CDL.Conversions;
block IntegerToReal
"Convert Integer to Real signals"
IBPSA.Controls.OBC.CDL.Interfaces.IntegerInput u
"Integer signal to be converted to a Real signal"
annotation (Placement(transformation(extent={{-140,-20},{-100,20}})));
IBPSA.Controls.OBC.CDL.Interfaces.RealOutput y
"Converted input signal as a Real"
annotation (Placement(transformation(extent={{100,-20},{140,20}})));

equation
y=u;
annotation (
defaultComponentName="intToRea",
Icon(
coordinateSystem(
preserveAspectRatio=true,
extent={{-100.0,-100.0},{100.0,100.0}}),
graphics={
Text(
extent={{-150,150},{150,110}},
textString="%name",
textColor={0,0,255}),
Rectangle(
extent={{-100,-100},{100,100}},
lineColor={0,0,127},
fillColor={255,255,255},
fillPattern=FillPattern.Solid),
Text(
textColor={255,127,0},
extent={{-120.0,-40.0},{-20.0,40.0}},
textString="I"),
Text(
textColor={0,0,127},
fillPattern=FillPattern.Solid,
extent={{0.0,-40.0},{100.0,40.0}},
textString="R"),
Polygon(
lineColor={0,0,127},
fillColor={0,0,127},
fillPattern=FillPattern.Solid,
points={{10.0,0.0},{-10.0,20.0},{-10.0,10.0},{-40.0,10.0},{-40.0,-10.0},{-10.0,-10.0},{-10.0,-20.0},{10.0,0.0}})}),
Documentation(
info="<html>
<p>
Block that outputs the <code>Real</code>
equivalent of the <code>Integer</code> input.
</p>
<pre>
y = u;
</pre>
<p>
where <code>u</code> is of <code>Integer</code> and
<code>y</code> of <code>Real</code> type.
</p>
</html>",
revisions="<html>
<ul>
<li>
January 3, 2017, by Michael Wetter:<br/>
First implementation, based on the implementation of the
Modelica Standard Library.
</li>
</ul>
</html>"));
end IntegerToReal;
Loading

0 comments on commit 8797a23

Please sign in to comment.