Skip to main content

Program for normal depth in trapezoidal channel

Short answer

Use bisection on f(y)=AR^{2/3} - nQ/√S₀ =0, with A=(b+zy)y, P=b+2y√(1+z²). Set lo=0.0001, hi=1; while f(hi)<0, hi*=2. Repeat mid=(lo+hi)/2: if f(mid)>0, hi=mid else lo=mid, until hi-lo<1e-6. Output mid as normal depth.

Write an algorithm, flow chart and computer program in any high level language to determine normal depth in a trapezoidal channel.

The normal depth yny_n satisfies Manning's equation, which cannot be solved directly for yy. It is found numerically by the bisection method on

f(y)=AR2/3−nQS0=0,A=(b+zy)y,P=b+2y1+z2,R=APf(y)=AR^{2/3}-\frac{nQ}{\sqrt{S_0}}=0,\qquad A=(b+zy)y,\quad P=b+2y\sqrt{1+z^2},\quad R=\frac AP

f(y)f(y) increases with yy, so the root is unique.

Algorithm

  1. Read bb, zz, nn, QQ, S0S_0.
  2. Compute the target value K0=nQ/S0K_0=nQ/\sqrt{S_0}.
  3. Set lower limit ylo=0.0001y_{lo}=0.0001 and upper limit yhi=1y_{hi}=1; while f(yhi)<0f(y_{hi})<0, double yhiy_{hi}.
  4. Repeat: ymid=(ylo+yhi)/2y_{mid}=(y_{lo}+y_{hi})/2. If f(ymid)>0f(y_{mid})>0 set yhi=ymidy_{hi}=y_{mid}, else ylo=ymidy_{lo}=y_{mid}.
  5. Stop when yhi−ylo<10−6y_{hi}-y_{lo}<10^{-6} (or 100 iterations).
  6. Print yn=(ylo+yhi)/2y_n=(y_{lo}+y_{hi})/2.

Flow chart

        [Start]
           |
   [Read b,z,n,Q,S0]
           |
   [ylo=0.0001, yhi=1]
           |
     /-----------\ yes
   < f(yhi) < 0 ? >-----> [yhi = 2*yhi] --+
     \-----------/                         |
           | no  <-------------------------+
           v
   [ymid = (ylo+yhi)/2]<---------+
           |                     |
     /-----------\ yes           |
   < f(ymid) > 0 >--> [yhi=ymid] |
     \-----------/               |
           | no                  |
      [ylo=ymid]                 |
           |                     |
     /---------------\ no        |
   < yhi-ylo < 1e-6 ? >----------+
     \---------------/
           | yes
   [Print yn = (ylo+yhi)/2]
           |
        [Stop]

C program

#include <stdio.h>
#include <math.h>

/* f(y) = A*R^(2/3) - n*Q/sqrt(S): zero at the normal depth */
double f(double y, double b, double z, double n, double Q, double S)
{
    double A = (b + z * y) * y;                 /* flow area        */
    double P = b + 2.0 * y * sqrt(1.0 + z * z); /* wetted perimeter */
    double R = A / P;                           /* hydraulic radius */
    return A * pow(R, 2.0 / 3.0) - n * Q / sqrt(S);
}

int main(void)
{
    double b, z, n, Q, S, lo, hi, mid;
    int i;

    printf("Enter b (m), z (H:1V), n, Q (m3/s), S0: ");
    scanf("%lf %lf %lf %lf %lf", &b, &z, &n, &Q, &S);

    lo = 0.0001;
    hi = 1.0;
    while (f(hi, b, z, n, Q, S) < 0.0)   /* bracket the root */
        hi *= 2.0;

    for (i = 0; i < 100; i++) {          /* bisection */
        mid = 0.5 * (lo + hi);
        if (f(mid, b, z, n, Q, S) > 0.0)
            hi = mid;
        else
            lo = mid;
        if (hi - lo < 1e-6)
            break;
    }
    printf("Normal depth yn = %.4f m\n", 0.5 * (lo + hi));
    return 0;
}

Sample run

Input: b = 5, z = 1.5, n = 0.015, Q = 20, S0 = 0.0004

Output: Normal depth yn = 1.7563 m

(The result was checked independently: A=13.409A=13.409 m², R=1.183R=1.183 m, AR2/3=15.000AR^{2/3}=15.000 and nQ/S0=15.000nQ/\sqrt{S_0}=15.000.)

✓ Answer checked by Claude Opus 5.5 (high effort)

All Hydraulics chapter 6 questions →