## Buildings.Examples.Tutorial.SpaceCooling

Package with example for how to build a model for space cooling

### Information

This package contains examples with step-by-step instructions for how to build a system model for space cooling as shown in the figure below. The temperautures correspond to design conditions that will be used to size the components. The room heat capacity has been increased by a factor of three to approximate the thermal storage effect of furniture and building constructions.

The model consists of

1. a room with a cooling load due to internal heat gains and due to conductive heat gains from the environment,
2. a fresh air supply with a heat recovery, a cooling coil and a fan. The fan is operating continuously at full speed. The room air temperature is controlled by a controller that switches the water flow rate through the coil on and off with a dead-band of 1 Kelvin.

To explain the implementation of this model, the model has been created in the following three stages:

1. Buildings.Examples.Tutorial.SpaceCooling.System1 implements the room model without air supply.
2. Buildings.Examples.Tutorial.SpaceCooling.System2 implements the air supply with open-loop control.

Extends from Modelica.Icons.ExamplesPackage (Icon for packages containing runnable examples).

### Package Content

Name Description
System1 First part of the system model, consisting of the room with heat transfer
System2 Second part of the system model with air supply and open loop control
System3 Third part of the system model with air supply and closed loop control

## Buildings.Examples.Tutorial.SpaceCooling.System1

First part of the system model, consisting of the room with heat transfer

### Information

This part of the system model implements the room with a heat gain. The room is simplified as a volume of air, a prescribed heat source for the internal convective heat gain, and a heat conductor for steady-state heat conduction to the outside. To increase the heat capacity of the room, such as due to heat stored in furniture and in building constructions, the heat capacity of the room air was increased by a factor of three. The convective heat transfer coefficient is lumped into the heat conductor model.

#### Implementation

This section describes step by step how we implemented the model.

1. First, to define the medium properties, we added the declaration

replaceable package MediumA = Buildings.Media.Air "Medium for air";

This will allow the propagation of the medium model to all models that contain air. In this example, there is only one model with air, but when we connect an air supply, there will be multiple models that use this medium.

We called the medium MediumA to distinguish it from MediumW that we will use in later versions of the model for components that have water as a medium.

Note that although the medium model is for unsaturated air, the cooling coil will be able to reduce the moisture content of the medium. Because the air outlet state of the cooling coil has a relative humidity below 100%, we can use this medium model and need not be able to model the fog region.

We also defined the system-level parameters

parameter Modelica.Units.SI.Volume V=6*10*3 "Room volume";
parameter Modelica.Units.SI.MassFlowRate mA_flow_nominal = V*1.2*6/3600
"Nominal mass flow rate";
parameter Modelica.Units.SI.HeatFlowRate QRooInt_flow = 1000
"Internal heat gains of the room";

to declare that the room volume is 180 m3, that the room has a nominal mass flow rate of 6 air changes per hour and that the internal heat gains of the room are 1000 Watts. These parameters have been declared at the top-level of the model as they will be used in several other models. Declaring them at the top-level allows to propagate them to other models, and to easily change them at one location should this be required when revising the model.

2. To model the room air, approximated as a completely mixed volume of air, an instance of Buildings.Fluid.MixingVolumes.MixingVolume has been used, as this model can be used with dry air or moist air. The medium model has been set to MediumA. We set the parameter energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial which will cause the initial conditions of the volume to be fixed to the values specified by the parameters on the Initialization tab.

The nominal mass flow rate of the volume is set to mA_flow_nominal. The nominal mass flow rate is used for numerical reasons and should be set to the approximate order of magnitude. It only has an effect if the mass flow rate is near zero and what "near zero" means depends on the magnitude of m_flow_nominal, as it is used for the default value of the parameter m_flow_small on the Assumptions tag of the model. See also Buildings.Fluid.UsersGuide for an explanation of the purpose of m_flow_small.

3. To increase the heat capacity of the room air to approximate energy storage in furniture and building constructions, we set the parameter mSenFac=3 in the instance vol. This will increase the sensible heat capacity of the room air by a factor of three.

4. We used the instance heaCon to model the heat conductance to the ambient. Since our room should have a heat loss of 10 kW at a temperature difference of 30 Kelvin, we set the conductance to G=10000 ⁄ 30 W/K.

5. Finally, we used the instance preHea to model a prescribed, constant heat gain of 1000 Watts, such as due to internal heat source.

This completes the initial version of the model. When simulating the model for 3 hours, or 10800 seconds, the response shown below should be seen.

