From 59fa38c9b3f4c492dd3837377a593e0346d5f070 Mon Sep 17 00:00:00 2001 From: Michael Wetter Date: Wed, 27 Sep 2023 05:56:51 -0700 Subject: [PATCH] Buildings sync weather bus (#3534) * Revised tutorial SimpleHouse * Improved documentation of base classes * Declared variables on weather bus * Updated reference results --- .../BoundaryConditions/WeatherData/Bus.mo | 43 +++++++++ .../Tutorial/SimpleHouse/SimpleHouse0.mo | 4 +- .../Tutorial/SimpleHouse/SimpleHouse1.mo | 15 +-- .../Tutorial/SimpleHouse/SimpleHouse2.mo | 4 +- .../Tutorial/SimpleHouse/SimpleHouse3.mo | 10 +- .../Tutorial/SimpleHouse/SimpleHouse4.mo | 52 +++++----- .../Tutorial/SimpleHouse/SimpleHouse5.mo | 17 ++-- .../Tutorial/SimpleHouse/SimpleHouse6.mo | 71 ++++++++------ .../Interfaces/PartialEightPortInterface.mo | 11 ++- .../Interfaces/PartialFourPortInterface.mo | 12 ++- .../Interfaces/PartialTwoPortInterface.mo | 19 +++- .../Validation/ExtremeAmbientConditions.mo | 71 ++++++++------ ...ples_Tutorial_SimpleHouse_SimpleHouse4.txt | 6 +- ...ples_Tutorial_SimpleHouse_SimpleHouse5.txt | 8 +- ...ples_Tutorial_SimpleHouse_SimpleHouse6.txt | 12 +-- ...Combined_Examples_AllElectricCWStorage.txt | 24 ++--- ...mbined_Validation_AllElectricCWStorage.txt | 96 +++++++++---------- ...ngTowers_Examples_FixedApproachWetBulb.txt | 8 +- ...angers_CoolingTowers_Examples_YorkCalc.txt | 20 ++-- ...ed_Validation_BESTEST_Cases6xx_Case600.txt | 16 ++-- ...ed_Validation_BESTEST_Cases6xx_Case640.txt | 16 ++-- ...ed_Validation_BESTEST_Cases6xx_Case660.txt | 16 ++-- ...ed_Validation_BESTEST_Cases6xx_Case670.txt | 16 ++-- ...ed_Validation_BESTEST_Cases6xx_Case685.txt | 16 ++-- 24 files changed, 348 insertions(+), 235 deletions(-) diff --git a/Buildings/BoundaryConditions/WeatherData/Bus.mo b/Buildings/BoundaryConditions/WeatherData/Bus.mo index 8c4a8942192..a0227ee8fae 100644 --- a/Buildings/BoundaryConditions/WeatherData/Bus.mo +++ b/Buildings/BoundaryConditions/WeatherData/Bus.mo @@ -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, @@ -16,6 +54,11 @@ This component is an expandable connector that is used to implement a bus that c ", revisions=" ", info="

-This model is used as the starting point for the SimpleHouse tutorial. +This model is used as the starting point for the +Buildings.Examples.Tutorial.SimpleHouse +tutorial. It contains a weather data reader and a PrescribedTemperature 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 diff --git a/Buildings/Examples/Tutorial/SimpleHouse/SimpleHouse1.mo b/Buildings/Examples/Tutorial/SimpleHouse/SimpleHouse1.mo index 08cc3c22dc1..2c91ecc7d57 100644 --- a/Buildings/Examples/Tutorial/SimpleHouse/SimpleHouse1.mo +++ b/Buildings/Examples/Tutorial/SimpleHouse/SimpleHouse1.mo @@ -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, @@ -52,13 +53,13 @@ The heat capacity value of a wall may be computed as C=A*d*cp*&rho

Required models

Connection instructions

diff --git a/Buildings/Examples/Tutorial/SimpleHouse/SimpleHouse2.mo b/Buildings/Examples/Tutorial/SimpleHouse/SimpleHouse2.mo index 1b19fc1226a..a33420a6d8f 100644 --- a/Buildings/Examples/Tutorial/SimpleHouse/SimpleHouse2.mo +++ b/Buildings/Examples/Tutorial/SimpleHouse/SimpleHouse2.mo @@ -53,10 +53,10 @@ Modelica.Thermal.HeatTransfer.Sources.PrescribedHeatFlow 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 weaBus. -In the dialog box select <New Variable> and here type HDirNor, +In the dialog box select <New Variable> and here type HDirNor, which is the direct solar irradiance on a surface of 1 m2, perpendicular to the sun rays. -Set the gain factor k to 2, +Set the gain factor k to 2, in order to get the solar irradiance through the window of 2 m2.

diff --git a/Buildings/Examples/Tutorial/SimpleHouse/SimpleHouse3.mo b/Buildings/Examples/Tutorial/SimpleHouse/SimpleHouse3.mo index 1f1b0287cc8..f4d181b7669 100644 --- a/Buildings/Examples/Tutorial/SimpleHouse/SimpleHouse3.mo +++ b/Buildings/Examples/Tutorial/SimpleHouse/SimpleHouse3.mo @@ -56,16 +56,16 @@ Modelica.Thermal.HeatTransfer.Components.ThermalResistor

Connection instructions

-The MixingVolume Medium parameter contains information about +The MixingVolume Medium parameter contains information about the type of fluid and its properties that should be modelled by the MixingVolume. -Set its value to MediumAir, which is declared in the template, -by typing redeclare package Medium = MediumAir. +Set its value to MediumAir, which is declared in the template, +by typing redeclare package Medium = MediumAir. For the nominal mass flow rate you may assume a value of 1 kg/m3 for now. You will have to change this value once you add a ventilation system to the model (see Buildings.Examples.Tutorial.SimpleHouse.SimpleHouse6). -Finally, set the energyDynamics of the MixingVolume, -which can be found in the Dynamics tab of the model parameter window, to FixedInitial. +Finally, set the energyDynamics of the MixingVolume, +which can be found in the Dynamics tab of the model parameter window, to FixedInitial.

Make a connection with the PrescribedHeatFlow as well. diff --git a/Buildings/Examples/Tutorial/SimpleHouse/SimpleHouse4.mo b/Buildings/Examples/Tutorial/SimpleHouse/SimpleHouse4.mo index 873d58c7d07..6d547e7f17f 100644 --- a/Buildings/Examples/Tutorial/SimpleHouse/SimpleHouse4.mo +++ b/Buildings/Examples/Tutorial/SimpleHouse/SimpleHouse4.mo @@ -7,7 +7,7 @@ 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, @@ -15,8 +15,9 @@ model SimpleHouse4 "Heating model" 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, @@ -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), @@ -80,16 +88,16 @@ the media for the models in the heating circuit should be set to MediumWater<

