Next Article in Journal
Analyzing the Source of Sulfate in Karst Groundwater Based on a Bayesian Stable Isotope Mixing Model: A Case Study of Xujiagou Spring Area, Northern China
Previous Article in Journal
Analysis of Interactions and Driving Factors in Subsystems of Regional Water Resource Carrying Capacity: A Case Study of Ningxia Hui Autonomous Region
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

Stochastic State-Space Modeling for Sludge Concentration Height at the Ucubamba Guangarcucho Wastewater Treatment Plant

by
Cristian-Luis Inca-Balseca
1,
Cristian Salazar
1,2,
Jesús Rodríguez
3,*,
María Barrera
4,
Anna Igorevna Kurbatova
2,
Evelyn Inca
5,
Nelly-Margarita Padilla-Padilla
1,
Ider-Nexar Moreno-Yepez
6,
Jorge-Vinicio Toapanta-Dacto
1,
Gustavo-Javier Ávila-Gaibor
1,
Marco-Hjalmar Velasco-Arellano
7,
Franklin-Marcelo Coronel
1 and
Julio-Cesar Morocho-Orellana
1
1
Escuela Superior Politécnica de Chimborazo (ESPOCH), Panamericana sur Km 1 ½, Riobamba 060155, Ecuador
2
Department of Environmental Safety and Product Quality Management, Institute of Environmental Engineering, Peoples’ Friendship University of Russia (RUDN University), 6 Miklukho-Maklaya Street, 117198 Moscow, Russia
3
Facultad de Ciencias de la Ingeniería e Industrias, Universidad UTE, Rumipamba y Burgueois, Quito 170509, Ecuador
4
Facultad de Ciencias de la Educación, Universidad Estatal de Milagro, Cdla. Universitaria “Dr. Rómulo Minchala Murillo” Km. 1.5 vía Km. 26, Milagro 091710, Ecuador
5
Independent Researcher, Riobamba 060108, Ecuador
6
URBANACONST S.A., Portoviejo 130103, Ecuador
7
Facultad de Ciencias de la Educación, Humanas y Tecnologías, Universidad Nacional de Chimborazo, Av. Eloy Alfaro y 10 de Agosto, Riobamba 060110, Ecuador
*
Author to whom correspondence should be addressed.
Water 2025, 17(6), 793; https://doi.org/10.3390/w17060793
Submission received: 8 January 2025 / Revised: 10 February 2025 / Accepted: 24 February 2025 / Published: 10 March 2025
(This article belongs to the Section Wastewater Treatment and Reuse)

Abstract

:
Wastewater treatment plants consist of many biological reactors and a settler, representing an example of large-scale, nonlinear systems. The wastewater treatment plant in this study operates using an activated sludge system, which relies on biological processes to treat wastewater effectively. It is for this reason that iterative process modeling was used through the implementation of an Extended Kalman Filter (EKF) to predict the height of the sludge layer in secondary clarifiers, where the accumulation of activated sludge occurs during the sedimentation process. This technique consists of maximum likelihood estimation that works more consistently in various noise scenarios. As a result of the evaluation of the model estimated by the Extended Kalman Filter (EKF), the suitability of the process tends to be concluded on. In this sense, the prediction of the height in the sludge layer in sewage systems represents a complicated and heteroscedastic process, which can be understood as a phenomenon that can be influenced by a variety of factors. Therefore, this study does not identify problems in estimates through a thorough examination of residuals. It is concluded that the implementation of state-space modeling increases the adaptability and adjustability of the process to achieve structural optimization in a treatment plant. This approach is a viable and effective solution for the efficient management of polluting sludge levels and minimizing the possible environmental impact in out-of-control situations in wastewater treatment plants.

1. Introduction

Resource recovery, maintaining water quality requirements, and maximizing energy efficiency are key challenges faced by wastewater treatment units [1]. Over the past few decades, computational models have gained recognition as valuable tools for addressing these challenges and enhancing both the operational and financial performance of wastewater treatment facilities or plants. To forecast wastewater treatment plant performance in this context, stochastic models based on time series and robust models have been developed [2]. With an ever-increasing amount of data available, data-driven models are becoming more attractive.
Consequently, the uncertainty in sedimentation tank models or secondary facultative lagoons is crucial for the simulation of a wastewater treatment system. This is notably highlighted in relevant and appropriate contributions in the scientific literature [3,4,5], as are evaluations of the effects of microbial community predictors on settling velocity or hindered sedimentation at the level of water resource recovery [6]. The recent literature also contains many three-dimensional computational fluid dynamic models, such as the case of Xu et al. (2022), and these models are commonly used to optimize the model and design of the computational fluid dynamics of the complete solid–liquid two-phase process [7]. In addition to considering the most recent contributions that have motivated the present development in this field, studies focused on building a stochastic state-space model of the sludge layer height in secondary clarifiers in wastewater treatment plants should also be considered [8].
According to this background, the spatial finite difference scheme of the advection–diffusion partial differential equation serves as the basis for the construction of these models, which also incorporate sedimentation dynamics using the real flow sedimentation curves and operational parameters of the sedimentation and biological treatment of wastewater. These models still serve as the basis for the one-dimensional modeling of clarifiers, mainly composed of reaction or facultative tanks and a sedimentation or maturation tank. In this context, the latest research in the literature improves the mathematical explanations of solid dispersion and mechanistic compression dynamics, for example, while primarily emphasizing appropriate mathematical formulations for ensuring proper positioning and stability [8].
The complexity of the clarifier’s behavior under operational conditions and the accuracy of one-dimensional models are affected by complex factors such as turbulence and uneven sludge distributions, which represent the two obstacles to accurately estimating the height of the sludge layer. Another limitation inherent in previous studies is the approach to great computational complexity, which translates into a cost in obtaining the model, thus making it barely practical to execute online operations that require quick and continuous calculations to calibrate the model with different points that can be used to determine the expected sludge concentration profile and infer the height of the sludge layer.
These limitations were mitigated in the present study by assuming continuous measurements of the sludge layer height (endogenous variable) at different points, facilitating the calibration of the model defined in a single state-space equation, based on signals from operational control parameters in wastewater treatment that were repeatedly optimized. These operational parameters are defined as the plant’s inlet flow, the suspended solids concentrations of the clarifier, and the clarifier recycling rate. Using these parameters can lead to reductions in model prediction costs with an ideal configuration of model predictive control with quality measurements and representative sampling.
Considering these problems, this research focused on the objective of constructing a model that maintains a flexible fit to the data by estimating the parameters that minimize, in a single procedure, the negative logarithmic probability of the independent state transition probabilities, where state filtering is carried out using an Extended Kalman Filter (EKF). The above is achieved by solving the stochastic differential equation at each point in time through transformation to a weighted fit based on both the underlying uncertainty (probability distribution) and the very nature of the observations associated with the accumulation of activated sludge at the Ucubamba Guangarcucho wastewater treatment plant in Ecuador.
This procedure involves the construction of a state-space model that estimates the state of a dynamic system from a sequence of noisy observations. This methodology is ideal for the prediction of time series in dynamic systems that need to be monitored or estimated in real time, considering the uncertainties of the measurements, which allows readings to be refined to produce a more accurate forecast of the future state of the system as new data become available. Given the challenges associated with the implementation of traditional or analytical methods, as well as the costs of experimentation and computation, this type of modeling can be used to achieve more effective risk control.

