- 2068 Magh · 6 marks
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 . For a trapezoidal section with bed width and side slope (z H : 1 V):
Define . The critical depth is the root of . for and for , so the bisection method always converges.
Algorithm
- Start.
- Read , , . Set and tolerance .
- Set and .
- While , set (bracket the root).
- Repeat: .
- If , set ; otherwise set .
- Stop repeating when .
- Print .
- 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: , , gives .
Setting gives a rectangular channel and gives a triangular channel, so the same program handles all three shapes.
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Program for normal depth in trapezoidal channel · Hydraulics, chapter 6
- Program for uniform depth in rectangular channel · Hydraulics, chapter 6
- Program for alternate depths in rectangular channel · Hydraulics, chapter 7
- Critical depth in four channel sections · Hydraulics, chapter 7
- 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
- Efficient trapezoidal section and triangular channel depth · Hydro Power, chapter 1 · asked 2×
- High level languages; C versus FORTRAN · Computer Programming, 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×