---
title: "Water hammer: rectangular grid and specified intervals"
subject: "Computational Techniques in Civil Engineering"
chapter: 6
key: "semester_8/computational_techniques_in_civil_engineering:water-hammer-numerical-solution"
source: https://www.bctengineer.com/q/semester_8/computational_techniques_in_civil_engineering/water-hammer-numerical-solution
site: BCT Engineering
---

# Water hammer: rectangular grid and specified intervals

Computational Techniques in Civil Engineering · Chapter 6: Method of Characteristics

- Asked in: 2079 Shrawan, 4+4 marks
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_8/computational_techniques_in_civil_engineering/water-hammer-numerical-solution
- Whole chapter: https://www.bctengineer.com/md/semester_8/computational_techniques_in_civil_engineering/chapter-6

## Question

Derive a numerical solution for evaluating the water hammer problem. (a) Using a rectangular grid, characteristics passing through the diagonal. (b) Using specified time intervals (characteristics not on the diagonal).

## Short answer

Use characteristic equations C+ and C- integrated by finite differences. On diagonal grid with dt=dx/a, no interpolation: K1=H_A+BpQ_A-RpQ_A|Q_A|, K2=H_B-BpQ_B+RpQ_B|Q_B|, Q_P=(K1-K2)/(2Bp), H_P=(K1+K2)/2. If dt is smaller, interpolate R and S with theta=a dt/dx, then use same formulas with R and S and friction length a dt.

## Answer

Water hammer is the pressure surge produced by a rapid change of velocity (valve closure, pump trip). It is solved with the characteristic equations of unsteady pipe flow.

For unsteady flow in a closed pipe (area $A_p$, diameter $D$, wave speed $a$, Darcy-Weisbach factor $f$), with head $H$ and discharge $Q$:

**Momentum:**
$$
L_1=\frac{\partial Q}{\partial t}+gA_p\frac{\partial H}{\partial x}+\frac{f\,Q|Q|}{2DA_p}=0
$$
**Continuity:**
$$
L_2=\frac{\partial H}{\partial t}+\frac{a^2}{gA_p}\frac{\partial Q}{\partial x}=0
$$

Along $C^+$ ($dx/dt=+a$) and $C^-$ ($dx/dt=-a$):
$$
C^+:\ \frac{dH}{dt}+\frac{a}{gA_p}\frac{dQ}{dt}+\frac{af}{2gDA_p^2}Q|Q|=0,\qquad
C^-:\ \frac{dH}{dt}-\frac{a}{gA_p}\frac{dQ}{dt}-\frac{af}{2gDA_p^2}Q|Q|=0
$$
Let $B_p=\dfrac{a}{gA_p}$.

#### (a) Rectangular grid: characteristics through the diagonal
Divide the pipe into $N$ reaches of length $\Delta x=L/N$ and choose $\Delta t=\Delta x/a$. The $C^+$ and $C^-$ lines through P then pass exactly through the grid points A and B of the previous time level.

```text
 t+dt :         P
               /|\
         C+  /  |  \  C-
 t    :    A----C----B
```
Integrating $C^+$ from A to P and $C^-$ from B to P (friction at the known end), with $R_p=\dfrac{f\Delta x}{2gDA_p^2}$:
$$
H_P=H_A-B_p(Q_P-Q_A)-R_pQ_A|Q_A|,\qquad H_P=H_B+B_p(Q_P-Q_B)+R_pQ_B|Q_B|
$$
With $K_1=H_A+B_pQ_A-R_pQ_A|Q_A|$ and $K_2=H_B-B_pQ_B+R_pQ_B|Q_B|$:
$$
Q_P=\frac{K_1-K_2}{2B_p},\qquad H_P=\frac{K_1+K_2}{2}
$$
No interpolation is needed. **Boundaries:** upstream reservoir, $H_P=H_{res}$ and $Q_P=(H_{res}-K_2)/B_p$; closed downstream valve, $Q_P=0$ and $H_P=K_1$.

#### (b) Specified time intervals: characteristics not on the diagonal
When $\Delta t$ and $\Delta x$ are chosen independently (for example to get the same $\Delta t$ in pipes of different length), the Courant condition $a\Delta t\le\Delta x$ must hold. The characteristics through P cut the time line at points R and S **between** grid points.

