This example model shows how the Thermal Liquid foundation library can be used to model water hammer in a long pipe. After slowly establishing a steady flow within the pipe by opening a valve accordingly, the same valve is shut within a few milliseconds. This triggers a water hammer effect. The valve is modeled using a Variable Local Restriction (TL) block and the pipe is divided into four segments using the Pipe (TL) block. Breaking the pipe into more segments increases fidelity at the expense of simulation performance.
The Pipe (TL) block can be configured to include or neglect dynamic compressibility and fluid inertia. Water hammer effect is reproduced in this model if the Valve Signal is set to Fast and both dynamic compressibility and inertia are enabled. See the documentation for the Pipe (TL) block for more details.