Artificial Intelligence for Electrocoagulation Treatment of Olive Mill Wastewater

An electrocoagulation system using bipolar aluminium electrodes was studied for the treatment of olive mill wastewater (OMW). Response surface methodology and adaptive neuro-fuzzy inference system (ANFIS) were employed to study the effects of operating parameters on the removal of chemical oxygen demand (COD). At the optimum condition of initial pH 4, current density 83 mA cm-2 and 20 min-electrolysis time, the estimated COD removal efficiency of 40.4% was close to the experimental result (42.7%) with a coefficient of determination r2=0.92. Results from ANFIS indicated that the order of operating parameters affecting the COD removal efficiency was pH>current density>electrolysis time. Additionally, the optimal combination of two inputs influencing the COD removal efficiency was current density × pH, since it recorded the least training root mean square error of 5.04. This study demonstrated that ANFIS could be used as a tool to describe the factors influencing electrocoagulation process.


Introduction
Extraction of oil from olive fruit is one of the important industries, and it is the main agri-business activity in North Sinai governorate of Egypt. The governorate contains 18 olive mills that generate olive mill wastewater (OMW) exceeding 720 cubic meters per day during the milling season. Through olive oil production, a huge amount of wastewater is generated, accounting for 0.5-1.5 m 3 of OMW per 1000 kg of olives (depending on the method used for the oil extraction) [1]. OMW arises from olive oil production is characterized by high pollutants content, for example: biological oxygen demand (BOD) 15-135 gL -1 , chemical oxygen demand (COD) 40-220 gL -1 , oil and grease (O&G), phenolic compounds 2-15 gL -1 and acidic pH 4.6-5.8 [2]. Moreover, OMW includes non-biodegradable and phytotoxic wastes, long-chain fatty acids and various phenol and poly-phenol compounds, which are very difficult to treat [3]. As a result, the direct discharge of OMW into the aquatic environment imposes a serious risk. Additionally, domestic wastewater treatment plants (WWTPs), which receive discharges of OMW, are suffering from frequent failure. Thus, treatment of OMW is one of the most crucial environmental issues in the North Sinai governorate, and there is a need for partial treatment of OMW before being discharged into the treatment units.
The treatment of OMW has been investigated by several techniques, such as chemical (coagulation/ flocculation/ precipitation) [4,5], biological (aerobic and anaerobic) [2,6,7] or combination of these methods [8]. Advanced methods, including adsorption [9], oxidation [10]. Ozonation [11] and filtration through membranes [12] have also been studied for the treatment of OMW. However, these methods have some drawbacks, which limit their wide application. For example, chemical precipitation suffers from generation of large amounts of sludge, requiring additional costs for transportation, handling and storage [8]. Additionally, in membrane technology, frequent fouling requires intense chemical cleaning or membrane replacement, leading to increase the operating costs of a treatment plant [12]. Furthermore, phenolic chemicals in the OMW possess antibiotic characteristics, which limit the application of biological treatment [2].
Among the wide range of methods, electrocoagulation has been adequately employed for the treatment of OMW [13]. Additionally, the process of electrocoagulation can cope with the addition of metal salts and/or polymers for the removal of metals, colloidal solids and particles and soluble inorganic pollutants [14]. An electrocoagulation reactor consists of an electrolytic cell with one anode and one cathode, equivalent to pairs of conductive metal plates that act as monopolar electrodes [15]. When an electrical current is introduced into solution, the positive side undergoes anodic reactions, while cathodic reactions are encountered on the negative side [16]. The metal ions sacrificed into the liquid medium tend to remove undesirable contaminants either by chemical reaction and precipitation, or by causing colloidal materials to coalesce and then be removed by electrolytic flotation [14]. Electrocoagulation has a number of advantages, such as reduced sludge production, no requirement for chemical use. Recently, electrocoagulation has proven effectiveness in the treatment of several wastewater sources including OMW [17].
Electrocoagulation process is generally affected by a number of parameters, including initial pH, current density and electrolysis time. These effects can be described by artificial intelligence, such as artificial neural networks (ANN) and fuzzy logic (FL). ANN has the advantage to accurately predict outputs from the experimental data even when relationships between process inputs and outputs are highly nonlinear and data is unstructured [18]. On the other side, FL is quite good in handling uncertainties and can interpret relationships between inputs/outputs by using linguistic terms in the form of "if-then" rules (similar to reasoning and humanlike thinking) [19]. Adaptive neuro-fuzzy inference system (ANFIS) combines the advantages of both ANN and FL in order to improve the accuracy of the resulting fuzzy model [20]. Therefore, the current study aimed at investigating the effectiveness of electrocoagulation process for the treatment of OMW. Full factorial design and artificial intelligence were performed to study the influence of various parameters, such as initial pH, current density and electrolysis time on the COD removal efficiency. Experimental findings were also discussed in depth with reference to the previous articles.

