damyarou

python, GMT などのプログラム

Python : Calculation of normal depth of open channel with rectangular cross section by 'scipy.optimize.brentq'

Calculation program of normal depth of open channel with rectangular cross sectionby Brent's method is introduced in this post. Basic equations for normal depth calculation of open channel with rectangular cross section are shown below.


\begin{gather}
Q=A\cdot v \\
v=\cfrac{1}{n}\cdot R^{2/3}\cdot i^{1/2} \\
R=\cfrac{b\cdot h}{b+2\cdot h}
\end{gather}
Q(known) discharge
b(known) width of rectangular open channe
n(known) Manning's roughness coefficient
i(known) gradient of channel invert
h(unknown) normal depth

Following equation is solved for h.


\begin{equation}
f=Q-\cfrac{b\cdot h}{n}\cdot \left(\cfrac{b\cdot h}{b+2\cdot h}\right)^{2/3}\cdot i^{1/2}=0
\end{equation}

The critical depth calculation of h_c is extra.

# normal depth and critical depth of rectangular cross section
import numpy as np
from scipy import optimize


def cal_hc(q,b):
    # critical depth
    g=9.8
    hc=(q**2/g/b**2)**(1/3)
    return hc


def func(h,q,b,n,i):
    f=q-b*h/n*(b*h/(b+2*h))**(2/3)*i**(1/2)    
    return f    


def main():
    q=42.0  # discharge
    b=4.0   # channel width
    n=0.014 # Manning's roughness coefficient
    i=0.001 # invert gradient
    
    h1=0.0
    h2=10.0
    hh=optimize.brentq(func,h1,h2,args=(q,b,n,i))

    print('hn=',hh) # normal depth
    
    hc=cal_hc(q,b)
    print('hc=',hc) # critical depth
    
#==============
# Execution
#==============
if __name__ == '__main__': main()

Calculation results are shown below.

hn= 3.866645305835682
hc= 2.2407023732785825

That's all. Thank you.