Getting started

To start using WNTR, open a Python console and import the package:

import wntr

A simple script,, is included in the examples folder. This example demonstrates how to:

  • Import WNTR
  • Generate a water network model
  • Simulate hydraulics
  • Plot simulation results on the network
import wntr

# Create a water network model
inp_file = 'networks/Net3.inp'
wn =

# Graph the network,

# Simulate hydraulics
sim = wntr.sim.EpanetSimulator(wn)
results = sim.run_sim()

# Plot results on the network
pressure_at_5hr = results.node.loc['pressure', 5*3600, :], node_attribute=pressure_at_5hr, node_size=30, 
                        title='Pressure at 5 hours')

Additional examples, listed in Table 7, are included in the examples folder.

Table 7 Description of WNTR Example Files
Example file Description Convert units Generate and modify water network models Generate a NetworkX graph from a water network model Simulate hydraulics using the EPANET and WNTR simulators Simulate water quality using EPANET Extract information from simulation results Define disaster scenarios, including power outage, pipe leak, and changes to supply and demand Compute resilience metrics, including topographic, hydraulic, water quality, water security, and economic metrics Run a stochastic simulation Define fragility curves Create interactive network and time series graphics Animate network graphics

Several EPANET INP files are included in the examples/network folder. Example networks range from a simple 9 node network to a 3,000 node network. Additional network models can be downloaded from the University of Kentucky Water Distribution System Research Database at