1.1. Literature Review

This section defines a mathematical formula system known as the Kalman filter, which tends to offer a productive recursive solution to the least-squares approach. With the help of this method, an ideal linear, unbiased estimator of a process’s state can be determined at any given moment using the data available at time t 1 and updated with new data at time t . The primary approach to estimating dynamic systems given in state-space form is represented by this type of filter.
Since the Kalman algorithm is the principal method for estimating dynamic systems represented in state-space form and has numerous applications in the field of econometrics, it is imperative to extend its understanding to other fields of knowledge. Applying this type of filter involves a mathematical process that employs a correction and prediction method. Essentially, this method takes its prior state estimation and predicts the current state by adding a correction term proportional to the prediction error, ensuring that the prediction error is statistically minimized.
The Extended Kalman Filter (EKF) has been explored in various studies as a potential tool for predicting sludge concentration in wastewater treatment facilities. In this context, the contributions of Li et al. [9] and Bartos et al. [10] have been significant, illustrating the usefulness of the Extended Kalman Filter (EKF) in estimating unmeasured states in wastewater treatment operations. Additionally, Kim et al. [11] presented a reduced-order dynamic model for the activated sludge process, with the potential to forecast the dynamic behavior of a biological wastewater treatment facility. Using simple and affordable sensors, Nair et al. [12] expanded the application of the Extended Kalman Filter (EKF) to estimate nutrient content in a prototype plant for a sequential batch moving bed biofilm reactor. All these studies demonstrate how the Extended Kalman Filter (EKF) can be used to forecast sludge concentration in wastewater treatment facilities.

1.2. Extended Kalman Filter (EKF)

The Kalman filtering (KF) process is a recursive prediction method that assumes a linear correlation exists between variables to determine the best estimate for an unknown state vector, x t , given knowledge of an observable vector, y t . However, when the model dynamics are nonlinear, a new filtering strategy is required (Figure 1). Among these methods is the Extended Kalman Filter (EKF), a linearization procedure based on the Taylor approximation that extends the standard Kalman filter [13].
To establish the foundations for constructing the Extended Kalman Filter (EKF), a nonlinear system characterized by the following state measurement model is analyzed:
x t = h t 1 t 1 , x t 1 + w t 1
y t = g t t , x t + v t
The Gaussian noise processes w t and v t are independent, with zero mean and covariance matrices Q t 1 and R t , respectively. The nonlinear transition matrix functions, which are assumed to be C 1 and may vary over time in certain situations, are represented by the variables h t 1 ( ) y g t   .
The fundamental principle of the Extended Kalman Filter is to linearize the state-space model of Equations (1) and (2) each time around the previous or most recent state estimate, which can be either x ^ t 1 or x ^ t / t 1 , depending on the specific function considered. The variables x ^ t 1 or x ^ t / t 1 represent the a priori and a posteriori state estimates, respectively.
Selecting Q t 1 and R t is one of the most challenging aspects for effective filter implementation, as the Kalman filtering process employs fixed covariance matrices [14].
In the scientific literature, stochastic models have been used to predict sludge height in wastewater treatment facilities. This strategy can improve effluent quality and optimize plant operations. Additionally, numerous wastewater treatment applications have utilized stochastic models for performance optimization, uncertainty analysis, and process performance prediction. To assess uncertainty in activated sludge modeling in wastewater treatment facilities, the use of a stochastic differential equation has been investigated. This method can aid in enhancing understanding and managing ambiguity throughout the treatment process.

1.3. Use of Model Generator (sdeTMB) for Solving Stochastic Differential Equations

Driven by the framework of continuous-time stochastic modeling, sdeTMB is an R package for parameter estimation, state filtering, and prediction in stochastic state-space models. This package eliminates the need for the user to write the required C++ file containing the negative log-likelihood function by providing an intuitive wrapper for the Template Model Builder. Instead, the provided R6 class object is used to automatically build the C++ script based on a user-specified model. Additionally, the package leverages the broader package ecosystem to streamline stochastic simulation paths and accelerate model prediction calculations.
The package implements the following technique: the continuous-discrete Extended Kalman Filter (EKF). Kalman filter implementations offer two key benefits: a substantial increase in computational performance and the ability to use a fixed-effects matrix for improved optimization convergence. TMB only provides automatic differentiation under certain conditions. The use of the Laplace approximation for likelihood calculations, which allows for state-space formulations when the observation residual density is non-Gaussian, is a significant advantage of this methodology.
Currently, algorithms are primarily designed to apply the Kalman filter and associated approaches within an integrated developer interface in RStudio 2023.12.0, as well as for k-step-ahead predictions and simulations. It also includes an implementation that, when calling the class object returned by the function, displays a simple residual analysis using packages such as ggplot2 (version 3.5.1), sdmTMB (version 0.6.0), predict, simulate, S3, method, plot, and estimate.

