Graph all the things

analyzing all the things you forgot to wonder about



Thought experiment: if a riverbed of constant width rises as you move downstream, how can the river's height and speed change? (choose any subset, answer at bottom of page)

water slowing down and dropping as riverbed rises downstream water speeding up and dropping as riverbed rises downstream water slowing down and rising as riverbed rises downstream water speeding up and rising as riverbed rises downstream
  1. top of river drops, speed decreases
  2. top of river drops, speed increases
  3. top of river rises, speed decreases
  4. top of river rises, speed increases

I made a model of river depth and speed, given riverbed altitude and flow, that explains the thought experiment and more, including river reversals!

You can play around with it in the visualization below - drag the riverbed nodes to change the riverbed altitude.

Initial Speed: 1 m/s    5 m/s
criticaldistance along river / kmaltitude / mspeed / (m/s)

This visualization uses a Runge-Kutta 4th order method with built-in criticality detection (more on criticality later). It assumes a 15m wide river with 70m3/s discharge (think Rio Grande). If your river doesn't make it to the end, then it isn't a possible river; water would build up at the start. Try reducing the initial water speed.

If you're careful, you can create both pools and fast-moving water in the same river by crossing the critical velocity line right as the riverbed slope angles downward.


I've always been interested in flowing water, and almost a decade ago I figured I could calculate a river's depth from its riverbed. Somehow I repeatedly fumbled the derivation and eventually gave up, only to revisit it recently.

Of course, there are many well-known fluid dynamics equations and simulation techniques. But many of these are taught as special cases of more esoteric equations like Navier-Stokes. Instead of working esoteric-down, I wanted to derive something interesting from first-principles-up.

After finishing my own derivations, I did some research and was pleasantly surprised to find my equations were equivalent to the Saint-Venant equations (save a factor of 2 I needed to fix).

River Physics

You only need high school mechanics understand what's going on in a river. Three forces act on the water:

  • gravity, which converts the water's potential energy into kinetic energy;
  • contact force (or water pressure), which causes parts of the water to push or pull on nearby water; and
  • friction, which converts the water's kinetic energy into other things like heat.

We'll ignore viscosity, so the only important difference between a liquid and solid for this problem is that when a liquid is under pressure, it applies that pressure in all directions.

To keep things simple, let's assume (among other unspoken assumptions) our river has

  • only one source (its headwater) and one sink (its mouth)
  • constant width
  • reached equilibrium (its depth at any point stays constant over time)
  • gentle slope so that we only only need to consider horizontal forces
  • no turbulence or viscosity

To answer our original thought experiment, we'll ignore friction and introduce some symbols:

  • x, horizontal distance downstream the river
  • a(x), the altitude of the riverbed at x
  • h(x), the depth of the river at x
  • v(x), the horizontal velocity of the river at x
  • w, the width of the river
  • \rho, the density of water
  • g, acceleration due to gravity
  • \Phi, the discharge of water (i.e. cubic meters per second)
  • V, an arbitrary volume of water
diagram of a riverbed of constant width using the above symbols

Our constant discharge can be used to relate the water's depth to its velocity: \Phi = whv. Where depth increases, velocity must decrease, and vice versa. Otherwise more water would pass through some parts of the river than others, which wouldn't make any sense. This simple fact already rules out option a. from the thought experiment.

