I wrote a simple Python code to solve a certain Hydraulic formula (The Manning's equation):
import math
def mannings(units,A,P,S,n):
if units=='SI':
k=1.0
elif units=='US':
k=1.49
R=A/P
V=(k/n)*(math.pow(R,(2/3)))*(math.sqrt(S))
Q=A*V
return R,V,Q
In the code above, the velocity V
is calculated from the k
, n
, R
and S
. The velocity is then used to calculate the discharge Q
by multiplying with Area A
. The user inputs the unit convention, the A
, P
, S
and n
. k
is decided on the basis of unit convention.
When I run the function using mannings('US',1.0618,2.7916,0.02,0.015)
, I get (0.38035535176959456, 14.047854719572745, 14.916012141242343)
. The R
value matches the R
calculated in a spreadsheet, but the V
and Q
are way off. The actual V
should be 7.374638178
and the Q
should be 7.830634155
.
It'd be great if someone can tell me what's going wrong here. This is a pretty straightforward formula and I was guessing it should work easily.