1.4. Wastewater Treatment Plant (WWTP)

The operational dynamics within wastewater treatment plants (WWTPs) significantly influence sludge behavior, particularly during the primary treatment phase, where fluctuations in influent flow rate, suspended solids concentration, and organic load impact sludge settling and accumulation [4,8]. These process variations necessitate advanced predictive modeling techniques to ensure effective monitoring and control. The Extended Kalman Filter (EKF) has been applied in wastewater treatment contexts to enable the precise estimation of sludge concentration by integrating real-time data from key operational parameters [9,10]. This methodological approach enhances process stability, improves predictive accuracy, and supports optimized decision-making for sludge management and overall plant performance.
According to the self-purification capacity of the system, the objective of a wastewater treatment plant (WWTP) is to receive and treat wastewater comprehensively, for its subsequent safe release into an aquatic environment. Wastewater treatment systems, on the other hand, involve a series of procedures and operations that range from the removal of solids to the final disposal of sludge, aiming to minimize potential environmental impacts and, as much as possible, reuse the resources generated in the process. The decomposition of organic matter throughout the treatment process produces sludge and biogas. These byproducts are crucial for the purification process due to their unique physical, chemical, and biological properties, which allow them to be reused beyond their disposal, offering greater utility and potential for exploitation [15]. Sewage sludge management is increasingly approached from a circular economy perspective, focusing on resource recovery, energy production, and the sustainable reuse of nutrients and organic matter [4].
As previously mentioned, sludge from wastewater treatment plant (WWTP) results from the concentration of solids contained in the effluent or from the formation of new suspended solids arising from dissolved solids, which are typically process byproducts containing a high concentration of organic matter, microorganisms, macro- and micronutrients, heavy metals, and water [16].
To determine the quality and stability of residual activated sludge, it is essential to identify specific contaminants that may pose environmental or health risks. These contaminants include heavy metals (such as lead, mercury, and cadmium), organic micropollutants (like pesticides and pharmaceuticals), and pathogenic microorganisms (bacteria, viruses, and parasites). Comprehensive sludge characterization typically involves measuring parameters such as total suspended solids (TSS), chemical oxygen demand (COD), biochemical oxygen demand (BOD), and nutrient content (nitrogen and phosphorus), which are critical for assessing sludge composition and treatment performance. Additionally, total biochemical oxygen demand (TBOD) serves as an indicator of effluent quality, reflecting the overall organic load.
In the literature, neural network models enhanced by evolutionary algorithms are commonly used to predict the operational efficiency of wastewater treatment plants, utilizing key wastewater quality parameters (such as pH, TSS, COD, and BOD) as input variables [17]. External environmental factors, including rainfall, sunlight exposure, and average daily air temperature, are also considered, as they can significantly influence the dynamics of sludge formation and the efficiency of the treatment process.

2. Materials and Methods

2.1. Description of Ucubamba Guangarcucho Wastewater Treatment Plant

The wastewater treatment plant is situated in the northeastern region of Cuenca, Ecuador, with the primary objectives of intercepting and treating 95% of the city’s wastewater, processing approximately 4.30 m3/day at an average flow rate of 1300 L/s. Additionally, wastewater management is supplemented by the operation of smaller treatment facilities distributed across different areas of the canton.
The plant’s design framework incorporates an advanced purification system, which consists of preliminary treatment units and a stabilization pond system arranged in two parallel treatment lines to optimize wastewater processing efficiency. This structural configuration is specifically engineered to regulate hydraulic pressure and inflow rates while simultaneously facilitating the removal of suspended solids, which inherently contribute to the treatment load.
The preliminary treatment infrastructure of the wastewater treatment plant (Figure 2) includes inflow distribution chambers, which are strategically partitioned to manage an influent capacity of 1800 L/s. The facility operates with a maximum hourly treatment flow of 2270 L/s during the dry season, while the recorded peak hourly treatment flow during the rainy season reaches 2500 L/s.

2.2. Process of Extraction, Transportation, Pumping, Thickening, and Dewatering of Sludge