To make more quantitative statements, we'll estimate the rate of change in the water's kinetic energy with respect to x due to two net horizontal forces: the riverbed altitude changing and the water depth changing (\frac{dK}{dx} = K' = F_1 + F_2). Note that all derivatives here are with respect to x, not time.

Accounting for the riverbed altitude change is simple: as water vertically translates down at a rate of a', gravity increases the water's kinetic energy at a rate of

F_1 = -\rho Vga'

Gravity also has the effect of creating water pressure. Water at distance z above the riverbed has h - z distance of water above it, weighing down. For an area A, the above water has weight \rho A(h - z) g, creating a pressure of \rho(h - z) g. As the water depth changes, the pressure at z above riverbed changes as P' = \rho h' g. Since water exerts force in all directions equally, this creates a horizontal pressure gradient, doing work at a rate of

F_2 = -\rho Vgh'

In total the water cell's kinetic energy increases at a rate of

K' = -\rho Vg (a' + h')
Kinetic energy is K = \frac12mv^2, K' = mvv', and m= \rho V, so
vv' = -g(a' + h')
And since our river has constant discharge \Phi = whv, v = \Phi / (wh) and v' = -\Phi h'/(wh^2). With a bit of work, we plug this in and solve for h' to get a dope ordinary differential equation (ODE):
h' = -\frac{g w^2h^3}{gw^2h^3 - \Phi^2}a'

That denominator could be 0 - oh no! Don't worry, though. This is the right equation. It turns out the two cases - whether gw^2h^3 > \Phi^2 or equivalently gh > v^2 - have huge implications for the river's behavior.

  • The slow case, gh > v^2, is called subcritical. The water is slow and deep enough that it can gain energy by speeding up and contracting its depth.
  • The fast case, gh < v^2, is called supercritical. The water moves quickly enough that it can briefly force water ahead of it up a slope. Fun fact - supercritical water is moving fast enough that waves only propagate forwards relative to the ground. This requires speeds of 3 to 10 m/s in a typical river.

When a river does transition between these sub- and supercritical cases, h undergoes a cusp at the critical point.

Looking at our formula for h' in the usual subcritical case, we can see that \frac{g w^2h^3}{gw^2h^3 - \Phi^2} > 1, so h' < -a'. In other words, if the riverbed is rising at a certain rate, the depth shrinks faster, so the top of the water drops. And since the depth shrinks, the velocity increases. Therefore the (typically) correct answer to the original thought experiment is b. In the supercritical case, we see that h' > 0, so v' < 0, which means that c. is also possible.

Adding in Friction

The ODE we got without friction was lovely, but unfortunately friction always makes things uglier. We could account for friction against the land and/or friction within liquid. But we assumed from the beginning that the water has 0 viscosity, and viscosity is just friction within a liquid, so it makes sense to ignore that effect.

We'll take a simplistic approach: the frictional force F_3 acting against the flow of water is proportional to

  • ratio of contact perimeter with land to cross-sectional area, and
  • v^2.
F_3 = -\rho V \alpha\frac{w + 2h}{wh} v^2
The motivation for v^2 is partly empirical, partly so that math is still nice, and partly intuitive. If a particle moves n times faster, it is likely to get into n times more collisions at n times higher speed, resulting in n^2 as much energy loss.

In any case, after adding this term to our equation for K' and solving, we get a new ODE for h:

h' = -\frac{gw^3h^3a' + \alpha \Phi^2(w + 2h)}{gw^3h^3 - \Phi^2w}

This ODE isn't linear, autonomous, or even homogeneous, so we don't have any hope of solving it. But we can use it numerically (as I did in the visualization above). And we can learn some interesting things about rivers with a constant slope!

Special Case: Constant Slope River

In the case that the riverbed slope a'(x) = -s at all x, our ODE becomes autonomous:

h' = \frac{gw^3h^3s - \alpha \Phi^2(w + 2h)}{gw^3h^3 - \Phi^2w}
Without solving it, we can already glean one fact: if s > 0 (any downhill river, as most are), there is a solution where the water depth stays a constant h_\text{eq} with x.
diagram of river with constant water depth moving down slope

Solving for h' = 0, we get:

gw^3sh_\text{eq}^3 - 2 \alpha \Phi^2 h_\text{eq} - \alpha \Phi^2 w = 0
Wow, we found a (depressed) cubic formula in real life! Instead of solving its hideous roots, let's just consider two cases: a narrow gorge (where h \gg w) and a bayou (where w \gg h):
h_\text{eq, gorge} \approx \sqrt\frac{2\alpha \Phi^2}{gw^3s}, \qquad v_\text{eq, gorge} \approx \sqrt\frac{gws}{2\alpha}
h_\text{eq, bayou} \approx \sqrt[3]\frac{\alpha \Phi^2}{gw^2s}, \qquad v_\text{eq, bayou} \approx \sqrt[3]\frac{g\Phi s}{\alpha w}

