Water Hammer Calculator: Surge in a Pipeline by the Method of Characteristics

Water Hammer Calculator: Surge in a Pipeline by the Method of Characteristics

CalcTree
October 8, 2026

Free water hammer example: a full surge transient by the method of characteristics in Python, checked against Joukowsky. Open a copy in your browser.

CalcTree
October 8, 2026
Need a calc we don't have yet?

Tell us what you need, or sign up and build it yourself in minutes.

Leave your email and we'll tell you when a template for it is ready:

Required
Thank you!

Your request has been received. We will let you know when it is available.

Sign up

Oops! Something went wrong while submitting the form.

Related templates

No items found.

No items found.

About this Water Hammer Example

This page is a worked example of a water hammer simulation in Python, running in your browser inside a CalcTree calculation page. It works out the pressure wave speed for a gravity main, gives the Joukowsky surge, then solves the transient along the whole pipe by the method of characteristics as a valve closes, and animates the head line between the pipe rating and vapour pressure. A frictionless run is compared with the Joukowsky result on the page.

  • Water or civil engineer: see how valve closure time, pipe material and friction change the surge, and adapt the example to your own main.
  • Engineer exploring Python in calculations: see a full transient solver, its animation and its closed-form check living in one calculation page.
  • Graduate engineer learning transients: read a method of characteristics solver in a short block of NumPy, change the pipe or the valve, and watch the wave respond.

It is an example of what a CalcTree page can do, built with CalcTree AI, not a design method to rely on as is. The model is idealised and its limits are stated on the page. Duplicate it into your own workspace to change the inputs, read the Python, or use it as the starting point for your own analysis, and verify anything you take into a real design.

More info on the Water Hammer Calculator

Inputs

You set the pipe length, internal diameter, wall thickness and the elevations at each end, choose the pipe material (steel, ductile iron, PVC-U or PE100), and give the reservoir level, flow velocity, Darcy friction factor, valve closure time and closure law exponent, and the pipe rating. The water properties, the number of reaches and the simulated time are inputs too. A design sketch of the pipeline, the steady hydraulic grade line and the valve closure law redraws from these inputs.

Wave speed and the Joukowsky surge

The pressure wave speed comes from the Korteweg formula, which combines the bulk modulus of the water with the stiffness of a thin pipe wall. From it the page gives the pipe period 2L/a, which decides whether a closure is rapid, the Joukowsky head rise for a rapid closure, and Michaud's estimate for a slower one as a first guide.

The method of characteristics

The momentum and continuity equations for unsteady pipe flow become two compatibility equations that hold along lines travelling upstream and downstream at the wave speed. The pipe is split into equal reaches and the time step is the time a wave takes to cross one reach, so both lines land exactly on the grid. Friction enters as a head loss over each reach, the reservoir holds its level, and the valve follows the orifice equation as it closes. The solver sits in a Python node on the page, so you can read it, change it and rerun it.

Checking the simulation and the pipe

A second, frictionless run of the same pipe with a rapid closure is compared with the Joukowsky head rise and the 4L/a wave period, within stated tolerances. The design run then reports the highest and lowest pressure along the whole pipe over the whole run. The highest is checked against the pipe rating and the lowest, as an absolute pressure, against the vapour pressure of water, which flags where the water column would separate.

Python libraries used

NumPy steps the head and flow at every node along the pipe by the method of characteristics. Matplotlib draws the pipeline sketch, the pressure history at the valve and the animated head line with its envelope.

Common Calculation Errors to Avoid

  • Using Joukowsky for every closure: the one-line surge only applies when the valve shuts within 2L/a. For a slower closure it overstates the surge, and with long pipes and real friction a rapid closure can exceed it through line packing.
  • Taking the speed of sound in water as the wave speed: the pipe wall stretches as the pressure passes, so the wave travels slower, and much slower in plastic pipe.
  • Assuming a linear closure: most valves cut off little flow at first and most of it near the end, so the effective closure is faster than the nominal closure time.
  • Checking only the valve end: the lowest pressure is usually along the upper part of the pipe, where the static pressure is smallest, so check the envelope along the whole length.
  • Designing to a pressure below vapour pressure: a single-pipe elastic model lets the water go into tension. If the minimum falls to vapour pressure the column separates, and a column separation analysis is needed.
  • A grid that does not resolve the closure: if the closure spans only a few time steps, the valve law is not represented and the surge is wrong. Use enough reaches.
Explore the wide range of resources available
200+

Engineering templates

50+

Common calculators

20+

Design guides

Ready to try?
Streamline your engineering workflows today!
Join engineers from top firms who've signed up
AECOM
ARCADIS
Jacobs
MOTT MACDONALD

FAQs

Can I run a water hammer analysis without WANDA, HYTRAN or Bentley HAMMER?

For a single pipe from a reservoir to a valve, yes. This page runs the full transient by the method of characteristics in your browser, which is a step beyond the one-line Joukowsky rise most online calculators stop at. Those packages do far more: networks, pumps and pump trips, air valves, surge vessels and column separation. For a system with any of those, use them.

When is a valve closure rapid?

When the valve shuts within 2L/a, the time the pressure wave takes to reach the reservoir and come back. The valve then sees the full surge before any relief arrives. A slower closure lets the reflected wave arrive while the valve is still open, and the surge is lower.

Why can the simulated surge be higher than Joukowsky?

In a long pipe with real friction, water upstream keeps flowing into the pipe after the valve shuts, until the friction head line has flattened out. This line packing adds to the surge at the valve, most noticeably in flexible pipe where the wave is slow.

How is the simulation checked?

A second run of the same pipe, with friction off and a rapid closure, is compared with the closed-form result: the Joukowsky head rise and a square wave with period 4L/a. Because the time step matches the wave crossing time exactly, the method reproduces both to rounding, so a failed check points to the solver or the inputs, not the grid.

Does the calculator model cavitation?

No. It flags it. If the lowest absolute pressure reaches the vapour pressure of water, the water column would separate and the collapse can produce a spike larger than the original surge. The check fails, and the next step is a column separation analysis and protection such as a slower closure, air valves or a surge vessel.

Can I change the pipe and rerun the simulation?

Yes. It is an example to build on: duplicate the page into your workspace, then change the pipe, the material, the flow, the valve or the Python itself. The sketch, wave speed, simulation, charts and checks all update together.

Related templates

Turn your documents into calcs like this one

Upload your documents and project files, then let AI generate and review calcs grounded in your context, not guesswork.