SECTION 1
Historical Context & Motivation
For centuries, scientists and engineers have needed to understand how substances move through connected systems. Whether it's salt dissolving in a series of water tanks, medicine distributing through the human body, or pollutants cycling through lakes and rivers, the core question is always the same: how much of a substance is in each part of the system at any given time? Compartment models were developed precisely to answer this question by treating each part of a system as a separate "compartment" and tracking the flow of material between them using differential equations.
1700s • Early Mixing Problems
1920s • Pharmacokinetics Emerges
1927 • SIR Epidemic Model
1960s–Today • Environmental & Engineering Applications
The central challenge that compartment models address is this: when you have multiple interconnected containers and material is constantly flowing in and out, how do you predict the amount in each container over time? A single differential equation can describe one tank, but the moment you connect tanks together, you need a system of differential equations — and that's exactly what this lesson is about.
SECTION 2
Core Principles & Definitions
Before diving into the math, you need to understand the building blocks of every compartment model. The basic idea is surprisingly simple: divide your system into boxes, track what goes in and what goes out of each box, and write a rate equation for each one. These rate equations form a system that you can solve to find how each compartment changes over time.
Compartment
Flow Rate
Concentration
Balance Law
System Coupling
KEY TAKEAWAY
SECTION 3
Visual Explanation
A Two-Tank Mixing System
The diagram below shows the classic two-compartment mixing problem. An external source pumps a salt solution into Tank 1, and fluid flows between the two tanks and out of the system. Each arrow is labeled with its flow rate, and the concentration of the outflow depends on the current amount of salt divided by the volume in that tank.
Notice how the equation for Tank 1 includes a term involving x₂ (the amount in Tank 2), and the equation for Tank 2 includes a term involving x₁. This is the coupling that makes this a system rather than two independent equations. You must solve both equations together because the rate of change in each tank depends on what's happening in the other.
SECTION 4
Mathematical Framework
Let's formalize the mathematics behind compartment models. The key step is translating the physical setup — tanks, pipes, flow rates — into a precise system of differential equations. We'll start with the general balance law and then see how it applies to a standard two-tank problem.
GENERAL BALANCE LAW
Here x is the amount of substance in the compartment (grams, moles, people, etc.) and t is time. 'Rate In' includes every source — both external inputs and transfers from other compartments. 'Rate Out' includes every drain.
OUTFLOW RATE FROM A WELL-MIXED TANK
f = volumetric flow rate (L/min), x = amount of substance in the tank (grams), V = volume of fluid in the tank (liters). The ratio x/V is the concentration of the substance leaving the tank.
TWO-TANK SYSTEM
x₁(t) and x₂(t) = grams of salt in Tank 1 and Tank 2. f₁₂ = flow from Tank 1 to Tank 2, f₂₁ = flow from Tank 2 to Tank 1, c₀ = concentration of the external inflow.
MATRIX FORM
The system can be written in matrix form where A is a 2×2 coefficient matrix containing the flow-rate-over-volume terms. This matrix notation becomes especially powerful for systems with three or more compartments, and it connects compartment models to linear algebra.
The key insight is that each equation has a negative term proportional to its own variable (substance leaving that tank) and a positive term proportional to the other tank's variable (substance arriving from the other tank). This cross-dependency is what couples the equations together and makes the system interesting to solve.
SECTION 5
Types of Compartment Models
Compartment models come in several varieties depending on the structure of the system and the nature of the flows. Understanding these types helps you recognize which model to use for a given real-world problem.
In a series model, substance flows in one direction — like food moving through stages of digestion. A parallel model has compartments that receive input from the same source but don't interact with each other. The closed-loop model is the most fully coupled: substance circulates back and forth, as in the two-tank mixing problem we saw earlier. Finally, the SIR model tracks people rather than chemicals, modeling how individuals transition from susceptible to infected to recovered — the flow rate depends nonlinearly on the product of S and I.
Open vs. Closed Systems
SECTION 6
Worked Example: Two-Tank Salt Problem
Let's work through a classic problem step by step. Tank 1 holds 100 liters of pure water and Tank 2 holds 100 liters of pure water. A brine solution with a concentration of 2 g/L flows into Tank 1 at 5 L/min. Fluid flows from Tank 1 to Tank 2 at 5 L/min, and fluid flows from Tank 2 out of the system at 5 L/min. The volumes stay constant since every inflow rate equals every outflow rate. Find the system of differential equations and the amount of salt in each tank as t → ∞.
Prerequisite: Integrating Factor Method
Two-Tank Mixing Problem
- 1
Step 1 — Identify the Variables and Given Values
Let x₁(t) = grams of salt in Tank 1 at time t, and x₂(t) = grams of salt in Tank 2 at time t. Given: V₁ = V₂ = 100 L, inflow rate f₀ = 5 L/min with concentration c₀ = 2 g/L, flow from Tank 1 to Tank 2: f₁₂ = 5 L/min, outflow from Tank 2: f_out = 5 L/min. Initial conditions: x₁(0) = 0, x₂(0) = 0.Two unknowns: x₁(t) and x₂(t), both starting at 0. - 2
Step 2 — Write the Balance Equation for Tank 1
Rate in: the external inflow brings salt at a rate of f₀ × c₀ = 5 × 2 = 10 g/min. Rate out: fluid leaves Tank 1 at 5 L/min carrying concentration x₁/100, so the outflow rate is 5 × (x₁/100) = x₁/20 g/min.dx₁/dt = 10 − x₁/20 - 3
Step 3 — Write the Balance Equation for Tank 2
Rate in: fluid arrives from Tank 1 at 5 L/min with concentration x₁/100, giving an inflow rate of 5 × (x₁/100) = x₁/20 g/min. Rate out: fluid leaves Tank 2 at 5 L/min with concentration x₂/100, giving an outflow rate of 5 × (x₂/100) = x₂/20 g/min.dx₂/dt = x₁/20 − x₂/20 - 4
Step 4 — Write the System
Combining the two equations, we have a system of first-order linear ODEs: dx₁/dt = 10 − x₁/20 and dx₂/dt = x₁/20 − x₂/20. Notice that the first equation depends only on x₁ (this is because there's no flow from Tank 2 back to Tank 1), so we can solve it independently and then substitute into the second equation.This is a series (cascade) compartment model — the first equation decouples. - 5
Step 5 — Solve the First Equation
Rewrite dx₁/dt = 10 − x₁/20 in standard linear form: dx₁/dt + x₁/20 = 10. Here P = 1/20, so the integrating factor is μ = e^(∫(1/20)dt) = . Multiply both sides by : ·dx₁/dt + (1/20)·x₁ = . The left side is the derivative of the product ·x₁, so: d/dt[·x₁] = . Integrate both sides: ·x₁ = + C. Divide by : x₁ = 200 + . Apply x₁(0) = 0: 0 = 200 + C, so C = −200.x₁(t) = 200(1 − ) - 6
Step 6 — Solve the Second Equation
Substitute x₁(t) into dx₂/dt + x₂/20 = x₁/20 = (200/20)(1 − ) = 10(1 − ). The integrating factor is again . Multiply both sides: d/dt[·x₂] = (1 − ) = − 10. Integrate both sides: ·x₂ = − 10t + C. Divide by : x₂ = 200 − 10t· + . Apply x₂(0) = 0: 0 = 200 + C, so C = −200. Therefore x₂(t) = 200 − − 10t·, which can be written as x₂(t) = 200 − (200 + 10t). As t → ∞, both → 0 and t· → 0, so x₂ → 200.x₂(t) = 200 − (200 + 10t) - 7
Step 7 — Find the Long-Term (Steady-State) Values
As t → ∞, → 0 and t· → 0. Therefore x₁ → 200 g and x₂ → 200 g. This makes sense: at steady state, each tank has concentration 200/100 = 2 g/L, matching the incoming brine concentration. No further change occurs because the inflow and outflow concentrations are equal.Steady state: x₁ = x₂ = 200 g (concentration = 2 g/L in each tank)
SECTION 7
Strengths & Limitations
Compartment models are one of the most widely used tools in applied mathematics, but they have both powerful advantages and important limitations. Understanding these will help you decide when a compartment model is the right tool — and when you might need something more sophisticated.
| Aspect | Strengths | Limitations |
|---|---|---|
| Simplicity | Easy to set up: just apply the balance law to each compartment. The physical intuition is very clear — you can draw the system as boxes and arrows. | Oversimplifies reality: real systems (oceans, human bodies) aren't perfectly mixed. Spatial variation within a compartment is ignored. |
| Scalability | Adding more compartments is straightforward: just add another equation to the system. Works for 2 tanks or 200 tanks. | Large systems become hard to solve by hand. Computer methods (numerical ODE solvers) are needed for more than 3–4 compartments. |
| Versatility | Applicable across fields: chemistry, biology, medicine, ecology, epidemiology, economics, and engineering. | Not suitable for problems where diffusion, spatial gradients, or wave-like behavior matter — those require partial differential equations. |
| Constant volumes | When inflow rate equals outflow rate, tank volumes remain constant, keeping the equations linear and solvable. | If volumes change over time (e.g., a tank filling up), the equations become nonlinear and much harder to solve analytically. |
Strengths vs. Limitations of Compartment Models
KEY TAKEAWAY
SECTION 8
Connection to Advanced Theory
Compartment models sit at the crossroads of several advanced mathematical topics. If you continue studying math and science in college, you'll see these ideas expanded in exciting ways. Here's a preview of how compartment models connect to the bigger picture.
| Compartment Models (This Lesson) | Advanced Extension |
|---|---|
| Two or three tanks with constant flow rates → linear system of ODEs | Eigenvalue methods: the matrix A from the system x' = Ax + b has eigenvalues that determine how fast the system approaches steady state. |
| Well-mixed assumption: concentration is uniform within each compartment | Partial differential equations (PDEs): when mixing isn't perfect, you need PDEs that track concentration as a function of both position and time. |
| SIR model with constant infection/recovery rates | Nonlinear dynamics and chaos: real epidemic models (SEIR, SIS) have variable rates and can exhibit complex behaviors like periodic outbreaks. |
| Exact analytical solutions for small systems | Numerical methods: Euler's method, Runge-Kutta, and other algorithms approximate solutions for large or nonlinear systems on computers. |
From Compartment Models to Advanced Mathematics
The beauty of compartment models is that they give you a concrete, visual entry point into systems of differential equations. The skills you're building now — setting up balance laws, recognizing coupling between equations, and interpreting steady-state behavior — are exactly the skills you'll use in college-level courses on linear algebra, dynamical systems, and mathematical modeling. If you master the two-tank problem today, you're well on your way to modeling everything from ocean currents to financial markets.
SECTION 9
Practice Problems
Question 1: CONCEPTUAL
Show answer
Question 2: BASIC CALCULATION
Show answer
Question 3: INTERMEDIATE
Show answer
Question 4: APPLIED
Show answer
Question 5: CRITICAL THINKING
Show answer
SUMMARY
Summary
Summary
Compartment models divide a system into well-mixed regions and use the balance law (Rate of change = Rate in − Rate out) to write a differential equation for each region. When compartments are connected by flows, their equations become coupled, forming a system of differential equations that must be solved together. The outflow rate from each compartment depends on the concentration (amount divided by volume) in that compartment, which changes over time.
Common types include series (cascade) models with one-way flow, closed-loop models with recirculation, and the SIR epidemic model for disease spread. At steady state, all derivatives equal zero and the system reaches equilibrium. The skills you've built here — setting up balance laws, recognizing coupling, and interpreting long-term behavior — form the foundation for advanced work in linear algebra, dynamical systems, and mathematical modeling.