Simulation results

WNTR uses Pandas data objects to store simulation results. The use of Pandas facilitates a comprehensive set of time series analysis options that can be used to evaluate results. For more information on Pandas, see http://pandas.pydata.org/.

Results are stored in Pandas Panels. A Panel is a 3-dimensional database. One Panel is used to store nodes results and one Panel is used to store link results. The Panels are indexed by:

  • Node or link attribute
  • Time in seconds from the start of the simulation
  • Node or link name

Conceptually, Panels can be visualized as blocks of data with 3 axis, as shown in Figure 8.

Pandas Panels

Figure 8 Conceptual representation of Panels used to store simulation results.

Node attributes include:

  • Demand
  • Expected demand (only when the WNTRSimulator is used)
  • Leak demand (only when the WNTRSimulator is used)
  • Pressure
  • Head
  • Quality (only when the EpanetSimulator is used. Water age, tracer percent, or chemical concentration is stored, depending on the mode of water quality analysis)
  • Type (junction, tank, or reservoir)

Link attributes include:

  • Velocity
  • Flowrate
  • Status (0 indicates closed, 1 indicates open)
  • Type (pipe, pump, or valve)

The example simulation_results.py demonstrates use cases of simulation results. Node and link results are accessed using:

print(results.node)
print(results.link)

The indices can be used to extract specific information from the Panels. For example, to access the pressure and demand at node ‘123’ at 1 hour:

print(results.node.loc['pressure',3600,'123'], results.node.loc['demand',3600,'123'])

To access the pressure for all nodes and times (the “:” notation returns all variables along the specified axis):

print(results.node.loc['pressure',:,:])

Attributes can be plotted as a time-series, as shown in Figure 9:

pressure_at_node123 = results.node.loc['pressure',:,'123']
pressure_at_node123.plot()
Time-series graph.

Figure 9 Example time-series graphic.

Attributes can be plotted on the water network model, as shown in Figure 10. In this figure, the node pressure at 1 hr and link flowrate at 1 hour are plotted on the network. A colorbar is included for both node and link attributes:

pressure_at_1hr = results.node.loc['pressure',3600,:]
flowrate_at_1hr = results.link.loc['flowrate',3600,:]
wntr.graphics.plot_network(wn, node_attribute=pressure_at_1hr, 
                        link_attribute=flowrate_at_1hr)
Network graphic

Figure 10 Example network graphic.

Network and time-series graphics can be customized to add titles, legends, axis labels, etc.

Panels can be saved to Excel files using:

results.node.to_excel('node_results.xls')
results.link.to_excel('link_results.xls')