Network 1: confluences only¶
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
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-2-34661278ac7e> in <module>
----> 1 from context import RiverNetwork
2 from RiverNetwork import RiverNetwork
~/checkouts/readthedocs.org/user_builds/rna/checkouts/stable/docs/context.py in <module>
5 sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
6
----> 7 import RiverNetwork
8 import fit_muskingum
ModuleNotFoundError: No module named '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')
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-3-a2c5a34c281e> in <module>
----> 1 structure1 = RiverNetwork('../data/network-structure-1.xlsx',wave_shapes_location='../data/wave_shapes.xls')
NameError: name 'RiverNetwork' is not defined
[4]:
structure1.draw()
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-4-6d428d49cfb8> in <module>
----> 1 structure1.draw()
NameError: name 'structure1' is not defined
[5]:
structure1.draw_base_loads(figsize=(7,3))
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-5-488e6f580629> in <module>
----> 1 structure1.draw_base_loads(figsize=(7,3))
NameError: name 'structure1' is not defined
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))
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-6-2cb26ba5bda4> in <module>
----> 1 structure1.set_constant_flow('S.1',31)
2 structure1.set_wave('S.2',shape_number=5,strength=5)
3 structure1.set_wave('S.3',shape_number=90,strength=5)
4 structure1.set_constant_flow('S.4',31)
5 structure1.draw_Qin(only_sources=True,figsize=(7,4))
NameError: name 'structure1' is not defined
[7]:
structure1.calc_flow_propagation(30)
structure1.draw_Qin(figsize=(7,5))
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-7-2242449ae3a7> in <module>
----> 1 structure1.calc_flow_propagation(30)
2 structure1.draw_Qin(figsize=(7,5))
NameError: name 'structure1' is not defined
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))
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-8-e14be04b88ee> in <module>
5 shape[7] = 3
6 shape[8] = 1
----> 7 structure1.set_shape('S.1',30,shape)
8 structure1.set_wave('S.2',shape_number=5,strength=5)
9 structure1.set_wave('S.3',shape_number=90,strength=5)
NameError: name 'structure1' is not defined
[9]:
structure1.calc_flow_propagation(30)
structure1.draw_Qin(figsize=(7,5))
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-9-2242449ae3a7> in <module>
----> 1 structure1.calc_flow_propagation(30)
2 structure1.draw_Qin(figsize=(7,5))
NameError: name 'structure1' is not defined
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))
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-10-2a54a87e143c> in <module>
5 shape[7] = 3
6 shape[8] = 1
----> 7 structure1.set_shape('S.1',30,shape)
8 structure1.draw_Qin(only_sources=True,figsize=(7,4))
NameError: name 'structure1' is not defined
[11]:
structure1.calc_flow_propagation(30)
structure1.draw_Qin(figsize=(7,5))
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-11-2242449ae3a7> in <module>
----> 1 structure1.calc_flow_propagation(30)
2 structure1.draw_Qin(figsize=(7,5))
NameError: name 'structure1' is not defined