Single Confluence

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

Loading network structure

[3]:
structure1 = RiverNetwork('../data/single-confluence.xlsx')
[4]:
structure1.draw(figsize=(4,4))
/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/A-single-confluence_5_1.svg

Here we see the network structure as defined with its nodes and edges. Each edge shows its corresponding \(k\) and \(x\). The incoming reaches have an \(x\) of 0.5 such that only a delay occurs and no attenuation. The numbers next to the nodes show the base loads, which is a static flow based on a long term average or can be an initial value. These base loads can also be plotted:

[5]:
structure1.draw_base_loads(figsize=(7,2.5))
_images/A-single-confluence_7_0.svg

Setting the inflows

We load a basic waveform from an excel file. Then this wave is translated to create a second waveform.

[6]:
I = pd.read_excel('../data/example-inflow-karahan-adjusted.xlsx').Inflow
t = pd.read_excel('../data/example-inflow-karahan-adjusted.xlsx').Time
I2 = I*0.4
I2 = np.append(I2[28:37],I2[0:28])
inflow = pd.DataFrame({'Q1':I,'Q2':I2},index=t)

The inflows are plotted:

[7]:
fig = plt.figure(figsize=(7,2.5),dpi=150)
fig.patch.set_alpha(0)
ax = fig.add_subplot(111)
for axis in ['top','bottom','left','right']:
    ax.spines[axis].set_linewidth(0.5)
plt.rcParams.update({'font.size': 8, 'pgf.rcfonts' : False})

sns.lineplot(data = inflow);
plt.ylabel('Flow, $Q$ [m$^3$/s]');
plt.xlabel('Timesteps');
_images/A-single-confluence_12_0.svg

Then the inflows are set to the sourcenodes

[8]:
structure1.set_shape('S.1',36,I - min(I))
structure1.set_shape('S.2',36,I2 - min(I2))

Note

The minimum flow is subtracted from the input because set_shape adds flow relative to the defined baseload. This behaviour might change in the future.

Calculating wave propagation

[9]:
structure1.calc_flow_propagation(36)
[10]:
structure1.draw_Qin(figsize=(7,4))
[10]:
(<Figure size 672x384 with 1 Axes>,
 <matplotlib.axes._subplots.AxesSubplot at 0x7fde1ff02470>)
_images/A-single-confluence_18_1.svg

In the graph we can see that A.1 is a superposition of S.1 and S.2. and is shifted one timestep to the right. E.1 the outflow of the last reach is than a muskingum transformation of A.1 with \(k = 5\) and \(x = 0.1\). This behaviour is as expected.