All projects

Surface Runoff Model

A Python simulation of surface runoff across a digital elevation grid, using a diffusion wave model.

Type Mathematical Modeling
Year 2025
Stack Python · NumPy · Plotly · Matplotlib
Status
Completed
Overview

This lab models surface runoff - the process by which rain becomes overland flow, once soil can't absorb any more water.

It uses the Diffusion Wave model, a simplified form of the full Saint-Venant equations that drops inertia but keeps gravity and friction - accurate enough for this scale of simulation, and considerably simpler to implement correctly.

The model tracks rainfall intensity, duration, and total amount against elevation and a single infiltration rate. It deliberately leaves out soil type, vegetation, land use, basin shape, and drainage networks - real factors, cut to keep the scope lean and within reason.

Technical

Implemented in Python inside a Jupyter notebook - NumPy for the grid math, Plotly for an interactive 3D heightmap, and Matplotlib for the animated frames.

The core is a fixed-timestep loop over a 50×50 grid. Rainfall is injected per cell from a Gaussian storm that moves deterministically across the terrain; infiltration is limited by both available surface water and remaining soil capacity, and saturation is hard-capped to keep floating-point overshoot out of the water balance. Each frame is rendered twice - once for water depth, once for soil saturation - then stitched into looping GIFs with imageio.

Reflection

Standing on the shoulders of giants

This was my first real detour into physics outside the curriculum, and it caught me off guard. Surface runoff sounds almost trivial - rain falls, water moves downhill - until you actually look at the equations behind it and realize entire careers were spent getting that "obvious" behavior right. There's something humbling about a subject that niche existing at all.

Reading about it wasn't enough. I wanted to recreate it - to take equations built by people much smarter than me and see if I could get water to behave the way it behaves in the real world, on a grid, in Python. The result was more than the assignment asked for, but that was the point. It was an experiment, and it worked.

More Works