-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfuns_dikes.py
84 lines (62 loc) · 2.21 KB
/
funs_dikes.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# -*- coding: utf-8 -*-
"""
Created on Thu Jul 06 14:51:04 2017
@author: ciullo
"""
import numpy as np
def dikefailure(sb, inflow, hriver, hbas, hground, status_t1,
Bmax, Brate, simtime, tbreach, critWL):
''' Function establising dike failure as well as flow balance between the
river and the polder
inflow = flow coming into the node
status = if False the dike has not failed yet
critWL = water level above which we have failure
'''
tbr = tbreach
# h1 = hriver - hbreach
# h2 = (hbas + hground) - hbreach
# h river is a water level, hbas a water depth
h1 = hriver - (hground + hbas)
# if the dike has already failed:
if status_t1 == True:
B = Bmax * (1 - np.exp(-Brate * (simtime - tbreach)))
if h1 > 0:
breachflow = 1.7 * B * (h1)**1.5
# h1 <0 ==> no flow:
else:
breachflow = 0
outflow = max(0, inflow - breachflow)
status_t2 = status_t1
# if the dike has not failed yet:
else:
failure = hriver > critWL
outflow = inflow
breachflow = 0
# if it fails:
if failure:
status_t2 = True
tbr = simtime
# if it does not:
else:
status_t2 = False
# if effects of hydrodynamic system behaviour have to be ignored:
if sb == False:
outflow = inflow
return outflow, breachflow, status_t2, tbr
def Lookuplin(MyFile, inputcol, searchcol, inputvalue):
''' Linear lookup function '''
minTableValue = np.min(MyFile[:, inputcol])
maxTableValue = np.max(MyFile[:, inputcol])
if inputvalue >= maxTableValue:
inputvalue = maxTableValue - 0.01
elif inputvalue < minTableValue:
inputvalue = minTableValue + 0.01
A = np.max(MyFile[MyFile[:, inputcol] <= inputvalue, inputcol])
B = np.min(MyFile[MyFile[:, inputcol] > inputvalue, inputcol])
C = np.max(MyFile[MyFile[:, inputcol] == A, searchcol])
D = np.min(MyFile[MyFile[:, inputcol] == B, searchcol])
outpuvalue = C - ((D - C) * ((inputvalue - A) / (A - B))) * 1.0
return outpuvalue
def init_node(value, time):
init = np.repeat(value, len(time)).tolist()
return init