```text
 t+dt :              P
                    /|\
              C+  /  |  \  C-
 t    :   A-----R----C----S-----B
```
With $\theta=\dfrac{a\Delta t}{\Delta x}\le1$, linear interpolation gives
$$
Q_R=Q_C-\theta(Q_C-Q_A),\quad H_R=H_C-\theta(H_C-H_A)
$$
$$
Q_S=Q_C-\theta(Q_C-Q_B),\quad H_S=H_C-\theta(H_C-H_B)
$$
The characteristic equations from R and S to P (friction length $a\Delta t$, so $R_p'=\dfrac{f\,a\Delta t}{2gDA_p^2}$) are
$$
H_P=H_R-B_p(Q_P-Q_R)-R_p'Q_R|Q_R|,\qquad H_P=H_S+B_p(Q_P-Q_S)+R_p'Q_S|Q_S|
$$
$$
Q_P=\frac{K_1'-K_2'}{2B_p},\quad H_P=\frac{K_1'+K_2'}{2},\qquad K_1'=H_R+B_pQ_R-R_p'Q_R|Q_R|,\ \ K_2'=H_S-B_pQ_S+R_p'Q_S|Q_S|
$$
The interpolation introduces numerical damping (diffusion), which grows as $\theta$ departs from 1, so the diagonal grid of part (a) is preferred when possible.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. In the diagonal rectangular grid, dt is chosen as:
   A. dx/a
   B. a dx
   C. dx/V
   D. arbitrarily
   Answer: A. Then characteristics through P pass exactly through A and B. (Key point: Diagonal grid)

2. For specified time intervals the requirement is:
   A. a dt <= dx
   B. a dt >= dx
   C. a dt = 2 dx
   D. dt = 0
   Answer: A. theta = a dt/dx <= 1. (Key point: Non-diagonal condition)

3. The interpolation in part (b) causes:
   A. numerical damping that grows as theta departs from 1
   B. no error
   C. instability always
   D. exact results
   Answer: A. So the diagonal grid is preferred when possible. (Key point: Drawback)

4. For an upstream reservoir, Q_P is:
   A. (H_res - K2)/Bp
   B. 0
   C. (K1 - K2)/2Bp
   D. K1/Bp
   Answer: A. With H_P = H_res in the C- equation. (Key point: Boundary)

## Related in Computational Techniques in Civil Engineering

- [MOC numerical, characteristics not on diagonal (25 cm)](https://www.bctengineer.com/question.md?key=semester_8%2Fcomputational_techniques_in_civil_engineering%3Amoc-numerical-off-diagonal-j) — Computational Techniques in Civil Engineering, chapter 6, asked 2×
- [MOC numerical, characteristics not on diagonal (30 cm)](https://www.bctengineer.com/question.md?key=semester_8%2Fcomputational_techniques_in_civil_engineering%3Amoc-numerical-off-diagonal-a2) — Computational Techniques in Civil Engineering, chapter 6, asked 2×
- [Algorithm for water hammer using MOC](https://www.bctengineer.com/question.md?key=semester_8%2Fcomputational_techniques_in_civil_engineering%3Awater-hammer-algorithm-moc) — Computational Techniques in Civil Engineering, chapter 6
- [Numerical solution techniques, advantages and suitability](https://www.bctengineer.com/question.md?key=semester_8%2Fcomputational_techniques_in_civil_engineering%3Anumerical-solution-techniques-compare) — Computational Techniques in Civil Engineering, chapter 1, asked 4×

## Related in other subjects

- [Hydraulic turbine characteristics and water starting time](https://www.bctengineer.com/question.md?key=semester_7%2Fpower_plant_equipment%3Ahydraulic-turbine-water-starting) — Power Plant Equipment, chapter 2
- [Surge and water hammer: 25 m³/s, 15 m surge tank](https://www.bctengineer.com/question.md?key=semester_7%2Fhydropower_engineering%3Asurge-numerical-25cumec-2-penstocks-15m-tank) — Hydropower Engineering, chapter 6, asked 3×
- [Surge and water hammer: 45 m³/s, 20 m surge tank](https://www.bctengineer.com/question.md?key=semester_7%2Fhydropower_engineering%3Asurge-numerical-45cumec-3-penstocks) — Hydropower Engineering, chapter 6, asked 2×
- [Surge and water hammer: 60 m³/s, 30 m surge tank](https://www.bctengineer.com/question.md?key=semester_7%2Fhydropower_engineering%3Asurge-numerical-60cumec-3-penstocks-30m-tank) — Hydropower Engineering, chapter 6, asked 2×
