Skip to main content

Program for uniform depth in rectangular channel

Short answer

Newton-Raphson solves f(y)=A R^(2/3)−nQ/√S₀=0, with A=by, P=b+2y, R=A/P; derivative f′(y)=R^(2/3)(5b/3−4R/3). Iterate y ← y − f/f′ from y=1 m. For b=5 m, n=0.015, Q=15 m³/s, S₀=0.0004, uniform depth y_n = 2.07 m.

Write algorithm and programme coding in any high level language (C or Fortran) for calculating uniform depth for rectangular channel.

The uniform (normal) depth yny_n of a rectangular channel is found from Manning's equation. It is non-linear in yy, so Newton-Raphson is used.

f(y)=AR2/3−nQS0=0,A=by,P=b+2y,R=APf(y)=AR^{2/3}-\frac{nQ}{\sqrt{S_0}}=0,\qquad A=by,\quad P=b+2y,\quad R=\frac AP dfdy=R2/3[53b−43R],ynew=y−f(y)f′(y)\frac{df}{dy}=R^{2/3}\left[\frac53b-\frac43R\right],\qquad y_{new}=y-\frac{f(y)}{f'(y)}

Algorithm

  1. Start.
  2. Read bb, nn, QQ, S0S_0.
  3. Compute the target K0=nQ/S0K_0=nQ/\sqrt{S_0} and take the initial guess y=1y=1 m.
  4. Repeat steps 5-8 up to 50 times:
  5. Compute A=byA=by, P=b+2yP=b+2y, R=A/PR=A/P.
  6. Compute f=AR2/3−K0f=AR^{2/3}-K_0 and f′=R2/3[(5/3)b−(4/3)R]f'=R^{2/3}[(5/3)b-(4/3)R].
  7. ynew=y−f/f′y_{new}=y-f/f'; if ynew≤0y_{new}\le0 take ynew=y/2y_{new}=y/2.
  8. If ∣ynew−y∣<10−6|y_{new}-y|<10^{-6} stop; otherwise set y=ynewy=y_{new}.
  9. Print the uniform depth yny_n.
  10. Stop.

Program (C)

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

/* Newton-Raphson for the uniform (normal) depth of a rectangular channel */
int main(void)
{
    double b, n, Q, S, y, A, P, R, f, dfdy, ynew, target;
    int i;

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

    target = n * Q / sqrt(S);        /* required value of A*R^(2/3) */
    y = 1.0;                         /* initial guess */

    for (i = 1; i <= 50; i++) {
        A = b * y;
        P = b + 2.0 * y;
        R = A / P;
        f = A * pow(R, 2.0 / 3.0) - target;
        /* d(A R^(2/3))/dy = R^(2/3) * ( (5/3) b - (2/3) R * 2 ) */
        dfdy = pow(R, 2.0 / 3.0) * ((5.0 / 3.0) * b - (4.0 / 3.0) * R);
        ynew = y - f / dfdy;
        if (ynew <= 0.0)             /* keep depth positive */
            ynew = 0.5 * y;
        if (fabs(ynew - y) < 1e-6) {
            y = ynew;
            break;
        }
        y = ynew;
    }
    printf("Uniform depth yn = %.4f m (after %d iterations)\n", y, i);
    return 0;
}

Sample run

Input: 5 0.015 15 0.0004 (b = 5 m, n = 0.015, Q = 15 m³/s, S0 = 0.0004)

Output: Uniform depth yn = 2.0708 m (after 4 iterations)

Check: A=10.354A=10.354 m², P=9.142P=9.142 m, R=1.1325R=1.1325 m, AR2/3=11.25AR^{2/3}=11.25, nQ/S0=11.25nQ/\sqrt{S_0}=11.25 ✓.

✓ Answer checked by Claude Opus 5.5 (high effort)

All Hydraulics chapter 6 questions →