Here’s a great primer (among many great irrigation tutorials) on water hammer:
https://www.irrigationtutorials.com/waterhammer.htm