The Ucubamba Guangarcucho wastewater treatment plant features six stabilization ponds, comprising two aerated ponds, two facultative ponds, and two maturation ponds. These ponds are hydraulically connected in parallel within their respective categories and arranged in a linear sequence across different pond types (Figure 3) to facilitate maintenance, cleaning, and repair operations while ensuring continuous treatment efficiency.
The process line for the extraction and dewatering of 220,000 m3 of sludge comprises several sequential operations, including initial extraction and pumping via dredging systems, sludge collection and conveyance through pressurized pipelines, pumping at intermediate stations, and screening within 18-inch-wide Parshall flumes (Model L8000T010; HONEYWELL BMS, Charlotte, NC, USA) to quantify the flow rate of treated wastewater, serving as data acquisition points during the final discharge into the Cuenca River. This phase corresponds to the terminal stage of the activated sludge extraction and dewatering system at the Ucubamba sector wastewater treatment plant.
The monitoring instruments employed in this process include the CBX Sludge Blanket Meter (Cerlic Controls AB, Segeltorp, Sweden) and the MultiTracker (Cerlic Controls AB, Segeltorp, Sweden), both of which provide high-precision, repeatable measurements of the sludge blanket level, based on real-time solid concentration analysis.
The activated sludge treatment integrates processes carried out across aeration lagoons and facultative lagoons, where the sludge layer plays a pivotal role in volume reduction and the biodegradation of pollutants. Within the aeration ponds, the primary objective is to decrease suspended solids and organic load to an optimal level, enabling the subsequent treatment stage through 1500 mm pipelines leading to the facultative ponds.
In the thickening stage, sludge undergoes gravity-assisted thickening, followed by the pumping of concentrated sludge, polyelectrolyte conditioning, dewatering via belt filter presses, pneumatic transfer to a storage silo, and final containment. Additionally, the Ucubamba Guangarcucho wastewater treatment plant incorporates auxiliary systems for water pumping, compressed air distribution, truck weighing, and real-time control and monitoring systems.
Untreated wastewater enters the treatment plant through three separate influent pipelines, which merge into a single 39-inch diameter conduit that directs the flow into the headworks facility, where preliminary treatment is conducted. The raw water pumping station conveys the wastewater to the grit chambers via two ductile iron pipelines: one 900 mm in diameter, capable of transporting 800 L/s, and another 1200 mm in diameter, with a capacity of up to 1600 L/s. Each pipeline extends approximately 96 m, collectively accommodating a maximum instantaneous flow of 2400 L/s.
As part of the sanitation process, the influent is sequentially distributed to the primary sedimentation tanks, percolating filters, aeration tanks, secondary sedimentation tanks, and final clarifiers, ultimately discharging into the Cuenca River.
The process flow diagram (Figure 4) illustrates the interconnection of treatment stages and the recirculation of return activated sludge (RAS) and waste activated sludge (WAS) within the system. This comprehensive schematic visually represents the integrated wastewater treatment process, which encompasses pre-treatment, primary treatment, secondary treatment, and disinfection. Pre-treatment involves influent interception, coarse screening, solid extraction screens, pumping stations, fine screening, and grit removal chambers. Primary treatment focuses on the removal of suspended solids, floating materials, and organic matter. Secondary treatment includes aeration tanks and secondary clarifiers, with biological sludge recirculation for enhancing microbial activity and organic matter decomposition. The facility incorporates ultraviolet (UV) disinfection, ensuring the treated effluent is adequately disinfected before being discharged into the Cuenca River.
The management of activated sludge within the WWTP prioritizes resource recovery and waste minimization, leveraging a circular treatment approach. This process integrates biological treatment, final sedimentation, disinfection, sludge thickening, anaerobic digestion, dewatering, and biosolid utilization. Such an approach fosters the recovery and reuse of valuable resources, significantly reducing waste generation and contributing to the closure of the nutrient and organic matter cycle.

2.3. Data

The data matrix generated during this study is structured as follows:
t represents the time variable throughout the stochastic process, during which measurements of the sludge blanket height S b h t are collected for each primary sedimentation tank.
Q f denotes the influent flow rate, which accounts for the concentration of suspended solids   C f within each biological tank pair while also considering percentage variations in the operational factor ( S f ) .
Additionally, the matrix includes data on the sludge recycling flow rate ( Q r ) for each sedimentation tank, providing critical insights into sludge dynamics and system performance.
Due to the large volume of data, the complete data matrix is provided as Supplementary Materials and is not included in the main body of this article.

2.4. Methodology for Data Analysis

The sdeTMB and ctsmTMB libraries were implemented in the free R 4.2.3 application under the RStudio 2023.12.0 integrated development environment, which allows for the estimation of mixed-effects models with non-Gaussian probability distributions, which defines the basis of this type of model. Utilizing models based on the sdeTMB library allows for the examination of data with complex structures, including time series, spatial data, or data with random effects; in this context, the sdeTMB library proves to be of practical use in constructing these models. Compared to conventional models, this methodology provides a more accurate modeling of data variability. Installing the sdeTMB library in RStudio is a prerequisite for using the function model = sdeTMB$new(). The syntax model = sdeTMB$new() can then be used to create a new object, where “model” represents the designation assigned to the resulting object. Consequently, the user must have a functional C++ compiler. Researchers working on Windows must install Rtools 4, while Mac users need to install Command Line Tools for the C++ compilers to function correctly.
Figure 5 provides a detailed description of the block diagram of the Extended Kalman Filter. This suggests that, somewhere—perhaps in a visual resource like a book, presentation, or technical document—there is a block diagram that explains in detail how the Kalman filter functions in a single dimension. This diagram likely visually illustrates the stages of the Kalman filter algorithm, such as measurement, update, and prediction, within a one-dimensional system. The block diagram serves as a graphical representation that helps to visually understand the operation and interaction of the different stages of the Kalman filter.
This study was conducted over a 30-day period in June 2024, generating a database comprising 4450 recorded data points, defined within time intervals ranging from 14:08 to 21:52. Utilizing this data matrix and applying the algorithm illustrated in Figure 5, the modeling of sludge concentration dynamics in sewer systems for the wastewater treatment plant was performed.

2.5. Estimation Process

To evaluate the state of a nonlinear system from noisy observations, the EKF uses an iterative procedure and a state estimation approach. After linearizing the nonlinear system around the current operating point, the EKF estimates the state using the conventional Kalman filter.
The state and observation equations of the nonlinear system, as well as the measurement noise and process noise covariance matrices, must be defined before implementing the Extended Kalman Filter. The RStudio 2023.12.0 program can be used to implement the EKF, as shown in Table 1, by applying the maximum likelihood estimation method.
In estimating an empirical equation to model the sludge blanket in the wastewater treatment plant as a function of time, parameters b0, b1, and b2 are specified as coefficients estimated from a statistical model. These coefficients represent the relationship between the predictor variables, represented by wastewater treatment operating parameters (Qf, Sf, and Qr), and the response variable (expressed on the logit scale). The invlogit function is used to convert the model’s prediction from the logit scale to the probability scale, making it easier to interpret.
To assess the adequacy and fit of the process, it is essential to compare the model’s predictions with documented data. This comparison was performed to evaluate the accuracy of the Kalman filter; to accomplish this, the predicted sludge blanket height was compared with the actual height. Descriptive graphs are typically used for this comparison.

2.6. Optimization Process

The optimization is completed by obtaining the following parameters: elapsed time, objective value, maximum gradient component, relative convergence, iterations, function, and gradient. The reference values for the state-space modeling of sludge concentration in wastewater treatment plants are shown in Table 2.

3. Results

