Computational modelling of geochemical speciation of the trace metals in the wastewater treatment process optimization

The speciation of trace metals in the wastewater treatment plants determines its ultimate fate in natural surface waters due to biological and chemical processes. The quantification of the trace metals speciation studies was undertaken in the WWTP and was of special concern due to their persistence and recalcitrance in the biosphere. The metals of interest included: Al, Co, Cr, Cd, Fe, Cu, Ni, Mn, Mo, Zn, Pb and Ti. Trace metals accumulation was determined using geochemical modelling-mass balance. The mass balance model had a numerical impact on cost optimization procedure that uses steady state with a set of pre-defined constraints to evaluate operation points, controller parameters and plant dimensions. The mass balance model allowed detection of inconsistencies within the trace metals datasets and assisted in identifying the systematic errors in the metal reduction. It quantified the overall removal and fate of trace metals in biological treatment plants. Mass balances comprising seasonal programmable sampling showed a significant reduction in the number of trace metals. Removal of metals from biological treatment processes was mainly by complexation of the metals with microorganisms, precipitation and adsorption. The comparison of the measured data indicated an increasing trend of high concentration in the sludge (biomass) that could be of danger to human health and environment. Geochemical modelling and computation of the speciation of the trace metals offer a powerful tool for the process design, troubleshooting and optimization representing a multi-variable system that cannot be effectively handled without appropriate computer-cased technique and modelling.


Introduction
The acceleration of industrialization and urban activities in developed and developing countries (mining and commercial regions) introduces a significant amount of pollutants (organics, inorganics, emerging contaminants, trace metals etc.) into the water systems, consequently leading to ecological degradation causing a higher anthropogenic emission of the pollutants into the biosphere (Cheng et al. 2002;Kamika et al. 2014). In recent years, trace metal production has decreased in many countries due to legislation, altered and disrupted industrial activities and improved cleaner technology (Karvelas et al. 2003). With the fourth industrial revolution (FIR/4IR), the exponentially increasing population push a need for controlling trace metals discharge into the environment in a more pronounced way due to the high level of bioaccumulation, toxicity and wide range of persistence and source (Wang et al. 2015). The xenobiotic properties of the trace metals allow them to accumulate in the environment (Burgess et al. 1999). The fate of the trace metals speciation has intensified environmental pollution and deteriorate the ecosystems with the accumulation of pollutants that have become persistence and recalcitrance in the biosphere (Veglio and Beolchini 1997;Volesky 2001). This results in health problems that demonstrate themselves at the acute and chronic levels that are reflected in the society's spiraling health care cost (Volesky 2001). The trace metals pollution effects of wastewater on the environment are well explained by (Fu and Wang 2011). Growing attention has been given to the potential health hazard presented by the presence of trace metals in the environment beyond the 1 3 279 Page 2 of 12 threshold limits. Another emerging technological advancement (nanotechnology) with a sparkling bright future is nanoparticles entering water streams and wastewater treatment process (Shamuyarira and Gumbo 2014). Mining industries and industrial activities have been considered as the major sources of trace metals contaminants. Trace metals can be precipitated, dissolved, adsorbed, co-precipitated with metal oxides or involved in microbial metabolism. Trace metals can be found in form of hydroxides, oxides, sulphide, silicates, sulphates, organic binding with humic compounds and complex sugar (Gawdzik and Gawdzik 2012). A robust technique for wastewater treatment is required to eliminate the environmental hazards associated with the trace metals in wastewater steams (Singanan and Peters 2013). The current economic, technical, conventional effective treatment technologies processes for the removal of the trace metals include: membrane technology, flotation, oxidation, electrodialysis, photocatalysis, coagulation flocculation ion exchange, electrochemical, adsorption, chemical-precipitation and biological process-microbial biomass (biosorption) based on trace metals binding capacities of various biological matters (where bacteria, algae, yeast and fungi has proved to be potential metal sorbents) (Barakat 2011;Davis et al. 2003;Fu and Wang 2011;Mohan and Pittman 2007;Sheoran and Sheoran 2006;Veglio and Beolchini 1997). The life cycle assessment (LCA) is put in place to analyze different technologies of environmental impact of the wastewater treatment in the populations. (Gallego et al. 2008) describes LCA as an environmental tool that allows the formulation of all the environmental loads related to a process/service/product. It is thus important to treat contaminated (trace metals) wastewater above the permissible license limit prior to its discharge into the environment.