To verify the correctness of the model, we can compare the simulated results to the following analytical solutions:

1. At steady-state, the temperature difference to the outside should be Δ T = Q̇ ⁄ UA = 1000/(10000/30) = 3 Kelvin, which corresponds to a room temperature of -7°C.
2. It can be shown that the time constant of the room is τ = C ⁄ UA = 1950 seconds, where C is the heat capacity of the room air and the thermal storage element that is connected to it, and G is the heat conductance.

Both analytical values agree with the simulation results shown in the above figure.

#### Notes

For a more realistic model of a room, the model Buildings.ThermalZones.Detailed.MixedAir could have been used. For transient heat conduction, models from the package Buildings.HeatTransfer.Conduction could have been used.

Extends from Modelica.Icons.Example (Icon for runnable examples).

### Parameters

TypeNameDefaultDescription
replaceable package MediumABuildings.Media.AirMedium for air
VolumeV6*10*3Room volume [m3]
MassFlowRatemA_flow_nominalV*1.2*6/3600Nominal mass flow rate [kg/s]
HeatFlowRateQRooInt_flow1000Internal heat gains of the room [W]

### Connectors

TypeNameDescription
replaceable package MediumAMedium for air

### Modelica definition

model System1 "First part of the system model, consisting of the room with heat transfer" extends Modelica.Icons.Example; replaceable package MediumA = Buildings.Media.Air "Medium for air"; Buildings.Fluid.MixingVolumes.MixingVolume vol( redeclare package Medium = MediumA, m_flow_nominal=mA_flow_nominal, V=V, energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial, mSenFac=3); Modelica.Thermal.HeatTransfer.Components.ThermalConductor theCon(G=10000/30) "Thermal conductance with the ambient"; parameter Modelica.Units.SI.Volume V=6*10*3 "Room volume"; parameter Modelica.Units.SI.MassFlowRate mA_flow_nominal=V*1.2*6/3600 "Nominal mass flow rate"; parameter Modelica.Units.SI.HeatFlowRate QRooInt_flow=1000 "Internal heat gains of the room"; Modelica.Thermal.HeatTransfer.Sources.FixedTemperature TOut(T=263.15) "Outside temperature"; Modelica.Thermal.HeatTransfer.Sources.FixedHeatFlow preHea(Q_flow= QRooInt_flow) "Prescribed heat flow"; equation connect(TOut.port, theCon.port_a); connect(theCon.port_b, vol.heatPort); connect(preHea.port, vol.heatPort); end System1;

## Buildings.Examples.Tutorial.SpaceCooling.System2

Second part of the system model with air supply and open loop control

### Information

This part of the system model adds a space cooling with open loop control to the model Buildings.Examples.Tutorial.SpaceCooling.System1. The space cooling consist of a model for the ambient conditions out, a heat recovery hex, a cooling coil cooCoi and a fan fan. There is also a return duct that connects the room volume vol with the heat recovery. Weather data are obtained from the instance weaDat which is connected to the model for the ambient air conditions out and the outside temperature that is used for the heat conductance TOut.

In this model, the duct pressure loss is not modeled explicitly, but rather lumped into the pressure drops of the heat exchangers.

#### Implementation

This section describes the steps that were required to build the model.

1. The first step was to copy the model Buildings.Examples.Tutorial.SpaceCooling.System1. Note that for larger models, it is recommended to extend models instead of copying them to avoid code duplication, as code duplication makes it hard to maintain different versions of a model. But for this model, we copied the old model to avoid this model to be dependent on Buildings.Examples.Tutorial.SpaceCooling.System1.

2. As this model will also use water as the medium for the water-side of the cooling coil, we added the medium declaration

replaceable package MediumW = Buildings.Media.Water "Medium for water";

3. Next, we defined system-level parameters for the water and air temperatures and the water and air mass flow rates. These declarations are essentially the design calculations which are then used to size the components and flow rates. It is good practice to list them at the top-level of the model to allow easy change of temperatures or loads at a central place, and automatic propagation of the new results to models that use these parameters.

Note that we use an assignment for the nominal air mass flow rate mA_flow_nominal that is different from the assignment in Buildings.Examples.Tutorial.SpaceCooling.System1 because now, the air flow rate is a result of the sizing calculations.

The calculations are as follows:

//////////////////////////////////////////////////////////
// Heat recovery effectiveness
parameter Real eps = 0.8 "Heat recovery effectiveness";

