Showing posts with label GATE preparations. Show all posts
Showing posts with label GATE preparations. Show all posts

Monday, September 14, 2020

Python Code - Discharge in Rectangular Channel using Manning's Formula

 Hi,

Next in the series 'Python for Civil Engineers' is the code for Manning's formula for the rectangular channel.



One has to provide the needed inputs to get the discharge, in the given rectangular channel, as the output. The Manning's formula for discharge calculations can be used for various channels such as rectangular, trapezoidal etc. The Python code in this post is written for the rectangular channel, in particular. Inputs needed are Manning's n, slope s, bottom width b, and water depth h. Also, mention the units when asked. 

def discharge():
n = float(input("n = Manning's value = "))
S = float(input("S = Channel's slope = "))
u = input("unit of width/height (m or ft)= ")
b = float(input("b = bottom width = "))
h = float(input("h = water depth = "))
k = 1
u1 = "Cumecs"
if u.lower() == "ft":
u1 = "cfs"
if u.lower() == "ft":
k = 1.49

Q = (k/n) * (b * h) * (b * h / (2.0 * h + b)) ** (2.0 / 3.0) * S ** (0.5)
Q = round(Q,3)
print(f' Q = {Q} {u1}')
return Q

print('''
Manning's Formula for discharge in rectangular channel Q = (k * A * R^(2/3) * S^0.5) / n
Q = Flow Rate, (in cfs, or m)
k = 1.49 for discharge in cfs, and 1 for in cumecs
A = Area of section = b*h , b = bottom width, h = water depth
R = hydraulic Radius = Area/Wetted Perimeter = bh/(2h+b)
n = Manning's Roughness coefficient
''')

print(f'Inputs needed to calculate the discharge Q')
discharge()

Thanks!

Resume-Now (BOLD LLC) is a FRAUD | defrauds Innocent Job Seekers

 Hi, Are you looking for a job change or a first-time job seeker?  I know, a somewhat difficult and desperate time it is sometimes.  In such...