Skip to content
Tutorials Center
My learning

Topics

Lesson 8 of 46 ยท The Modelling Cycle

Building the Model: Balance Laws and Rate Rules

Build equations the professional way: write a balance law for a stock, add a rate rule for each flow, check the units, and derive Newton's cooling law.

You have a sharp question and a list of assumptions. Now comes the step people imagine when they hear "mathematical modelling": writing equations. The good news is that most dynamic models are built from the same two ingredients, and once you know them you can build models of cooling coffee, filling bathtubs, bank accounts, medicine in the blood and many other things with the same recipe.

What you will learn

  • The balance law: rate of change of a stock = inflows โˆ’ outflows
  • How a rate rule turns a flow into a formula
  • How to derive Newton's cooling law and estimate its parameter from physics
  • How to check units and the equilibrium of a freshly built model

Key terms

Stock: a quantity that accumulates, such as water in a tub, money in an account or heat stored in coffee.

Flow: a rate at which a stock is filled or drained, measured in stock per time.

Balance law: change of a stock = what comes in โˆ’ what goes out.

Rate rule (constitutive relation): a formula saying how a flow depends on the state, such as "outflow is proportional to the amount".

Equilibrium: a state where inflows and outflows cancel and the stock stops changing.

The balance law

Many quantities obey a simple accounting identity. If something is conserved (it cannot appear or vanish except by crossing the boundary), then over a short time ฮ”t:

stock(t + ฮ”t) = stock(t) + (inflow โˆ’ outflow) ยท ฮ”t

Rearrange and let ฮ”t become tiny, and you get the differential equation

d(stock)/dt = inflow โˆ’ outflow

This is the most reused sentence in applied mathematics. Water, money, people, heat, a drug in the blood, charge in a capacitor: all follow it. The art of modelling is deciding what the stock is and what flows cross its boundary.

A bathtub with a tap and a drain, labeled with the stock V of t, an inflow of 5 liters per minute and an outflow of 0.1 times V
Stock and flow: a bathtub is the standard picture of a balance law.

Rate rules: giving each flow a formula

The balance law is true by definition. The model comes from the rate rules, the assumptions about each flow. Take a bathtub whose tap delivers 5 liters per minute and whose drain lets out 10% of the current volume per minute:

  • inflow = 5 L/min (constant, from the tap)
  • outflow = 0.1 ยท V (more water means more pressure, so faster draining)

Insert them in the balance law:

dV/dt = 5 โˆ’ 0.1 V

Two checks, even before solving:

  1. Units. dV/dt is L/min. 5 is L/min โœ“. 0.1 V is (1/min) ร— L = L/min โœ“. If one term had been in L, the equation would be wrong.
  2. Equilibrium. Set dV/dt = 0: 5 = 0.1 V, so V* = 50 L. The tub settles at 50 liters whatever its starting amount. That is plausible, so the model passes.

The solution, starting from an empty tub, is V(t) = 50 (1 โˆ’ e^(โˆ’0.1 t)). It rises quickly at first and then flattens out, because the drain keeps up better as the tub fills.

Python The bathtub model: three ways to see it

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Case study: deriving Newton's cooling law

Back to the coffee. What is the stock? The heat energy stored in the coffee. A simple link between stock and temperature: stored heat Q = m c T, where m is the mass and c the specific heat capacity (about 4,186 J/(kgยทK) for water-like liquids). So a balance law for heat is a balance law for temperature:

m c ยท dT/dt = โˆ’ (heat loss rate)

Rate rule. Experiments by Isaac Newton led to the model that heat flows out at a rate proportional to the temperature difference between the object and its surroundings. Writing the proportionality as h A (heat transfer coefficient times exposed surface area):

heat loss rate = h A (T โˆ’ T_env)

Combine them:

dT/dt = โˆ’ (h A / (m c)) ยท (T โˆ’ T_env) = โˆ’ k (T โˆ’ T_env)

with k = h A / (m c). This is Newton's law of cooling. Check units: h A is W/K, m c is J/K, so k has units (W/K)/(J/K) = 1/s โœ“. The equilibrium is T = T_env, which is exactly what a coffee does. The pieces fit.

Can we estimate k from physics?

Yes, roughly, and it is a great sanity check. Take m = 0.25 kg, c = 4186 J/(kgยทK), surface area about A = 0.04 mยฒ and a heat transfer coefficient of order h = 10 W/(mยฒยทK) for still air.

Python Estimating the cooling rate k from physical quantities

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The range of answers (roughly 10 to 50 minutes) is wide, and that is a lesson in itself: a physical estimate gives the right order of magnitude but is very sensitive to h, which depends on air movement and evaporation. A cooling rate of 0.06 per minute needs an effective h near 25 W/(mยฒยทK), which is plausible once evaporation and an open surface are included, but the estimate alone cannot tell you that. In practice you measure k with a stopwatch and a thermometer. That is why the earlier lessons used k = 0.06 per min as an illustrative value rather than a derived one. Fitting parameters to data returns in Chapter 8.

Try it

Experiment with the bathtub. Predict the equilibrium level first, using only inflow / c, then check with the sliders.

Bathtub equilibrium explorer

The "95%" time uses the exact solution: V reaches 95% of equilibrium when e^(โˆ’c t) = 0.05, so t = ln(20)/c. Notice that it depends only on c, not on the inflow. The drain sets how fast the tub settles; the tap sets where.

Common misconceptions

"The equation comes from the data." The structure (balance law and rate rule) comes from understanding. Data later fixes the numbers in it.

"If the units match, the model is right." Matching units is necessary, not sufficient. A wrong rate rule can still have perfect units.

"The stock must be a physical thing." Money, population and information are stocks too. If it accumulates and flows, the same law applies.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. What is the balance law for a stock S?

    The stock changes by what comes in minus what goes out.
  2. 2. For dV/dt = 5 - 0.1 V (V in liters, t in minutes), what is the equilibrium volume?

    At equilibrium dV/dt = 0, so 5 = 0.1 V and V = 50 L.
  3. 3. In Newton's cooling law dT/dt = -k (T - T_env), what are the units of k?

    dT/dt has units of temperature per time and (T - T_env) has units of temperature, so k must be 1 per time.
  4. 4. The heat-loss rule says loss is proportional to T - T_env. What does it imply about cooling speed?

    The loss rate scales with the temperature difference, so it is largest at the start and shrinks as the object cools.
  5. 5. In the bathtub model, which parameter controls how fast the tub settles toward equilibrium?

    The settling time is of order ln(20)/c, independent of inflow and starting volume.

Summary

  • Most dynamic models combine a balance law (d(stock)/dt = in โˆ’ out) with rate rules for each flow.
  • Check units and equilibrium of a new equation before solving it.
  • Newton's cooling law dT/dt = โˆ’k (T โˆ’ T_env) follows from heat balance and a loss rate proportional to the temperature difference, with k = hA/(mc).
  • Physical estimates give orders of magnitude; measured data fixes parameters precisely.

Next: Solving, Interpreting and Iterating