Collection and composition of OMW
The seasonal extraction of olive oil usually lasts from June to January, and by the end of this season, we harvested about 400 L of OMW samples. The samples were collected in 40 L-capacity containers and stored in a freezing room (-15°C). The main characteristics of OMW are listed in Table 1.

Mechanism of electrocoagulation
Electrocoagulation is a technique used to create conglomerates of suspended, dissolved or emulsified particles in aqueous solution using electrical current [21]. An electrocoagulation reactor consists of anode and cathode like a battery cell, where metal plates (being iron or aluminum) are used as electrodes. The metal plates are usually positioned in a parallel connection with a definite inter electrode distance [22]. Figure 1 illustrates a schematic diagram of a two-electrode electrocoagulation process. Electrodes are known to be sacrificed, since the electrolytic dissolution of Al anodes by oxidation in water produces aqueous Al 3+ species (Eq. 1). The released ions neutralizes the negatively charged particles leading to coagulation, and thus suspended solids could be removed by precipitation [23]. However, at the Al cathodes, reduction takes place which results in hydrogen bubbles and hydroxyl ions (Eq. 2). The hydrogen bubbles float, and hence drive the flotation process [13]. Additionally, the generated hydroxides or polyhydroxides act as coagulant/flocculant for the dispersed particles converting them into flocs of enough density to be precipitated under gravity [4].
Anode (oxidation used for coagulation): Cathode (reduction used for flotation): Dissociation of water by electrocoagulation generates hydroxide ions, which are recognized as one of the most reactive aqueous radical specie. This radical has been suggested to promote the oxidation of toxic pollutants due to its high affinity value of about 136 kcal [24]. Furthermore, electrolytic dissociation of water molecules could produce tiny bubbles of hydrogen and oxygen gases (Eq 3). These bubbles (average diameter of approximately 20 μm) are helpful to remove the suspended solids in upward direction (flotation), making a separate layer on the surface [14]. Moreover, the oxygen produced through the anodic reactions can prevent anaerobic conditions of the wastewater, as well as can oxidize or bleach the chemicals like dyes. RuO 2 /Tianodic reaction used for flotation:

System Components and Functions
A bipolar electrolytic cell, undertaken in an 800 mL beaker for the treatment of OMW, is schematically displayed in Figure 2. Six aluminum plates, each had a dimension of length 1.5 cm × height 8.0 cm × 2 faces with an effective surface area of 18 cm 2 , were vertically installed with  an inter-electrode distance of 8 mm. We selected aluminium as the sacrificial anode, rather than iron, because the residual ferrous ions are easily oxidized by air, which may increase the color of effluent. The Aluminum plates were cut from commercial grade sheet (95-99%) of 3 mm thickness. Three alternate plates were connected to the positive pole and the other three were connected to negative pole of the DC power supply, thus acting as anode and cathode respectively. The power supply had ampere meter with digital working range 0-20 ampere and 0-200 V of electrical potential.

Experimental Procedures
In this study, three experiments were carried out to investigate the effect of operating parameters on electrocoagulation process. As listed in Table 2, a full 3 2 factorial design was employed to optimize the main factors (i.e., pH, current density and contact time) affecting the COD removal and their interactions. The design of each experiment was composed of two inputs and three levels (low, medium and high) for every factor, with a total of 9 runs.
All experiments were carried out in triplicates and the average values were recorded. To remove the oxide and/or passivation layer from the electrodes, the electrode surfaces were cleaned using a 5% (v/v) HCl solution for 5 min after each run. Experimental work was performed at ambient temperatures in the range of 25-27°C. Values of pH were adjusted by adding 1 M NaOH and/or 1 M HCl.

Statistical Tools
Response surface modeling is a statistical technique for designing experiments, building models, evaluating the effects of several factors, and searching optimum conditions for desirable responses [25]. The formula of Eq. 4 was used to fit a polynomial equation to the experimental data. ε β β β β Where, y is the COD removal efficiency (%); k is the number of variables; x i represents the independent variables (i.e., pH, current density and contact time); β˳ is the constant term; β i , β ij , β ii represent the coefficients of the linear, interaction and quadratic parameters, respectively; ε is the residual associated to the experiments. The function rstool in MATLAB R2014b was applied to estimate these parameters.

