- 2076 Baisakh · 8 marks
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 satisfies Manning's equation, which cannot be solved directly for . It is found numerically by the bisection method on
increases with , so the root is unique.
Algorithm
- Read , , , , .
- Compute the target value .
- Set lower limit and upper limit ; while , double .
- Repeat: . If set , else .
- Stop when (or 100 iterations).
- Print .
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: m², m, and .)
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Program for critical depth in trapezoidal channel · Hydraulics, chapter 7
- Normal depth in compound channel · Hydraulics, chapter 6
- Program for uniform depth in rectangular channel · Hydraulics, chapter 6
- Program for alternate depths in rectangular channel · Hydraulics, chapter 7
- Bed slope for critical normal depth · Hydraulics, chapter 7
- Distance to within 5% of normal depth · Hydraulics, chapter 8
- Efficient trapezoidal section and triangular channel depth · Hydro Power, chapter 1 · asked 2×
- High level languages and natural language · Computer Programming, chapter 1
- Normal depth in triangular channel (1:1) · Hydro Power, chapter 1 · asked 2×
- Remez exchange algorithm with flow chart · Digital Signal Analysis and Processing, chapter 5 · asked 4×