Apply the master energy equation to a fluid flowing in a pipe.
U1 + K1 + Wnc = U2 + K2
This relates the energy at point 1 in the fluid to the energy at some other point 2. The potential energy we'll consider is gravitational. Any work done can be written as a force multiplied by a distance:
W = Fnet Δx = ΔPAΔx
so:
mgy1 + ½mv12 + ΔPAΔx = mgy2 + ½mv22
ΔP is the pressure difference between points 1 and 2:
ΔP = P1 - P2.
The energy expression becomes:
mgy1 + ½mv12 + P1AΔx = mgy2 + ½mv22 + P2AΔx
If we divide through by volume we get energy/volume, which is energy density. Mass over volume is mass density, and AΔx = volume, so the energy density relationship is:
ρgy1 + ½ρv12 + P1 = ρgy2 + ½ρv22 +P2
This is Bernoulli's equation. Combining this with the continuity equation allows us to relate pressures, speeds, and heights at any two points in a flowing fluid.