Week 03 · Ordinary differential equations and cooling

Turn a rate law into a trajectory and check its fit.

← Week 2 · Subject contents · Week 4 →

Turn a rate law into a trajectory and check its fit.

Work through the problem

An object cools at a rate proportional to how much hotter it is than its surroundings. Write dT/dt = −k(T−Tₐ), with k in inverse minutes. Dividing by T−Tₐ and integrating gives T(t)−Tₐ = (T₀−Tₐ)e⁻ᵏᵗ.

At ambient 20 °C and initial 80 °C, a reading of 50 °C at 5 minutes halves the excess temperature. Thus k = log(2)/5 and the prediction at 10 minutes is 35 °C. A real observation at 10 minutes gives a residual with which to check the model.

Run the Python lab

from math import exp, log, isclose
ambient, start, observed = 20, 80, 50
k = log((start-ambient)/(observed-ambient))/5
def temperature(t):
    return ambient + (start-ambient)*exp(-k*t)
for minute, reading in [(0,80), (5,50), (10,36)]:
    print(minute, round(temperature(minute), 1), round(reading-temperature(minute), 1))
assert isclose(temperature(10), 35)

Output from the lab

0 80.0 0.0
5 50.0 0.0
10 35.0 1.0

Practice

  1. Why might an early reading deviate systematically?

Check your reasoning

  1. The object may have internal temperature gradients. A single temperature and constant k can then be inadequate.

← Week 2 · Subject contents · Week 4 →

Further reading · MIT 6.262 · Discrete Stochastic Processes