/////////////////////////////////////////////////////////
// Design air conditions
parameter Modelica.Units.SI.Temperature TASup_nominal = 291.15
"Nominal air temperature supplied to room";
parameter Modelica.Units.SI.DimensionlessRatio wASup_nominal = 0.012
"Nominal air humidity ratio supplied to room [kg/kg] assuming 90% relative humidity";
parameter Modelica.Units.SI.Temperature TRooSet = 297.15
"Nominal room air temperature";
parameter Modelica.Units.SI.Temperature TOut_nominal = 303.15
"Design outlet air temperature";
parameter Modelica.Units.SI.Temperature THeaRecLvg=
TOut_nominal - eps*(TOut_nominal-TRooSet)
"Air temperature leaving the heat recovery";
parameter Modelica.Units.SI.DimensionlessRatio wHeaRecLvg = 0.0135
"Air humidity ratio leaving the heat recovery [kg/kg]";

/////////////////////////////////////////////////////////
// Cooling loads and air mass flow rates
parameter Modelica.Units.SI.HeatFlowRate QRooInt_flow=
1000 "Internal heat gains of the room";
parameter Modelica.Units.SI.HeatFlowRate QRooC_flow_nominal=
-QRooInt_flow-10E3/30*(TOut_nominal-TRooSet)
"Nominal cooling load of the room";
parameter Modelica.Units.SI.MassFlowRate mA_flow_nominal=
1.3*QRooC_flow_nominal/1006/(TASup_nominal-TRooSet)
"Nominal air mass flow rate, increased by factor 1.3 to allow for recovery after temperature setback";
parameter Modelica.Units.SI.TemperatureDifference dTFan = 2
"Estimated temperature raise across fan that needs to be made up by the cooling coil";
parameter Modelica.Units.SI.HeatFlowRate QCoiC_flow_nominal=
mA_flow_nominal*(TASup_nominal-THeaRecLvg-dTFan)*1006+mA_flow_nominal*(wASup_nominal-wHeaRecLvg)*2458.3e3
"Cooling load of coil, taking into account outside air sensible and latent heat removal";

/////////////////////////////////////////////////////////
// Water temperatures and mass flow rates
parameter Modelica.Units.SI.Temperature TWSup_nominal = 285.15
"Water supply temperature";
parameter Modelica.Units.SI.Temperature TWRet_nominal = 289.15
"Water return temperature";
parameter Modelica.Units.SI.MassFlowRate mW_flow_nominal=
-QCoiC_flow_nominal/(TWRet_nominal-TWSup_nominal)/4200
"Nominal water mass flow rate";

Now, we explain the component models that are used to assemble the system model.

1. The weather data are obtained from the instance weaDat in which we set the location to Chicago, IL. We also configured the model to use a constant atmospheric pressure, as opposed to the pressure from the weather file, as we are not interested in modeling the effect of changes in the atmospheric pressure. Furthermore, we configured the model to use a constant dry-bulb temperature of TOut_nominal. This helps in testing the model at the design conditions, and can easily be changed later to use weather data from the file. Thus, although we use a model that reads a weather data file, for now we want to use constant outside conditions to simplify the testing of the model.

2. To use weather data for the heat conduction, we changed the instance TOut to a model that allows obtaining the temperature from the input port. To connect this input port to weather data, we added the connector weaBus, as this is needed to pick a single variable, the dry-bulb temperature, from the weather bus which carries all weather data.

3. To model ambient outside air conditions, we use the instance out which is connected directly to the weather data model weaDat. In this model, we also set the medium model to MediumA.

4. Next, we set in all new component models the medium model to MediumA if it is part of the air system, or to MediumW if it is part of the water system. From the information section of the cooling coil, we see that its parameter Medium1 needs to be water, and Medium2 needs to be air.

Next, we configured the air-side components of the model.

1. For the heat recovery hex, we set the effectiveness to the parameter eps, which we defined earlier to be 0.8. We also set the nominal mass flow rates to mA_flow_nominal and the pressure drops on both sides to 200 Pascals. This pressure drop is attained when the air mass flow rate is equal to mA_flow_nominal, and it is adjusted for other flow rates using a quadratic law with regularization when the flow rate is below 10% of mA_flow_nominal. This default value can be changed on the tab Flow resistance of the model.

2. To configure the cooling coil model cooCoi, we set the water and air side nominal mass flow rates and pressure drops to

m1_flow_nominal=mW_flow_nominal,
m2_flow_nominal=mA_flow_nominal,
dp1_nominal=6000,
dp2_nominal=200,

