Water hammer in hydraulics and wave surges in electricity