Documentation · Quick start · Examples · Gallery · Studio and Case Builder · Licenses · Cite
HydroPol2D is a computer model of floods and water quality. It follows rain across a landscape, cell by cell. It computes how much water plants and snow hold, how much soaks into the soil and reaches the groundwater, and where the rest flows, how deep it gets and what pollutants it carries. It works for cities, suburbs and rural catchments, including places with few measurements. This repository is the MATLAB version of the model. It is free and open source.
Stanford campus, CA, simulated on a 10 m grid. Top: flood depth, flow speed, flood hazard and water level. Bottom: infiltration, rainfall, groundwater depth and groundwater recharge. Click for the full video.
| Area | What HydroPol2D computes |
|---|---|
| Flood flow | Water flowing over the land and in rivers. Five ways to compute it are available. The default is local inertial. |
| Rain to runoff | Rain caught by leaves, snow that builds up and melts, evaporation and plant water use, and water soaking into three soil layers. |
| Groundwater | The water table, groundwater flow between cells, a deep aquifer and water exchange with rivers. |
| Structures | Reservoirs and gates, dam breaks, storm drains, detention ponds and green infrastructure such as rain gardens. |
| Water quality and risk | Pollutants that build up on surfaces and wash off with runoff, and the risk for people standing in floodwater. |
| Grids and computers | A regular grid or a flexible mesh. It runs on a normal computer or on an NVIDIA graphics card, and its time step adapts so that water is conserved. |
| Outputs | Maps (GeoTIFF), animations (MP4), hydrographs and water balances (CSV), and figures (PDF and PNG). |
git clone https://github.com/marcusnobrega-eng/HydroPol2D.gitOpen MATLAB in the HydroPol2D folder and run an example:
run('Examples/VTilted_Excel/run_excel.m') % a simple synthetic catchment, about 3 min
run('Examples/Stanford/run_excel.m') % San Francisquito Creek, CA, about 14 minYou need MATLAB R2020a or newer with the Mapping Toolbox and the Image Processing Toolbox. Runs on a graphics card also need the Parallel Computing Toolbox and an NVIDIA card. Terrain smoothing needs the Optimization Toolbox.
Your own case is one Excel workbook. Copy
Input_Data_Sheets/HydroPol2D_Inputs.xlsx, fill in
its tabs and run run_HydroPol2D.m. As supplied, the workbook runs the
30 m San Francisquito Creek example on the CPU
(Input_Data_Sheets/Readme.txt). The website explains every tab, with a
picture of each one, in
Case Workbook Settings
and Run from Excel.
For automated studies, a script can replace the workbook
(Config/input_data_bypass_script.m).
| Example | Run in MATLAB | What it shows | Time | Expected results |
|---|---|---|---|---|
| V-tilted catchment (synthetic) | run('Examples/VTilted_Excel/run_excel.m') |
10.8 mm/h of rain for 90 min, 180 min simulated, on a regular grid or a mesh | ~3 min | rain 16.20 mm, peak outflow 1.525 m³/s, runoff coefficient 0.94, maximum depth 0.15 m |
| San Francisquito Creek, CA (30 m grid) | run('Examples/Stanford/run_excel.m') |
100 mm/h of rain for 1 h on a 157 km² catchment, 180 min simulated | ~14 min | rain 99.97 mm, peak outflow across the domain edge 402.8 m³/s, runoff coefficient 0.16, maximum depth 5.87 m |
| One check per process | each case's run script | about 80 small synthetic cases, each with a pass or fail rule | 1-10 min each | Validation_Cases.csv |
Each example writes its results to its own Outputs/ folder. A 24 h version of the Stanford case,
with maps and a video, is on the
website.
Results from studies. Their inputs are not in this repository.
![]() A 50-year storm over an urban catchment with storm drains, São Paulo, Brazil |
![]() A full dam break over a city in Pernambuco, Brazil |
A rainfall-runoff event in a catchment near Palo Alto, CA
stanford_lidar.mp4
A 22-day simulation with rainfall that varies in space (MSWEP), Pune, India
pune.mp4
| Product | What it is | License |
|---|---|---|
| HydroPol2D (MATLAB) | This repository. The model's source code in MATLAB. You prepare a case in an Excel workbook and run it in MATLAB. | Free and open source (GPL-3.0) |
| HydroPol2D Studio | A desktop app for Mac and Windows. You build a model on a map, run it, calibrate it and view the results in one window, with no MATLAB and no coding. It runs the Python version of the model. | Proprietary, needs a license code |
| HydroPol2D Case Builder | A tool that prepares a ready-to-run case for a city or a catchment from public global data: the model area, terrain, rivers, land use, soil, rain and weather. It writes cases for this MATLAB version and for the Python version. | Proprietary, needs a license code |
- HydroPol2D (MATLAB) is free under the GNU General Public License v3.0. You may use,
study, change and share it. Software that you distribute and that is built on it must stay open
source under the same license. The bundled TopoToolbox code keeps its own GPL-3.0 license
(
third_party/NOTICE.md). - HydroPol2D Studio and HydroPol2D Case Builder are proprietary. To get a license, write to Marcus N. Gomes Jr. at marcusnobrega.engcivil@gmail.com. Studio downloads are on its release page.
| Path | Contents |
|---|---|
run_HydroPol2D.m |
Main script. It reads the case workbook and runs the model. HydroPol2D_V115.m, its former name, still works. |
HydroPol2D_Functions/ |
Model code |
Input_Data_Sheets/ |
Case workbook template |
Config/ |
Script settings for automated studies |
Examples/ |
Examples you can run |
Validation/ |
Process checks with pass or fail rules |
Applications/ |
Cluster (SLURM) template and dam-case runners |
tools/ |
Workbook builder, which converts older General_Data.xlsx cases, and other tools |
third_party/ |
Bundled TopoToolbox terrain code |
The HydroPol2D website, in English, Portuguese and Spanish, has the full manual: getting started, inputs, case workbook, theory, validation, Studio, Case Builder and the changelog.
This repository is at v1.19.0-rc2 (release notes), a release
candidate. It matches HydroPol2D Studio 0.9.0rc2. Version v1.17.0 stays the stable reference
until the last hardware and packaging checks pass.
- San Francisquito Creek, terrain: USGS 3D Elevation Program (3DEP), 10 m averaged to 30 m
(
Examples/Stanford/Static/DEM.tif) and 10 m (Examples/Stanford/Static_10m_LiDAR), U.S. public domain. - San Francisquito Creek, land use: ESA WorldCover 2020 (v100), CC BY 4.0. © ESA WorldCover project 2020 / Contains modified Copernicus Sentinel data (2020) processed by ESA WorldCover consortium. The class codes 10 to 90 and their names in the land-use table are WorldCover's.
- San Francisquito Creek, other maps: single values set for the example (soil class 8, depth to bedrock 1.5 m, LAI 1, albedo 0.25, initial soil moisture 0.1104).
- V-tilted catchment: all inputs are generated by
prepare_standard_case.m.
If you use HydroPol2D, please cite:
- Gomes Jr, M.N., et al., 2023. HydroPol2D: Distributed hydrodynamic and water quality model: Challenges and opportunities in poorly-gauged catchments. Journal of Hydrology, 625, 129982.
- Gomes Jr, M.N., Castro, M.A., Castillo, L.M., Sánchez, M.H., Giacomoni, M.H., de Paiva, R.C. and Bates, P.D., 2025. Spatio-temporal performance of 2D local inertial hydrodynamic models for urban drainage and dam-break applications. Journal of Hydrology.
More publications using HydroPol2D
- Gomes Jr, M.N., Jalihal, V., Castro, M. and Mendiondo, E.M., 2025. Exploring the impact of rainfall temporal distribution and critical durations on flood hazard modeling. Natural Hazards.
- Gomes Jr, M.N., et al., 2024. Global optimization-based calibration algorithm for a 2D distributed hydrologic-hydrodynamic and water quality model. Environmental Modelling & Software, 179, 106128.
- Rápalo, L.M., Gomes Jr, M.N. and Mendiondo, E.M., 2024. Developing an open-source flood forecasting system adapted to data-scarce regions: A digital twin coupled with hydrologic-hydrodynamic simulations. Journal of Hydrology, 644, 131929.
- Rápalo, L.M., Gomes Jr, M.N. and Mendiondo, E.M., 2025. Multiple levels of human instability due to urban overland flow within the 21st century: An urban catchment study case in Brazil. International Journal of Disaster Risk Reduction.
- Castro, M., Gomes Jr, M., Rápalo, L. and Mendiondo, E., 2025. Performance of low-complexity hydrodynamic models for dam-break flood mapping: Trade-offs between full momentum, diffusive-wave, and local-inertial models (under review).
- Castro, M.D.A.R.A., Gomes Jr, M.N. and Mendiondo, E.M., 2025. Probabilistic dam-break flood mapping via Monte Carlo simulations using a 2D local-inertial model (DOI not available).
- Sanchez, M.H., Gomes Jr, M.N., Rápalo, L., Castro, M.D.A.R.A. and Mendiondo, E.M., 2026. Assessment of urban vulnerability to floods under current and future demographic and climate scenarios. SSRN (under review).
- Sousa, M.R.D., Mendiondo, E.M. and Gomes, M.N., 2026. Hydrological-hydrodynamic modeling of climate-induced urban flooding of design storms using HydroPol2D: a case study in São Carlos, Brazil. RBRH.
- Sánchez, M.H., 2025. A novel framework for flood vulnerability assessment and fuzzy-controlled reservoir optimization in data-scarce urban watersheds. Master's thesis, University of São Paulo.
- Castro, M.D.A.R.A., 2024. Métodos determinísticos e probabilísticos para a avaliação do impacto de rompimentos de barragens via modelagem hidrodinâmica. Master's thesis, University of São Paulo.
- Rápalo, L.M.C., 2024. Open-source tools for flood risk assessment for multiple spatio-temporal scales under scenarios of change. Doctoral dissertation, University of São Paulo.
- Gomes Jr, M.N., 2023. Advances in open source hydroinformatics for flood modeling and disaster education. Doctoral dissertation, University of São Paulo.
Dr. Marcus N. Gomes Jr., mngomes@stanford.edu. Please report bugs and ask questions as GitHub issues. For licenses and for a short course (2-hour classes with slides), write to marcusnobrega.engcivil@gmail.com.
Acknowledgments: University of São Paulo, São Carlos School of Engineering. University of Texas at San Antonio, Civil and Environmental Engineering. Stanford University, Stanford Doerr School of Sustainability, Department of Earth System Science.

