# Emulating changes in building temperature

I need to emulate what happens to the temperature in a building when turning the heating on and off, for a kind of computer simulation. I don't even know where to start, so I hope you can help me out. Let's say we start with an outdoor temperature of 0°C, and the house having the same temperature indoor, °C.

There is a button I can twist to adjust the power to the heating system. Let's say it's between 1 and 20kW, in 1kW intervals. I can only turn it on and off in 10 min intervals, ie from 16:00 to 16:10 it is on the same power value fx 4kW, then maybe a new power value from 16:10 to 16:20 fx 6kW.

For a given series of power values, let's say a whole day, So how will this affect the temperature in the house?

I know I need to specify a lot of variables about the house, but I honestly have no idea how to model that. And I am happy with a very crude approximation.

Is it possible to model this in a way that a simple computer scientist can understand?

I can’t write this computer simulation for you (at least not based on the data provided) but will instead explain a few basic relationships that govern the heating and cooling of objects. I hope this helps.

Consider a building an object that is composed of $n$ objects of masses $m_i$ with specific heat capacities $c_{p,i}$, then the building has an overall heat capacity given by:

$cM=\displaystyle\sum_{i=1}^{n} c_{p,i} m_i$.

1. Heating:

Understand $cM$ to be the total heat energy $\Delta Q$ needed to raise the building’s temperature by 1 degree Celsius:

$\Delta Q=cM\Delta T$ for $\Delta T = 1 C$.

If we add an amount of heat per unit of time $t$, that is $\frac{\Delta Q}{\Delta t}$, then we can write:

$\frac{\Delta Q}{\Delta t}=cM \frac{\Delta T}{\Delta t}$.....(Eq.1).

With $\frac{\Delta T}{\Delta t}$ the rate of temperature change in time.

2. Cooling:

Assuming that the building’s temperature $T$ is higher than that of its surroundings $T_O$, the building is constantly losing heat in accordance with Newton’s cooling law:

$\frac{\Delta Q}{\Delta t}=hA(T(t)-T_O)$.....Eq.2

Where $h$ the heat transfer coefficient, $A$ the total outside surface of the building and $T(t)$ the building’s temperature at any time $t$.

3. Thermostatic heating:

Most buildings require temperature to be kept near a desired set point, say $T_s$ (typically 18 to 20 degrees Celsius).

It should now be apparent that when $T(t) \geq T_s$ and the heating power $\frac{\Delta Q}{\Delta t}$ is still ‘on’, then in accordance with Eq.1, $T(t)$ will continue rising. But that is not a desired outcome. Instead it would be better to switch the heating power to ‘off’ when $T(t) \geq T_s$. This is of course the principle of thermostatic heating. When the building has cooled back down so a that $T(t) \leq T_s$, the thermostatic controller switches the heating power back on. This system requires no timed heating power program and also adapts well to changing values of $T_O$, the building's surrounding temperature.

At this set temperature the average power consumption is given by Eq.2:

$\frac{\Delta Q}{\Delta t}=hA(T_s-T_O)$.