The Kalman filter is a recursive estimation technique that provides an optimal estimate of the state of a dynamic system based on noisy measurements. In the case of wastewater treatment, the Kalman filter can be used to predict the sludge blanket height in the wastewater treatment plant over time.
Figure 6 shows the hourly series with records starting from the first day of June 2024, corresponding to the exact record at 14:08 h for monitoring the final process in 18-inch Parshall channels leading to the aeration and facultative lagoons or tanks within the wastewater treatment plant, with the height of the activated sludge blanket recorded in meters. A comparison with the metric records of the average height of the activated sludge blanket reveals a complex and heteroscedastic pattern, indicating an accumulation behavior of 1.5 m or more of this type of sludge on the first day of recording and the fourth day. Additionally, a strong accumulation of sludge exceeding 2 m is recorded for the days 2 June 2024, 15 June 2024, and 17 June 2024, due to the reduced volume of water in the influent at the WWTP, as evidenced by the representation of the red line indicating the mass flow rate. This suggests that as the influent flow increases, the dilution flow reduces the sludge level in the WWTP. The minimum and maximum heights of the sludge layer are represented in the graph by the shaded gray color, assuming the minimum and maximum heights of the present solid layer that is linked to the level of use of clarifiers that are used to separate the suspended solids from the treated water.
The plotting of probabilistic forecasts (gray area shown in Figure 6) is highly useful in practice as it provides insight into the reliability of the sludge blanket height forecast at the influent of the treatment plant by estimating a 95% prediction interval.
One of the most important factors when modeling the height of the activated sludge layer is time. To observe behavior in the predictions, it is crucial to consider the time intervals of every two and every four hours. This is because the Kalman filter uses a dynamic model to anticipate the system’s evolution over time (Figure 7).
According to Figure 7, a small estimation error is observed, indicating a difference between the actual values (the red line) and the Extended Kalman Filter (EKF) estimates (the green and blue lines). We can see that the estimation errors in the fit using the Extended Kalman Filter (EKF) decrease within the filter’s convergence region.

Residual Analysis

The discrepancy between actual measurements and filter estimates for the variable of interest (activated sludge layer height) is represented by the residuals (Figure 8). Residuals should behave randomly, with constant variance and a zero mean. If trends (Figure 8a), autocorrelations (Figure 8c), or heteroscedasticity (Figure 8b) are visible in the residuals, this indicates that the model does not fit the data adequately. This highlights the importance of residual analysis, as it allows us to identify potential issues with the model, including systematic errors, biases, or noise. By fine-tuning the parameters of the Extended Kalman Filter, the model can be further improved.
As shown in the graphs represented in Figure 8, no potential estimation issues are identified, such as the non-normality of residuals, the presence of autocorrelation, or periodic components (Figure 8d). This indicates that the method employed is efficient for estimating sludge concentration in the WWTP, effectively determining the treatment system’s efficiency, the amount of available sludge, and the contamination risks to ecosystems exposed to this waste.

4. Discussion

The quality of water must be monitored in various wastewater treatment plants to ensure compliance with specific standards. Monitoring detects problems in the WWTP, resulting in quality improvements and lower maintenance risks [18]. The management of the WWTP is a sophisticated and comprehensive process influenced by unpredictable factors such as weather, illegal discharges, and water leaks [19]. These variables can alter the flow and properties of the incoming water, requiring more robust treatment measures [20]. The WWTP aims to regulate all processes to ensure water quality, minimize environmental impacts, and reduce operational costs.
The implementation of predictive models has the potential to transform the way facilities manage WWTPs by enabling real-time process simulation through digital emulation developments [21]. Consequently, various challenges have emerged, including the application of conventional models and machine learning techniques to forecast wastewater properties and effluent contributions, as well as research to identify irregularities in activated sludge accumulation and optimize energy use in WWTPs [22].
Since sludge contains harmful bacteria that pose a threat to human health and the environment, it has become one of the most challenging and concerning environmental issues related to wastewater treatment [23]. In this context, residual sludge can significantly affect the operational efficiency of treatment plants. The primary phases of the physical separation of the sludge produced during traditional treatment are predominantly associated with sedimentation and filtration. Proper sludge management is necessary to avoid negative impacts on the environment and public health [24]. If not managed correctly, residual sludge can accumulate and clog recirculation systems and treatment equipment within the wastewater treatment plant, reducing operational efficiency and potentially leading to the release of pollutants into the environment.
The literature generally reports variable estimates of sludge generation, so it is not appropriate to generalize this, as it depends on a series of factors, including the properties of the raw water, the type and dose of coagulant, the conditions of the coagulation process, and the structure or configuration of the treatment plant. Therefore, the estimation of sludge production in each treatment plant design represents a unique phenomenon influenced by various factors, as highlighted in [25]. Therefore, due to methodological heteroscedasticity in model construction, variable management, and reliable measurement records, there is no unification for making direct comparisons with models present in various studies.
A challenge with the estimated model, unlike the contributions in existing models, is that it lacks easy interpretation in terms of the estimated parameters of the studied phenomenon, in terms of its complex qualitative dynamics of process functioning, where the method of data collection is vital to ensure they are of high quality and representative for analyzing correlations between endogenous and exogenous variables. It is important to avoid single-point measurement records that could erroneously lead to the conclusion of the uniform height of the activated sludge blanket, assuming that there is the incidence of the level of turbulence produced by the water flow [8].
A significant advantage in the implementation of the Extended Kalman Filter technique to predict the level of activated sludge in the WWTP of the sewer system lies in its dynamic real-time adjustment as new data are incorporated, creating highly accurate information. This contrasts with traditional models, where model re-estimation requires constant updates and monitoring to validate predictive capability over extended periods and larger time ranges.
The simulation results for actuator models in a biological wastewater treatment process demonstrate that the Extended Kalman Filter method effectively estimates the states of a WWTP model, allowing for efficient fault detection [26].
However, accurately predicting the evolution of solid concentration in different elements of WWTPs is a challenge. Therefore, constant monitoring and adjustments to the model are required based on the water flow rate and other factors that influence fluid dynamics and the dilution flow rate. This approach helps to detect failures and make the necessary adjustments to maintain the efficiency of the estimation model, which, in addition to determining the concentration, can be complemented with chemical analyses to detect the risks of soil and water contamination. Although models for estimating residual sludge have been improved using artificial intelligence (AI) systems such as machine learning (ML) and deep learning (DL) neural networks, given the large amount of data they handle [27,28,29], models based on mathematical equations remain accurate.

