Skip to main content

Program for critical depth in trapezoidal channel

Short answer

The algorithm solves f(y) = Q^2 T − g A^3 = 0 for trapezoidal section with A = (b+zy)y, T = b+2zy by bisection. Bracketing the root by doubling y_high until f changes sign, then iterating to tolerance 1e-6. Example: for Q=6, b=2.5, z=2, yc = 0.691 m. The C program implements this.

Write algorithm and programme coding in any high level language (C or Fortran) for determination of critical depth in trapezoidal channel section.

Principle. Critical flow requires Q2TgA3=1\dfrac{Q^2 T}{g A^3} = 1. For a trapezoidal section with bed width bb and side slope zz (z H : 1 V):

A=(b+zy)y,T=b+2zyA = (b + zy)y,\quad T = b + 2zy

Define f(y)=Q2T−gA3f(y) = Q^2 T - gA^3. The critical depth is the root of f(y)=0f(y) = 0. f>0f > 0 for y<ycy < y_c and f<0f < 0 for y>ycy > y_c, so the bisection method always converges.

Algorithm

  1. Start.
  2. Read QQ, bb, zz. Set g=9.81g = 9.81 and tolerance ε=10−6\varepsilon = 10^{-6}.
  3. Set ylow=10−6y_{low} = 10^{-6} and yhigh=1y_{high} = 1.
  4. While f(yhigh)>0f(y_{high}) > 0, set yhigh=2 yhighy_{high} = 2\,y_{high} (bracket the root).
  5. Repeat: ymid=(ylow+yhigh)/2y_{mid} = (y_{low} + y_{high})/2.
    • If f(ymid)>0f(y_{mid}) > 0, set ylow=ymidy_{low} = y_{mid}; otherwise set yhigh=ymidy_{high} = y_{mid}.
  6. Stop repeating when yhigh−ylow<εy_{high} - y_{low} < \varepsilon.
  7. Print yc=(ylow+yhigh)/2y_c = (y_{low} + y_{high})/2.
  8. Stop.

Program in C

#include <stdio.h>
#include <math.h>
#define G 9.81

/* f(y) = Q^2*T - g*A^3 ; zero at critical depth */
double f(double y, double Q, double b, double z)
{
    double A = (b + z * y) * y;
    double T = b + 2.0 * z * y;
    return Q * Q * T - G * A * A * A;
}

int main(void)
{
    double Q, b, z, lo, hi, mid, tol = 1e-6;
    int i;

    printf("Enter discharge Q (m3/s): ");
    scanf("%lf", &Q);
    printf("Enter bed width b (m): ");
    scanf("%lf", &b);
    printf("Enter side slope z (z H : 1 V): ");
    scanf("%lf", &z);

    lo = 1e-6;
    hi = 1.0;
    while (f(hi, Q, b, z) > 0.0)      /* expand until sign changes */
        hi *= 2.0;

    for (i = 0; i < 100 && (hi - lo) > tol; i++) {
        mid = 0.5 * (lo + hi);
        if (f(mid, Q, b, z) > 0.0)
            lo = mid;                 /* root is deeper */
        else
            hi = mid;                 /* root is shallower */
    }
    mid = 0.5 * (lo + hi);
    printf("Critical depth yc = %.4f m\n", mid);
    return 0;
}

Sample run: Q=6Q = 6, b=2.5b = 2.5, z=2z = 2 gives yc=0.6912 my_c = 0.6912\ \text{m}.

Setting z=0z = 0 gives a rectangular channel and b=0b = 0 gives a triangular channel, so the same program handles all three shapes.

✓ Answer checked by Claude Opus 5.5 (high effort)

All Hydraulics chapter 7 questions →