Skip to content

Commit

Permalink
Buildings sync weather bus (#3534)
Browse files Browse the repository at this point in the history
* Revised tutorial SimpleHouse

* Improved documentation of base classes

* Declared variables on weather bus

* Updated reference results
  • Loading branch information
mwetter authored Sep 27, 2023
1 parent 43a3d56 commit 59fa38c
Show file tree
Hide file tree
Showing 24 changed files with 348 additions and 235 deletions.
43 changes: 43 additions & 0 deletions Buildings/BoundaryConditions/WeatherData/Bus.mo
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,44 @@ within Buildings.BoundaryConditions.WeatherData;
expandable connector Bus "Data bus that stores weather data"
extends Modelica.Icons.SignalBus;

Modelica.Units.SI.Temperature TDryBul(displayUnit="degC")
"Dry bulb temperature";
Modelica.Units.SI.Temperature TWetBul(displayUnit="degC")
"Wet bulb temperature";
Modelica.Units.SI.Temperature TDewPoi(displayUnit="degC")
"Dew point temperature";
Modelica.Units.SI.Temperature TBlaSky(displayUnit="degC")
"Black-body sky temperature";

Real relHum(final unit="1") "Relative humidity";

Real HDirNor(final unit="W/m2") "Direct normal solar irradiation";
Real HGloHor(final unit="W/m2") "Global horizontal solar irradiation";
Real HDifHor(final unit="W/m2") "Diffuse horizontal solar irradiation";

Real HHorIR(final unit="W/m2") "Horizontal infrared irradiation";

Modelica.Units.SI.Angle winDir "Wind direction";
Modelica.Units.SI.Velocity winSpe "Wind speed";

Modelica.Units.SI.Height ceiHei "Cloud cover ceiling height";
Real nOpa(final unit="1") "Opaque sky cover";
Real nTot(final unit="1") "Total sky cover";

Modelica.Units.SI.Angle lat "Latitude of the location";
Modelica.Units.SI.Angle lon "Longitude of the location";
Modelica.Units.SI.Height alt "Location altitude above sea level";

Modelica.Units.SI.AbsolutePressure pAtm "Atmospheric pressure";

Modelica.Units.SI.Angle solAlt "Solar altitude angle";
Modelica.Units.SI.Angle solDec "Solar declination angle";
Modelica.Units.SI.Angle solHouAng "Solar hour angle";
Modelica.Units.SI.Angle solZen "Solar zenith angle";

Modelica.Units.SI.Time solTim "Solar time";
Modelica.Units.SI.Time cloTim "Model time";

annotation (
defaultComponentName="weaBus",
Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,
Expand All @@ -16,6 +54,11 @@ This component is an expandable connector that is used to implement a bus that c
</html>", revisions="<html>
<ul>
<li>
September 22, 2023, by Michael Wetter:<br/>
Declared the variables that are on the bus.<br/>
This is for <a href=\"https://github.com/ibpsa/modelica-ibpsa/issues/1798\">IBPSA, #1798</a>.
</li>
<li>
June 25, 2010, by Wangda Zuo:<br/>
First implementation.
</li>
Expand Down
4 changes: 3 additions & 1 deletion Buildings/Examples/Tutorial/SimpleHouse/SimpleHouse0.mo
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ First implementation.
</ul>
</html>", info="<html>
<p>
This model is used as the starting point for the <code>SimpleHouse</code> tutorial.
This model is used as the starting point for the
<a href=\"modelica://Buildings.Examples.Tutorial.SimpleHouse\">Buildings.Examples.Tutorial.SimpleHouse</a>
tutorial.
It contains a weather data reader and a <code>PrescribedTemperature</code> component
that allows the user to connect thermal components to the dry bulb temperature.
It was based on from the Modelica crash course organised by KU Leuven
Expand Down
15 changes: 8 additions & 7 deletions Buildings/Examples/Tutorial/SimpleHouse/SimpleHouse1.mo
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ model SimpleHouse1 "Building wall model"
extends SimpleHouse0;

Modelica.Thermal.HeatTransfer.Components.HeatCapacitor walCap(
C=AWall*dWall*cpWall*rhoWall, T(fixed=true))
C=AWall*dWall*cpWall*rhoWall,
T(fixed=true))
"Thermal mass of wall"
annotation (Placement(transformation(extent={{-10,-10},{10,10}},
rotation=270,
origin={170,0})));
Modelica.Thermal.HeatTransfer.Components.ThermalResistor walRes(R=dWall/AWall
/kWall) "Thermal resistor for wall: 25 cm of rockwool"
Modelica.Thermal.HeatTransfer.Components.ThermalResistor walRes(
R=dWall/AWall/kWall) "Thermal resistor for wall: 25 cm of rockwool"
annotation (Placement(transformation(extent={{60,-10},{80,10}})));
equation
connect(walRes.port_b, walCap.port) annotation (Line(points={{80,0},{100,0},{100,
Expand Down Expand Up @@ -52,13 +53,13 @@ The heat capacity value of a wall may be computed as <i>C=A*d*c<sub>p</sub>*&rho
<h4>Required models</h4>
<ul>
<li>
<a href=\"modelica://Modelica.Thermal.HeatTransfer.Components.ThermalResistor\">
Modelica.Thermal.HeatTransfer.Components.ThermalResistor</a>
</li>
<li>
<a href=\"modelica://Modelica.Thermal.HeatTransfer.Components.HeatCapacitor\">
Modelica.Thermal.HeatTransfer.Components.HeatCapacitor</a>
</li>
<li>
<a href=\"modelica://Modelica.Thermal.HeatTransfer.Components.ThermalResistor\">
Modelica.Thermal.HeatTransfer.Components.ThermalResistor</a>
</li>
</ul>
<h4>Connection instructions</h4>
<p>
Expand Down
4 changes: 2 additions & 2 deletions Buildings/Examples/Tutorial/SimpleHouse/SimpleHouse2.mo
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ Modelica.Thermal.HeatTransfer.Sources.PrescribedHeatFlow</a>
To be able to use the value of the outdoor solar irradiance
you will need to access the weather data reader.
To do this, make a connection to the <code>weaBus</code>.
In the dialog box select <i>&lt;New Variable&gt;</i> and here type <i>HDirNor</i>,
In the dialog box select <i>&lt;New Variable&gt;</i> and here type <code>HDirNor</code>,
which is the direct solar irradiance on a surface of <i>1 m<sup>2</sup></i>,
perpendicular to the sun rays.
Set the gain factor <i>k</i> to 2,
Set the gain factor <code>k</code> to 2,
in order to get the solar irradiance through the window of <i>2 m<sup>2</sup></i>.
</p>
<p>
Expand Down
10 changes: 5 additions & 5 deletions Buildings/Examples/Tutorial/SimpleHouse/SimpleHouse3.mo
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,16 @@ Modelica.Thermal.HeatTransfer.Components.ThermalResistor</a>
</ul>
<h4>Connection instructions</h4>
<p>
The <code>MixingVolume</code> <i>Medium</i> parameter contains information about
The <code>MixingVolume</code> <code>Medium</code> parameter contains information about
the type of fluid and its properties that should be modelled by the <code>MixingVolume</code>.
Set its value to <i>MediumAir</i>, which is declared in the template,
by typing <i>redeclare package Medium = MediumAir</i>.
Set its value to <code>MediumAir</code>, which is declared in the template,
by typing <code>redeclare package Medium = MediumAir</code>.
For the nominal mass flow rate you may assume a value of <i>1 kg/m<sup>3</sup></i> for now.
You will have to change this value once you add a ventilation system to the model (see
<a href=\"modelica://Buildings.Examples.Tutorial.SimpleHouse.SimpleHouse6\">
Buildings.Examples.Tutorial.SimpleHouse.SimpleHouse6</a>).
Finally, set the <i>energyDynamics</i> of the <code>MixingVolume</code>,
which can be found in the <i>Dynamics</i> tab of the model parameter window, to <i>FixedInitial</i>.
Finally, set the <code>energyDynamics</code> of the <code>MixingVolume</code>,
which can be found in the <code>Dynamics</code> tab of the model parameter window, to <code>FixedInitial</code>.
</p>
<p>
Make a connection with the <code>PrescribedHeatFlow</code> as well.
Expand Down
52 changes: 30 additions & 22 deletions Buildings/Examples/Tutorial/SimpleHouse/SimpleHouse4.mo
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@ model SimpleHouse4 "Heating model"
parameter Modelica.Units.SI.MassFlowRate mWat_flow_nominal=0.1
"Nominal mass flow rate for water loop";
parameter Boolean use_constantHeater=true
"To enable/disable the connection between the constant source and heater";
"To enable/disable the connection between the constant source and heater and circulation pump";

Buildings.Fluid.HeatExchangers.Radiators.RadiatorEN442_2 rad(
redeclare package Medium = MediumWater,
T_a_nominal=333.15,
T_b_nominal=313.15,
energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial,
allowFlowReversal=false,
Q_flow_nominal=QHea_flow_nominal) "Radiator"
Q_flow_nominal=QHea_flow_nominal) "Radiator"
annotation (Placement(transformation(extent={{140,-140},{160,-120}})));

Buildings.Fluid.HeatExchangers.HeaterCooler_u heaWat(
redeclare package Medium = MediumWater,
m_flow_nominal=mWat_flow_nominal,
Expand All @@ -25,38 +26,45 @@ model SimpleHouse4 "Heating model"
dp_nominal=5000,
Q_flow_nominal=QHea_flow_nominal) "Heater for water circuit"
annotation (Placement(transformation(extent={{60,-140},{80,-120}})));
Buildings.Fluid.Movers.FlowControlled_m_flow pum(

Fluid.Movers.Preconfigured.FlowControlled_m_flow pum(
redeclare package Medium = MediumWater,
use_inputFilter=false,
m_flow_nominal=mWat_flow_nominal,
energyDynamics=Modelica.Fluid.Types.Dynamics.SteadyState,
allowFlowReversal=false,
nominalValuesDefineDefaultPressureCurve=true,
inputType=Buildings.Fluid.Types.InputType.Constant) "Pump"
annotation (Placement(transformation(extent={{160,-190},{140,-170}})));
Buildings.Fluid.Sources.Boundary_pT bouWat(redeclare package Medium = MediumWater, nPorts=1)
"Pressure bound for water circuit" annotation (Placement(transformation(
allowFlowReversal=false) "Pump"
annotation (Placement(transformation(extent={{110,-190},{90,-170}})));

Buildings.Fluid.Sources.Boundary_pT bouWat(
redeclare package Medium = MediumWater,
nPorts=1)
"Pressure bound for water circuit"
annotation (Placement(transformation(
extent={{-10,-10},{10,10}},
origin={20,-180})));
Modelica.Blocks.Sources.Constant conHea(k=1)
if use_constantHeater "Gain for heater"
annotation (Placement(transformation(extent={{80,-110},{60,-90}})));
Modelica.Blocks.Sources.Constant conPum(k=mWat_flow_nominal)
if use_constantHeater "Gain for pump"
annotation (Placement(transformation(extent={{130,-160},{110,-140}})));
equation
connect(heaWat.port_b,rad. port_a) annotation (Line(points={{80,-130},{140,-130}},
color={0,127,255}));
connect(rad.port_b, pum.port_a) annotation (Line(points={{160,-130},{175,-130},
{175,-180},{160,-180}}, color={0,127,255}));
{175,-180},{110,-180}}, color={0,127,255}));
connect(heaWat.port_a, pum.port_b) annotation (Line(points={{60,-130},{39.75,-130},
{39.75,-180},{140,-180}}, color={0,127,255}));
{39.75,-180},{90,-180}}, color={0,127,255}));
connect(rad.heatPortCon, zon.heatPort) annotation (Line(points={{148,-122.8},{
148,40},{160,40}}, color={191,0,0}));
connect(rad.heatPortRad, walCap.port) annotation (Line(points={{152,-122.8},{152,
1.77636e-15},{160,1.77636e-15}}, color={191,0,0}));
if use_constantHeater then
connect(conHea.y, heaWat.u) annotation (Line(points={{59,-100},{40,-100},{40,-124},
connect(conPum.y, pum.m_flow_in) annotation (Line(points={{109,-150},{100,-150},
{100,-168}}, color={0,0,127}));
connect(conHea.y, heaWat.u) annotation (Line(points={{59,-100},{40,-100},{40,-124},
{58,-124}}, color={0,0,127}));
end if;
connect(bouWat.ports[1], pum.port_b)
annotation (Line(points={{30,-180},{140,-180}},color={0,127,255}));
annotation (Line(points={{30,-180},{90,-180}}, color={0,127,255}));
annotation (Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-220,
-220},{220,220}})),
experiment(Tolerance=1e-6, StopTime=1e+06),
Expand All @@ -80,16 +88,16 @@ the media for the models in the heating circuit should be set to <i>MediumWater<
<h4>Required models</h4>
<ul>
<li>
<a href=\"modelica://Buildings.Fluid.HeatExchangers.Radiators.RadiatorEN442_2\">
Buildings.Fluid.HeatExchangers.Radiators.RadiatorEN442_2</a>
</li>
<li>
<a href=\"modelica://Buildings.Fluid.HeatExchangers.HeaterCooler_u\">
Buildings.Fluid.HeatExchangers.HeaterCooler_u</a>
</li>
<li>
<a href=\"modelica://Buildings.Fluid.Movers.FlowControlled_m_flow\">
Buildings.Fluid.Movers.FlowControlled_m_flow</a>
<a href=\"modelica://Buildings.Fluid.HeatExchangers.Radiators.RadiatorEN442_2\">
Buildings.Fluid.HeatExchangers.Radiators.RadiatorEN442_2</a>
</li>
<li>
<a href=\"modelica://Buildings.Fluid.Movers.Preconfigured.FlowControlled_m_flow\">
Buildings.Fluid.Movers.Preconfigured.FlowControlled_m_flow</a>
</li>
<li>
<a href=\"modelica://Buildings.Fluid.Sources.Boundary_pT\">
Expand All @@ -104,7 +112,7 @@ Modelica.Blocks.Sources.Constant</a>
<p>
The radiator contains one port for convective heat transfer and one for radiative heat transfer.
Connect both in a reasonable way. Since the heating system uses water as a heat carrier fluid,
the media for the models should be set to <i>MediumWater</i>.
the media for the models should be set to <code>MediumWater</code>.
</p>
<p>
The <code>Boundary_pT</code> model needs to be used to set an absolute pressure somewhere in the system.
Expand Down
17 changes: 9 additions & 8 deletions Buildings/Examples/Tutorial/SimpleHouse/SimpleHouse5.mo
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
within Buildings.Examples.Tutorial.SimpleHouse;
model SimpleHouse5 "Heating controller model"
extends SimpleHouse4(pum(inputType=Buildings.Fluid.Types.InputType.Stages,
massFlowRates=mWat_flow_nominal*{1}), final use_constantHeater=false);
extends SimpleHouse4(final use_constantHeater=false);

Modelica.Blocks.Math.BooleanToInteger booInt "Boolean to integer"
Modelica.Blocks.Math.BooleanToReal booRea1(realTrue=mWat_flow_nominal)
"Boolean to integer"
annotation (Placement(transformation(extent={{0,-160},{20,-140}})));
Modelica.Blocks.Math.BooleanToReal booRea "Boolean to real"
annotation (Placement(transformation(extent={{0,-120},{20,-100}})));
Expand All @@ -17,9 +17,7 @@ model SimpleHouse5 "Heating controller model"
"Zone air temperature sensor"
annotation (Placement(transformation(extent={{90,160},{70,180}})));
equation
connect(booInt.y, pum.stage) annotation (Line(points={{21,-150},{150,-150},{150,
-168}}, color={255,127,0}));
connect(booInt.u, not1.y) annotation (Line(points={{-2,-150},{-11.5,-150},{-11.5,
connect(booRea1.u, not1.y) annotation (Line(points={{-2,-150},{-11.5,-150},{-11.5,
-110},{-19,-110}}, color={255,0,255}));
connect(not1.u,hysRad. y) annotation (Line(points={{-42,-110},{-59,-110}},
color={255,0,255}));
Expand All @@ -31,6 +29,8 @@ equation
annotation (Line(points={{-19,-110},{-2,-110}}, color={255,0,255}));
connect(booRea.y, heaWat.u) annotation (Line(points={{21,-110},{40,-110},{40,-124},
{58,-124}}, color={0,0,127}));
connect(booRea1.y, pum.m_flow_in) annotation (Line(points={{21,-150},{100,-150},
{100,-168}}, color={0,0,127}));
annotation (Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-220,
-220},{220,220}})),
experiment(Tolerance=1e-6, StopTime=1e+06),
Expand Down Expand Up @@ -68,11 +68,12 @@ Modelica.Thermal.HeatTransfer.Sensors.TemperatureSensor</a>
</ul>
<h4>Connection instructions</h4>
<p>
The heater modulation level should be set to one when the heater is on and to zero otherwise.
The heater modulation level should be set to <i>1</i> when the heater is on and to <i>0</i> otherwise.
Furthermore, the pump should only circulate water when the heater is on.
</p>
<h4>Reference result</h4>
<p>
The figure below shows the air temperature when the controller is added.
The figure below shows the air temperature after the controller is added.
</p>
<p align=\"center\">
<img alt=\"Air temperature as function of time.\"
Expand Down
Loading

0 comments on commit 59fa38c

Please sign in to comment.