5. Conclusions

The activated sludge concentration levels in the sewer system of the wastewater treatment plant remain within permissible limits when the dilution flow is adequate. This article summarized the EKF for a class of nonlinear systems in a special observable canonical form. Numerous nonlinear observers were developed that provide an estimate of a variable of interest based on the measurements of another process variable. These observers vary with respect to the measured and estimated variables, the parameters assumed to be known, and the type of convergence. This work developed and analyzed the EKF for state estimation (activated sludge height) based on biomass concentration measurements. The simulation results illustrate the preceding analysis and theoretical findings, demonstrating the EKF’s capabilities to offer reliable estimates.
A simplified Extended Kalman Filter is used for real-time identification. The reduced-order model presented in this document can serve as a tool for predicting the dynamic behavior of a wastewater treatment plant, as parameters under varying operating conditions can be recorded and adjusted in real time. The model parameters are effectively estimated even when measurements are affected by significant noise. This model is designed for operational and control purposes as an integral part of a WWTP control structure.
It should be noted that influent flow prediction and effluent characterization are the most studied applications, but the need for advances in anomaly detection and energy consumption optimization is highlighted. Despite progress in modeling, the lack of integration with data-driven models to achieve an optimal balance between prediction and computational requirements is noted. Future research should focus on implementing data-driven deep learning models to enhance the economic and operational efficiency of WWTPs, with the aim of increasing their environmental sustainability.

Supplementary Materials

The following supporting information can be downloaded at: https://www.mdpi.com/article/10.3390/w17060793/s1. Complete dataset generated during the study, including: t : Time variable (hours) recorded throughout the stochastic process for each primary sedimentation tank. S b h t : Sludge blanket height (meters) measured at each time interval ( t ), representing sedimentation dynamics. Q f : Influent flow rate (m3/day) corresponding to each biological tank pair, including suspended solids concentration ( C f ) and operational factor variations ( S f ). S f : Operational factor (%) reflecting variations in operational conditions that influence sludge processing efficiency. Q r : Sludge recycling flow rate (m3/day) for each sedimentation tank, providing insights into sludge recirculation patterns and system performance.

Author Contributions

Conceptualization, M.B., J.R., F.-M.C. and J.-C.M.-O.; Methodology, M.B., J.R., G.-J.Á.-G., C.-L.I.-B. and J.-C.M.-O.; Formal analysis, J.R., A.I.K., M.-H.V.-A. and J.-C.M.-O.; Investigation, C.S., E.I. and J.-C.M.-O.; Data curation, C.-L.I.-B., E.I., N.-M.P.-P. and J.-C.M.-O.; Software, C.-L.I.-B., I.-N.M.-Y., A.I.K. and J.-C.M.-O.; Resources, J.-V.T.-D., M.-H.V.-A. and J.-C.M.-O.; Supervision, J.R., G.-J.Á.-G., F.-M.C. and J.-C.M.-O.; Validation, G.-J.Á.-G., F.-M.C. and J.-C.M.-O.; Visualization, I.-N.M.-Y. and J.-C.M.-O.; Writing—original draft, M.B., J.R., C.S. and J.-C.M.-O.; Writing—review and editing, N.-M.P.-P., I.-N.M.-Y., F.-M.C. and J.-C.M.-O.; Funding acquisition, J.R. All authors have read and agreed to the published version of the manuscript.

Funding

This research received no external funding.

Data Availability Statement

The original data for this article are included within the main text. The datasets generated during and/or analyzed during the current study are available from the corresponding author on reasonable request.

Conflicts of Interest

Ider-Nexar Moreno-Yepez was employed by URBANACONST S.A. The remaining authors declare that the research was conducted in the absence of any commercial or financial relationships that could be construed as a potential conflict of interest.