Trace metals
Besides the hazard posed by the high-level concentration of trace metals, they are essential nutrients for the cell growth in microbes within the permissible concentration threshold (Karlsson et al. 2012;Matheri et al. 2016;Schattauer et al. 2011;Zhang et al. 2012). Many micro-nutrients (trace metals) act as microbial agents (enzyme and co-enzyme) however, an excessive amount may result in toxicity or inhibition (Bożym et al. 2015;Edokpayi et al. 2016;Schattauer et al. 2011). Trace metals are adsorbed to the surface of microbe fibrils on negatively charged that extend into bulk solution from cells membrane through cell walls. The microbe fibrils are negatively charged by the ionization of the functional groups such as hydroxyl-OH and COOH. Once adsorbed, trace metals are absorbed by cells of the bacterial. Enzyme systems are generally attacked by the trace metals inside the cells. Trace metals toxicity is believed to occur through the structure disruption of the enzymes and proteins molecules within the cells. (Zhang et al. 2012) reported that selected trace metals are a limiting factor when included in coenzymes, where the cell becomes more sensitive to inhibitory substances or the cells' synthesis is seriously affected by the deficiency. Meanwhile, recovery of the trace metals is a valuable resources in the resource benefaction (Wang et al. 2016

Geochemical modelling
Modelling the fate transport and occurrence of the micropollutants (i.e. trace metal) through the wastewater treatment plants is of the present concern (Pomiès et al. 2013). Geochemical modelling and computation of the speciation of the trace metals offer an extremely powerful tool for the process design, troubleshooting and optimization. Representation of a multivariable system and plant efficiency cannot be achieved without appropriate computational complexity techniques and modelling (Volesky 2001). The modelling assumes basic mass balance principles (modelbased predictive) and simple reaction kinetics (Srivastava and Majumder 2008). The mass balance has a numerical cost on the optimization procedure that uses steady state or dynamic state with a set of pre-defined constraints for operation point evaluation, controller and plant dimensions parameters. Appropriate constraints are selected to ensure that controllability measures and process parameters lie within specified bounds (Vega et al. 2007). The mass balance is a valuable tool for investigating the performance of the WWTP. This is an effective method that assess the sustainability and reliability of the big data (Gans et al. 2007). According to Sötemann et al. (2006), the primary purpose of the steady state model is determination of the fate and transport of trace metals, organic and emerging contaminants, reactor volume, sludge age, oxygen demand or gas production of the biological process units in WWTP. The steady-state models are useful in determining the design variables such as volume and sludge age prior to simulation of the defined system according to changing flows and loads (i.e. optimized operation) using dynamic models. Once the parameters are determined, the individual process units can be modelled using the simulation models to check their load response, cyclic flow and performance. The steps for modelling consist of the definition of the objectives, collection of the plant routine data, data quality control, model selection, evaluation of the model structure, experimental design, data collection for simulation and lastly calibration and validation (Langergraber et al. 2004).
The objective of this study was to predict the occurrence, fate and transport of the speciation trace metals in the wastewater treatment plant by carrying out a geochemical modelling using a mass balance. Impact of trace metals on the environment due to industry 4.0 (4IR) (industrialization, urbanization and population growth) was evaluated. Trace metals and nanoparticles (from nanotechnology industry) toxicity, bioaccumulation, persistence and recalcitrance in the biosphere were determined. Geochemical modelling and computation of trace metals speciation was evaluated to assist with the process redesign and troubleshooting of the wastewater treatment plant.

Material and methods
Sampling was undertaken from the inflow and outflow of the wastewater treatment plant in Gauteng Province, South Africa. The sampling points were: division box, primary clarifier (settler), biological nutrients removal (BNR) for activated sludge WWTP or trickling filter for the biofilm WWTP, humus tank, and chlorine contact dam (CCT ). The samples were collected in 500 mL plastic containers with no headspace volume to minimise aerobic biodegradation of organics substrates. They were marked with the indication of time, date and location of collection. Aliquots for trace metals analysis were acidified to a pH of about 2 with nitric acid and stored in the dark at 4 °C. This was to protect trace metals from sorption and precipitation losses to the walls of the container (Mackenzie 2011;Metcalf et al. 1991).