Artificial Intelligence
According to a first-order Takagi-Sugeno fuzzy model, a typical rule set with two fuzzy "if-then" rules are employed to describe the ANFIS architecture [26]. These rules are (assuming that the fuzzy inference system under consideration has two inputs x and y and one output z): Rule 1: If x is A 1 and y is B 1 , then f 1 =p 1 x + q 1 y + r 1 Rule 2: If x is A 2 and y is B 2 , then f 2 =p 2 x + q 2 y + r 2 Where, x and y are the crisp inputs to the node; A i and B i are the linguistic labels (low, medium, high, etc.) characterized by convenient membership functions; f i are the outputs within the fuzzy region specified by the fuzzy rule; p i , q i and r i are the design parameters determined during the training process (i=1 or 2).
The function exhsrch in MATLAB R2014a is used to select the input attribute that has higher impact on the considered output. Essentially, exhsrch builds an ANFIS model for each combination and trains it for one epoch (to quickly find the right inputs) and reports the performance achieved. The dataset is randomly classified into training (70%) and checking (30%) arguments. The training process stops when the designated epoch number is completed or the error goal is attained, whichever comes first. The checking data are used for testing the generalization capability of the model, and avoiding an overfitting of the training data. An input variable having the least training root mean square error (RMSE) is the most relevance with respect to the output.

Analytical Analysis
Values of pH were determined by using pH meter (pHep®, HANNA, USA). The conductivity was measured using calibrated Conductivity meter (Lutron®, YK-22CT, Taiwan). Determination of turbidity was performed using Digital Nephlometer (Orbeco-Hellige® USA). Analysis of COD was carried out according to APHA [27]. All the chemicals used in this study were of analytical grade and purchased from local suppliers, Egypt.

Effect of electrolysis time and current density (1st experiment)
The main effects plot in Figure 3a shows the relative effects of electrolysis time (10, 20 and 30 min) and current density (27, 55 and 83 mA cm -2 ) on COD removal efficiency when pH was kept constant at a value of 7.
Results depicted that the mean COD removal efficiency increased from 3.8% to 9.3% for an increase in electrolysis time from 10 to 30 min, respectively (r 0.7156, p 0.3186). Accordingly, the correlation between COD removal efficiency versus reaction time demonstrated an increasing trend. Electrocoagulation is based on the in situ formation of the coagulant as the sacrificial anode corrodes due to an applied current, while the simultaneous evolution of hydrogen at the cathode allows for pollutant removal by flotation. As the electrolysis time proceeds, three main processes are operated synergistically to remove pollutants: i.e., electrochemistry, coagulation and hydrodynamics. The amount of coagulant produced by electrolysis can be estimated by Faraday's law when current and treatment times are known. In a similar study for OMW, Esfandyari et al. [13] found that COD removal efficiency was 46.5% at 5-min reaction time, which increased to 96.2% in reaction time of 30 min. Additionally, Inan et al. [28] found that 4-min retention time provided 28% COD removal efficiency, which increased to 52% for 30-min retention time when treating OMW using electrocoagulation.
Additionally, it was found that the mean COD removal efficiency considerably elevated from 2.7% to 16.6% when the current density was  raised from 27 to 83 mA cm -2 , respectively (r 0.9328, p 0.0335). Thus, the removal of COD was increased with increasing current density. Current density (calculated as the applied current divided by the effective surface area of the electrode) is considered one of the main parameters that can affect the pollutant removal in the electrocoagulation process. When direct current passes through the aluminium anodes, Al 3+ ions dissolve and combine with hydroxyl ions in the water forming metal hydroxyls. The metal hydroxides have high ability to absorb different ions and micro-colloidal particles from the wastewater. Additionally, the increase in current density could result in increasing the rate of bubble-production and in decreasing the bubble size. Inan et al. [28] suggested that when current density varies from 10 to 40 mA cm -2 , the average diameter is 15-30 µm for hydrogen bubbles and 45-60 µm for oxygen bubbles. This condition is beneficial in terms of high pollutant removal efficiency by hydrogen floatation. In a similar study, Esfandyari et al. [13] found that the removal efficiency of COD for OMW rose from 48.8 to 88.7% when the current density was raised from 5 to 40 mA cm -2 , respectively.
A three level factorial design was employed to determine the relationship between the COD removal efficiency and the independent variables (electrolysis time and current density). The three levels were 10, 20 and 30 min for the electrolysis time and 27, 55 and 83 mA cm -2 for the current density. The visualization of the predicted model equation was obtained by the surface response plot (Figure 3b). No clear peak was observed suggesting that optimum conditions for maximum COD removal could be outside the design boundary. Accordingly, the optimum region was found through a visual inspection of the surface, and the estimated stationary point is a saddle point. The quadratic response surface model indicated that the highest COD removal of 19.7% could be attained at the best condition of 20 min and 83 mA cm -2 . Similarly, the experimental data indicated that the optimum values for electrolysis time and current density were 20 min and 83 mA Assuming electrolysis time (x 1 ) and current density (x 2 ) were the independent variables in Eq 4, the estimated quadratic model parameters would be β˳: -7.12443, β 1 : 1.890774, β 1 : -0.48516, β 11 : -0.046, β 22 : 0.005931 and β 12 : 0.004107.

