Modeling a physical system

There is some fairly complicated math involved in convolution, so before starting on the math, let's start with an example to motivate the procedure (if you want to dig right into the math, you can go to the next page).

The problem we will consider is that of the interior temperature of an unheated building (this is actual data taken in February in southeastern Pennsylvania). The graph below shows the temperature external to the building (blue) and internal to the building (green). Note: a slight adjustment was made to the data for the purposes of this demonstration (see below for explanation if you are interested).

Straw Bale House Temps


As you might expect the temperature inside varies significantly less that the temperature outside, and the internal temperature lags the external temperature somewhat. It seems reasonable to assume that the current internal temperature is some weighted average of past temperatures. Consider a weighting function that we'll call h(t). An example is shown below. We'll consider two possible weighting functions, an exponential decay, and a plain moving average. The exponential weighting function drops off rapidly, while the moving average weights all points equally. You can select either one:

Impulse Response Type (valid for t≥0)

    $h(t)=\frac{1}{\tau} \quad \quad (t<\tau)$

You can change the "width" of the function by adjusting τ (time constant for exponential, or window width for moving average).

Note: the height changes as well as the width because the area of the weighting function must equal 1 (see below for explanation if you are interested).

The blue function to the right is the external temperature. The red (transparent) function indicates how the weighting function contributes at a time, "t". The weighting function is shown for reference only, the actual height is shown on the previous graph. You can also click in any of the bottom three graphs to set the value of "t".

As an example try setting the time "t" to 8 days. The graph now shows the weighting function, reversed, and shifted over to t=8 seconds. The product is shown in magenta in the graph below that one (labelled "f(λ)·h(t-λ) vs λ"). The integral of the magenta line is the weighted average. You can see that, for exponential weighting, the points in the recent past have are accentuated while those further in the past are attenuated. Thus the points from the recent past contribute more to the integral.

The very bottom graph shows the external temperature (blue), the calculated internal temperature (i.e., the weighted average of the external temperature, and is shown in purple), and the measured internal temperature is shown in green. The weighted average is calculated as

\[y(t)=\int_{-\infty}^{+\infty}{h(t-\lambda)\cdot f(\lambda)\cdot d\lambda}\]

In this equation, f(t) is the internal temperature, h(t) is the weighting function, and y(t) is the weighted average. Note that the variable λ is just a dummy variable for integration and does not appear in the final result.

Things to try

Some minor points (you can probably skip this)

Input and output data must have equal averages

Because we are calculating the internal temperature as a weighted average of the external temperature, they should have the same average (so if the external temperature were constant, the internal temperature would settle at that same temperature). The measured internal and external temperatures are shown at the left. I adjusted them so that their averages were the same (since this was February in Philadelphia, I picked 0°). You can see it made little difference - the biggest change is that the internal temperature is a few degrees lower in the adjusted data (right graph).

The main reason the original internal temperature was higher is because this model neglects any heat input from solar energy, but assumes that the only thing that affects the internal temperature is the external temperature.

Straw Bale House Temps

The area of the weighting function must equal 1

We define the weighted average as

\[y(t)=\int_{-\infty}^{+\infty}{h(t-\lambda)\cdot f(\lambda)\cdot d\lambda}\]

If the function to be averaged is a constant f(λ)=K, then

\[y(t)=\int_{-\infty}^{+\infty}{h(t-\lambda)\cdot K\cdot d\lambda}=K\int_{-\infty}^{+\infty}{h(t-\lambda) d\lambda}\]

Obviously we want the average of a constant to be equal to that constant, so we want the integral of the weight function to be equal to 1

\[\int_{-\infty}^{+\infty}{h(t-\lambda) d\lambda}=\int_{-\infty}^{+\infty}{h(\lambda) d\lambda}=1\]

(note that since the integral goes from -∞→+∞ the value of t is unimportant).

Initial Transient

Set the weighting function to an exponential with τ=1.5 days. If you look at the graph for calculated internal temperature, you will note that it does not agree with the measured internal temperature near t=0. This is because our calculation assumed that the internal temperature started at 0° at t=0 days, and the external temperature was 0° for t<0; see graph labeled "f(λ) = Ext T, …". This is known as a "zero state solution" (initial conditions are zero). In order to get a "complete solution" you need to add in the "zero input solution" that accounts for the initial temperature (i.e. set the calculated internal temperature to about 8° at t=0 (to match the actual internal temperature).