Inactive Tutor answered 07/18/19
Shock waves occur when the speed of the fluid reaches the speed of sound. When a piston accelerates, the fluid near the surface of the piston accelerates with it due to the surface friction (ie, no-slip condition). If that piston accelerates fast enough, and the fluid is accelerated to near the speed of sound, a shock wave will form.
The local speed of sound depends on the fluid conditions being discussed, namely temperature, density and fluid composition (gas or liquid).