The Continuity Equation
Squeeze the end of a garden hose and the water shoots out faster. Watch a river narrow between two
rock walls and the current quickens. Blow smoke through a pinched straw and it races. In every case
nothing is created and nothing is destroyed — the same mass of fluid per second has to get
through a smaller opening, so it has no choice but to speed up. That single, stubborn bookkeeping fact
— mass is conserved — is the most reliable statement in all of fluid dynamics, and
when we write it down as a differential equation for a flowing continuum it is called the
continuity equation.
This page builds that equation from scratch. We fix a little box of space, tally the mass flowing in
and out through its faces, and demand that any imbalance show up as the mass inside changing. The
divergence theorem turns that tally into a beautifully compact local law,
\partial\rho/\partial t + \nabla\cdot(\rho\mathbf{u}) = 0. We will read off
its meaning, recast it in convective form using the
material derivative,
and pin down the single most useful special case — an
incompressible flow, for which the velocity field must be
divergence-free, \nabla\cdot\mathbf{u} = 0.
Fix a box and count what crosses it
The cleanest way to enforce conservation of mass is to stop chasing the fluid and instead nail down a
region of space. Pick any fixed volume V — a
control volume — bounded by a closed surface S. Fluid pours
through this imaginary box freely; we are going to keep the books on it. Two things, and only two
things, can change the mass currently inside:
- fluid crossing the boundary S (carrying mass in or out);
- nothing else — there are no sources or sinks creating fluid from nowhere.
Reveal the figure step by step: the fixed box, the mass streaming in one face, the mass streaming out
another, and the balance that ties them to the mass stored inside.
Put that in symbols. The mass inside the box is
\int_V \rho\,dV. The mass leaving per second through a patch of surface with
outward normal \mathbf{n} is the density times the velocity component
crossing it, \rho\,\mathbf{u}\cdot\mathbf{n}, integrated over the whole
surface. Conservation of mass says the rate at which stored mass drops equals the net rate it flows
out:
\frac{d}{dt}\int_V \rho\,dV = -\oint_S \rho\,\mathbf{u}\cdot\mathbf{n}\,dS.
This is the integral (control-volume) form of the continuity equation — already
complete and exact. The quantity \rho\mathbf{u} is the mass
flux (mass per unit area per unit time); its surface integral is the net mass flow rate out
of the box.
From the box to a point: the divergence theorem
The integral form is true for every control volume, of every size and shape. That is a huge
amount of information, and we can squeeze it down to a statement at a single point. Two moves do it.
First, because V is fixed in space, the time derivative slides inside the
integral as a partial derivative:
\frac{d}{dt}\int_V \rho\,dV = \int_V \frac{\partial \rho}{\partial t}\,dV.
Second — the key step — the
divergence theorem
converts the surface flux into a volume integral of the divergence:
\oint_S \rho\,\mathbf{u}\cdot\mathbf{n}\,dS = \int_V \nabla\cdot(\rho\mathbf{u})\,dV.
Substitute both into the balance and gather everything under one integral:
\int_V \left[\frac{\partial \rho}{\partial t} + \nabla\cdot(\rho\mathbf{u})\right]dV = 0.
Here is the punchline. This holds for any region V whatsoever. If a
continuous integrand integrated to zero over every possible box, it must be zero everywhere —
otherwise draw a tiny box around a point where it isn't zero and the integral there wouldn't vanish. So
the bracket itself must be identically zero, and we arrive at the differential form:
-
Conservative (divergence) form. For any fluid, compressible or not, mass
conservation is
\frac{\partial \rho}{\partial t} + \nabla\cdot(\rho\mathbf{u}) = 0.
-
What each term says. \partial\rho/\partial t is the
local build-up of density at a fixed point; \nabla\cdot(\rho\mathbf{u})
is the net mass flux flowing out of that point per unit volume. If more mass leaves than
arrives, the local density must fall — and vice versa.
-
Steady flow. If nothing changes in time,
\partial\rho/\partial t = 0, so
\nabla\cdot(\rho\mathbf{u}) = 0: the mass flux is divergence-free even
though the density itself may vary through space.
The convective form, and what divergence means
There is a second, equally useful way to write the same law. Expand the divergence of the product
\rho\mathbf{u} with the product rule,
\nabla\cdot(\rho\mathbf{u}) = \mathbf{u}\cdot\nabla\rho + \rho\,\nabla\cdot\mathbf{u},
and drop it into the continuity equation:
\frac{\partial \rho}{\partial t} + \mathbf{u}\cdot\nabla\rho + \rho\,\nabla\cdot\mathbf{u} = 0.
The first two terms are exactly the material derivative of the density —
D\rho/Dt = \partial\rho/\partial t + \mathbf{u}\cdot\nabla\rho, the rate of
change of density following a parcel. So the law collapses to the compact convective form:
\frac{D\rho}{Dt} + \rho\,\nabla\cdot\mathbf{u} = 0.
This version wears its physical meaning on its sleeve. Rearrange it to
\nabla\cdot\mathbf{u} = -\dfrac{1}{\rho}\dfrac{D\rho}{Dt}. Now recall that a
parcel of fixed mass m = \rho\,\delta V has
D\rho/Dt = -(m/\delta V^2)\,D(\delta V)/Dt, so a short calculation gives
\nabla\cdot\mathbf{u} = \frac{1}{\delta V}\frac{D(\delta V)}{Dt}.
In words: the divergence of the velocity is the fractional rate at which a fluid parcel's
volume is expanding. Positive divergence means the parcel is swelling (its density falling);
negative divergence means it is being squeezed. That is the concrete meaning of
\nabla\cdot\mathbf{u} you should carry everywhere — it is a
local volumetric expansion rate, not an abstract piece of notation.
The incompressible special case: a divergence-free field
Liquids, and gases moving well below the speed of sound, barely change their density at all — a parcel
of water keeps essentially the same volume no matter how you push it. Such a flow is called
incompressible, meaning each parcel's density is constant along its path:
D\rho/Dt = 0. Feed that straight into the convective form
D\rho/Dt + \rho\,\nabla\cdot\mathbf{u} = 0, and since
\rho \neq 0 the second term must vanish on its own:
-
The condition. An incompressible flow has a
divergence-free velocity field:
\nabla\cdot\mathbf{u} = \frac{\partial u}{\partial x} + \frac{\partial v}{\partial y} + \frac{\partial w}{\partial z} = 0.
-
Why. No parcel changes volume (D(\delta V)/Dt = 0), and
since \nabla\cdot\mathbf{u} is the fractional rate of volume
change, it must be zero everywhere.
-
What it does not require. The density need not be the same everywhere — think of
warm and cold layers of the ocean. It only requires that each parcel keeps its own
density as it drifts.
This is one of the most-used equations in engineering. It is a single scalar constraint that the three
velocity components must satisfy together, and it is what makes the flow of water, blood and slow air
tractable: whatever else the velocity field does, its divergence has to cancel to zero at every point.
Worked examples
Example 1 — is this field incompressible? A two-dimensional flow is
\mathbf{u} = (3x + 2y,\ -3y + 5x). Compute its divergence:
\nabla\cdot\mathbf{u} = \frac{\partial u}{\partial x} + \frac{\partial v}{\partial y} = 3 + (-3) = 0.
The divergence is zero, so this field is incompressible — even though it stretches fluid in one
direction, it squeezes it by exactly as much in the other, conserving each parcel's volume. Notice the
cross terms (2y and 5x) never entered: only
\partial u/\partial x and \partial v/\partial y
matter for the divergence.
Example 2 — completing an incompressible field. A flow has
u = 4x in the x-direction. What
y-component v makes it incompressible (in 2-D)? We
need \partial u/\partial x + \partial v/\partial y = 0, and
\partial u/\partial x = 4, so we need
\partial v/\partial y = -4. The simplest choice is
v = -4y \quad\Longrightarrow\quad \nabla\cdot\mathbf{u} = 4 + (-4) = 0. \checkmark
Example 3 — a pipe that narrows (the hose). Water (incompressible) flows steadily
through a pipe whose area shrinks from A_1 = 0.02\ \text{m}^2 to
A_2 = 0.005\ \text{m}^2. The integral form over the pipe reduces to
A_1 v_1 = A_2 v_2 (equal volume flow rate in and out). If
v_1 = 1.5\ \text{m/s}, then
v_2 = \frac{A_1 v_1}{A_2} = \frac{(0.02)(1.5)}{0.005} = 6\ \text{m/s}.
Quarter the area, quadruple the speed. This is the hose-nozzle rule, and it is nothing but continuity
applied to a control volume wrapping the pipe.
Example 4 — a compressible nozzle. Now let the fluid be a gas whose density changes.
Steady continuity through a duct reads \rho_1 A_1 v_1 = \rho_2 A_2 v_2 (equal
mass flow rate). If air enters at
\rho_1 = 1.2\ \text{kg/m}^3,\ A_1 = 0.10\ \text{m}^2,\ v_1 = 40\ \text{m/s}
and leaves a section where \rho_2 = 0.80\ \text{kg/m}^3,\ A_2 = 0.10\ \text{m}^2,
then
v_2 = \frac{\rho_1 A_1 v_1}{\rho_2 A_2} = \frac{(1.2)(0.10)(40)}{(0.80)(0.10)} = 60\ \text{m/s}.
Because the gas thinned out, it must speed up even though the area stayed the same — the mass flux
\rho v is what is conserved, not the speed.
No — and this is the classic trap. Incompressible means each fluid parcel
keeps its own density as it moves, D\rho/Dt = 0; it does not
mean the density is uniform in space (\nabla\rho = 0). The ocean is very
nearly incompressible, yet warm surface water is genuinely less dense than the cold deep — the density
varies from place to place. What is forbidden is a parcel changing its density as it drifts
along.
The velocity-side statement is the clean one to lean on: incompressible is exactly
\nabla\cdot\mathbf{u} = 0, a divergence-free velocity field. That follows
from D\rho/Dt = 0 in the convective continuity equation, and it holds whether
or not the density happens to be uniform. Only in the further, stronger case of a constant-density
fluid do the two ideas coincide.
The continuity equation is the template for every conservation law in physics: a
stored quantity plus the divergence of its flux equals a source,
\partial_t(\text{stuff}) + \nabla\cdot(\text{flux}) = \text{source}. For heat
you can add a source (a flame, a resistor); for electric charge in a reacting plasma you might too. But
mass has no sources in ordinary fluid mechanics — you cannot create or annihilate
matter by stirring water — so the right-hand side is exactly zero. That single "0" is a deep statement:
it is the fluid-dynamical face of the conservation of mass, the same principle Lavoisier weighed out in
the 1770s. (Push to relativistic or nuclear regimes and mass-energy can convert, and even this
equation grows a term — but for a garden hose, zero it is.)