Analytical methods for trace metals
Sample preparation methods for trace metals analysis involved using nitric acid (12 mL) and hydrogen peroxide (4 mL) for digestion of the sample (10 mL) by hot plate digestion at 120 °C for 2 h. Deionized water was added to dilute the samples and make 100 mL after digestion. The samples were then filtered using cellulose acetate membrane filter (0.22 µm). The classes of metals were: suspended metals, total metals, metals in unacidified samples (retained on the membrane filter of 0.45 µm); dissolved metals, metals unacidified samples (pass through a membrane filter of 0.45 µm); the total of the suspended and dissolved metals, metals determined on an unfiltered sample after digestion. Acid-extractable metals in solution after an unfiltered sample were treated with a hot dilute mineral acids according to the standard method (Beamish, 2012;Biller & Bruland, 2012). Multi-elements solutions were used as calibration standards using 100 mg/L nitric acid and deionized water. The samples were then analysed using inductively coupled plasma optical emission spectrometry (ICP-OES) of ICAP 6500 Duo model-(165 Spectro Arcos equipped with autosampler (Cetac ASX-520) technique. The parameters for operating the ICP-OES were set as instrument power of 1400 W, flow rate of the auxiliary argon of 2 L/min, argon gas flow rate of 13 L/min, the flow rate of the argon nebuliser 0.95 L/min and iTEVA software was used. Based on the optical metals wavelength (lower determination 166.250 nm and extending to 847.000 nm), the most prominent analytical lines were chosen as follows:   (Dimpe et al. 2014;Scientific 2009a;Scientific 2009b;Wiel 2003). Calculation of the concentration of the elements in the aqueous sample and in the digested solid sample is shown in the Eq. 1 and Eq. 2 respectively (Wiel 2003).
where C was elements concentration in the aqueous sample in mg/L, C 1 was concentration of the element in the test sample in mg/L, C 0 was concentration of the element in the blank sample in mg/L, f d was a dilution factor in digestion of an aqueous sample in f d = 1, f a was a dilution factor of the test portion, V was volume of the test sample (digest) in (L), w was element mass fraction in the solid sample in mg/kg, M was mass of the digested sample in g.

Trace metals mass balance with geochemical modelling
The mass balance modelling of the trace metals was based on wastewater monitoring data (measured data), experimental analysed data and theoretical data. Geochemical modelling of mass transport in fluid systems was mostly based on the chemical kinetics controlled only by basic/acid properties of the exposed cell wall surface as described by (Mullen et al. 1989) and (Fein et al. 1997). The model was used for evaluation of the data and validated to attain high level of confidence in the experimental output. Trace metals accumulated independent and dependent on metabolism on both dead and living biomass as well as in cellular products such as polysaccharides. The removal of the trace metal was determined using a mass balance of the completely mixed reactor as: Assuming first-order removal kinetics r C = −kC ), where: Substituting and integrating gave: But when t = 0, C = C o and K was equal to: Substituting the K to the expression at non-steady state solution gave Eq. 8.
At the steady state conditions when the rate of the accumulation was equal to zero (dC/dt = 0) was given by: The complete mixed reactor in series at a steady state was presented as: General mass balance: Assuming first-order removal kinetics r C = −kC 2 , C 2 yielded: But from C 0 , the value of the C 1 was equal to: Combining the above expression yielded: The n th reactor in series was represented by the corresponding expression: where C was final concentration in mg/L, C 0 was initial concentration in mg/L, Q was hydraulic flow rate in m 3 /d, V was reactor volume in m 3 , r c was rate of the reaction and k was rate of kinetic in/d. The mass balance model was developed in Microsoft Excel 2016 and the workbook consisted of several spreadsheets based on the datasets that assisted into identifying the systematic errors in the trace metal reduction. This quantified the overall removal and fate of these trace metals in biological treatment plants.