This model also requires the specification of the UA-value. We allow the component model to do this based on design conditions by setting the parameters:

use_Q_flow_nominal=true,
Q_flow_nominal= QCoiC_flow_nominal
T_a1_nominal=TWSup_nominal,
T_a2_nominal=THeaRecLvg,
W_a2_nominal= wHeaRecLvg

In order to see the coil inlet and outlet temperatures, we set the parameter

show_T = true

Its default value is false.

To use prescribed initial values for the state variables of the cooling coil, we set the parameter

energyDynamics=Modelica.Fluid.Types.Dynamics.FixedInitial

3. For the fan, we set the nominal mass flow rate to mA_flow_nominal and also connect its input port to the component mAir_flow, which assigns a constant air flow rate. We leave the fan efficiency at its default value of 0.7. We set the parameter

to configure the fan to be a steady-state model. This was done as we are using a constant fan speed in this example.

4. For the two temperature sensors in the supply duct, we also set the nominal mass flow rate to mA_flow_nominal.

Now, what is left is to configure the water-side components.

1. We configured the component souWat so that it obtains its mass flow rate from the input connector, and we connected this input connector to the constant block mWat_flow. To set the water temperature that leaves this component, we set the parameter T=TWSup_nominal. Alternatively, we could have used the model Buildings.Fluid.Movers.FlowControlled_m_flow as is used for the fan, but we chose to use the simpler model Buildings.Fluid.Sources.MassFlowSource_T as this model allows the direct specification of the leaving fluid temperature.
2. To complete the water circuit, we also used the instance sinWat. This model is required for the water to flow out of the heat exchanger into an infinite reservoir. It is also required to set a reference for the pressure of the water loop. Since in our model, no water flows out of this reservoir, there is no need to set its temperature.

This completes the initial version of the model. When simulating the model, the response shown below should be seen.

#### Notes

If we were interested in computing electricity use for the pump, we could have used the same model as for the fan.

To explicitly model duct pressure drop, we could have added Buildings.Fluid.FixedResistances.PressureDrop to the model. However, computationally it is cheaper to lump these pressure drops into other component models. In fact, rather than separately computing the pressure drop of the heat recovery and the air-side pressure drop of the cooling coil, we could have modeled the cooling coil pressure drop as dp_nominal = 2*200+200 and set for the heat recovery dp1_nominal = 0 and dp2_nominal = 0. Setting the nominal pressure drop to zero will remove this equation from the model.

Extends from Modelica.Icons.Example (Icon for runnable examples).

### Parameters

