Delta Banner

Mathematics & Science Learning Center
Computer Laboratory


Applications of Differential Equations

Compartmental Analysis

A Theoretical Introduction

Many real world problems can be thought of as the analysis of a single "compartment" into which some substance is flowing at a certain rate and out of which the same substance is flowing at some, probably different, rate. Examples of such situations that come to mind are:

  • Chemical Mixtures: In this scenario a chemical holding tank has both an inflow pipe and an outflow pipe. A fluid containing a certain concentration of the substance flows into the tank through the inflow pipe and is immediately mixed with the fluid already contained in the tank. An outflow pipe carries this mixture back out of the tank. The inflow and outflow rates are not necessarily the same, and the initial concentration of the fluid in the tank is usually different from that of the fluid flowing into it. (Otherwise the problem is incredibly boring!)

  • Pollution: In a typical example in this category one might analyze the amount of some pollutant contained in a lake. Water, possibly fresh, or maybe containing more of the pollutant flows into the lake through runoff from the surrounding land, and also from incoming streams. Water also flows out of the lake, probably by a river or stream flowing to the ocean. A moment's reflection should confirm for you that this situation is simply a variation on the theme of the chemical mixture problems mentioned above.

  • Gaseous Exchange: In a typical example here a room, or maybe a whole building, contains air which has been tainted with some foreign gas such as carbon dioxide, carbon monoxide, or radon. Ventilation is initiated through either ducts or maybe simply windows and doors, and the air in the "compartment" is purged, perhaps through the cold-air return of the venting system, (not such a great idea!) or more likely through other windows or doors.

    The reverse of the above scenario, with the incoming air being tainted instead would also fit into the same class of problems. Once again, it is easy to see that this situation is a variation on the theme of the chemical mixture problems mentioned in our first example.

Our analysis of all of these example types begins with the same basic assumption:

rate of change of the amount of substance in the compartment = input rate - output rate

If we let y represent the amount of the substance present in the tank at time t, then this assumption immediately becomes:

dy/dt = input rate - output rate

The question then becomes one of determining the two rates on the right-hand side of the above equation. The method for doing this may be different from one example to another, and is best illustrated by doing a specific example to highlight the thinking involved.


A large tank initially holds 400 gallons of water into which 1600 pounds of a certain salt has been dissolved. An inflow pipe brings in water containing 2 pounds of the same salt per gallon at a rate of 5 gallons per minute. An outflow pipe allows the fully mixed fluid in the tank to exit at the same rate of 5 gallons per minute. Find the initial value problem that models the amount of the salt, y, in the tank at time t.

First let us note that the initial condition is obvious. We are told that there are initially 1600 pounds of salt in the tank, so y(0) = 1600.

Now we address the input rate mentioned in the model. This is also fairly easy to determine. We wish to determine the rate at which the amount of salt is entering the tank with respect to time, or to put it in terms of units, how many pounds of salt per minute are entering the tank. Well, the fluid is entering at 5 gallons per minute, and each gallon is carrying 2 pounds of salt. This quickly leads to the conclusion that salt is entering at 10 pounds per minute. (A unit analysis of the inflow also supports this conclusion.)

Finally we need to determine the rate at which salt is leaving the tank. This is the trickiest of the components to determine, since the concentration of the salt in the outflow is always changing. However, we do have a variable which keeps track of the amount of salt in the tank at any time, namely y pounds. But how much of that amount goes out of the tank each minute in the outflow? Well, since the flow rates of the volume of fluid coming into the tank and the volume leaving the tank are the same, namely 5 gallons per minute, it is pretty clear that the total fluid volume in the tank will never change. It will always remain the same—the initial 400 gallons. So the concentration of the salt in the tank at any particular time, t, is the total amount of salt in the tank, y pounds, divided by the total volume of the fluid, 400 gallons. i.e. the concentration is y/400 pounds per gallon. And this is the concentration that will be flowing out of the outflow pipe. So the outgoing liquid flows at 5 gallons per minute, carrying y/400 pounds of salt per gallon. We conclude that the product of these quantities is the rate at which the salt is leaving the tank, i.e. the output rate is 5y/400 pounds per minute, or, reducing, y/80 pounds per minute.

Summarizing, we have just found:

input rate = 10
output rate = y/80

In conclusion, then, the initial value problem which models this example is:

dy/dt = 10 - y/80

y(0) = 1600

This particular initial value problem quickly succumbs to the methods you have been learning in the lecture part of this course. After all, the differential equation is separable. However, since we're using Mathematica, we'll have it do the heavy lifting for us, and also take advantage of some of its other abilities to explore the nature of our example further.

Mathematica Icon Go ahead and switch to a new Mathematica notebook by clicking on the button at left. Come back here immediately, and we'll discuss what you should enter into your new notebook.

OK, let's move on...
Compass If you're lost, impatient, want an overview of this laboratory assignment, or maybe even all three, you can click on the compass button on the left to go to the table of contents for this laboratory assignment.

ODE Laboratories: A Sabbatical Project by Christopher A. Barker

©2017 San Joaquin Delta College, 5151 Pacific Ave., Stockton, CA 95207, USA