Download (right-click, save target as ...) this page as a Jupyterlab notebook from: CHYD-2
LAST NAME, FIRST NAME
R00000000
Apply computational thinking (ENGR 1330) principles and hydraulics/fluid mechanics principles to produce a plot of water surface in an open channel.
Completion, plausible solutions, use JupyterLab as a calculator.
Water flows at a steady rate of 192 $\frac{ft^3}{s}$ through a concrete-lined rectangular channel 16 ft wide as depicted in Figure 1. Water enters the 0.35% sloped channel ($S_0$ = 0.0035) at location 1 and is flowing at 110% normal depth ($1.1 \times y_n$). The water exits over a 3-foot tall weir (assume sharp-crest weir) at location 2.1
Find:
# sketch here
# list known quantities
# list unknown quantities
# governing principles (fluid mechanics)
# solution (using JupyterLab notebook) (computational thinking/algorithm development)
# prototype functions
def A_rect(B,y):
A_rect = B*y
return(A_rect)
def P_rect(B,y):
P_rect = B + y + y
return(P_rect)
def Rh(A,P):
Rh = A/P
return(Rh)
def slope_f(discharge,mannings_n,area,radius):
slope_f = (discharge**2)*(mannings_n**2)/( (radius**(4/3))*(area**2) )
return(slope_f)
# input information
begin_depth = 4.64
end_depth = 0.3
discharge = 192
how_many = 199
manningn = 0.015
slope = 0.0035
width = 16
import numpy
# empty lists for variables
depth = [0 for i in range(how_many)] #flow depth
bse = [0 for i in range(how_many)] #channel bottom elevation
wse = [0 for i in range(how_many)] #water surface elevation
deltax = [0 for i in range(how_many)] #space steps
distance = [0 for i in range(how_many)] #station locations
velocity = [0 for i in range(how_many)] #section velocity
delta_depth = (begin_depth-end_depth)/(how_many-1)# change in depth for finding spatial steps
depth[0] = (begin_depth) # assign downstream value
for i in range(how_many):
depth[i] = (depth[0]-i*delta_depth)# depth values to evaluate
velocity[i] = (discharge/A_rect(width,depth[i])) #velocity for each depth
for i in range(how_many-1):
depth_bar = 0.5*(depth[i]+depth[i+1]) #compute average depth in reach
area_bar = A_rect(width,depth_bar) #compute average area in reach
perimeter_bar = P_rect(width,depth_bar) #compute average wetted perimeter
radius_bar = Rh(area_bar,perimeter_bar) #compute average hydraulic radius
friction = slope_f(discharge,manningn,area_bar,radius_bar) #compute friction slope
deltax[i] = ((depth[i+1]+(velocity[i+1]**2)/(2*9.8)) - (depth[i] + (velocity[i]**2)/(2*9.8)))/(slope-friction)
#if numpy.sign(deltax[i]) != numpy.sign(deltax[i-1]) :
#raise Exception(print('hydraulic jump nearby - switch delta x sign'))
wse[0]=bse[0]+depth[0] # water surface at control point
for i in range(1,how_many):
distance[i] = distance[i-1]+deltax[i-1]; # station distances
bse[i] = bse[i-1]-deltax[i-1]*slope; # bottom elevations
wse[i] = bse[i]+depth[i] # water surface elevations
import matplotlib.pyplot as plt # the python plotting library
plottitle ='Water Surface Profile for Q=' + str(round(discharge,1)) + ' CMS '
mydata = plt.figure(figsize = (10,5)) # build a square drawing canvass from figure class
plt.plot(distance, bse, c='black') # basic line plot
plt.plot(distance, wse, c='blue') # basic line plot
plt.legend(['Channel Bottom','Water Surface'])
plt.xlabel('Station Location (meters)')
plt.ylabel('Elevation (meters)')
plt.title(plottitle)
plt.show()
print("Depth at station",distance[how_many-1]," is",depth[how_many-1])
in the code see exception block, one can try to correct for the hydraulic jump, but out of scope for the class.
or do into two parts entry to yc, then yc to flow over weir as below
# input information
begin_depth = 0.3
end_depth = 1.63
discharge = 192
how_many = 199
manningn = 0.015
slope = 0.0035
width = 16
import numpy
# empty lists for variables
depth = [0 for i in range(how_many)] #flow depth
bse = [0 for i in range(how_many)] #channel bottom elevation
wse = [0 for i in range(how_many)] #water surface elevation
deltax = [0 for i in range(how_many)] #space steps
distance = [0 for i in range(how_many)] #station locations
velocity = [0 for i in range(how_many)] #section velocity
delta_depth = (begin_depth-end_depth)/(how_many-1)# change in depth for finding spatial steps
depth[0] = (begin_depth) # assign downstream value
for i in range(how_many):
depth[i] = (depth[0]-i*delta_depth)# depth values to evaluate
velocity[i] = (discharge/A_rect(width,depth[i])) #velocity for each depth
for i in range(how_many-1):
depth_bar = 0.5*(depth[i]+depth[i+1]) #compute average depth in reach
area_bar = A_rect(width,depth_bar) #compute average area in reach
perimeter_bar = P_rect(width,depth_bar) #compute average wetted perimeter
radius_bar = Rh(area_bar,perimeter_bar) #compute average hydraulic radius
friction = slope_f(discharge,manningn,area_bar,radius_bar) #compute friction slope
deltax[i] = ((depth[i+1]+(velocity[i+1]**2)/(2*9.8)) - (depth[i] + (velocity[i]**2)/(2*9.8)))/(slope-friction)
#if numpy.sign(deltax[i]) != numpy.sign(deltax[i-1]) :
#raise Exception(print('hydraulic jump nearby - switch delta x sign'))
wse[0]=bse[0]+depth[0] # water surface at control point
for i in range(1,how_many):
distance[i] = distance[i-1]+deltax[i-1]; # station distances
bse[i] = bse[i-1]-deltax[i-1]*slope; # bottom elevations
wse[i] = bse[i]+depth[i] # water surface elevations
import matplotlib.pyplot as plt # the python plotting library
plottitle ='Water Surface Profile for Q=' + str(round(discharge,1)) + ' CMS '
mydata = plt.figure(figsize = (10,5)) # build a square drawing canvass from figure class
plt.plot(distance, bse, c='black') # basic line plot
plt.plot(distance, wse, c='blue') # basic line plot
plt.legend(['Channel Bottom','Water Surface'])
plt.xlabel('Station Location (meters)')
plt.ylabel('Elevation (meters)')
plt.title(plottitle)
plt.show()
print("Depth at station",distance[how_many-1]," is",depth[how_many-1])
526 meters
# input information
begin_depth = 1.65
end_depth = 2.1
discharge = 192
how_many = 199
manningn = 0.015
slope = 0.0035
width = 16
import numpy
# empty lists for variables
depth = [0 for i in range(how_many)] #flow depth
bse = [0 for i in range(how_many)] #channel bottom elevation
wse = [0 for i in range(how_many)] #water surface elevation
deltax = [0 for i in range(how_many)] #space steps
distance = [0 for i in range(how_many)] #station locations
velocity = [0 for i in range(how_many)] #section velocity
delta_depth = (begin_depth-end_depth)/(how_many-1)# change in depth for finding spatial steps
depth[0] = (begin_depth) # assign downstream value
for i in range(how_many):
depth[i] = (depth[0]-i*delta_depth)# depth values to evaluate
velocity[i] = (discharge/A_rect(width,depth[i])) #velocity for each depth
for i in range(how_many-1):
depth_bar = 0.5*(depth[i]+depth[i+1]) #compute average depth in reach
area_bar = A_rect(width,depth_bar) #compute average area in reach
perimeter_bar = P_rect(width,depth_bar) #compute average wetted perimeter
radius_bar = Rh(area_bar,perimeter_bar) #compute average hydraulic radius
friction = slope_f(discharge,manningn,area_bar,radius_bar) #compute friction slope
deltax[i] = ((depth[i+1]+(velocity[i+1]**2)/(2*9.8)) - (depth[i] + (velocity[i]**2)/(2*9.8)))/(slope-friction)
#if numpy.sign(deltax[i]) != numpy.sign(deltax[i-1]) :
#raise Exception(print('hydraulic jump nearby - switch delta x sign'))
wse[0]=bse[0]+depth[0] # water surface at control point
for i in range(1,how_many):
distance[i] = distance[i-1]+deltax[i-1]; # station distances
bse[i] = bse[i-1]-deltax[i-1]*slope; # bottom elevations
wse[i] = bse[i]+depth[i] # water surface elevations
import matplotlib.pyplot as plt # the python plotting library
plottitle ='Water Surface Profile for Q=' + str(round(discharge,1)) + ' CMS '
mydata = plt.figure(figsize = (10,5)) # build a square drawing canvass from figure class
plt.plot(distance, bse, c='black') # basic line plot
plt.plot(distance, wse, c='blue') # basic line plot
plt.legend(['Channel Bottom','Water Surface'])
plt.xlabel('Station Location (meters)')
plt.ylabel('Elevation (meters)')
plt.title(plottitle)
plt.show()
print("Depth at station",distance[how_many-1]," is",depth[how_many-1])
# input information
begin_depth = 2.45
end_depth = 4.64
discharge = 192
how_many = 199
manningn = 0.015
slope = 0.0035
width = 16
import numpy
# empty lists for variables
depth = [0 for i in range(how_many)] #flow depth
bse = [0 for i in range(how_many)] #channel bottom elevation
wse = [0 for i in range(how_many)] #water surface elevation
deltax = [0 for i in range(how_many)] #space steps
distance = [0 for i in range(how_many)] #station locations
velocity = [0 for i in range(how_many)] #section velocity
delta_depth = (begin_depth-end_depth)/(how_many-1)# change in depth for finding spatial steps
depth[0] = (begin_depth) # assign downstream value
for i in range(how_many):
depth[i] = (depth[0]-i*delta_depth)# depth values to evaluate
velocity[i] = (discharge/A_rect(width,depth[i])) #velocity for each depth
for i in range(how_many-1):
depth_bar = 0.5*(depth[i]+depth[i+1]) #compute average depth in reach
area_bar = A_rect(width,depth_bar) #compute average area in reach
perimeter_bar = P_rect(width,depth_bar) #compute average wetted perimeter
radius_bar = Rh(area_bar,perimeter_bar) #compute average hydraulic radius
friction = slope_f(discharge,manningn,area_bar,radius_bar) #compute friction slope
deltax[i] = ((depth[i+1]+(velocity[i+1]**2)/(2*9.8)) - (depth[i] + (velocity[i]**2)/(2*9.8)))/(slope-friction)
#if numpy.sign(deltax[i]) != numpy.sign(deltax[i-1]) :
#raise Exception(print('hydraulic jump nearby - switch delta x sign'))
wse[0]=bse[0]+depth[0] # water surface at control point
for i in range(1,how_many):
distance[i] = distance[i-1]+deltax[i-1]; # station distances
bse[i] = bse[i-1]-deltax[i-1]*slope; # bottom elevations
wse[i] = bse[i]+depth[i] # water surface elevations
import matplotlib.pyplot as plt # the python plotting library
plottitle ='Water Surface Profile for Q=' + str(round(discharge,1)) + ' CMS '
mydata = plt.figure(figsize = (10,5)) # build a square drawing canvass from figure class
plt.plot(distance, bse, c='black') # basic line plot
plt.plot(distance, wse, c='blue') # basic line plot
plt.legend(['Channel Bottom','Water Surface'])
plt.xlabel('Station Location (meters)')
plt.ylabel('Elevation (meters)')
plt.title(plottitle)
plt.show()
print("Depth at station",distance[how_many-1]," is",depth[how_many-1])
# total distance
486+384+526