Fundamentals 4 min read

How to Model Cooling with Differential Equations: Step-by-Step Guide

This article outlines a three‑step process for constructing differential‑equation models, demonstrates it with a Newton cooling problem, derives the governing equation, solves it analytically and numerically using Python’s sympy, and predicts the object’s temperature after 20 minutes.

Model Perspective
Model Perspective
Model Perspective
How to Model Cooling with Differential Equations: Step-by-Step Guide

Building a differential equation model generally involves three steps:

(1) Identify the quantities to study (independent variable, unknown function, necessary parameters) and choose a coordinate system.

(2) Determine the fundamental laws governing these quantities.

(3) Use these laws to formulate the differential equation and its initial/boundary conditions. The following example illustrates common methods for constructing such models.

1. Object Cooling Model

1.1 Problem

An object is placed in air. At time t₀ its temperature is T₀, and after 10 minutes its temperature is T₁. Establish the relationship between the object's temperature and time, assuming the ambient air temperature remains constant at T_a, and predict the temperature after 20 minutes.

1.2 Modeling

Newton's law of cooling states that when an object’s surface temperature differs from the surrounding medium, the heat loss per unit area per unit time is proportional to the temperature difference, with the proportionality constant called the heat transfer coefficient.

Let u(t) denote the object's temperature at time t. Applying Newton's law yields the differential equation:

du/dt + k (u - T_a) = 0

1.3 Solution

Since k and T_a are constants, the equation can be rewritten and integrated on both sides, leading to the solution:

u(t) = T_a + (u(0) - T_a) e^{-k t}

1.4 Explanation

Substituting the initial condition u(0)=150°C and the measured temperature u(10)=100°C into the solution determines k, and the temperature–time relationship becomes u(t)=24 + 126 e^{-k t}. Evaluating at t=20 minutes gives a temperature of approximately 69.84°C.

Code

<code>import sympy as sp
sp.var('t, k')  # define symbolic variables t, k
u = sp.var('u', cls=sp.Function)  # define symbolic function
eq = sp.diff(u(t), t) + k * (u(t) - 24)  # define equation
uu = sp.dsolve(eq, ics={u(0): 150})  # solve symbolically
print(uu)

kk = sp.solve(uu, k)  # solve for k, may have multiple solutions
k0 = kk[0].subs({t: 10.0, u(t): 100.0})
print(kk, '\t', k0)
u1 = uu.args[1]  # extract symbolic expression
u0 = u1.subs({t: 20, k: k0})  # substitute specific values
print("Temperature after 20 minutes:", u0)</code>

Result: [log(126/(u(t) - 24))/t] 0.0505548566665147 Temperature after 20 minutes: 69.8412698412698

References

Si Shougui, Sun Xijing, Python Mathematics Experiments and Modeling

Pythondifferential equationsmathematical modelingNewton coolingSymPy
Model Perspective
Written by

Model Perspective

Insights, knowledge, and enjoyment from a mathematical modeling researcher and educator. Hosted by Haihua Wang, a modeling instructor and author of "Clever Use of Chat for Mathematical Modeling", "Modeling: The Mathematics of Thinking", "Mathematical Modeling Practice: A Hands‑On Guide to Competitions", and co‑author of "Mathematical Modeling: Teaching Design and Cases".

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.