Network 2: adding a bifurcation¶
This simple network contains confluences and a single 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/working/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-2.xlsx',wave_shapes_location='../data/wave_shapes.xls')
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-3-caf6cbb5fc11> in <module>
----> 1 structure1 = RiverNetwork('../data/network-structure-2.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,4))
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-5-385fa3c576d0> in <module>
----> 1 structure1.draw_base_loads(figsize=(7,4))
NameError: name 'structure1' is not defined
Determining calculation order¶
The procedure for determining calculation order with multiple sinks is slight different. In that case a virtual sink is added to the system and all other sinks are connected to this node. Then a the same procedure is repeated: reversed BFS starting at this virtual sink. The resulting list is reversed and the result is a calculation order that guarantees that always all upstream flows are already calculated.
Example of the calculation order determining. In the left graph a temporary node and edges are added in red. From this node the reversed breadth-first search algorithm finds edges in a certain order. The order is indicated with numbers next to the edges. In the right graph the order of these edges is reversed and the temporary edges and node are removed. The order now corresponds to the calculation order that guarantees that all upstream parts are calculated before traversing downstream. This can be seen best at node A.3: all upstream edges are traversed before going downstream.
Experiment 1¶
[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.
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