References

  1. Peterson, K.T.; Sagan, V.; Sloan, J.J. Deep learning-based water quality estimation and anomaly detection using Landsat-8/Sentinel-2 virtual constellation and cloud computing. GIScience Remote Sens. 2020, 57, 510–525. [Google Scholar] [CrossRef]
  2. Meehan, K.; Jepson, W.; Harris, L.M.; Wutich, A.; Beresford, M.; Fencl, A.; Young, S. Exposing the myths of household water insecurity in the global north: A critical review. Wiley Interdiscip. Rev. Water 2020, 7, e1486. [Google Scholar] [CrossRef]
  3. Guyonvarch, E.; Ramin, E.; Kulahci, M.; Plósz, B.G. Quantifying the sources of uncertainty when calculating the limiting flux in secondary settling tanks using ICFD. Water Sci. Technol. 2020, 81, 241–252. [Google Scholar] [CrossRef] [PubMed]
  4. Stentoft, P.A.; Munk-Nielsen, T.; Møller, J.; Madsen, H.; Pérez, V.; Mikkelsen, P.; Vezzaro, L. Prioritize effluent quality, operational costs or global warming?–Using predictive control of wastewater aeration for flexible management of objectives in WRRFs. Water Sci. Technol. 2021, 196, 116960. [Google Scholar] [CrossRef] [PubMed]
  5. Zhou, P.; Li, Z. Arbitrary polynomial chaos expansion for uncertainty analysis of the one-dimensional hindered-compression continuous settling model. J. Water Process Eng. 2023, 52, 103489. [Google Scholar] [CrossRef]
  6. Qiu, Y.; Hug, T.; Wágner, D.S.; Smets, B.F.; Valverde-Pérez, B.; Plósz, B.G. Dynamic calibration of a new secondary settler model using Cand. Microthrix as a predictor of settling velocity. Water Res. 2023, 246, 120664. [Google Scholar] [CrossRef]
  7. Xu, Q.; Luo, X.; Xu, C.; Wan, Y.; Xiong, G.; Chen, H.; Zhou, Q.; Yan, D.; Li, X.; Li, Y.; et al. The whole process CFD numerical simulation of flow field and suspended solids distribution in a full-scale high-rate clarifier. Sustainability 2022, 14, 10624. [Google Scholar] [CrossRef]
  8. Vetter, P.B.; Stentoft, P.A.; Munk-Nielsen, T.; Madsen, H.; Møller, J.K. Toward smart wastewater treatment plants: A novel data-driven sludge blanket model based on stochastic differential equations. Water Sci. Technol. 2024, 90, 1397–1415. [Google Scholar] [CrossRef]
  9. Li, X.; Law, A.W.K.; Yin, X. Partition-based distributed extended Kalman filter for large-scale nonlinear processes with application to chemical and wastewater treatment processes. AIChE J. 2023, 69, e18229. [Google Scholar] [CrossRef]
  10. Bartos, M.; Thomas, M.; Kim, M.G.; Frankel, M.; Sela, L. Online state estimation in water distribution systems via Extended Kalman Filtering. Water Res. 2024, 264, 122201. [Google Scholar] [CrossRef]
  11. Kim, H.; Hong, Y.S.T. Online state and parameter estimation of a biological sequencing batch reactor using an advanced nonlinear Bayesian derivativeless filtering algorithm with Activated Sludge Model No. 1. J. Water Process Eng. 2024, 66, 105869. [Google Scholar] [CrossRef]
  12. Nair, A.; Fanta, F.; Haugen, H.; Ratnaweera, H. Implementing an Extended Kalman Filter for estimating nutrient composition in a sequential batch MBBR pilot plant. Water Sci. Technol. 2019, 80, 317–328. [Google Scholar] [CrossRef] [PubMed]
  13. Zhao, J.; Dai, H.; Wang, Z.; Chen, C.; Cai, X.; Song, M.; Geng, H. Self-organizing modeling and control of activated sludge process based on fuzzy neural network. J. Water Process Eng. 2023, 53, 103641. [Google Scholar] [CrossRef]
  14. Donas, A.; Galanis, G.; Famelis, I.T. A Hybrid Extended Kalman Filter Based on a Parametrized Feedforward Neural Network for the Improvement of the Results of Numerical Wave Prediction Models. Environ. Sci. Proc. 2023, 26, 199. [Google Scholar] [CrossRef]
  15. Eche, J.J.E.; de la Cruz, E.G.S. Innovación en la gestión de lodos generados en plantas de tratamiento de aguas residuales de origen doméstico en Lima-Perú. Rev. Inst. Investig. Fac. Minas Metal. Cienc. Geogr. 2021, 24, 205–215. [Google Scholar] [CrossRef]
  16. Nascimento, A.L.; de Souza, A.J.; Oliveira, F.C.; Coscione, A.R.; Viana, D.G.; Regitano, J.B. Chemical attributes of sewage sludges: Relationships to sources and treatments, and implications for sludge usage in agriculture. J. Clean. Prod. 2020, 258, 120746. [Google Scholar] [CrossRef]
  17. Wu, Y.; He, S. Solving the set-union knapsack problem by a novel hybrid Jaya algorithm. Soft Comput. 2020, 24, 1883–1902. [Google Scholar] [CrossRef]
  18. Leigh, C.; Alsibai, O.; Hyndman, R.J.; Kandanaarachchi, S.; King, O.C.; McGree, J.M.; Neelamraju, C.; Strauss, J.; Talagala, P.D.; Turner, R.D.R.; et al. A framework for automated anomaly detection in high frequency water-quality data from in situ sensors. Sci. Total Environ. 2019, 664, 885–898. [Google Scholar] [CrossRef]
  19. Sun, C.; Puig, V.; Cembrano, G. Real-Time Control of Urban Water Cycle under Cyber-Physical Systems Framework. Water 2020, 12, 406. [Google Scholar] [CrossRef]
  20. Torres Lozada, P.; Arango-Vallejo, L.A.; Torres, W.A. Estimación de la producción de lodos en plantas convencionales de tratamiento de agua potable mediante modelos de predicción. Rev. UIS Ing. 2022, 21, 87–96. [Google Scholar] [CrossRef]
  21. Zaghloul, M.S.; Achari, G. A Review of Mechanistic and Data-Driven Models of Aerobic Granular Sludge. J. Environ. Chem. Eng. 2022, 10, 107500. [Google Scholar] [CrossRef]
  22. Yasmin, N.S.A.; Abdul Wahab, N.; Ismail, F.S.; Musa, M.A.J.; Halim, M.H.A.; Anuar, A.N. Support vector regression modelling of an aerobic granular sludge in sequential batch reactor. Membranes 2021, 11, 554. [Google Scholar] [CrossRef] [PubMed]
  23. Singh, B.J.; Chakraborty, A.; Sehgal, R. A systematic review of industrial wastewater management: Evaluating challenges and enablers. J. Environ. Manag. 2023, 348, 119230. [Google Scholar] [CrossRef] [PubMed]
  24. Sharma, L.D.; Sarangthem, I.; Thangjam, R.; Sadhukhan, R.; Oinam, N.; Yanglem, B.; Banarjee, L.; Anal, H.J.; Jatav, H.S. Sewage Sludge and Its Health Risk Assessment: Opportunities and Challenges. In Sustainable Management and Utilization of Sewage; Springer Nature: Berlin/Heidelberg, Germany, 2021; pp. 205–225. [Google Scholar] [CrossRef]
  25. Yaqub, M.; Asif, H.; Kim, S.; Lee, W. Modeling of a full-scale sewage treatment plant to predict the nutrient removal efficiency using a long short-term memory (LSTM) neural network. J. Water Process Eng. 2020, 37, 101388. [Google Scholar] [CrossRef]
  26. Niu, G.; Liu, Y.; Zhou, J.; Fan, X.; Chen, Z.; Corriou, J.P.; Huang, M. SBR-Extended Kalman Filter model-based fault diagnosis and signal reconstruction for the papermaking wastewater treatment process. J. Water Process Eng. 2023, 56, 104420. [Google Scholar] [CrossRef]
  27. Dogan, H.; Temel, F.A.; Yolcu, O.C.; Turan, N.G. Modelling and optimization of sewage sludge composting using biomass ash via deep neural network and genetic algorithm. Bioresour. Technol. 2023, 370, 128541. [Google Scholar] [CrossRef]
  28. Bień, J.D.; Bień, B. Forecasting the municipal sewage sludge amount generated at wastewater treatment plants using some machine learning methods. Desalin. Water Treat. 2023, 288, 265–272. [Google Scholar] [CrossRef]
  29. Li, G.; Ji, J.; Ni, J.; Wang, S.; Guo, Y.; Hu, Y.; Li, Y.Y. Application of deep learning for predicting the treatment performance of real municipal wastewater based on one-year operation of two anaerobic membrane bioreactors. Sci. Total Environ. 2022, 813, 151920. [Google Scholar] [CrossRef]