Effect of electrolysis time and pH (2nd experiment)
The main effects plot in Figure 4a shows the relative effects of electrolysis time (10, 20 and 30 min) and pH (4, 7 and 9) on COD removal efficiency when current density was remained constant at a value of 83 mA cm -2 .
The mean COD removal efficiency was observed to increase from 18.0% to 26.6% with increasing the electrolysis time from 10 to 30 min, respectively (r 0.9518, p 0.1524). These results implied the positive effect of a relatively high electrolysis time on EC process for treatment of OMW. Long operating time is a positive factor to remove the COD from OMW due to an increase in the amount of metal hydroxide flocs. This trend promotes the removal of contaminants via sweep coagulation followed by precipitation mechanism, thus removal efficiency of COD increased [22].
Increasing the pH from 4 to 9 had an adverse effect on the electrocoagulation process, where COD removal efficiency considerably dropped from 38.7% to 14.0%, respectively (r -0.9515, p 0.0026). These results indicated that the highest COD removal efficiency was attained at pH of 4. The solution pH is one of the most important parameters affecting the electrocoagulation process. According to Sposito [29], when pH is lower than 6, aluminum hydroxide species, such as soluble Al(OH) 2+ (Eq. 5) and Al(OH) 2 + (Eq. 6) are predominant. However, the solid Al(OH) 3 is most prevalent in the pH range of 6 and 8.5 (Eq. 7). When pH is above 9, soluble Al(OH) 4 is found to be the predominant species (Eq. 8). The influence of pH on the solubility of Al(OH) 3 was clearly identified in the solubility diagram of aluminum hydroxide [22]. Additionally, in acidic conditions, oxidation of aluminum plates with simultaneous reduction of water result in formation of Al 3+ (Eq. 9) [17]. Those results were in good agreement with a study by Esfandyari et al. [13], which obtained maximum COD removal efficiency of 84.5% at pH equals to 4. Moreover, Hanafi et al. [14] suggested that the optimum pH for treatment of OMW wastewater by electrocoagulation is below 6.

Effect of current density and pH (3rd experiment)
The main plot in Figure 5a displays the relative effects of current density (27,55 and 83 mA cm -2 ) and pH (4, 7 and 9) on COD removal efficiency when electrolysis time was remained constant at a value of 20 min.
The mean COD removal rate was seen to increase from 8.9% to 24.7% when enhancing current density from 27 to 83 mA cm -2 , respectively (r 0.8715, p 0.1592). Accordingly, an increase in current density implied an increase in the COD removal percentage. Current density influences the treatment efficiency of the electrocoagulation, since it determines the coagulant dosage rate, as well as the bubble production rate and size and the flocs growth. Khosla et al. [23] demonstrated that bubbles density increases and their size decreases with increasing current density, causing a greater upwards flux and a faster removal of pollutants. Additionally, high current density promotes an increase in the amount of oxidized aluminium. The combination of the Al 3+ ions and highly reactive specie (OH)to form aluminium hydroxide is effectively considered as flocculating/coagulating agent to remove the pollutants from the OMW (Eq. 10) [3]. Flocs of Al(OH) 3 have large surface areas, which aid high adsorption of soluble compounds (organic) and colloidal particles.
On the contrary, the mean COD removal efficiency gradually decreased with rising pH, where it recorded 21.4%, 11.2% and 10.1% at pH of 4.0, 7.0 and 9.0, respectively (r -0.9492, p 0.2740). It can be observed that the optimum values for current density and pH were 83 mA cm -2 and 4, respectively at electrolysis time of 20 min, which achieved COD removal efficiency of 42.7%. Thus, the higher the pH the lower is the percent of COD removal. This can be explained by the fact that under high pH values Al(OH) 3 dissolves in water and forms hydroxo-complexes [Al(OH) n ] -(n-3) . Shen et al. [16] indicated that the amphoteric character of aluminium hydroxide that does not precipitate at pH<2. Additionally, high pH (e.g., >8) will increase Al(OH) 3 solubility causing the formation of soluble AlO 2 - [22], which could be useless for OMW treatment.
In a treatment of OMW using electrocoagulation, Inan et al. [28] found that the maximum COD removal efficiency of 52% was observed under pH 6, which dropped to 30% with further increasing pH to 9. Their study noted that, in neutral and weak-acid solutions, the most effective purification happens in the presence of aluminum anodes. Additionally, Adhoum and Monser [3] found that the highest COD removal efficiency (approximately 59%) of OMW was recorded at pH values between 4 and 6. Accordingly, a direct treatment of OMW using electrocoagulation process is considered feasible, since the typical pH of OMW is between 4.5 and 5.5.
A three-level full factorial design was applied to investigate the effects of the two independent variables, i.e., current density and pH, on the dependent response, i.e., COD removal efficiency. Figure 5b illustrates profile for the quadratic response surface plot, representing the predicted model equation. Through a visual inspection of the surface, the estimated stationary point is a minimum point. The experimental results indicated that the highest COD removal efficiency of 42.7% was estimated at current density 83 mA cm -2 and pH 4. The calculated COD removal efficiency under the mentioned condition was 44.6%, and the coefficient of determination between the calculated and experimental results reached r 2 0.88.

