Modelling water quality and ecosystem metabolism in regulated rivers