Figure 1. Extended Kalman Filter process diagram.
Figure 1. Extended Kalman Filter process diagram.
Water 17 00793 g001
Figure 2. Primary structure of Ucubamba Guangarcucho wastewater treatment plant. (a) Arrival box–bypass–admission gate 1. (b) Arrival box– bypass–admission gate 2. (c) A: Arrival box–bypass–admission gate 3.
Figure 2. Primary structure of Ucubamba Guangarcucho wastewater treatment plant. (a) Arrival box–bypass–admission gate 1. (b) Arrival box– bypass–admission gate 2. (c) A: Arrival box–bypass–admission gate 3.
Water 17 00793 g002
Figure 3. Spatial location of Ucubamba Guangarcucho wastewater treatment plant complex.
Figure 3. Spatial location of Ucubamba Guangarcucho wastewater treatment plant complex.
Water 17 00793 g003
Figure 4. Diagram of activated sludge treatment processes at Ucubamba Guangarcucho wastewater treatment plant.
Figure 4. Diagram of activated sludge treatment processes at Ucubamba Guangarcucho wastewater treatment plant.
Water 17 00793 g004
Figure 5. Estimation methodology using Extended Kalman Filter.
Figure 5. Estimation methodology using Extended Kalman Filter.
Water 17 00793 g005
Figure 6. Model adjustment for prediction in meters for the height of the mud blanket at the wastewater treatment plant.
Figure 6. Model adjustment for prediction in meters for the height of the mud blanket at the wastewater treatment plant.
Water 17 00793 g006
Figure 7. Predictions versus observations of height in meters for mud blanket at wastewater treatment plant.
Figure 7. Predictions versus observations of height in meters for mud blanket at wastewater treatment plant.
Water 17 00793 g007
Figure 8. Residual adequacy representation for the estimated model.
Figure 8. Residual adequacy representation for the estimated model.
Water 17 00793 g008
Table 1. Model parameter estimation.
Table 1. Model parameter estimation.
EstimateStd. Errort ValuePr (>|t|)Signif Codes
Logtheta1.81323.6451 × 10−249.7430<2.2 × 10−16***
b0−1.86179.4031 × 10−2−19.7992<2.2 × 10−16***
b11.7059 × 10−46.9952 × 10−624.3862<2.2 × 10−16***
b2−1.2624 × 10−21.2972 × 10−3−9.7322<2.2 × 10−16***
logsigma_x−3.14662.7883 × 10−2−112.8516<2.2 × 10−16***
Note: *** Statistical significance based on a p-values less than 0.000.
Table 2. Optimization parameters in model estimation.
Table 2. Optimization parameters in model estimation.
ParametersValue
Elapsed time3.19 s
Objective value−7.531 × 103
Maximum gradient component4.2 × 10−4
Relative convergence4
Iterations18
Function38
Gradient19
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Share and Cite

MDPI and ACS Style

Inca-Balseca, C.-L.; Salazar, C.; Rodríguez, J.; Barrera, M.; Kurbatova, A.I.; Inca, E.; Padilla-Padilla, N.-M.; Moreno-Yepez, I.-N.; Toapanta-Dacto, J.-V.; Ávila-Gaibor, G.-J.; et al. Stochastic State-Space Modeling for Sludge Concentration Height at the Ucubamba Guangarcucho Wastewater Treatment Plant. Water 2025, 17, 793. https://doi.org/10.3390/w17060793

AMA Style

Inca-Balseca C-L, Salazar C, Rodríguez J, Barrera M, Kurbatova AI, Inca E, Padilla-Padilla N-M, Moreno-Yepez I-N, Toapanta-Dacto J-V, Ávila-Gaibor G-J, et al. Stochastic State-Space Modeling for Sludge Concentration Height at the Ucubamba Guangarcucho Wastewater Treatment Plant. Water. 2025; 17(6):793. https://doi.org/10.3390/w17060793

Chicago/Turabian Style

Inca-Balseca, Cristian-Luis, Cristian Salazar, Jesús Rodríguez, María Barrera, Anna Igorevna Kurbatova, Evelyn Inca, Nelly-Margarita Padilla-Padilla, Ider-Nexar Moreno-Yepez, Jorge-Vinicio Toapanta-Dacto, Gustavo-Javier Ávila-Gaibor, and et al. 2025. "Stochastic State-Space Modeling for Sludge Concentration Height at the Ucubamba Guangarcucho Wastewater Treatment Plant" Water 17, no. 6: 793. https://doi.org/10.3390/w17060793

APA Style

Inca-Balseca, C.-L., Salazar, C., Rodríguez, J., Barrera, M., Kurbatova, A. I., Inca, E., Padilla-Padilla, N.-M., Moreno-Yepez, I.-N., Toapanta-Dacto, J.-V., Ávila-Gaibor, G.-J., Velasco-Arellano, M.-H., Coronel, F.-M., & Morocho-Orellana, J.-C. (2025). Stochastic State-Space Modeling for Sludge Concentration Height at the Ucubamba Guangarcucho Wastewater Treatment Plant. Water, 17(6), 793. https://doi.org/10.3390/w17060793

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop