Inspiration
Cities treat rain as waste. A roof is a creek that nobody measures.
I kept seeing the same two answers to urban water: a carbon calculator with no physics, or a city BMP manual that a homeowner cannot run. Meanwhile stormwater is the main source of pollution in a lot of U.S. creeks. The first inch off a driveway carries sediment, phosphorus, and nitrogen. That water blows out streams in a storm and is gone when the garden actually needs it.
PyStorm asked for Python that does environmental work, not Python that calls a chatbot. The judge is from Python.org. So I built the thing I wished existed: a hydrology engine for one house.
What it does
Swale turns an address into a screening-level stormwater plan.
- Geocode the lot.
- Pull a typical year of daily rainfall and reference ET (Open-Meteo).
- Assign a hydrologic soil group (preset, SoilGrids when it responds, or a documented fallback).
- Simulate roof, driveway, and yard runoff day by day for that year.
- Under a DIY budget, size cisterns, rain gardens, trees, permeable driveway, and downspout disconnects.
- Report gallons kept on the lot, pounds of TSS / P / N not exported, and potable water offset from irrigation reuse.
Every number is labeled as a planning estimate, not a construction document.
On the Seattle bungalow demo, the engine keeps on the order of tens of thousands of gallons out of the pipe in a typical year. Phoenix, with ~17 inches of rain and sandy soil, gets a different plan because the climate is different. That regional contrast is the point.
How I built it
Python is the product.
- NRCS TR-55 curve numbers for the 1-inch water-quality storm:
$$Q = \frac{(P - 0.2S)^2}{P + 0.8S}, \quad S = \frac{1000}{\mathrm{CN}} - 10$$
- Simple Method (Schueler 1987) for annual runoff coefficient and pollutant loads:
$$R_v = 0.05 + 0.9\,I_a, \quad L = 0.226 \cdot R \cdot C \cdot A$$
- NumPy daily water balance: cistern storage, rain-garden ponding, HSG infiltration, tree interception.
- SciPy
differential_evolutionto spend a budget on gallons kept, with a greedy gallons-per-dollar fallback you can actually explain. - FastAPI serves the demo.
python -m swaleis a first-class CLI so the engine does not depend on a browser. - Tests check the TR-55 textbook case (CN 80, 3-inch storm → (Q = 1.25) in) and that an empty plan matches the baseline.
There is no LLM on the critical path. The numbers come from hydrology.
What I learned
- A 1-inch storm on a mostly pervious lot barely runs off under TR-55. The interesting number for a house is annual gallons, from a daily tank/garden simulation, not a single design storm.
- SoilGrids is the right API and also a 504. A hackathon demo that blocks on a slow soil service is a dead demo. Presets carry known HSGs; live lookups time out fast and fall back.
- Optimizers will happily specify a 10 ft² driveway. Snap to sizes a person could actually buy.
- “Accurate claims” is a feature. Screening-level models are useful. Pretending they are monitoring data is not.
Challenges
Getting baseline and treated runoff onto the same water balance. An early version used the Simple Method for “today” and the daily model for “after,” which made percent-reduction dishonest. Both sides now share the same rainfall year.
The other hard part was making the science visible in a 60-second demo: lot diagram, monthly hydrograph, gallons kept, and the formulas in the footer — without turning it into a dashboard of unexplained APIs.
Environmental impact
Urban runoff is a real pollution and flooding problem. Swale does not clean a watershed by itself. It gives a household (or a classroom, or a city engagement team) a lot-scale, cited, reproducible estimate of:
- gallons diverted from the storm sewer in a typical year
- pounds of TSS, phosphorus, and nitrogen not exported (residential EMCs)
- gallons of municipal water displaced if a cistern is used for irrigation
Scale is multiplicative and still a model: if 10,000 similar lots used the Seattle plan, multiply the gallons-kept figure by 10,000 for order of magnitude — not a monitoring study.
Who it is for
Homeowners, renters with a landlord who will listen, school lots, and anyone who has been told to “get a rain barrel” and wanted the numbers first.
What's next
Perc-test overrides, local rainfall records, and exporting a one-page plan a conservation district could actually hand someone. The engine is already a Python package. The UI is the demo.
Log in or sign up for Devpost to join the conversation.