Modelling the concentration of bacteria in a river is a complex, multifacted problem. This example lets us explore a toy model that manages to capture some of the key ideas by ignoring much of the real-world complexity.

We limit ourselves to a single reach (i.e. a stretch of river without anything remarkable along it), and specify an inlet concentration of bacteria at the upstream (left) edge of the domain.

Clicking in the simulation below will instantly add bacteria to any point in the river, which will then be carried downstream (right) by the flow. Bacteria decay over time at a constant rate, mimicking UV exposure (though this varies with the time and season in real life).

We can adjust the inlet concentration, the decay rate of the bacteria, or the flow rate with the sliders below.

Phrased mathematically, we are solving an advection–reaction equation for the concentration $C$ of bacteria, given by

$\pd{C}{t}= - u\pd{C}{x} - kC,$

where $u$ is the flow speed, $k$ is the decay rate, and $x$ is the distance along the river.

To play with the details of this model, try out the full-screen simulation. In that simulation, sliders can be found by clicking Parameters