Adaptive neuro-fuzzy inference system
ANFIS was carried out to determine which of the studied experimental variables and their interactions presented higher effects on the COD removal efficiency. We employed the function exhsrch in MATLAB 2014a to perform an exhaustive search within the available inputs to select the set of inputs that most influence the COD removal efficiency (the only considered output). The three input attributes of the electrocoagulation experiments were initial pH, current density and electrolysis time. The model selected 1 input from 3 candidates, so that the total number of ANFIS models was C(3, 1)=3. Table 3, the parameters pH, current density and electrolysis time recorded training RMSEs of 9.97, 10.12 and 12.55, as well as checking RMSEs of 9.82, 11.80 and 11.89, respectively. This meant that the order of operating parameters affecting the COD removal efficiency was pH>current density>electrolysis time. The results from the function clearly indicated that the input attribute pH had the least RMSE or in other words the most relevance with respect to the output (COD removal efficiency).

As listed in
The training and checking RMSEs were comparable, signifying that there was no overfitting in the data. Accordingly, we explored if more than one input could attribute to build the ANFIS model. The current ANFIS model selected 2 input from 3 candidates, so that the total number of models was C(3, 2)=3. Results in Table 4 indicated that the training RMSEs were 9.43, 9.53 and 5.04 for electrolysis time × current density, electrolysis time × pH and current density × pH, respectively. This indicated that the optimal combination of two inputs was current density × pH (i.e., the 3 rd experiment), since it recorded the least training RMSE.

Conclusions
In this study, three experiments, based on full 3 2 factorial design, were carried out to investigate the effects of operating parameters: electrolysis time and current density (1 st experiment); electrolysis time and pH (2 nd experiment); current density and pH (3 rd experiment) on the COD removal from OMW. It was concluded that: • The 1 st experiment indicated that the optimum values for electrolysis time and current density were 20 min and 83 mA cm -2 , respectively, which attained COD removal efficiency of 22.5%. The coefficient of determination between experimental and calculated COD values was r 2 0.753.
• Results from the 2 nd experiment revealed that at the optimum condition of 20 min-electrolysis time and pH 4, the calculated COD removal efficiency of 40.4% was close to the experimental result (42.7%) with a coefficient of determination r 2 =0.92. Note: Input variable with the least training RMSE is the most relevance with respect to COD removal efficiency. Note: Input variable with the least training RMSE is the most relevance with respect to COD removal efficiency. • Results from the 3 rd experiment indicated that the highest COD removal efficiency of 42.7% was estimated at current density 83 mA cm -2 and pH 4. The calculated COD removal efficiency under the mentioned condition was 44.6%, and the coefficient of determination between the calculated and experimental results reached r 2 0.88.

Operating parameter
• According to artificial intelligence, the order of operating parameters affecting the COD removal efficiency was pH>current density>electrolysis time.
• The optimal combination of two inputs affecting the COD removal efficiency was current density × pH, since it recorded the least training RMSE.
However, electric-energy consumption and economic analysis of such electrocoagulation bipolar unit treating OMW remains to be determined; and that will be the focus of our future work.