Abstract
Understanding the relationship between raw water quality and chemical dosage is especially important for drinking water treatment plants (DWTP) that have multiple water sources where the ratio of different supply sources could change with seasons or in a matter of weeks in response to changing hydrologic conditions. In this study, the potential for deploying machine learning algorithms, including principal component regression (PCR), support vector regression (SVR) and long short-term memory (LSTM) neural network, are tested to build predictive models. These tools were used to estimate chemical dosage at a daily time-scale. Influent water quality such as pH, color, turbidity, and alkalinity, as well as chemical dosage including sulfuric acid, ferric sulfate and liquid oxygen were used to build and test these models. An 80/20 percent data split was used for training and testing model performance using correlation coefficients, relative mean square error, relative root mean square error and Nash–Sutcliffe efficiency. Results indicate, compared with PCR, both SVR and LSTM were able to capture the nonlinear relationship between chemical dose and source water quality changes and displayed higher predictive skills. These types of models have application in real-time operational support without requiring computationally expensive physics-based models.
HIGHLIGHTS
A study that examines water quality and chemical use from a water treatment plant.
Appropriate chemical dosage is essential to ensure safe potable water.
Understanding the relationship between water quality and chemical use is a key step.
Different algorithms are tested to build predictive models.
Support vector machine and neural networks better capture nonlinear relationships.
INTRODUCTION
Drinking water treatment plants (DWTP), within design limits, can treat raw water from supply sources to meet regulatory water quality standards through a combination of physical, chemical and biological treatment processes. Chemical cost is a significant item of total operational cost for DWTP (Heberling et al. 2015; Price & Heberling 2018), which is primarily driven by source water quality for the same amount of raw water being treated.
Adjustment of chemical dosage based on influent water quality is often needed. A dramatic decline in water quality, often caused by extreme rainfall events, severe algal blooms or the presence of cyanobacteria, may require increased monitoring of the treatment process (Besmer & Hammes 2016), timely adjustment of chemical dosage or even temporary shutdown of the DWTP (Kansas Department of Health and Environment 2011). Although the DWTP has standard operating procedures and some flexibility to alter treatment processes within its design limit to cope with fluctuations in raw water quality, a wide range of water quality fluctuations still pose challenges for DWTP at times. A decision-supporting tool that can be used to help operators determine the right amount of chemical dosage depending on intake water quality can be instrumental in reducing chemical cost while achieving water quality standards. Such a tool is especially important for treatment plants that have multiple water supply sources because water quality at an intake is a mixture of water from different supply sources with distinct water quality.
Chemical dosage adjustment requires real-time data, understanding of the fluctuations of the physical, chemical and biological characteristics of the raw water, and in-house expertise on the specific treatment processes. Approaches that facilitate such adjustment can be categorized in two methods. The first is an on-site jar test, which requires treatment plant operators or laboratory technicians to conduct a pre-identified list of laboratory tests to determine the chemical dosage based on experience and professional judgment. The disadvantages of this approach include that it requires dedicated resources and time to conduct laboratory tests, and jar test findings may not correlate directly to real-time treatment. This would also require timing adjustment of the frequency of sample analysis whenever drastic water quality changes occur. The second is the application of statistical methods to build predictive models relating chemical dosage to source water quality changes.
Many case studies using artificial intelligence to predict treatment process performance (Çamdevýren et al. 2005; Veerapaneni et al. 2010) and facilitate chemical dosage in DWTP have been reported in the literature (Golfinopoulos et al. 1998; Maier et al. 2004; Lamrini et al. 2005; Bae et al. 2006; Veerapaneni et al. 2010; Heddam et al. 2011; Kim & Parnichkun 2016; O'Reilly et al. 2018). Nearly all of these studies focused on developing predictive tools for single chemical dosage. This study considers simultaneous dosing requirements of multiple chemicals used in the treatment process and aims to evaluate three machine learning algorithms in building a predictive tool.
This study is motivated by water quality management at a regional water supply agency, Tampa Bay Water, located on the west coast of Florida in the United States. Its drinking water treatment plant accepts a mixture of water from two surface water supply sources, the Hillsborough River and the Alafia River, and an offline reservoir that contains a blend of water from those two sources. Water quality in Hillsborough River and Alafia River is not the same due to land use and hydrogeologic differences in the watersheds. For instance, during the drought season from January to May, harvested water from the Hillsborough River resembles groundwater quality characteristics due to the interaction between surface and groundwater systems where groundwater dominates the total river flow, whereas water quality in an offsite reservoir is the time-averaged water quality of both sources. At any given time, a single source or a mixture of up to three sources may be used to supply water to the DWTP depending on season, water availability, and demand on the system. Examining the relationship between raw water quality and chemical dosage helps in the understanding of key parameters that drive chemical use. It can also play a crucial role in potentially rotating supply sources based on both water quantity and quality.
The goal of this study is to develop a predictive tool for chemical dosage based on intake water quality at the daily time-scale. Specifically, it aims to: (1) examine the relationship between historical chemical dosage and influent water quality data; (2) evaluate dominant influent water quality parameters; and (3) compare performance of different models in predicting chemical dosage.
METHODOLOGY
In this section, three different approaches, namely principal component regression (PCR), support vector regression (SVR) and long short-term memory (LSTM) neural network, tested in this study are described briefly and references are provided for interested readers. Model evaluation metrics used for model comparison are also provided.
Principal component regression (PCR)
PCR is an approach used to build a regression model of a reduced dimension of original dependent variables, which uses principal component analysis. Principal component analysis (Shaw 2003; Abdi & Williams 2010) is a dimension reduction technique, aiming to replace a large number of correlated predictors with a reduced number of representative uncorrelated predictors, known as the principal components. Mathematically, each principal component is a linear combination of original predictors, coefficients of which can be obtained through the decomposition of the covariance matrix. A larger eigenvalue denotes that a higher variance can be explained in the direction represented by its corresponding eigenvector. The main advantage of such an approach is dimension reduction and its detailed mathematical derivations are widely reported in the literature. Rather than using the original time series, principal components are used as potential predictors in the PCR. PCR has been applied to build predictive models in water quantity and water quality (Çamdevýren et al. 2005; Wang et al. 2013).
Support vector regression
Long short-term memory neural network
A long short-term memory (LSTM) network is a specific type of recurrent neural network, in the configuration of which connections between neurons form a directed cycle (Sutskever et al. 2014). Using recurrent neural networks, information from previous time steps can be used as input for predicting the output of the current time step. The concept of information control is introduced, and distinct types of gates are used in its configurations (Hochreiter & Schmidhuber 1997). The salient feature of LSTM is that it can bring information in the past, e.g., crossing several time steps, and avoid earlier signals fading away in learning and simulating the underlying system dynamics. This is primarily because it does not have a problem with exploding and/or vanishing gradients. Although different variants of the LSTM network have been developed, the basic structure of an LSTM network (Gers 2001), typically consisting of three gates, is illustrated in Figure 1. The three different gates are the input gate, forget gate, and output gate, each of which is represented by a sigmoid neural network layer (σ) and a multiplicative unit (×). Mathematical description of the LSTM structure depicted in Figure 1 can be found in Gers et al. (2000).
LSTM is implemented in Matlab using the stochastic gradient descent with momentum (SGDM) optimizer. Hyperparameters of the model, e.g., initial learning rate and momentum of the SGDM, are determined through Bayesian optimization.
Model evaluation metrics
The value of NSE lies between 1.0 and −∞. A value of 1.0 denotes perfect prediction with the numerator being zero in Equation (5). An efficiency of a negative value indicates that the model is not as good as using the mean value of chemical dosage for prediction.
The three modeling techniques described in this section have been tested in this study to evaluate which has better predictive skills in determining daily chemical use based on influent water quality. Although the modeling techniques are general and can be applied to any other DWTP, results presented in later sections may only apply to the study area in this study, given that water quality parameters and water treatment process may not be the same.
CASE STUDY
Study area and data
Tampa Bay Water (TBW), formed in 1998, is a regional water utility in southwest Florida that provides wholesale water to six of its member governments including the cities of Tampa, St Petersburg and New Port Richey and the counties of Hillsborough, Pinellas and Pasco, serving about 2.5 million residents. TBW has a diverse water supply system, with 13 groundwater wellfields of up to 454,628 cubic metres per day (120.1 million gallons per day (mgd)) permitted capacity on an annual basis, 454,249 cmd (120 mgd) surface water treatment plant and 5.678 × 107 cubic metre (15 × 109 gallon) off-stream reservoir. In addition, a seawater desalination plant of 94,635.30 cmd (25 mgd) has been in operation since 2005.
The surface water treatment plant accepts a mixture of water from two surface water supply sources and an offline reservoir, depending on source rotation from those sources. The two surface water supply sources are the Tampa Bypass Canal connecting to the Hillsborough River, and the Alafia River. A mixture of different portions from the supply sources is based on regional demand, water availability and expert judgment. To ensure high-quality effluent, the plant incorporates a three-stage water treatment process. The first stage is a Veolia patented process that aims to remove the color and particles from the raw water. The second stage is ozone disinfection that kills microorganisms including bacteria, viruses, and protozoa. The third stage is biologically active filtration where remaining organic molecules are removed. After the three-stage process, treated water is disinfected again using chlorine and chloramines. Each of those processes demands chemical use and the chemical dosage is dependent on source water quality.
In this study, water quality data, normalized chemical dosage in the units of milligrams per litre (mg/L), and streamflow at the two surface water rivers during the years 2015–2019 were collected. All data are available at the daily time-scale. Water quality parameters include color, pH, turbidity, alkalinity, temperature, conductivity, chloride and sulfate. Chemicals used in the treatment processes include sulfuric acid, ferric sulfate, polymers, hydrated lime, liquid oxygen, microsand, sodium hydroxide and sodium hypochlorite. Only a subset of chemicals is identified for predictive model building after preliminary analysis. Water quality data at the intake were obtained from supervisory control and data acquisition (SCADA) readings; chemical dosage was obtained from operators and streamflow was retrieved from Tampa Bay Water's database, which gathers hydrologic data from its service area.
Results
Influent water quality exhibits strong seasonality as shown in Figure 2. Color, measured in platinum cobalt units (PCU), is typically introduced by dissolved organic materials from decaying plants and leaves, dissolved minerals and/or industrial discharges. Presence of color can reduce both the quantity and quality of light penetration into the water column. Color measured in the source water varies between 0 and 260 PCU on a daily basis with high values during the months of August, September, and October (Figure 2(a)). Figure 2(b) shows the daily fluctuation of alkalinity, which is a measure of the water's capacity to neutralize acids. It serves as a buffer against rapid pH changes. The buffering capacity comes from the dissolution of compounds in rocks and minerals, e.g., calcium carbonate, magnesium carbonate, phosphates and hydroxides. Because of this, the alkalinity of groundwater is typically greater than that of surface waters. Figure 2(b) indicates that it varies from 40 to 130 mg/L and has higher values in the months of January to May, corresponding to the dry season when influent is a mixture of reservoir water and surface water from the Tampa Bypass Canal, which is connected to the Hillsborough River.
There is a statistically significant correlation among some of the water quality parameters, as shown in Figure 3. The scatterplots of different combinations of water quality parameters are shown in the grids and corresponding correlation values are shown in ovals. The correlation values between different pairs of water quality parameters are shown in the ovals. The red ovals indicate negative and blue indicate positive correlation that is statistically significant at the 0.05 significance level. Otherwise, the correlation value is presented in a grey oval, as shown for the correlation between temperature and turbidity. One of the water quality parameters, color, is negatively correlated with pH, alkalinity, conductivity, calcium hardness, chloride and sulfate. Alkalinity is positively correlated with conductivity, calcium hardness, chloride and sulfate. The correlation ranges from 0.74 to 0.90. Conductivity, reflecting the capacity of water to conduct an electronic current, is a measure of ionized substances in water. Strong correlation among water quality parameters provides a basis to employ principal component analysis, using a smaller number of variables to represent the total variabilities exhibited in those variables to reduce the dimensions of a predictive model.
Streamflow data can also be used as predictors for chemical use in the treatment processes since strong correlation has been identified between streamflow and water quality parameters. For the study area, the months of July, August, and September are the rainy season during which time extra surface water can be harvested and stored in the offline reservoir. In this study, both water quality parameters and streamflow data at the two surface water sources are incorporated as predictors. Figure 4 shows the cross-correlation between predictors and chemical use at the daily time-scale. All the correlation values displayed in Figure 4 are statistically significant at the significance level of 0.05.
The pattern of cross-correlation is the same for ferric sulfate, Actiflo polymer and liquid oxygen, as indicated by the colors of the ovals in the last three columns in Figure 4(a). Sulfuric acid is positively correlated with pH, alkalinity, chloride and sulfate. Most of the correlation values are within the range of 0.6 to 0.8. It is, however, negatively correlated with streamflow at Hillsborough River and Alafia River, with the correlation value of −0.48 and −0.40, respectively. Ferric sulfate is negatively correlated with streamflow data and several water quality parameters, including pH, alkalinity, conductivity, calcium hardness, chloride and sulfate. Linear correlation between Actiflo polymer and water quality/quantity is not as strong as that between sulfuric acid and water quality parameters.
Figure 4(b) shows scatterplots of potential predictors and chemical dosage. The blue line is a linear regression of the two variables in each boxplot. It provides insights that otherwise might be ignored by only examining the numbers. For instance, the correlation between alkalinity and sulfuric acid is 0.82; and the correlation between color and ferric sulfate is 0.73. Although the two correlation values are similar, the scatterplot between alkalinity and sulfuric acid shows a different feature compared with the scatterplot between color and ferric sulfate. The variability of alkalinity is smaller at the lower end of sulfuric acid; the variability of color is higher at the lower end of ferric sulfate. Understanding such features facilitates an examination of the performance of predictive models. Preliminary investigation found that lag-1 correlation, i.e., correlation between chemical dosage at the current day and chemical dosage the previous day, is significant. Therefore, lagged-1 chemical dosages, one for each predictand, were also included as predictors. In total, 15 predictors, including nine water quality parameters, streamflow data at two surface water rivers, and four lagged-1 chemical dosages, are used for building predictive models.
As shown earlier, there is a strong cross-correlation between water quality parameters. Figure 5 below shows the percentage of variance explained by each principal component in the 14 predictors. The first five principal components, in total, explain 82.7% of the variance exhibited in all the predictors. Each principal component is a combination of all the 15 predictors.
Since predictors are of different units and the magnitude of values varies, each predictor was normalized to ensure data has a zero mean. In building predictive models, 80% of the data was used for model calibration and the remaining 20% was set aside for testing model performance. For the PCR model, the first five principal components were used. Figure 6 shows the scatterplots between observed data and model prediction for both training and testing periods. The nonlinear relationship between predictors and chemical dosage for sulfuric acid and ferric sulfate can be inferred from Figure 6(a) and 6(b). At the higher end of actual sulfuric acid dosage, when it is over 120 mg/L, the PCR model underpredicts observations. At the lower end of actual ferric sulfate, when it is less than 100 mg/L, the PCR model overpredicts these values.
In using SVR, different kernel functions including the linear and RBF kernel are tested to obtain better performance. A grid search method is used to identify the optimal hyperparameters in training the SVR model. Mapping the predictors to a higher-dimensional space allows SVR to better capture the relationship between predictors and chemical dosage. Figure 7 shows scatterplots between actual chemical dosage and predictions from the SVR model for both the training and testing periods. Compared with principal component regression, the SVR model better captures the variabilities in sulfuric acid and ferric sulfate.
In training the LSTM model, an input layer of 14 nodes is first added, followed by an LSTM layer with ten nodes and a fully connected layer of four nodes, corresponding to the dosage of the four chemicals. The mean square error of the model during the training period is used to optimize the selection of hyperparameters of the LSTM model. Figure 8 shows the scatterplots between actual chemical dosage and predictions from the SVR model for both the training and testing periods. Model performance for both the training and testing periods is summarized in Table 1.
Evaluation metric . | Chemical dosage . | Training data . | Testing data . | ||||
---|---|---|---|---|---|---|---|
PCR . | SVR . | LSTM . | PCR . | SVR . | LSTM . | ||
R2 | Sulfuric acid | 0.67 | 0.71 | 0.75 | 0.71 | 0.74 | 0.71 |
Ferric sulfate | 0.62 | 0.69 | 0.77 | 0.61 | 0.66 | 0.70 | |
Actiflo polymer | 0.49 | 0.55 | 0.67 | 0.49 | 0.64 | 0.54 | |
Liquid oxygen | 0.42 | 0.56 | 0.53 | 0.42 | 0.38 | 0.36 | |
RRMSE | Sulfuric acid | 0.20 | 0.18 | 0.17 | 0.21 | 0.20 | 0.21 |
Ferric sulfate | 0.16 | 0.14 | 0.12 | 0.18 | 0.16 | 0.16 | |
Actiflo polymer | 0.18 | 0.17 | 0.14 | 0.20 | 0.16 | 0.19 | |
Liquid oxygen | 0.26 | 0.23 | 0.23 | 0.29 | 0.30 | 0.30 | |
NSE | Sulfuric acid | 0.67 | 0.71 | 0.75 | 0.69 | 0.73 | 0.71 |
Ferric sulfate | 0.62 | 0.69 | 0.77 | 0.59 | 0.65 | 0.69 | |
Actiflo polymer | 0.49 | 0.54 | 0.67 | 0.42 | 0.63 | 0.46 | |
Liquid oxygen | 0.42 | 0.55 | 0.53 | 0.36 | 0.34 | 0.34 |
Evaluation metric . | Chemical dosage . | Training data . | Testing data . | ||||
---|---|---|---|---|---|---|---|
PCR . | SVR . | LSTM . | PCR . | SVR . | LSTM . | ||
R2 | Sulfuric acid | 0.67 | 0.71 | 0.75 | 0.71 | 0.74 | 0.71 |
Ferric sulfate | 0.62 | 0.69 | 0.77 | 0.61 | 0.66 | 0.70 | |
Actiflo polymer | 0.49 | 0.55 | 0.67 | 0.49 | 0.64 | 0.54 | |
Liquid oxygen | 0.42 | 0.56 | 0.53 | 0.42 | 0.38 | 0.36 | |
RRMSE | Sulfuric acid | 0.20 | 0.18 | 0.17 | 0.21 | 0.20 | 0.21 |
Ferric sulfate | 0.16 | 0.14 | 0.12 | 0.18 | 0.16 | 0.16 | |
Actiflo polymer | 0.18 | 0.17 | 0.14 | 0.20 | 0.16 | 0.19 | |
Liquid oxygen | 0.26 | 0.23 | 0.23 | 0.29 | 0.30 | 0.30 | |
NSE | Sulfuric acid | 0.67 | 0.71 | 0.75 | 0.69 | 0.73 | 0.71 |
Ferric sulfate | 0.62 | 0.69 | 0.77 | 0.59 | 0.65 | 0.69 | |
Actiflo polymer | 0.49 | 0.54 | 0.67 | 0.42 | 0.63 | 0.46 | |
Liquid oxygen | 0.42 | 0.55 | 0.53 | 0.36 | 0.34 | 0.34 |
All the three models have better predictive skill for sulfuric acid and ferric sulfate compared with Actiflo polymer and liquid oxygen. Although performance in the training period is not the ultimate objective of model building, it can provide insights into how well a model could perform for the testing period. For the training data, the R2 between model predictions and observation ranges between 0.62 and 0.75 for sulfuric acid and ferric sulfate, indicating 62%–75% variance can be explained by the predictive models. The R2 reduces to within the range of 0.42 and 0.66 for Actiflo polymer and liquid oxygen. This indicates that the dosages of Actiflo polymer and liquid oxygen are not fully determined by influent water quality; it may also relate to other treatment processes that are not explicitly captured in this study. This can also be reflected in the metric of RRMSE, the value of which range between 0.10 and 0.16 for sulfuric acid and ferric sulfate during the testing period. RRMSE is within the range of 0.11 and 0.23 for Actiflo polymer and liquid oxygen. For the testing data, NSE is greater than 0.5 for sulfuric acid and ferric sulfate for all the three models.
Among the three predictive models, both SVR and LSTM are generally better than PCR, whereas the performance of SVR and LSTM is comparable, although there is some difference between the two depending on the type of chemicals. LSTM better captures variabilities for sulfuric acid and ferric sulfate when the chemical dosage is relatively higher, i.e., sulfuric acid over 120 mg/L and ferric sulfate over 200 mg/L. SVR, on the other hand, has better performance for Actiflo polymer when the observation is less than 0.75 mg/L.
DISCUSSION
Adjustment of chemical dosage in the treatment processes in drinking water treatment plants (DWTP) based on influent water quality is essential in producing quality water and maintaining operational cost at the targeted level. Data analyses provided in the Results section provide insights into what water quality conditions would require a higher dosage of different chemicals, indicating higher chemical cost and potential challenges for the treatment processes. It is well recognized that improved source water quality generally leads to a lower chemical cost for DWTP (Holmes 1988; Piper 2003; Forster & Murray 2007; Abildtrup et al. 2013; Mosheim & Ribaudo 2017; Warziniack et al. 2017). Therefore, source water protection, broadly defined as actions that protect source water quality conditions from adverse impact prior to the intake, and real-time water quality monitoring have received growing attention from practitioners in recent years (Price & Heberling 2018).
Historically, chemical dosage was determined by an implicit model, i.e., mainly experience and professional judgement. Therefore, such chemical dosage might not be optimal given water quality conditions at that time. Predictive models explored in this study aim to provide an explicit and alternative model in determining chemical dosage. Both predictive models built using SVR and LSTM have excellent performance for sulfuric acid and ferric sulfate. These models can be used by water managers to predict chemical dosage. For Actiflo polymer and liquid oxygen, predictive models developed in this study can be further fine-tuned to incorporate treatment processes, e.g., outlet water quality from prior treatment units. For instance, the dosage of liquid oxygen is mostly related to what is coming out of the Actiflo and overfeed of chemicals in Actiflo can lead to much higher ozone demand. Operators do this in real-time by making an adjustment, then watching to see whether it affects the ozone residual. Incorporating intermediate water quality in the upstream treatment processes to predict chemical dosage in the downstream processes is a potential extension of the current study.
Analyses presented in this study also have implications for water resources management to incorporate both water quantity and water quality. This is especially true for water utilities that have multiple supply sources with varying water quality to feed their DWTP. For the case study of Tampa Bay Water, water quality in Hillsborough River and Alafia River is not the same due to land use and hydrogeologic differences in the watersheds. For instance, during the drought season from January to May, harvested water from Hillsborough river resembles groundwater quality characteristics due to the interaction between surface and groundwater systems. Figure 9 shows the temporal variation of one water quality parameter, color, and portions of influent from different supply sources. A decision tool that incorporates both water quantity and water quality at each supply source can be developed to determine water withdrawal from each, which is beyond the scope of this study. Real-time monitoring of water quality at the source water, which is currently unavailable at the time of conducting this study, would facilitate the developing of a decision support tool based on the current study. This can be another extension of this study.
CONCLUSIONS
This study presented data-driven approaches to predict chemical dosage in DWTP based on influent water quality. Three machine learning algorithms, namely principal component regression, support vector machine and long short-term memory neural network, are tested to build predictive models for chemical dosage at the daily time-scale. Predictors include water quality parameters, e.g., pH, color and turbidity, and streamflow information. An 80%/20% split was used for the training and testing datasets. Four evaluation metrics, namely correlation, relative mean square error, relative root mean square error, and Nash–Sutcliffe efficiency, were used. Both SVR and LSTM were found to better capture the nonlinear relationship than PCR. This was demonstrated through better predictive skills. The performance of SVR and LSTM was comparable, although there was a slight difference between the two. LSTM better captured variabilities for sulfuric acid and ferric sulfate when the chemical dosage was relatively higher, i.e., sulfuric acid over 120 mg/L and ferric sulfate over 200 mg/L. SVR, on the other hand, had better performance for Actiflo polymer when the observation was less than 0.75 mg/L. Extension of the analyses presented in this study includes further incorporation of treatment processes to improve predictive skill for Actiflo polymer and liquid oxygen dosages. Results from this study can be further utilized in building a decision support tool that incorporates both water quantity and quality to determine withdrawal from different supply sources to feed the DWTP. Although the analyses were conducted for a case study presented in this paper, the methodology is general and can be useful for other regions.
ACKNOWLEDGEMENTS
The authors thank the constructive comments from the two anonymous reviewers that have improved the manuscript.
DATA AVAILABILITY STATEMENT
Data cannot be made publicly available; readers should contact the corresponding author for details.