Time series forecasting (predictive modelling) of trace metals speciation with python codes-machine learning
The import of dependencies, for linear regression used was scikit-learn (built-in Python (Jupiter library). Another dependency was imported to split our data into train and test. Read test and train data set was from the wastewater treatment plant trace metals speciation on seasonal basis. Data descriptive analysis (data exploration) was determined based on (i) identify ID, input and target features (ii) identify categorical and numerical features, and (iii) identity column with missing values. Smart first effective model was undertaken for data treatment (mission values treatment) by: (i) creating a dummy flag for missing values, (ii) imputing missing values with the mean/median, and (iii) imputing missing values of the categorical variables. Data modelling was undertaken. Validation of the model's performance was evaluated by estimating the performance and measure error of the machine learning time-series prediction. Summary method: import scikitlearn library, import (load) data, describe data, split data into test and train sets, split the targets into training/testing set, create linear regression, train the model using set of training, make predictions using set of testing, the coefficients, check the prediction performance using mean squared error (MSE). The plot output started with naïve forecast, average forecast, simple exponential smoothing (SOS), Holt's linear trend forecast and Holt-winters forecast (Fig. 1).

Speciation of the trace metals using mass balance
The sources of trace metals included the discharge from the industrial activities, products, products used in the residential applications such as personal care products and cleaning agents, groundwater infiltration and commercial discharge. The concentration of trace metals in wastewater varied with time. Daily, weekly and monthly variations concentration was observed as pattern of function of industrial production activities. The variation was important in the operation, control and redesign of the WWTP. The trace metals diurnal patterns for activated sludge and biofilm plant are indicated in Figs. 2 and 3 respectively. High concentration of Al, Zn, and Fe was observed in the all the process units. The highest concentration of Al, Zn and Fe was observed in the biological nutrient removal (BNR) unit due to the recycling of the sludge that maintains the concentration followed by the influent in the primary pretreatment units.
High Al, Fe and Zn concentration was observed in the all the process units in the biofilm WWTP. The highest concentration of the trace metals, in general, was observed in the primary pretreatment unit due to the high concentration of the trace metals in the influent. The Zn was in dominance followed by Fe and Al. All the other trace metals contributed to metabolism and growth of micro-organism while other were accumulated either in with the microbes and sludge discharge. According to (Metcalf et al. 1991), trace metals (micro) of importance in the biological wastewater treatment, disposal of biosolids and reuse included: iron, lead, copper, manganese, nickel, molybdenum, vanadium, selenium, chromium zinc, zinc, aluminum, cobalt. The macro metals that were of importance to the metabolism and in the biological wastewater treatment included; calcium, sodium, iron, potassium and magnesium. Removal of metals from biological treatment processes was mainly by complexation of the metals with microorganisms, precipitation and adsorption. The raw wastewater inflow in the biofilters and activated sludge WWTP shows variation in a dominance of Fe and Al respectively as shown in Fig. 4 with raw wastewater inflow dominating with respective effluent. The mass balance models showed smooth curve that was consistent with the overall analysis. Mass balance model allowed detection of inconsistencies within the trace metals datasets and assisted in identifying the systematic errors in the metal reduction. All the treatment plants showed a distinctly marked profile with a low concentration of trace metals. The trace metals in the wastewater could influence the possibilities for reuse of the sewage sludge in the agriculture sector by providing the nutrients to the soil. Trace metals in wastewater are beneficial in terms of in metabolism, the growth of biological life and absence of sufficient quantities that lead to micro-pollution, toxicity and limit the growth of algae. According to (Metcalf et al. 1991), microbes combine with metals ions and are discharge to the surface. The precipitation works with addition of chlorides to form metal sulfides in sludge stabilizer unit. Trace metals are said to be complexed by carboxyl group found in microbial polysaccharides and other polymers or absorbed by protein materials in the biological cells (Metcalf et al. 1991). According to Mullen et al. (1989) and Ahluwalia and Goyal (2007), the removal of metals in biological processes were found to fit the Freundlich isotherm models. All the trace metals were below the threshold 20 mg/L and compiled with the wastewater treatment plant license and international standards (Abdel-Shafy and Mansour 2014; Department of Water and Sanitation, [Accessed June 2021]; Mackenzie 2011; Raval et al. 2016). According to Pomiès et al. (2013), the removal efficiency depends on physio and chemical properties of the trace metals, WWTP operating conditions (parameters), sludge retention time (SRT) and hydraulic retention time (HRT) and temperature. Another study by (Luo et al. 2014) suggested regardless of the technology employed, the trace metal removal depends on physio-chemical properties of the micro-pollutants and the treatment conditions. This is essential for the performance predicting, assessment and evaluation on the receiving environment. Figures 5,6,7,8,9 and 10 shows prediction of the trace metals using time-series forecasting with Python codes machine learning.

Speciation of the trace metals using time-series forecasting with python codes-machine learning
The mean squared error reported was Naïve (0.023), average (0.019), simple exponential smoothing (0.022), Holt linear (0.037) and Holt winter (0.041). Simple exponential smoothing (SES) and moving average forecasting had a good prediction of the trace metals speciation using time-series machine learning (python) with Holt winter been the poorest for the prediction of the trace metals speciation. The final    effluent of the trace metal speciation was below the permissible limit as showed in Fig. 11.

Conclusions and recommendations
The optimized operation requirement (via modelling) of WWTP played an important role in minimizing the release of trace metals into the aquatic environment. The predicted fate of transport of the trace metals in the WWTP was modelled using mass balance concept. This show a speciation of the trace metals in multiple units associated with water, air, microbes, biosolids and biomass, with biological treatment systems with the quantitative dependent upon physical-chemical and biological properties. Using the mass balance model made the integrated design process friendly and easier especially in data-entry and making results of the analysis process easy and understandable. The mass balance showed removal performance and treatment efficiency of the WWTP. The machine learning algorithms in python with scikit-learn showed high accuracy of the time series prediction of the trace metals speciation. Implementation of the bioinformatics tools for mathematical modeling analysis in the wastewater treatment systems in counter-checking the behaviors of complex biomolecular systems, explanatory, forecasting and predictions that are useful in the decision making and precisely engineering cellular functions, troubleshooting, design of new and upgrade of the existing WWTPs, and enhancing the effluent permissible limits on discharge to the environment. Highly recommended to monitor the concentration of micronutrients (trace metals) and macro-nutrients to guarantee the efficiency of biomethane production. These nutrients open an insight on the effect of the metabolic intermediates, end products and this opens excellent prospects for process optimization.
Acknowledgements The authors wish to acknowledge the WRC-Water Research Commission, South Africa, Project No. K5/2563 for funding.