The network is a grid of nodes joined by pipes. Node heads H solve mass balance with linearised head loss, relaxed by Gauss-Seidel every frame:
q_ij = g_ij (H_i - H_j), g = 1 / (r (|q| + q0))
leak_i = C_i sqrt(H_i) (pressure dependent)
sum_j q_ij = demand_i + leak_i
Sensors compare their head with the healthy-network baseline. A drop above the threshold flags a leak; the location is estimated from the sensors with the largest drops. Valves around the estimated node close; if the estimate is right the leak stops, otherwise customers lose service while the leak keeps running. Crews then repair and reopen the valves.