import math
#Variable Decleration
V_dot=0.2 #Volumetric flow rate in m^3/s
y=0.15 #Depth of flow in m
b=0.4 #Width in m
g=9.81 #Acceleration due to gravity in m/s^2
#Calculations
V=V_dot/(y*b) #Velocity in m/s
yc=(V_dot**2/(g*b**2))**0.33 #Critical depth in m
#Flow is supercritical
Fr=V/((g*y)**0.5) #Froude Number
Es1=y+(V_dot**2/(2*g*b**2*y**2)) #Specific Energy in m
#Alternate Depth
#Solving the Ploynomial Equation
coeff=[1,-Es1,0,V_dot**2/(2*g*b**2)]
x=numpy.roots(coeff)
#Result
print "The velocity of flow is",round(V,2),"m/s"
print "As the froude number Fr",round(Fr,2),"> 1 the flow is supercritical"
print "The Alternate Depth is",round(x[0],3),"m"
import math
#Variable Decleration
b=0.8 #Bottom width of the trapezoidal channel in m
y=0.52 #Depth of flow in m
theta=60 #Angle in degrees
alpha1=0.3 #Slope angle in degrees
n=0.03 #Mannings Coefficient
a=1 #m^1/3/s
alpha2=1 #Slope in degrees
#Calculations
Ac=y*(b+(y/tan((theta*pi)/180))) #Cross-sectional Area in m^2
p=b+((2*y)/sin((theta*pi)/180)) #Perimeter in m
Rh=Ac/p #Hydraulic Radius in m
S01=tan((alpha1*pi)/180) #Slope of the bottom channel
S02=tan((alpha2*pi)/180) #Slope of the bottom channel
V_dot1=(a/n)*(Ac*Rh**0.66*S01**0.5) #Volumetric Flow rate in m^3/s
V_dot2=(a/n)*(Ac*Rh**0.66*S02**0.5) #Volumetric Flow rate in m^3/s
#Result
print "The volumetric flow rate when alpha is 0.3 degrees is",round(V_dot1,2),"m^3/s"
print "The volumetric flow rate when alpha is 1 degrees is",round(V_dot2,2),"m^3/s"
import math
#Variable Decleration
S0=0.003 #Bottom slope
l1=3 #Length in m
p1= 10.486 #Perimeter in section 1 in m
p2=10 #Perimeter of section 2 in m
Ac1=21 #Area of section 1 in m^2
Ac2=16 #Area of section 2 in m^2
a=1 #m^1/3/s
n1=0.03 #Mannings coefficient for section 1
n2=0.05 #Mannings Coefficient for section 2
#Calcualtions
Rh1=Ac1/p1 #Hydraulic Radius at section 1 in m
Rh2=Ac2/p2 #Hydraulic Radius at section 2 in m
Rh=(Ac1+Ac2)/(p1+p2) #Hydraulic Radius of the entire channel in m
V_dot=a*S0**0.5*(((Ac1*Rh1**0.66)/n1)+((Ac2*Rh2**0.66)/n2)) #Volumetric Flow rate in m^3/s
n_eff=(a*(Ac1+Ac2)*Rh**0.66*S0**0.5)/V_dot #Effective Mannings Coefficient
#Result
print "The flow rate is",round(V_dot),"m^3/s"
print "The effective Mannings Coefficient is",round(n_eff,3)
#The decimal point accuracy in python is the possible source of discrepancy in textbook and computed answer
#The answer computed is weel within the permissbile error limit
import math
#NOTE:Variable names have been changed
#Variable Decleration
n=0.016 #mannings Coefficient
V_dot=2 #Volumetric Flow rate in m^3/s
S0=0.001 #Bottom Slope
theta=60 #Angle in degrees
#Calculations
#Part(a)
#Using the Mannings Equation
b1=((2*n*V_dot*4**0.66)/(a*S0**0.5))**0.375 #Width of the Rectangular section in m
Aca=b1**2*0.5 #Area of rectangular section in m^2
p=2*b1 #Perimeter in m
y1=b1/2 #Depth of flow in m
#Part(b)
b2=((n*V_dot)/(0.75*3**0.5*((3**0.5/4)**0.66)*a*S0**0.5))**0.375 #Width in m
y2=((3**0.5)/2)*b2 #Depth of flow in m
#Result
print "The cross-section for rectangular section are b=",round(b1,2),"m y=",round(y1,2),"m"
print "The cross-section for trapezoidal section are b=",round(b2,2),"m y=",round(y2,3),"m"
import math
#Variable Decleration
y=2 #Depth of Flow in m
b=6 #Bottom width in m
a=1 #m^1/3/s
S0=0.004 #Bed Slope
n=0.014 #Mannings Coefficient
g=9.81 #Acceleration due to gravity in m/s^2
#Calculations
Ac=y*b #Area in m^2
p=b+2*y #Perimeter in m
Rh=(Ac*10**-1)/(p*10**-1) #Hydraulic Radius in m
#Flow rate
V_dot=(a/n)*(Ac*Rh**0.66*S0**0.5) #Volumetric Flow rate in m^3/s
#Critical Depth
yc=V_dot**2/(g*Ac**2) #Critical Depth in m
#Result
print "As yn=",round(y,2),"m < yc=",round(yc,2),"m the slope is STEEP"
import math
#Variable Decleration
rho=1000 #Density of water in kg/m^3
g=9.81 #Accelration due to gravity in m/s^2
y1=0.8 #Pre jump height in m
V1=7 #Velocity in m/s pre jump
b=10 #Width of the channel in m
#Calculations
#Part(a)
Fr1=V1/((g*y1)**0.5) #Froude Number pre Jump
#Greater than 1 hence supecritical
y2=0.5*y1*(-1+((1+8*Fr1**2)**0.5)) #Post Jump Height
V2=(y1/y2)*V1 #Velocity post jump in m/s
Fr2=V2/((g*y2)**0.5) #Froude Number after Jump
#Part(b)
h_L=y1-y2+(V1**2-V2**2)/(2*g) #Head Loss in m
Es1=y1+V1**2/(2*g) #Specific Energy before jump in m
Dissipation_Ratio=h_L/Es1 #Dissipiation Ratio
#Part(c)
m_dot=rho*b*y1*V1 #Mass Flow rate in kg/s
E_dissipiated=m_dot*g*h_L #Energy Dissipiated in kW
#Result
print "The Depth of flow after the Jump is",round(y2,2),"m and the Froude Number is",round(Fr2,3)
print "The head loss is",round(h_L,3),"m and the Energy Dissipation Ratio is",round(Dissipation_Ratio,3)
print "The energy wasted is",round(E_dissipiated/1000),"kW"
#NOTE:Answer differ due to decimal point accuracy
import math
#Variable Decleration
y1=3 #Depth of flow in m
a=0.25 #Height of Sluice Gate in m
y2=1.5 #Depth of flow after the turbulence subsides in m
Cd=0.47 #Coefficient of Discharge
b=6 #Width of the channel in m
g=9.81 #Acceleration due to gravity in m/s^2
#Calculations
depth_ratio1=y1/a #Depth ratio
depth_ratio2=y2/a #Depth ratio
V_dot=Cd*b*a*((2*g*y1)**0.5) #Volumetric Flow rate in m^3/s
#Result
print "The volumetric Flow rate is",round(V_dot,2),"m^3/s"
import math
#Variable Decleration
V1=1.2 #Velocity in m/s
g=9.81 #Acceleration due to gravity in m/s^2
y1=0.8 #Depth of flow before encounternign the bump in m
delta_zb=0.15 # depth in m
#Calculations
Fr1=V1/((g*y1)**0.5) #Froude Number
yc=((y1**2*V1**2)/g)**0.33 #Critical depth in m
#Flow is subcritical
Es1=y1+(V1**2/(2*g)) #Specific Energy in m
#Solving the equation
coeff=[1,-0.723,0,0.047]
y=numpy.roots(coeff) #Depth of flow in m
Depression=y1-(y[0]+delta_zb)
#Result
print "The depression of the water surface is present and is",round(Depression,2),"m"
import math
#Variable Decleration
y1=1.5 #Depth of flow in m
Pw=0.6 #Height in m
b=5 #Width in m
g=9.81 #Acceleration due to gravity in m/s^2
#Calculations
H=y1-Pw #Weir Head in m
#Using the Discharge Coefficient Formula
Cwd_rec=0.598+(0.0897*(H/Pw)) #Coefficient of Discharge
V_dot=(2*Cwd_rec*b*(2*g)**0.5*(H**1.5))/3 #Volumetric Flow rate in m^3/s
#Result
print "The Volumetric Flow rate is",round(V_dot,2),"m^3/s"