There are so many interesting points you can draw from these.

  • In a narrow gorge, as water flow increases, the water doesn't move any faster - instead it just gets deeper.
  • In a bayou, water speed increases with only the cube root of downhill slope, whereas in a narrow gorge, it increases more elastically with the square root.

Reducing the ODE to an implicit function of h is technically possible with partial fractions, but gives an equation far too complicated to be useful. Instead, let's consider an even easier case: a flat river.

Extra Special Case: Flat River

How can a riverbed be flat? Wouldn't the river just stand still? Not necessarily - the water can actually propel itself forward a good distance by eating into its own potential energy. As the water moves forward, its depth decreases and it speeds up. This may sound strange, but consider that last 170km of the Mississippi drops by only 1cm per km - a 0.001% grade. Many rivers have sections like this, such as the Danube descending at less than 0.003% grade for 450km between Budapest and Belgrade.

With a flat river, we can solve the ODE to get an implicit function of h:

\frac{1}{\alpha \Phi^2}\left(\frac1{48}gw^3\left(2(2h + w)^3 - 9w(2h + w)^2 + 18w^2(2h + w) - 6w^3ln|2h + w|\right) - \Phi^2wln|2h + w|\right) = -x + C

We can't solve for h explicitly, but it looks like this in the subcritical case:

plot of water depth dropping and speed increasing on flat riverbed

As h drops to \sqrt[3]\frac{\Phi^2}{gw^2} (the critical point), the water reaches it lowest possible energy state (balancing potential and kinetic energy), so it can no longer shorten itself to fight friction. In other words, a river can have a perfectly flat section and still move, but only for a moderate distance.

In the case that a supercritical river hits a flat section at high speed, it will also be able to progress for a short distance before it loses its speed and pushes backward. Imagine a fast hose aimed at a narrow channel before any of the water starts to roll backwards:

plot of water depth rising and speed dropping on flat riverbed

The cusp we see here is a type of hydraulic jump. This video does a great job demonstrating them.

Intermittent River Reversals

Because some real rivers are nearly flat, their direction can actually be reversed under the right circumstances. The Mississippi and Chicago rivers have both reversed because of storm surges. Storm surges increased water depth toward the mouth end of the river, pushing the water upstream via the higher water's potential energy (the subcritical case). During Hurricane Isaac, the reversed flow on the Mississippi was nearly twice as great as normal and lasted for 24 hours.

But I think the most interesting incident was the 1812 earthquake that caused the Mississippi to reverse for 3 days. From what I can gather, the earthquake didn't change the overall slope of the river - instead it just opened up new depressions and cavities for the river to flow into. The biggest of these was Reelfoot Lake, which was formerly dry land, but remains a lake to this day. Since the southern part of the river is essentially flat, the depth of the river exceeded its altitude change over hundreds of kilometers, so the water was able to flow backwards to fill these new depressions.

Critical Behavior

Ok, so there are sub- and supercritical flows, and I've hinted that you can transition between them, but there's still something unsettling about the ODE. Once you hit the cusp where the denominator is 0, the ODE seems to give no possible way forward. In other words, once the water is out of potential and kinetic energy to fight friction, the equation seems unsatisfiable. But this doesn't match our intuition of some rivers, where a slow-moving lake can give way to a fast-moving cascade and vice versa. There are two reasons for this.

First, there is a cool way for the ODE to exhibit transcritical flow. The trick is that the numerator and denominator need to cross 0 at the exact same time; typically when the riverbed descends at the exact point when the water runs out of energy to burn. This is actually feasible because real rivers aren't exactly steady-state. An empty lakebed will fill up until it reaches the point where water can drain from it at an exactly critical rate. In the interactive visualization above, I did some tricks to make it easier to get this critical behavior.

Second, these equations ignore turbulence. This is of greatest importance in more general supercritical to subcritical transitions, where different layers of water move at different speeds (see below diagram). It's a limitation of this Saint Venant approach that some works aim to address.

illustration of a reverse roller with diferent layers of water moving in different directions

Final Morsels

With no mathematical justification: my collection of soothing river videos.

Thought Experiment Answer: typically b., but c. is also possible in very fast water.