- 2068 Bhadra · 2+5 marks
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 of a rectangular channel is found from Manning's equation. It is non-linear in , so Newton-Raphson is used.
Algorithm
- Start.
- Read , , , .
- Compute the target and take the initial guess m.
- Repeat steps 5-8 up to 50 times:
- Compute , , .
- Compute and .
- ; if take .
- If stop; otherwise set .
- Print the uniform depth .
- 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: m², m, m, , ✓.
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Program for critical depth in trapezoidal channel · Hydraulics, chapter 7
- Program for alternate depths in rectangular channel · Hydraulics, chapter 7
- Program for normal depth in trapezoidal channel · Hydraulics, chapter 6
- Normal depth in compound channel · Hydraulics, chapter 6
- Hump and constriction: critical depth, 2 m channel · Hydraulics, chapter 7 · asked 2×
- Hump and constriction: critical depth, 1.8 m channel · Hydraulics, chapter 7
- High level languages; C versus FORTRAN · Computer Programming, chapter 1
- Uniform flow in rectangular channel (Chezy) · Hydro Power, chapter 1
- High level languages and natural language · Computer Programming, chapter 1
- Efficient rectangular section and triangular channel depth · Hydro Power, chapter 1 · asked 2×