Skip to main content

Program for alternate depths in rectangular channel

Short answer

Use the specific energy equation E = y + q²/(2gy²). Given one depth, compute E; solve for the other root by Newton-Raphson, starting on the opposite side of critical depth yc. Example: for Q=5 m³/s, b=3 m, y₁=1.5 m, the alternate depth y₂ = 0.3403 m.

Write algorithm and program coding in any high level language (C or Fortran) for computing alternate depths in a rectangular channel section.

Principle. For a given discharge, two depths (one subcritical, one supercritical) have the same specific energy. For a rectangular channel with q=Q/bq = Q/b:

E=y+q22gy2,yc=(q2g)1/3,Emin=1.5 ycE = y + \frac{q^2}{2gy^2},\qquad y_c = \left(\frac{q^2}{g}\right)^{1/3},\qquad E_{min} = 1.5\,y_c

Given depth y1y_1, find EE, then find the other root y2y_2 of f(y)=y+q22gy2−E=0f(y) = y + \dfrac{q^2}{2gy^2} - E = 0 by Newton-Raphson, with f′(y)=1−q2gy3f'(y) = 1 - \dfrac{q^2}{gy^3}. The starting guess is taken on the opposite side of ycy_c from y1y_1 so that the other root is found.

Algorithm

  1. Start.
  2. Read QQ, bb, y1y_1. Set g=9.81g = 9.81.
  3. Compute q=Q/bq = Q/b, yc=(q2/g)1/3y_c = (q^2/g)^{1/3} and E=y1+q2/(2g y12)E = y_1 + q^2/(2g\,y_1^2).
  4. If E<1.5 ycE < 1.5\,y_c, print "flow not possible" and stop.
  5. If y1>ycy_1 > y_c, set y2=0.5 ycy_2 = 0.5\,y_c; otherwise set y2=2 ycy_2 = 2\,y_c.
  6. Repeat: ynew=y2−f(y2)/f′(y2)y_{new} = y_2 - f(y_2)/f'(y_2) (if ynew≤0y_{new} \le 0, halve y2y_2 instead).
  7. Stop when ∣ynew−y2∣<10−8|y_{new} - y_2| < 10^{-8}; set y2=ynewy_2 = y_{new}.
  8. Print EE, ycy_c and y2y_2.
  9. Stop.

Program in C

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

int main(void)
{
    double Q, b, y1, q, E, yc, y2, f, df, yn;
    int i;

    printf("Enter Q (m3/s), b (m), y1 (m): ");
    scanf("%lf %lf %lf", &Q, &b, &y1);

    q  = Q / b;
    yc = cbrt(q * q / G);                      /* critical depth */
    E  = y1 + q * q / (2.0 * G * y1 * y1);     /* specific energy */

    if (E < 1.5 * yc - 1e-9) {
        printf("E is less than Emin = %.4f m : flow impossible\n", 1.5 * yc);
        return 0;
    }
    /* start on the opposite side of yc */
    y2 = (y1 > yc) ? 0.5 * yc : 2.0 * yc;

    for (i = 0; i < 100; i++) {
        f  = y2 + q * q / (2.0 * G * y2 * y2) - E;
        df = 1.0 - q * q / (G * y2 * y2 * y2);
        if (fabs(df) < 1e-12) break;
        yn = y2 - f / df;
        if (yn <= 0.0) yn = 0.5 * y2;          /* keep depth positive */
        if (fabs(yn - y2) < 1e-8) { y2 = yn; break; }
        y2 = yn;
    }
    printf("E = %.4f m, yc = %.4f m\n", E, yc);
    printf("Alternate depth y2 = %.4f m\n", y2);
    return 0;
}

Sample run: Q=5 m3/sQ = 5\ \text{m}^3/\text{s}, b=3 mb = 3\ \text{m}, y1=1.5 my_1 = 1.5\ \text{m} gives E=1.5629 mE = 1.5629\ \text{m}, yc=0.6567 my_c = 0.6567\ \text{m} and alternate depth y2=0.3403 my_2 = 0.3403\ \text{m}.

✓ Answer checked by Claude Opus 5.5 (high effort)

All Hydraulics chapter 7 questions →