- 2069 Poush · 6 marks
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 :
Given depth , find , then find the other root of by Newton-Raphson, with . The starting guess is taken on the opposite side of from so that the other root is found.
Algorithm
- Start.
- Read , , . Set .
- Compute , and .
- If , print "flow not possible" and stop.
- If , set ; otherwise set .
- Repeat: (if , halve instead).
- Stop when ; set .
- Print , and .
- 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: , , gives , and alternate depth .
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Program for uniform depth in rectangular channel · Hydraulics, chapter 6
- Froude number ratio for alternate depths · Hydraulics, chapter 7
- Specific energy from alternate depths · Hydraulics, chapter 7
- Program for critical depth in trapezoidal channel · Hydraulics, chapter 7
- Program for normal depth in trapezoidal channel · Hydraulics, chapter 6
- Hydraulic exponent for rectangular section 10/3 · Hydraulics, chapter 6 · asked 2×
- High level languages; C versus FORTRAN · Computer Programming, chapter 1
- High level languages and natural language · Computer Programming, chapter 1
- Most economical rectangular channel section · Hydro Power, chapter 1 · asked 2×
- Efficient rectangular section and triangular channel depth · Hydro Power, chapter 1 · asked 2×