Getting started#

To start using WNTR, open a Python console or IDE like Spyder and import the package:

import wntr

WNTR comes with a simple getting started example, shown below, that uses the EPANET Example Network 3 (Net3) INP file.

This example demonstrates how to:

  • Import WNTR

  • Generate a water network model

  • Simulate hydraulics

  • Plot simulation results

"""
The following example demonstrates how to import WNTR, create a water 
network model from an EPANET INP file, simulate hydraulics, and plot 
simulation results on the network.
"""
# Import WNTR
import wntr

# Create a water network model
inp_file = 'networks/Net3.inp'
wn = wntr.network.WaterNetworkModel(inp_file)

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

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

Additional examples of Python code snippets are included throughout the WNTR documentation. The examples provided in the documentation assume that a user has experience using EPANET (https://www.epa.gov/water-research/epanet) and Python (https://www.python.org/), including the ability to install and use additional Python packages, such as those listed in Requirements and Optional dependencies.

See Examples for more information on downloading and running examples.