TypeNameDefaultDescription
replaceable package MediumABuildings.Media.AirMedium for air
replaceable package MediumWBuildings.Media.WaterMedium for water
VolumeV6*10*3Room volume [m3]
Realeps0.8Heat recovery effectiveness
TemperatureTASup_nominal291.15Nominal air temperature supplied to room [K]
DimensionlessRatiowASup_nominal0.012Nominal air humidity ratio supplied to room [kg/kg] assuming 90% relative humidity [1]
TemperatureTRooSet297.15Nominal room air temperature [K]
TemperatureTOut_nominal303.15Design outlet air temperature [K]
TemperatureTHeaRecLvgTOut_nominal - eps*(TOut_nom...Air temperature leaving the heat recovery [K]
DimensionlessRatiowHeaRecLvg0.0135Air humidity ratio leaving the heat recovery [kg/kg] [1]
HeatFlowRateQRooInt_flow1000Internal heat gains of the room [W]
HeatFlowRateQRooC_flow_nominal-QRooInt_flow - 10E3/30*(TOu...Nominal cooling load of the room [W]
MassFlowRatemA_flow_nominal1.3*QRooC_flow_nominal/1006/...Nominal air mass flow rate, increased by factor 1.3 to allow for recovery after temperature setback [kg/s]
TemperatureDifferencedTFan2Estimated temperature raise across fan that needs to be made up by the cooling coil [K]
HeatFlowRateQCoiC_flow_nominalmA_flow_nominal*(TASup_nomin...Cooling load of coil, taking into account outside air sensible and latent heat removal [W]
TemperatureTWSup_nominal285.15Water supply temperature [K]
TemperatureTWRet_nominal289.15Water return temperature [K]
MassFlowRatemW_flow_nominal-QCoiC_flow_nominal/(TWRet_n...Nominal water mass flow rate [kg/s]

### Connectors

TypeNameDescription
replaceable package MediumAMedium for air
replaceable package MediumWMedium for water
BusweaBus

## Buildings.Examples.Tutorial.SpaceCooling.System3

Third part of the system model with air supply and closed loop control

### Information

This part of the system model modifies Buildings.Examples.Tutorial.SpaceCooling.System2 to use the actual outside temperature for a summer day, and it adds closed loop control. The closed loop control measures the room temperature and switches the chilled water flow rate on or off.

#### Implementation

This section describes how we modified Buildings.Examples.Tutorial.SpaceCooling.System2 to build this model.

1. The first step was to copy the model Buildings.Examples.Tutorial.SpaceCooling.System2.

2. Next, we changed in weaDat the parameter that determines whether the outside dry bulb temperature is used from the weather data file or set to a constant value. This can be accomplished in the GUI of the weather data reader as follows:

With this change to using real weather data, we also change the simulation time to be one day during the summer, where the start time is 4320 h (15552000 s) and the stop time is 4344 h (15638400 s).

If the model is now simulated, the following plot could be generated that shows that the room is cooled too much due to the open loop control:

To add closed loop control, we proceeded as follows.

1. First, we made an instance of the on/off controller Buildings.Controls.OBC.CDL.Logical.OnOffController and set its name to con. We set the parameter for the bandwidth to 1 Kelvin. This model requires as an input the measured temperature and the set point.

2. For the set point, we made the instance TRooSetPoi to feed a constant set point into the controller.

3. The instance senTemRoo has been added to measure the room air temperature. Note that we decided to measure directly the room air temperature. If we would have used a temperature sensor in the return air stream, then its temperature would never change when the mass flow rate is zero, and hence it would not measure how the room temperature changes when the fan is off.

4. Since the controller output is a boolean signal, but the instance souWat needs a real signal as an input for the water mass flow rate, we needed to add a conversion block. We therefore replaced the instance mWat_flow from a constant block to the block Buildings.Controls.OBC.CDL.Conversions.BooleanToReal. Because the cooling control has a reverse action, i.e., if the measured value exceeds the set point, the system should switch on instead of off, we configured the parameters of the conversion block as follow:

realTrue=0
realFalse=mW_flow_nominal

This will output mW_flow_nominal when the room temperature is above the set point, and 0 otherwise.

This completes building the model shown in the figure on Buildings.Examples.Tutorial.SpaceCooling. When simulating the model, the response shown below should be seen.

#### Notes

To add a continuous controller for the coil water flow rate, we could have used the model Buildings.Controls.OBC.CDL.Continuous.PID.

Extends from Modelica.Icons.Example (Icon for runnable examples).

### Parameters

TypeNameDefaultDescription
replaceable package MediumABuildings.Media.AirMedium for air
replaceable package MediumWBuildings.Media.WaterMedium for water
VolumeV6*10*3Room volume [m3]
Realeps0.8Heat recovery effectiveness
TemperatureTASup_nominal291.15Nominal air temperature supplied to room [K]
DimensionlessRatiowASup_nominal0.012Nominal air humidity ratio supplied to room [kg/kg] assuming 90% relative humidity [1]
TemperatureTRooSet297.15Nominal room air temperature [K]
TemperatureTOut_nominal303.15Design outlet air temperature [K]
TemperatureTHeaRecLvgTOut_nominal - eps*(TOut_nom...Air temperature leaving the heat recovery [K]
DimensionlessRatiowHeaRecLvg0.0135Air humidity ratio leaving the heat recovery [kg/kg] [1]
HeatFlowRateQRooInt_flow1000Internal heat gains of the room [W]
HeatFlowRateQRooC_flow_nominal-QRooInt_flow - 10E3/30*(TOu...Nominal cooling load of the room [W]
MassFlowRatemA_flow_nominal1.3*QRooC_flow_nominal/1006/...Nominal air mass flow rate, increased by factor 1.3 to allow for recovery after temperature setback [kg/s]
TemperatureDifferencedTFan2Estimated temperature raise across fan that needs to be made up by the cooling coil [K]
HeatFlowRateQCoiC_flow_nominalmA_flow_nominal*(TASup_nomin...Cooling load of coil, taking into account outside air sensible and latent heat removal [W]
TemperatureTWSup_nominal285.15Water supply temperature [K]
TemperatureTWRet_nominal289.15Water return temperature [K]
MassFlowRatemW_flow_nominal-QCoiC_flow_nominal/(TWRet_n...Nominal water mass flow rate [kg/s]

### Connectors

TypeNameDescription
replaceable package MediumAMedium for air
replaceable package MediumWMedium for water
BusweaBus