Network 1: confluences only

In the following sections two examples of networks are given. These exmples show how the developed class can be used to model small river networks. This simple network only contains confluences and no bifurcations.

[1]:
import pandas as pd
import networkx as nx
import matplotlib.pyplot as plt
import numpy as np
[2]:
from context import RiverNetwork
from RiverNetwork import RiverNetwork

Loading network structure

An extra file containing wave shapes is loaded as well. This file makes it possible to select arbitrary wave shapes as input flows.

[3]:
structure1 = RiverNetwork('../data/network-structure-1.xlsx',wave_shapes_location='../data/wave_shapes.xls')
[4]:
structure1.draw()
/home/docs/checkouts/readthedocs.org/user_builds/rna/envs/latest/lib/python3.7/site-packages/networkx/drawing/nx_pylab.py:579: MatplotlibDeprecationWarning:
The iterable function was deprecated in Matplotlib 3.1 and will be removed in 3.3. Use np.iterable instead.
  if not cb.iterable(width):
/home/docs/checkouts/readthedocs.org/user_builds/rna/envs/latest/lib/python3.7/site-packages/networkx/drawing/nx_pylab.py:676: MatplotlibDeprecationWarning:
The iterable function was deprecated in Matplotlib 3.1 and will be removed in 3.3. Use np.iterable instead.
  if cb.iterable(node_size):  # many node sizes
_images/B-network-structure-1_7_1.svg
[5]:
structure1.draw_base_loads(figsize=(7,3))
_images/B-network-structure-1_8_0.svg

Determining calculation order

In order to determine the calculation order the following following procedure is used: A Depth First Search (DFS) algorithm is used starting at the sink E.1. The output of this algorithm is a list and tells us all steps from the sink all the way to the sources. The source furthest away from the sink is last in the list (BFS opposed to DFS). By reversing this list a new list with a safe calculation order is created. This list guarantees that all edges are traversed and calculated before they are used.

Experiment 1

With this baseload and network structure it is possible to perform experiments by setting different inflows on top of the base flows. There are two constant flows selected: these are based on the base load. And two waves are selected from the wave shape file.

[6]:
structure1.set_constant_flow('S.1',31)
structure1.set_wave('S.2',shape_number=5,strength=5)
structure1.set_wave('S.3',shape_number=90,strength=5)
structure1.set_constant_flow('S.4',31)
structure1.draw_Qin(only_sources=True,figsize=(7,4))
[6]:
(<Figure size 672x384 with 1 Axes>,
 <matplotlib.axes._subplots.AxesSubplot at 0x7fc2deb1fe48>)
_images/B-network-structure-1_13_1.svg
[7]:
structure1.calc_flow_propagation(30)
structure1.draw_Qin(figsize=(7,5))
[7]:
(<Figure size 672x480 with 1 Axes>,
 <matplotlib.axes._subplots.AxesSubplot at 0x7fc2de9b45f8>)
_images/B-network-structure-1_14_1.svg

Warning

Coloring should change to improve readability. E.g. cluster nodes and give similar colors.

Here we see that: S.1 (blue) + S.2 (orange) gives A.1 (purple). A.2 (brown) is shifted relative to A.1. S.3 (green) + S.4 (red) gives B.1 (yellow). A.2 and B.1 give A.3 (pink). And clearly A.3, A.4 (grey) and E.1 (light blue) are just simple muskingum transformations.

Experiment 2

Now it is possible to add any other extra inflow. In the following experiment a peak flow is added to S.1.

[8]:
shape = np.zeros(30)
shape[4] = 1
shape[5] = 3
shape[6] = 10
shape[7] = 3
shape[8] = 1
structure1.set_shape('S.1',30,shape)
structure1.set_wave('S.2',shape_number=5,strength=5)
structure1.set_wave('S.3',shape_number=90,strength=5)
structure1.set_constant_flow('S.4',30)
structure1.draw_Qin(only_sources=True,figsize=(7,4))
[8]:
(<Figure size 672x384 with 1 Axes>,
 <matplotlib.axes._subplots.AxesSubplot at 0x7fc2deb15a58>)
_images/B-network-structure-1_19_1.svg
[9]:
structure1.calc_flow_propagation(30)
structure1.draw_Qin(figsize=(7,5))
[9]:
(<Figure size 672x480 with 1 Axes>,
 <matplotlib.axes._subplots.AxesSubplot at 0x7fc2deb9ceb8>)
_images/B-network-structure-1_20_1.svg

Because of the peak shape the propagation through the network can clearly be seen.

Experiment 3

This effect can even be made larger:

[10]:
shape = np.zeros(30)
shape[4] = 1
shape[5] = 3
shape[6] = 40
shape[7] = 3
shape[8] = 1
structure1.set_shape('S.1',30,shape)
structure1.draw_Qin(only_sources=True,figsize=(7,4))
[10]:
(<Figure size 672x384 with 1 Axes>,
 <matplotlib.axes._subplots.AxesSubplot at 0x7fc2df4597f0>)
_images/B-network-structure-1_24_1.svg
[11]:
structure1.calc_flow_propagation(30)
structure1.draw_Qin(figsize=(7,5))
[11]:
(<Figure size 672x480 with 1 Axes>,
 <matplotlib.axes._subplots.AxesSubplot at 0x7fc2df426d30>)
_images/B-network-structure-1_25_1.svg