Modelling and simulation of water quality control