aboutsummaryrefslogtreecommitdiff
path: root/makeBoundary.py
diff options
context:
space:
mode:
Diffstat (limited to 'makeBoundary.py')
-rwxr-xr-xmakeBoundary.py21
1 files changed, 14 insertions, 7 deletions
diff --git a/makeBoundary.py b/makeBoundary.py
index d2a48a2..59f4dc0 100755
--- a/makeBoundary.py
+++ b/makeBoundary.py
@@ -23,6 +23,7 @@ definition_dict = read_definition('boundaryDefinition.txt')
slope = abs(definition_dict["slope"]) # slope at top boundary
target_flow = definition_dict["target_flow"] # imposed discharge
location = definition_dict["location"] # boundary location
+plotting = definition_dict["plotting"] # enable or disable plotting
n_co = definition_dict["n_co"] # Manning's 'n' coefficients
# TODO: use weighted mean 'n' values. See
# http://help.floodmodeller.com/isis/ISIS/River_Section.htm (Eq. 4)
@@ -33,6 +34,7 @@ panel = definition_dict["panel"] # panel fill order
ztol = definition_dict["ztol"] # tolerance in overtopping height
numH = definition_dict["numH"] # number of height intervals
+
# print(len(markers))
# with open('./1D_top.txt', "r") as data:
@@ -65,18 +67,22 @@ if location == 'top':
xin = xtp[nrows-1:len(xtp):nrows]
yin = ytp[nrows-1:len(xtp):nrows]
zin = ztp[nrows-1:len(xtp):nrows]
+ outputFilename = "BCTop.txt"
elif location == 'bottom':
xin = xtp[0:len(xtp):nrows]
yin = ytp[0:len(xtp):nrows]
zin = ztp[0:len(xtp):nrows]
+ outputFilename = "BCBottom.txt"
elif location == 'left':
xin = xtp[:nrows]
yin = ytp[:nrows]
zin = ztp[:nrows]
+ outputFilename = "BCLeft.txt"
elif location == 'right':
xin = xtp[nrows*(ncols-1):]
yin = ytp[nrows*(ncols-1):]
zin = ztp[nrows*(ncols-1):]
+ outputFilename = "BCRight.txt"
print(xin)
@@ -204,12 +210,13 @@ for p in range(num_panels):
zregion[p],
zmin[p],
zmax)
- plot_region(
- h_i[p]-zmin[p], 'maximum depth / m',
- r_h[p], 'hydraulic radius / m',
- K_i[p], r'conveyance / $m^3/s$',
- Q_i[p], r'discharge / $m^3/s$',
- 'Panel {}'.format(p))
+ if plotting:
+ plot_region(
+ h_i[p]-zmin[p], 'maximum depth / m',
+ r_h[p], 'hydraulic radius / m',
+ K_i[p], r'conveyance / $m^3/s$',
+ Q_i[p], r'discharge / $m^3/s$',
+ 'Panel {}'.format(p))
# sort list of discharge lists according to panel fill order:
sortedQ = [Q_i[i] for i in panel]
@@ -269,7 +276,7 @@ for i, p in enumerate(panel):
#print('A_i_west = {} A_i = {} A_i_east = {}'.format(A_extra, A_i[-1], A_i_east[-1]))
def save_bc():
- with open('BCTop.txt', 'w') as f:
+ with open(outputFilename, 'w') as f:
f.write('{:6} {:>2} {:>2} {:>10}\n'.format('#x', 'c', 'q', 'h'))
for ind_z, (xitem, zitem) in enumerate(zip(xin, zin)):
panel_x = bisect.bisect(markers, xitem)