01 / 21

Compartment
Models

Learn how to model flow between interconnected systems using differential equations: from drug dosing to population dynamics.

Differential Equations

What Is a Compartment?

A compartment is an idealized container that holds a well-mixed quantity: a substance, population, or energy level. We track how that quantity changes over time by writing a rate equation for each compartment.

Input
Material enters from an external source or another compartment.
Storage
The compartment holds a current amount \( x(t) \) at time \( t \).
Output
Material leaves the compartment via decay, transfer, or elimination.

The Balance Law

Rate in
\( x(t) \)
amount at time \( t \)
Rate out
\( \frac{dx}{dt} = \text{Rate in} - \text{Rate out} \)

Where Do We See Compartment Models?

Pharmacokinetics
Drug concentration in blood, tissue, and organs after a dose.
Epidemiology
SIR models: susceptible, infected, recovered populations.
Ecology
Nutrient cycling through soil, water, and atmosphere.

The Single-Compartment ODE

The simplest model: a substance enters at a constant rate \( a \) and leaves proportionally to the current amount at rate constant \( k \).

Solving the Single-Compartment ODE

1
Rewrite as linear first-order: \( \frac{dx}{dt} + kx = a \).
2
Integrating factor: \( \mu(t) = e^{kt} \). Multiply both sides.
3
Integrate: \( \frac{d}{dt}\bigl[e^{kt}x\bigr] = ae^{kt} \). Integrating gives \( e^{kt}x = \frac{a}{k}e^{kt} + C \).
4
Apply IC: \( x(0) = x_0 \) yields \( C = x_0 - \frac{a}{k} \).

Visualizing the Solution Curve

\( t \)
\( x \)
\( \frac{a}{k} \)
\( x_0 \)
\( x_0' \)
\( x_0 < a/k \) (rises)
\( x_0 > a/k \) (falls)

Special Case: Pure Decay

When there is no input (\( a = 0 \)), the model reduces to pure exponential decay:

Radioactive Decay
\( k \) is the decay constant; \( t_{1/2} \) is the half-life.
Drug Clearance
After IV injection with no additional dosing: pure first-order elimination.

Open vs Closed Systems

Open System Closed System
External input Yes: material enters/exits environment No: material stays within compartments
Total mass Changes over time Conserved: \( x_1 + x_2 + \cdots = \text{const} \)
Steady state \( x_{\text{ss}} = a/k \) (nonzero equilibrium) All material eventually collects in one compartment
Example IV drip medication Dye mixing between two connected tanks

The Two-Compartment Model

\( a \)
\( x_1(t) \)
Compartment 1
\( k_{12} \)
\( k_{21} \)
\( x_2(t) \)
Compartment 2
\( k_{10} \)
Elimination

How to Build a Compartment Model

1
Identify compartments: What distinct "pools" hold the quantity of interest?
2
Draw arrows: For every transfer, draw a directed arrow and label it with a rate or rate constant.
3
Write the balance law for each compartment: \( \frac{dx_i}{dt} = \sum \text{(inflows)} - \sum \text{(outflows)} \).
4
Specify initial conditions: What is \( x_i(0) \) for every compartment?
5
Solve or simulate: Use analytical methods (integrating factor, eigenvalues) or numerical methods (Euler, RK4).

Example 1: IV Drug Infusion

A patient receives a drug via IV at a constant rate of \( a = 5 \, \text{mg/hr} \). The drug is eliminated at rate \( k = 0.1 \, \text{hr}^{-1} \). Initially the bloodstream has no drug: \( x(0) = 0 \).

Example 1: Solution Curve

\( t \) (hr)
\( x \) (mg)
0
10
20
30
40
50
0
25
50
50
\( x(t) = 50(1 - e^{-0.1t}) \)

Example 2: Mixing Tank

A \( 100 \, \text{L} \) tank initially contains pure water. Brine with concentration \( 3 \, \text{g/L} \) flows in at \( 2 \, \text{L/min} \). The well-stirred mixture flows out at \( 2 \, \text{L/min} \). Let \( x(t) \) = grams of salt at time \( t \).

Example 3: Two Connected Tanks

Tank A (\( 50 \, \text{L} \)) and Tank B (\( 50 \, \text{L} \)) are connected. Fluid flows from A to B at \( 4 \, \text{L/min} \) and from B to A at \( 4 \, \text{L/min} \). Tank A starts with \( 10 \, \text{g} \) of salt, Tank B with \( 0 \, \text{g} \). No external inflow/outflow.

Common Mistakes

✕ Wrong Sign
Outflows must be subtracted. Writing \( +kx \) instead of \( -kx \) gives exponential growth, not decay.
✕ Rate vs Amount
The output rate is \( \frac{x}{V} \cdot r \), not just \( r \). Don't forget to divide by volume to get concentration.
✕ Changing Volume
If inflow rate \( \neq \) outflow rate, the volume changes with time. The denominator becomes \( V(t) \), not a constant.

Question 1 of 5

A single compartment has constant input rate \( a = 12 \) and elimination rate constant \( k = 3 \). What is the steady-state value \( x_{\text{ss}} \)?

Question 2 of 5

In the ODE \( \frac{dx}{dt} = a - kx \) with \( x(0) = 0 \), which expression gives \( x(t) \)?

Question 3 of 5

A \( 200 \, \text{L} \) tank has brine flowing in at \( 5 \, \text{L/min} \) with concentration \( 2 \, \text{g/L} \) and outflow at \( 5 \, \text{L/min} \). What is the rate out of salt (\( \text{g/min} \)) when there are \( x \) grams of salt in the tank?

Question 4 of 5

In a closed two-compartment system with \( x_1(0) = 20 \) and \( x_2(0) = 0 \), what must be true for all \( t \geq 0 \)?

Question 5 of 5

A substance decays with rate constant \( k = 0.2 \, \text{hr}^{-1} \) and no input. Approximately how long until the amount drops to half its initial value?