Fluid Dynamics
Continuity Equation
∂ρ/∂t + ∇·(ρu) = 0 — what flows in must flow out (or accumulate)
The continuity equation states that mass is conserved in a fluid: ∂ρ/∂t + ∇·(ρu) = 0, where ρ is density and u velocity. The first term is local accumulation rate; the second is net outflow per unit volume. For an incompressible fluid (ρ constant), it reduces to ∇·u = 0 — velocity field is divergence-free. Integrating over a volume gives the integral form: dm/dt + ∮ ρu·dA = 0 — change in mass equals minus net outflow through surface (Gauss's theorem). The same equation form appears in many fields: charge conservation in electromagnetism (∂ρ_q/∂t + ∇·J = 0), probability conservation in quantum mechanics (∂|ψ|²/∂t + ∇·j_prob = 0), and heat continuity. Foundation of CFD codes, hydraulics (Q = Av incompressible: pipe flow), and meteorology.
- Differential∂ρ/∂t + ∇·(ρu) = 0
- Incompressible∇·u = 0
- Integraldm/dt + ∮ρu·dA = 0
- Pipe flowA₁v₁ = A₂v₂
- EM analog∂ρ_q/∂t + ∇·J = 0
- QM analogProbability current
Interactive visualization
Press play, or step through manually. The visualization is yours to drive — try it before reading on.
Watch the 60-second explainer
A condensed visual walkthrough — narrated, captioned, under a minute.
Why continuity matters
- Computational fluid dynamics. Every CFD code enforces continuity at every cell, every timestep. Compressible solvers track ρ as an independent variable; incompressible solvers project velocity onto the divergence-free subspace via a pressure Poisson equation.
- Hydraulics. Pipe networks, water-supply systems, and HVAC ducts all rely on Q = Av for steady incompressible flow. Sizing pipes for required flow rate, balancing manifolds, and analyzing leaks all start from continuity.
- Weather forecasting. Atmospheric general circulation models couple a compressible continuity equation for air mass to thermodynamic, momentum, and water-vapor equations. Mass conservation pins the surface pressure tendency to vertically integrated divergence — a key diagnostic in synoptic meteorology.
- Electromagnetism. Charge continuity is built into Maxwell's equations through the displacement current; without it, current loops would not close around capacitors, and electromagnetic waves would not exist.
- Quantum mechanics. Probability current j_prob = (ℏ/2mi)(ψ*∇ψ − ψ∇ψ*) makes |ψ|² behave like a conserved fluid density, foundational to scattering theory and quantum transport.
- Heat and species transport. Continuity for thermal energy and chemical species, with diffusive and advective fluxes, drives reactor design, combustion modeling, and atmospheric chemistry.
Derivation in three lines
- Mass in a fixed control volume V: m(t) = ∫_V ρ dV. Rate of change: dm/dt = ∫_V (∂ρ/∂t) dV.
- Net mass flux out through boundary ∂V with outward normal: ∮_∂V ρu·dA. Conservation says these are equal and opposite: ∫_V (∂ρ/∂t)dV = −∮_∂V ρu·dA.
- Apply the divergence theorem to convert the surface integral to a volume integral. Since V is arbitrary, the integrands must be equal: ∂ρ/∂t + ∇·(ρu) = 0.
The incompressible reduction
- Constant density: ∂ρ/∂t = 0 and ∇ρ = 0.
- Continuity becomes ρ∇·u = 0, hence ∇·u = 0.
- The velocity field is solenoidal — it can be written as u = ∇×ψ for some vector potential ψ in 3D, or as u = (∂ψ/∂y, −∂ψ/∂x) in 2D, where ψ is the streamfunction. Streamlines are curves of constant ψ, and ψ-spacing measures volumetric flow rate.
- Pressure becomes a Lagrange multiplier enforcing ∇·u = 0 — this is why incompressible CFD solves a pressure Poisson equation at each step.
A universal form for any conserved quantity
| Field | Density | Current | Continuity statement |
|---|---|---|---|
| Fluid | ρ (mass) | ρu | ∂ρ/∂t + ∇·(ρu) = 0 |
| Electromagnetism | ρ_q (charge) | J | ∂ρ_q/∂t + ∇·J = 0 |
| Quantum mechanics | |ψ|² (probability) | j_prob = (ℏ/2mi)(ψ*∇ψ − ψ∇ψ*) | ∂|ψ|²/∂t + ∇·j_prob = 0 |
| Heat transport | ρc_p T (energy) | −k∇T + ρc_p T u | ∂(ρc_p T)/∂t + ∇·(...) = 0 (no source) |
| Particle number | n | nu | ∂n/∂t + ∇·(nu) = generation − loss |
Concrete numbers
- Garden hose. Hose ID 13 mm (A ≈ 1.3 cm²), flow 10 L/min ≈ 1.7×10⁻⁴ m³/s, so v ≈ 1.3 m/s. Squeezing the nozzle to A/4 quadruples velocity to ~5 m/s — same Q.
- Aorta. Cross-section ~3 cm², cardiac output 5 L/min ≈ 8.3×10⁻⁵ m³/s, so v ≈ 0.28 m/s at peak averaged over the cycle. Capillaries: total cross-section ~4500 cm², so v drops to ~0.2 mm/s — slow flow for diffusion.
- Storm drain. 0.6 m pipe (A ≈ 0.28 m²) at 1 m/s carries 0.28 m³/s = 280 L/s — enough to drain a small parking lot during a downpour.
- Wind tunnel. Test section 2 m × 2 m at 50 m/s draws 200 m³/s of air. Continuity sets the contraction ratio: a 6:1 area contraction accelerates flow from settling-chamber 8 m/s to 50 m/s with low turbulence.
Common misconceptions
- "Only for fluids." Continuity is the local form of any conservation law. Charge, probability, energy, individual particle species, and momentum components all satisfy continuity equations with their respective densities and currents.
- "Implies ρ is constant." The full equation ∂ρ/∂t + ∇·(ρu) = 0 allows ρ to vary in space and time. Only the divergence-free reduction ∇·u = 0 requires constant density.
- "Trivially true." The integral form 'mass in = mass out + accumulation' is intuitive, but the local differential form is non-trivial — it constrains velocity gradients pointwise.
- "Q = Av always holds." A₁v₁ = A₂v₂ requires both incompressibility and steadiness. For unsteady or compressible flow, ρAv is constant only along characteristics, not across them.
- "Stream function exists in 3D." A scalar streamfunction exists only in 2D or in 3D with axial symmetry (Stokes streamfunction). General 3D incompressible flow needs a vector potential.
- "Continuity sets pressure." Continuity is a constraint, not a determination of pressure. Pressure is the Lagrange multiplier that enforces it; the actual pressure value comes from solving a Poisson equation derived from momentum conservation.
Frequently asked questions
Why must ∇·u = 0 for incompressible fluids?
For an incompressible fluid, density is constant: ∂ρ/∂t = 0 and ∇ρ = 0. The full continuity equation ∂ρ/∂t + ∇·(ρu) = 0 then reduces to ρ∇·u = 0, so ∇·u = 0. Physically: if mass density cannot change, then for any fixed control volume the inflow rate must equal the outflow rate; the velocity field has no sources or sinks. This makes incompressibility a kinematic constraint on u rather than a thermodynamic statement about ρ.
What is the integral form (Gauss's theorem)?
Apply the divergence theorem to ∇·(ρu) and integrate over a fixed volume V: ∫(∂ρ/∂t)dV + ∮ρu·dA = 0, where the second integral is over the boundary surface ∂V with outward normal. Equivalently, dm/dt = −∮ρu·dA — the rate of change of mass inside V equals minus the net outward mass flux. This integral form is convenient for finite-volume CFD codes, which apply it to each computational cell, and is the bridge between point-wise differential statements and global accounting.
How does it apply to pipe flow (Q = Av)?
For incompressible steady flow through a pipe of changing cross-section A(x), apply the integral form to a slice between two stations: ρA₁v₁ = ρA₂v₂, hence A₁v₁ = A₂v₂. The volumetric flow rate Q = Av is constant. Where the pipe narrows, velocity rises; where it widens, velocity falls. This is the basis of nozzles, diffusers, Venturi meters, and orifice flow measurements. It also underlies the airspeed-area relation in aircraft engine intakes and rocket nozzles (with compressibility added at supersonic Mach).
Why does charge conservation have the same form?
Take the divergence of Ampère-Maxwell: ∇·(∇×B) = μ₀∇·J + μ₀ε₀(∂/∂t)∇·E. The left side vanishes; using Gauss's law ∇·E = ρ_q/ε₀ gives ∂ρ_q/∂t + ∇·J = 0. This is the local statement of charge conservation, structurally identical to mass continuity. The pattern generalizes: any conserved scalar Q with current density J_Q satisfies ∂Q/∂t + ∇·J_Q = 0. Mass, charge, energy, momentum components, particle number, and probability all obey continuity equations.
How is it used in CFD?
In finite-volume CFD, the integral form ∫(∂ρ/∂t)dV + ∮ρu·dA = 0 is applied to every computational cell. Mass flux through each face is summed; the net flux equals the rate of change of cell-averaged density. For incompressible flow, ∇·u = 0 is enforced as a constraint at each timestep — pressure is solved as a Lagrange multiplier (Poisson equation for pressure) so that the resulting velocity is divergence-free. Failure to maintain ∇·u = 0 to numerical precision is the most common source of mass-loss errors in simulations.
What is the probability current in QM?
Take ∂|ψ|²/∂t using Schrödinger's equation. Define the probability current j = (ℏ/2mi)(ψ*∇ψ − ψ∇ψ*). Then ∂|ψ|²/∂t + ∇·j = 0 — the probability density |ψ|² obeys a continuity equation, and total probability is conserved. This is one reason quantum mechanics admits a particle interpretation: probability flows like a fluid, with a well-defined current. The same machinery extends to relativistic theories (Klein-Gordon, Dirac) where the conserved quantity is charge rather than positive-definite probability.