Integral management of the WWTP for optimal phosphorus recovery