This example shows how to use Simulink® to create the thermal model of a house. This system models the outdoor environment, the thermal characteristics of the house, and the house heating system.
The sldemo_househeat_data.m file initializes data in the model workspace. To make changes, you can edit the model workspace directly or edit the file and re-load the model workspace. To view the model workspace, from the Simulink Editor Modeling tab, click Model Explorer.
First, open the sldemo_househeat model.
This model calculates heating costs for a generic house. Opening the model loads the information about the house from the sldemo_househeat_data.m file. The file does the following:
Defines the house geometry (size, number of windows)
Specifies the thermal properties of house materials
Calculates the thermal resistance of the house
Provides the heater characteristics (temperature of the hot air, flow-rate)
Defines the cost of electricity (0.09$/kWhr)
Specifies the initial room temperature (20 ºC = 68 ºF)
Note: Time is given in units of hours. Certain quantities, like air flow-rate, are expressed per hour (not per second).
The Set Point is a constant block. It specifies the temperature that must be maintained indoors. By default, it is 70 ºF. Temperatures are given in ºF. The model converts the temperature to ºC.
The Thermostat subsystem contains a Relay block. The thermostat allows fluctuations of 5 ºF above or below the desired room temperature. If air temperature drops below 65 ºF, the thermostat turns on the heater.
Open the Thermostat subsystem.
The Heater subsystem models a constant air flow rate,
Mdot, which is specified in the sldemo_househeat_data.m file. The thermostat signal turns the heater on or off. When the heater is on, it blows hot air at temperature THeater (50 ºC = 122 ºF by default) at a constant flow rate of Mdot (1kg/sec = 3600kg/hr by default). Equation 1 expresses the heat flow into the room.
Open the Heater subsystem.
The Cost Calculator is a Gain block. Cost Calculator integrates the heat flow over time and multiplies it by the energy cost. The model plots the heating cost in the PlotResults scope.
The House is a subsystem that calculates room temperature variations. It takes into consideration the heat flow from the heater and heat losses to the environment. Heat losses and the temperature time derivative are expressed by Equation 2.
Open the House subsystem.
Model the Environment
To simulate the environment, the model uses a heat sink with infinite heat capacity and time varying temperature, Tout. The constant block Avg Outdoor Temp specifies the average air temperature outdoors. The Daily Temp Variation Sine Wave block generates daily outdoor temperature fluctuations. You can vary these parameters and to see how they affect the heating costs.
Run the simulation. Use the PlotResults scope to visualize the results. The scope plots the heat cost and indoor versus outdoor temperatures. The temperature outdoor varies sinusoidally. The indoors temperature remains within 5 ºC of the Set Point. The Time axis is in hours.
According to this model, it would cost about $30 to heat the house for two days. Try varying the parameters and observe the system response.
This model calculates the heating costs only. If the temperature of the outside air is higher than the room temperature, the room temperature will exceed the desired Set Point.
You can modify this model to include an air conditioner. You can implement the air conditioner as a modified heater. To do this, add parameters like the following to sldemo_househeat_data.m.
Cold air output
Temperature of the stream from the air conditioner
Air conditioner efficiency
To control both the air conditioner and the heater, modify the thermostat.