Required models

  • - -Buildings.Fluid.HeatExchangers.Radiators.RadiatorEN442_2 -
  • -
  • Buildings.Fluid.HeatExchangers.HeaterCooler_u
  • - -Buildings.Fluid.Movers.FlowControlled_m_flow + +Buildings.Fluid.HeatExchangers.Radiators.RadiatorEN442_2 +
  • +
  • + +Buildings.Fluid.Movers.Preconfigured.FlowControlled_m_flow
  • @@ -104,7 +112,7 @@ Modelica.Blocks.Sources.Constant

    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 MediumWater. +the media for the models should be set to MediumWater.

    The Boundary_pT model needs to be used to set an absolute pressure somewhere in the system. diff --git a/Buildings/Examples/Tutorial/SimpleHouse/SimpleHouse5.mo b/Buildings/Examples/Tutorial/SimpleHouse/SimpleHouse5.mo index cf90827e6e5..86e10905d90 100644 --- a/Buildings/Examples/Tutorial/SimpleHouse/SimpleHouse5.mo +++ b/Buildings/Examples/Tutorial/SimpleHouse/SimpleHouse5.mo @@ -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}}))); @@ -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})); @@ -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), @@ -68,11 +68,12 @@ Modelica.Thermal.HeatTransfer.Sensors.TemperatureSensor

Connection instructions

-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 1 when the heater is on and to 0 otherwise. +Furthermore, the pump should only circulate water when the heater is on.

Reference result

-The figure below shows the air temperature when the controller is added. +The figure below shows the air temperature after the controller is added.

\"Air0.1 kg/s.

Required models

Connection instructions

@@ -121,9 +137,10 @@ Buildings.Fluid.Actuators.Dampers.Exponential Connect the components such that they exchange mass (and therefore also energy) with the MixingVolume representing the zone air. Add a boundary_pT to draw air from the environment. -Enable its temperature input and connect it to the TDryBul variable in the weather data reader. +Enable its temperature input and connect it to the TDryBul variable in the weather data reader. Also reconsider the nominal mass flow rate parameter value in the MixingVolume given the flow rate information of the ventilation system. +Finally, make sure that the fan is only active when the damper is open.

Reference result

diff --git a/Buildings/Fluid/Interfaces/PartialEightPortInterface.mo b/Buildings/Fluid/Interfaces/PartialEightPortInterface.mo index 2fc0af7b7fb..ca891fdd0cc 100644 --- a/Buildings/Fluid/Interfaces/PartialEightPortInterface.mo +++ b/Buildings/Fluid/Interfaces/PartialEightPortInterface.mo @@ -1,6 +1,6 @@ within Buildings.Fluid.Interfaces; partial model PartialEightPortInterface - "Partial model transporting fluid between eight ports without storing mass or energy" + "Partial model with eight ports and declaration of quantities that are used by many models" extends Buildings.Fluid.Interfaces.EightPort; parameter Modelica.Units.SI.MassFlowRate m1_flow_nominal(min=0) "Nominal mass flow rate" annotation (Dialog(group="Nominal condition")); @@ -163,7 +163,8 @@ protected preferredView="info", Documentation(info="

-This component defines the interface for models that transport four fluid streams between eight ports. +This component defines the interface for models with eight fluid ports +and four fluid streams. It is similar to Buildings.Fluid.Interfaces.PartialTwoPortInterface, but it has eight ports instead of two.

@@ -173,6 +174,12 @@ mass transfer and pressure drop equations. ", revisions="