Next Article in Journal
Rooftop Rainwater Retention Potential in Former Agricultural Areas Under a Changing Climate: A True Orthophoto-Based Assessment of a Suburbanizing Polish Village
Previous Article in Journal
Study on the Measurement and Enhancement Pathways of Ecological Efficiency of Marine Fisheries in China’s Coastal Areas
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

Analysis and Characterization of Sludge Produced by Natural Extract-Facilitated Electrocoagulation for Hardness Removal

by
Neali Valencia-Espinoza
1,
Brenda S. Morales-Verdin
1,
Daniel M. Paredes-Molina
1,
Fabricio G. Mendez-Landin
2,
James McGree
3,
Alain R. Picos-Benítez
4,
Patricio J. Espinoza-Montero
5,
Alejandro Vega-Rios
6,
Ashantha Goonetilleke
7,
Locksley F. Castañeda
8,*,
Erick R. Bandala
9 and
Oscar M. Rodriguez-Narvaez
1,*
1
Dirección de Investigación y Soluciones Tecnológicas, Centro de Innovación Aplicada en Tecnologías Competitivas, Calle Omega 201, León 37545, Mexico
2
Unidad Profesional Interdisciplinaria de Ingenierías Campus Guanajuato, Instituto Politécnico Nacional, Avenida Mineral de Valenciana 200 Col. Fraccionamiento Industrial Puerto Interior, Silao de la Victoria 36275, Mexico
3
School of Mathematical Sciences, Queensland University of Technology, GPO Box 2344, Brisbane, QLD 4001, Australia
4
Unidad Profesional Interdisciplinaria de Ingeniería Campus Zacatecas, Instituto Politécnico Nacional, Zacatecas 98160, Mexico
5
Escuela de Ciencias Químicas, Pontificia Universidad Católica del Ecuador, Quito 170525, Ecuador
6
Centro de Investigación en Materiales Avanzados, S.C., Miguel de Cervantes No. 120, Chihuahua 31136, Mexico
7
Department of Civil Engineering, Birla Institute of Technology and Science, Pilani Campus, Vidya Vihar, Pilani 333031, Rajasthan, India
8
Department of Geomatic and Hydraulic Engineering, CONHACYT—University of Guanajuato, Av. Juárez 77, Centro, Guanajuato 36000, Mexico
9
NanBioRenewables LLC, 100 Seapoint Blv. Bldg 5, Savannah, GA 31404, USA
*
Authors to whom correspondence should be addressed.
Water 2026, 18(16), 1983; https://doi.org/10.3390/w18161983
Submission received: 22 June 2026 / Revised: 11 August 2026 / Accepted: 11 August 2026 / Published: 13 August 2026
(This article belongs to the Section Wastewater Treatment and Reuse)

Abstract

This study focused on the generation and characterization of sludge produced by electrocoagulation (EC) combined with Moringa oleifera seed extract (MOSE) to remove water hardness. First, an experimental data set was generated and used as the baseline data for mathematical modeling to identify the effects of different parameters on Ca2+ and Mg2+ ion hardness removal. Then, using the generated data set, operational conditions were optimized using neural networks integrated with a genetic algorithm, resulting in the selection of Fe electrodes, 12.5 mL of MOSE per 100 mL of water, a current density (j) of 49.16 mA cm−2, and a reaction time of 5.3 min, considering Ca2+ ions as the sample contaminant. Additionally, machine learning analysis identified contaminant type, reaction time, and cathode material as the most influential variables affecting sludge formation, with optimal conditions identified for both Ca2+ and Mg2+ ion systems. For all the mathematical models, experimental validation was performed. The MOSE extract was characterized for the presence of proteins, polyphenols, flavonoids, and polysaccharides, which provide functional groups that promote aggregation and floc development. Sludge characterization by FT-IR, TGA, and TEM revealed the formation of organic–inorganic hybrid matrices composed of biomolecules interacting with electrochemically generated Fe3+ and Al3+ species, as well as Ca2+ and Mg2+ ions. These results highlight the role of plant-derived biomolecules in modulating the sludge structure and composition, providing insight into the mechanisms of sludge formation and the implications for handling and valorization of EC-based water treatment systems.

1. Introduction

Water hardness is defined as the concentration of dissolved calcium (Ca) and magnesium (Mg), expressed as the sum of the concentrations of Ca2+ and Mg2+ in mg L−1 CaCO3 [1,2]. The high concentrations of Mg2+ and Ca2+ in water are harmful not only to human health but also to industrial production processes. For example, at an industrial level, hard water reduces equipment efficiency due to scale formation: when heated, metal carbonates precipitate and adhere to pipes, reducing heat transfer and obstructing flow [3]. Therefore, it is essential to implement effective water treatment measures to reduce hardness.
Conventional technologies such as reverse osmosis (RO), nanofiltration (NF), use of ion exchange resins and lime softening have significant limitations. For example, RO, although highly effective in removing hardness ions, produces excessively demineralized water with low content of essential salts, affecting its organoleptic characteristics and nutritional value [4,5,6], while lime softening generates significant volumes of floc that require specialized management and subsequent pH adjustments of the treated water. These limitations are motivations for the development of more selective and sustainable alternatives for hard water treatment.
In this context, electrochemical methods, particularly electrocoagulation (EC), emerge as a solution for removing water hardness. It has proven effective for various types of water, including brackish, marine, and groundwater, and is even used as a pretreatment in desalination systems. The characteristics of the sludge formed during EC are key determinants of the process efficacy. Influenced by these characteristics, the sludge may exhibit poor sedimentation, causing solids to be carried away in the treated water and reducing process efficiency [7,8]. Additionally, sludge properties dictate its management. Sludge, being bulky and high in water content, complicates subsequent post-processing (i.e., thickening, dewatering, and transport) and increases disposal costs [8,9,10]. Therefore, analyzing the sludge characteristics is vital for efficient water clarification and contaminant removal [10]. Consequently, sludge formation is a fundamentally important stage because the metal electrodes (commonly iron or aluminum) come into solution under an electric charge, releasing metal ions that subsequently form metal hydroxides in situ. These hydroxides act as coagulants, destabilizing colloidal particles and promoting the aggregation of dissolved or suspended contaminants, forming flocs that eventually turn into sludge [11,12,13]. However, the sludge produced contains high concentrations of metals, making their handling and final disposal challenging [11]. Also, the operating conditions (i.e., current density (j), pH, and electrode types) influence the sludge characteristics and composition, which adds further complexity to the process [14,15].
A range of approaches, such as the use of additives, has been investigated to improve the EC process, ensure high sludge removal and generate sludge with homogeneous characteristics. A cost-effective approach is the use of plant extracts that can act similarly to chemical coagulants and electrolytes for achieving the desired sludge characteristics and removal efficiency [16]. For example, Moringa oleifera (MO) seed extract has been described as an effective compound for improving coagulation efficiency and stabilizing sludge formation because of the number of cationic proteins with molecular weights between 6.5 and 48 kDa and isoelectric points between 9 and 11, which allow it to function as a polyelectrolyte with a positive charge and to neutralize the negative charge present in the colloidal particles [17,18].
However, to optimize process efficiencies, numerous experimental setups, time, and other resources are required. Unfortunately, in most cases, there is a lack of these required resources, which entails the need for the development of innovative optimization methodologies. Recently, artificial intelligence models (AI) and machine learning models have been used to enhance the removal of several target pollutants or compounds from water and wastewater. For example, Artificial Neural Networks (ANNs) are AI models capable of predicting process behavior by using training data from real experiments and by appropriately selecting input and output variables. Compared to experimental design methods, ANNs have several advantages, including the ability to reuse the model by recalibrating it with a new dataset obtained from experiments [19,20,21].
ANN has several advantages over conventional optimization methodologies, such as experimental methods, and its calibration is relatively more straightforward compared to other AI models. Furthermore, specific processes can be optimized by retraining ANN using new experimental data. Nevertheless, ANN also has several disadvantages. For example, it cannot undertake the optimization process independently because of possible trapping in local minima. However, this limitation can be sidestepped by coupling ANN with another AI model such as a genetic algorithm (GA), which is based on Darwin’s theory of evolution (ANN/GA) [22,23].
For the ANN/GA model, the global solution is represented by a unique organism that is the most adaptable from a selected population with exceptional genetics. Also, the use of the ANN/GA model for optimization is a tool that has been proven to help reduce the requirements for a range of different applications, such as in wastewater treatment for the design, monitoring, optimization, and control of facilities [24,25]. Therefore, past studies have primarily focused on optimizing and modeling several wastewater treatment processes [22]. However, only a limited number of studies have been undertaken to enhance important water treatment processes.
Accordingly, the aim of this study was to investigate the optimal conditions for enhancing the EC process using Moringa oleifera seed extract (MOSE) to efficiently remove water hardness (removal of magnesium and calcium ions, which serve as control inorganic contaminants). Additionally, the generated sludge was characterized to determine which combination of parameters yields the highest hardness removal. Further, the study outcomes have contributed to the development of a mathematical model based on machine learning techniques and neural networks, coupled with a genetic algorithm, to achieve predictive capability for investigating process behavior.

2. Materials and Methods

2.1. Materials

The reagents used in the study were sodium chloride (NaCl, Sigma-Aldrich, Naucalpan de Juárez, Mexico State, Mexico), Moringa oleifera seed (Parsley Farms LLC, Warroad, MN, USA), calcium carbonate (CaCO3, Sigma-Aldrich, Naucalpan de Juárez, Mexico State, Mexico), magnesium carbonate (MgCO3, Sigma-Aldrich, Naucalpan de Juárez, Mexico State, Mexico), sodium hydroxide (NaOH, 0.1 M, Sigma-Aldrich, Naucalpan de Juárez, Mexico State, Mexico), hydrochloric acid (HCl, 50%, J. T. Baker, Monterrey, Nuevo León, Mexico), ethylenediaminetetraacetic acid (EDTA, 0.01 M, LabChem, Guadalajara, Jalisco, México), ammonium chloride (NH4 Cl, J. T. Baker, Monterrey, Nuevo León, Mexico), concentrated ammonium (NH3, Sigma-Aldrich, Naucalpan de Juárez, Mexico State, Mexico), black indicator erychrome T (C10H12N3NaO7S, Sigma-Aldrich, Naucalpan de Juárez, Mexico State, Mexico), methanol (Karal, León, Guanajuato, Mexico), NaNO2, AlCl3*6H2O (99.5%, Fermont, Monterrey, Nuevo León, Mexico), NaOH (Karal, 97%), Folin’s reagent (2N concerning acid, Sigma-Aldrich, Naucalpan de Juárez, Mexico State, Mexico), Na2CO3, Bradford reagent (Biorad), Bovine Serum Albumin (BSA) (Biorad, Mexico city, Mexico), Quercetin (≥95%, Sigma, Naucalpan de Juárez, Mexico State, Mexico), gallic acid (≥98%, Sigma, Naucalpan de Juárez, Mexico State, Mexico), glucose (≥98%, Sigma, Naucalpan de Juárez, Mexico State, Mexico), Anthrone (97%, Sigma, Naucalpan de Juárez, Mexico State, Mexico), 96% v/v ethanol (Karal, León, Guanajuato, Mexico), and sulfuric acid (93–98%, Fisher Scientific, Mexico city, Mexico). All the reagents were used as received.

2.2. Production and Characterization of Moringa oleifera Seed Extract (MOSE)

MOSE was obtained using a modified salting-out process previously reported by our research group [16]. In summary, 1 g of moringa oleifera seed flour and 11.2 g of NaCl were added to 200 mL of distilled water, stirred for 30 min, and subsequently vacuum-filtered using Whatman No. 40 paper.
For MOSE characterization, the concentrations of total flavonoids, polyphenols, protein, and sugar were analyzed using modified versions of the AlCl3 method, the Folin method, the Bradford method, and the Anthrone method, respectively, as previously reported by our research group [26]. For the assays, six replicates were tested, consisting of two statistical duplicates and three biological triplicates, and all were measured for absorbance using a Thermo Scientific Multiskan SkyHigh instrument (Mexico city, Mexico) with a 96-well microplate. The complete methodology is described in the Supplementary Information.

2.3. Removal of Water Hardness

Synthetic hard water (400 mg/L) was prepared by adding CaCO3 or MgCO3 salts to beakers containing distilled water. Afterward, the solution was heated to the boiling point until a homogeneous solution was obtained [27,28,29]. The solution was then cooled and adjusted to a pH of 8 with aqueous HCl (12% v/v) solution. To determine total hardness, 50 mL of the synthetic hard water was placed in a 250 mL Erlenmeyer flask. Immediately, 5 drops of an ethanol solution containing Eriochrome Black T (0.2 g/100 mL) as an indicator were added until the synthetic hard water turned red wine-colored. The solution was titrated with 0.01 M EDTA, stirring continuously until the solution turned blue.
An Imhoff cone was used as a batch reactor and filled with 600 mL of synthetic hard water containing 400 mg L−1 of the target carbonate (i.e., CaCO3 or MgCO3). Then, different volumes of the Moringa oleifera seed extract (0, 12.5, and 25 mL per 100 mL of solution) were added to the synthetic water. Subsequently, the electrodes were arranged in different configurations (Al/Al, Al/Fe, Fe/Al, and Fe/Fe) with a 1 cm separation, and different current densities (32.89 and 57.45 mA cm−2) were applied (Figure 1). The experiments were conducted for 40 min, with samples collected every 10 min. All experiments were performed in duplicate. The total hardness of the sample was determined as described above.

2.4. Mathematical Modeling

2.4.1. Neural Networks

This empirically based study required numerous experimental setups, time, and resources. However, in practical situations, these resources can be lacking. Therefore, there is a need to develop novel, applicable optimization methodologies. Recently, artificial intelligence (AI) and machine learning models have been used to predict the reduction in the levels of target contaminants in water and wastewater. Artificial Neural Networks (ANNs) are AI models capable of predicting process behavior by training on experimental data and selecting appropriate input and output variables. Compared to experimental design methods, ANNs offer several advantages, including the ability to reapply the model by recalibrating it with a new dataset [30].
The application of the ANN model consisted of 5 steps: (i) data collection, (ii) ANN design, (iii) training, (iv) validation, and (v) application. Since there is no established methodology for developing the model, the appropriate selection of input variables, the number of layers, the number of neurons in the hidden layers, the transfer function, and the output layers must be determined through trial and error. The methodology described by Picos-Benítez et al. [23] was employed in the current study to minimize error and to ensure the appropriate selection of neurons and hidden layers. The possibility of overfitting was carefully considered. Overfitting typically occurs when a model exhibits excellent performance with training data but poor predictive capability for unseen data. In the present study, the validation subset contained approximately 29 independent observations that were excluded from the training process.
As several variables can exert non-linear interactions in the EC/MOSE process, a Levenberg–Marquardt Backpropagation (LM-BP) algorithm was chosen. In total, 294 experimental data sets were collected, with 70% used for training the ANN, 20% for testing, and the remaining 10% for model validation based on the root mean squared error (RMSE, Equation (1)) and the mean absolute percentage error (MAPE, Equation (2)). During Levenberg–Marquardt backpropagation, the model utilized the training data for weight adjustment while concurrently monitoring a 20% testing subset. The software automatically terminated training when the loss function for the test subset ceased to improve and began to increase. This cross-validation approach helps the model capture generalizable patterns rather than overfitting the training data.
R M S E = 1 n i = 1 n ( t i t d i ) 2
M A P E = 1 N [ i = 1 1 | t i t d i t i | ] 100
where:
  • t i : is the real value
  • t d i : the predicted value by the ANN
  • n and N: the number of testing data

2.4.2. Genetic Algorithm (GA)

For this study, a population of individuals (controlled parameters) and codifiers were identified to generate the input vector, which included the type of electrode (TE), MOSE concentration, current density (j), and initial hardness concentration. The fitness function (i.e., ANN model) evaluated all possible solutions. The variables were selected by studying the behavior of the electrocoagulation process and selecting those with a significant influence on the required output variable (i.e., hardness removal efficiency). The GA created an initial random population, and for the following individuals and procreation, three rules were applied: (i) selection of the best individuals; (ii) crossover rules; and (iii) mutation rules. The upper and lower bounds for the input variables were selected based on the analyzed experimental data. The upper bounds represented the maximum values identified for mL of MOSE, type of electrode (aluminum or iron), j, time, and hardness. As shown in the lower bounds, the minimum values proven were 0 for j, time, and hardness. This value represents an experiment where no j was applied, and no hardness was removed. In addition, time 0 represents a sample analyzed without treatment, and a sample without hardness represents the minimum value observed for this parameter. As in ANN modeling, no methodology has been defined for determining the initial parameters of the GA [31]. Therefore, the initial parameter values for the population size, mutation rate, individual selection, and crossover type were determined by trial and error. The selected values are shown in Table 1.

2.4.3. Machine Learning

Random forest technique was used to develop a predictive model of the difference in contaminant concentration at time t, relative to the initial concentration [32]. Variables considered included contaminant type (CaCO3 or MgCO3), with or without MOSE, MOSE volume, cathode type, anode type, and experiment time duration. Random forest is an ensemble method in which many decision trees are developed from bootstrap samples of the data. To reduce dependence among trees, in each bootstrap sample, only a subset of the predictors is used to select the best splits. Once a collection of decision trees has been found, a prediction is formed by averaging the predictions across each tree. A key benefit of the use of random forest is the ability to estimate the importance or contribution of each predictor within the developed predictive model. In addition, the bootstrap approach provides an assessment of ‘out-of-sample’ predictive performance via the root mean squared error, which can be used for model validation.

2.5. Characterization of Sludge

To characterize the sludge, four experimental runs were performed, established by mathematical analysis to identify the effect of the different approaches. The first run was performed after application of EC with MOSE (EC/MOSE) using four conditions. The second was performed using the same conditions, without MOSE. The third was conducted under the same conditions, but without MOSE and the contaminant (i.e., without CaCO3 or MgCO3). After each run, the sludge was separated from the liquid phase and dried at 60 °C in a muffle furnace until constant weight was reached.
Thermogravimetric analysis (TGA) was conducted using approximately 17 ± 0.5 mg of sludge in an aluminum pan. The temperature program used a heating rate of 10 °C/min to 700 °C, with an SDT Q600 instrument, TA Instruments (New Castle, DE, USA). Fourier-transform infrared (FT-IR) spectroscopy was employed to identify the surface functional groups of the different sludges. Spectra were recorded using a Thermo Scientific Smart iTR (model Nicolet iS10), Thermo Fisher Scientific (Waltham, MA, USA) equipped with a diamond ATR across a wavenumber range of 500–4000 cm−1. Transmission Electron Microscopy (TEM) and Energy-Dispersive Spectroscopy (EDS) analyses were performed using sample dispersions in isopropyl alcohol placed on copper grids with a continuous carbon membrane (200 mesh) using a Hitachi 7700, Hitachi (Tokyo, Japan), operated at 120 kV.

3. Results and Discussions

3.1. Hardness Removal

Cation Hardness Removal

Figure 2 illustrates the removal of Mg2+ and Ca2+ ion hardness by electrocoagulation (EC) using two volumes of NaCl or MOSE (12.5 and 25 mL) over 40 min, two sacrificial anodes (Al and Fe), and two current densities (j = 32.89 and 57.44 mA cm−2) at an initial cation (Mg2+ and Ca2+) concentration of 400 mg L−1. Figure 2a compares the residual concentration of Mg2+ ions ([Mg2+]res) when using Al and Fe sacrificial anodes without MOSE (i.e., electrocoagulation process) and with 12.5 mL of NaCl at both current densities. At 32.89 mA cm−2, the Al anode yields a lower [Mg2+]res than the Fe anode (56 vs. 72 mg L−1). Increasing the j to 57.44 mA cm−2 enhances removal efficiency, achieving 90% and 84% removal for Al and Fe, respectively. This efficiency increase aligns with Faraday’s Law, which states that higher current densities release more metal into solution, producing a greater dose of coagulant [25,33].
For Ca2+ ion removal, the Al sacrificial anode achieved higher removal efficiencies at both current densities (42 and 53.75%). In contrast, for the Fe anode, the increase in j did not significantly improve removal efficiency (28% vs. 29.2%), compared with the experiments for Mg2+ ions (Figure 2a). This outcome is attributed to the fact that Ca2+ ions tend to precipitate primarily as CaCO3 or Ca(OH)2, which are less soluble and crystallize into more stable and complex structures. Furthermore, Ca2+ ions exhibit lower mobility, and greater energy input is required to destabilize their bonds and form a removable precipitate. In contrast, Mg2+ ions form MgCO3 or Mg(OH)2, which are relatively more soluble and precipitate in an amorphous or gelatinous form, facilitating their removal [34,35].
Figure 2b displays experiments conducted with a higher NaCl dose (25 mL per 100 mL of solution). At a j of 32.89 mA cm−2, [Mg2+]res values of 32 and 63 mg L−1 were achieved using Al and Fe as sacrificial anodes, corresponding to 92 and 84.2% removal efficiency, respectively. However, at a j of 57.44 mA cm−2, an improvement in Mg2+ cation removal can be observed (94% and 88% for Al and Fe sacrificial anodes, respectively), attributed to increased coagulant generation. The results in Figure 2b surpass those in Figure 2a due to the higher NaCl volume, which enhanced conductivity and current flow in the system, thereby promoting coagulant formation [36,37]. Additionally, Figure 2b demonstrates improved Ca2+ hardness removal compared to experiments at the lower j (Figure 2a), consistent with Faraday’s law. Nevertheless, Ca2+ hardness removal remains less efficient than Mg2+ hardness removal.
Figure 2c compares Mg2+ ion removal using Al and Fe sacrificial anodes with 12.5 mL of MOSE at two current densities (j = 32.89 and 57.44 mA cm−2). It is evident that at 32.89 mA cm−2, the Al anode achieved a higher removal rate compared to the Fe anode (90% vs. 84%). Increasing the j to 57.44 mA cm−2 further improved Mg2+ removal, reaching 100% for Al and 88% for Fe. It can be highlighted that the removal percentages obtained using MOSE at both current densities exceed those obtained under the same experimental conditions without MOSE (Figure 2a), confirming that the addition of MOSE to the EC process enhances Mg2+ removal. This improvement is attributed to coagulating agents in the extract that interact with Fe and Al ions, forming complexes with high affinity for Mg2+. Across all experimental conditions, MOSE addition improved the removal efficiency (Figure 2a). However, the improvements did not reach the levels achieved for the Mg2+ experiments, highlighting that while MOSE enhances the EC process, the nature of the contaminant limits overall efficiency.
In the experiments where MOSE was increased to 25 mL per 100 mL of solution (Figure 2d), the Al anode achieved higher removal efficiencies than the Fe anode at both current densities (98% vs. 86% and 100% vs. 91%). Compared with iron flocs, the higher efficiency observed with the Al anode is likely due to the superior adsorption capacity of Al flocs for soluble and colloidal species, facilitated by the formation of polynuclear hydrolytic complexes [38]. Additionally, the removal percentages achieved with 25 mL of MOSE exceeded those for a lower dose (Figure 2c), confirming that increased MOSE dosage improves removal efficiency. This trend was consistent across all experiments. Although removal efficiency was higher than in EC experiments without MOSE, it did not reach the levels achieved with MgCO3 as the contaminant (Figure 2d).
In summary, the generation of Mg2+ ions in the EC/MOSE system may be associated with the different precipitation behavior of magnesium and calcium during electrocoagulation. Magnesium forms amorphous Mg(OH)2 precipitates that are more readily incorporated into the hybrid flocs generated by MOSE and electrocoagulation than the more crystalline calcium phases [34,35,39].
Water hardness has been successfully removed using different treatment technologies, including adsorption and conventional electrocoagulation. Ghanbarizadeh et al. [40] demonstrated that modified adsorbents, such as activated alumina, zeolite, and activated carbon, can effectively remove hardness through ion exchange and surface adsorption mechanisms. Likewise, Medina-Collana et al. [41] reported a maximum hardness removal efficiency of 25.83% using conventional electrocoagulation in a filter-press reactor, identifying the applied electrical potential as the most influential operational parameter due to its direct effect on the electrochemical generation of coagulant species [42].
Although direct quantitative comparisons should be interpreted with caution because of differences in reactor design, operating conditions, and water composition, these results demonstrate the beneficial effect of combining electrocoagulation with MOSE. Unlike the adsorption process, where hardness removal depends mainly on surface interactions or conventional electrocoagulation, where electrochemically generated hydroxides govern removal, the proposed EC–MOSE system promotes the formation of organic–inorganic hybrid flocs through the interaction of Fe/Al hydroxides with the biomolecules present in MOSE.
On the other hand, and reinforcing the previous comments, Ingin et al. [35] demonstrated that calcium and magnesium exhibit distinct precipitation behaviors depending on pH, ion ratio, and water matrix, indicating that both hardness-forming ions should not necessarily be considered equivalent during water softening. This observation is consistent with the experimental design adopted in the present study, where Mg2+ and Ca2+ ions were investigated independently to identify the influence of each hardness-forming species on the EC/MOSE process and the characteristics of the generated sludge to be evaluated separately [35]. Therefore, besides achieving high hardness removal efficiencies, the proposed EC/MOSE system provides additional insight into the physicochemical characteristics and formation mechanism of the generated sludge through its comprehensive characterization by FT-IR, TGA, TEM, and EDS, representing an aspect that has been scarcely addressed in previous hardness removal studies.

3.2. Mathematical Modeling

3.2.1. Machine Learning

Before developing the predictive model, an exploratory data analysis (EDA) was conducted to examine pairwise relationships between predictors (such as time) and the response (removal; Figure S1 in Supplementary Information). From Figure S1a, the relationship between the contaminant and the sludge amount removed suggests that in the case of Mg2+ ions, there is greater extraction (in general) compared to Ca2+ ions. Similarly, from the remaining plots in Figure S1, it can be seen that time, with or without MOSE, MOSE volume, and cathode type, is related to the amount removed.
The random forest technique was employed to develop a predictive model for the amount of contaminant removed. The predictive model achieved an out-of-sample RMSE of 62.62 mg L−1 and explained 67.1% of the variation in the data. Figure S2 plots the observed data versus the model predictions and shows reasonable agreement. Contaminant type, time, and cathode type can be identified as the most important variables, which aligns with the EDA results.
Based on the predictive model, the combination of variables (considered in the experiment) that maximized predicted removal for different time durations (2, 4, 6, 8, 10, 20, 30, and 40 min) was determined. Figure 3a shows the resulting predictions that maximized removal for each time duration, and Table 2 shows the optimal conditions required for EC/MOSE. These conditions were used to study the physicochemical characteristics of the sludge.

3.2.2. Neural Networks

Four variables were used as inputs for the ANN model (electrode material, MOSE dose, j, and hardness concentration relative to Ca2+ concentration), and one output variable was considered (hardness removal efficiency relative to Ca2+ concentration) (Figure S3). For the analysis, the experimental data generated were used, as in the machine learning analysis. After collecting the experimental data, the next step was to train the model and select the best ANN architecture using 70% of the data, while testing various hidden layers and neurons per layer to improve prediction accuracy. This step was made by trial and error until an ANN with the lowest MAPE and MSE was found. Figure 3b and Table S1 present the input values used in training and the selection of the ANN architecture. After finding an ANN architecture that yielded the lowest RMSE and MAPE, the ANN’s predictive capabilities were tested using 10% of the data.
The comparison between experimental and ANN-predicted values for this validation dataset showed excellent agreement, yielding an RMSE of 0.041 and a MAPE of 8%. The low prediction errors obtained using previously unseen data indicate that the developed ANN is able to retain its predictive capability beyond the training dataset, and they do not show overfitting (Figure S4).
As shown in Figure 3b, there is no direct relationship between the input variables used and the removal efficiency. However, past studies have used ANN to predict the EC process for removing various contaminants, including synthetic dyes [19,43], real wastewater streams from aquaculture farms [20], tanneries [44], and inorganic [45,46] and organic [47] compounds. In those studies, the controlled parameters have included initial contaminant concentration, energy consumption, experiment duration, and pH or electrolyte concentration. Additionally, in some cases, variables such as settling time and electrode distance were also controlled. In this study, electrode type was selected as an input variable due to ions produced during the EC process and their impact on hardness removal. The experimental results obtained show that the removal efficiency ranged from 0% to 100% for the selected input variables. Understanding the complex, non-linear interactions between the selected input and output variables requires extensive and time-consuming investigations [48]. However, an ANN can reduce this effort by using experimental data to identify those non-linear interactions during training. After testing several ANN formulations, the lowest MAPE (8%) and MSE (0.41%) were observed in an ANN with a first hidden layer of twelve neurons, a second layer with seven neurons, and a tangential-sigmoid transfer function (Figure S3). Finally, after comparing the ANN-predicted values with 10% of the experimental data, it was found that the model developed is capable of emulating the behavior of the EC process with proper training. However, ANNs have limitations in optimization, such as the risk of getting trapped at a local minimum. Also, since the model’s accuracy improves as more actual experimental datasets are used for training, they are only limited by the amount of resources required. Further, because ANNs are considered black-box models, they cannot identify the complex non-linear interactions that drive high removal efficiency [30]. In this study, these limitations were overcome by integrating with a genetic algorithm (GA).

3.2.3. Optimization of EC Using GA

The primary goal of combining the ANN model with a GA was to identify operational conditions that maximize the EC process’s hardness-removal efficiency at relatively low energy, reactant use and time, while employing the most economical electrode type. Past studies have employed the Design of Experiments approach to model and predict the optimal conditions for advanced oxidation processes [49] or EC [45,47]. This one-factor-at-a-time optimization approach is suitable for studies that require understanding all the interactions between input and output variables. In some past studies, an AI model, such as particle swarm optimization (PSO), has been used to investigate the removal of multiple contaminants, demonstrating that utilizing an alternative AI model is helpful when studying all related parameters is not feasible.
When a GA is applied, the ANN is used as a fitness function to virtually simulate all experimental data that could not be collected during the data collection phase due to time and/or resource limitations. As a result, the model is essential for simulating the process and testing all possible combinations of experimental conditions, thus avoiding the waste of resources [50]. A combined ANN and GA AI model was necessary to simulate the complex non-linear processes involved in hardness removal. The GA model was built with a population of individuals, each containing a genetic code based on MOSE dose, electrode type, j, experimental time, and initial hardness concentration. After applying crossover probabilities and a mutation rate to an initial population based on potential experimental conditions that maximized removal efficiency while minimizing requirements, the GA was able to generate combinations of experimental conditions as a potential solution to the optimization challenge (Table 3).
Table 3 provides a clear example of a global solution to the optimization problem, where the GA suggests using a low-cost electrode, reducing MOSE usage, and applying a high j, whilst using only a quarter of the experimental time and maximizing the initial hardness concentration. However, controlling the hardness concentration under real-world conditions is difficult. Nonetheless, the hardness concentration offers insights into the process performance of these parameters. According to the ANN-GA model, a 10 min experimental duration is sufficient to complete hardness removal in the sample. In conclusion, the study outcomes provide reliable knowledge on how AI application can enhance the electrocoagulation process by recommending suitable experimental conditions for testing. Figure 4 and Table S2 show the results after testing the conditions recommended by the AI model. As is evident, nearly 100% hardness removal was achieved, confirming the model’s reliability.

3.3. Characterization of MOSE

The concentrations of proteins, polyphenols, sugars, and flavonoids in MOSE were quantified as 0.192, 34.418, 79.033, and 1.614 mg L−1, respectively. Polyphenols were the biomolecules with the highest concentration among those analyzed. Comparing these results with past research, it was evident that MOSE yields high levels of flavonoids and phenolic compounds. According to the work of Jung et al. [51], the protein concentration decreases from 5 to 0.5 mg mL−1 with increasing extraction time (1 min to 120 min), mirroring the trend in turbidity removal efficiency. The difference could be attributed to the extraction time. The current study used 60 min, which may indicate a low protein concentration.
Past studies have used MOSE as a coagulant in water treatment (i.e., phosphate buffer, distilled water, n-hexane, and ethanol) [52,53,54]. Among the various extraction processes, salting-out extraction using different saline solutions (e.g., KCl, MgCl2, and NaCl) has been highlighted, as these solutions enhance the extraction of the active coagulation component from Moringa oleifera seeds [55]. The saline solution increases ionic strength, thereby enhancing the solubility of the active ingredient, a cationic protein known as Moringa oleifera coagulant protein (MOCP). It is reported to be highly alkaline, and its ability to interact with suspended particles facilitates their agglutination and sedimentation, thereby enhancing sludge stability [56].
As noted above, there are other biomolecules in the extract with the ability to carry out the coagulation of contaminants. Polysaccharides, as well as other phytochemicals (e.g., polyphenols and flavonoids), are involved in acting through the bridging mechanism, forming flocs that bind colloidal particles [57,58]. Furthermore, these biomolecules have amino, carboxylic groups, and other compounds (Table 4), which are the functional groups reported for generating the formation of sludge [55].
MOSE possesses intrinsic mechanisms that promote natural coagulation of compounds due to the presence of biomolecules such as MOCP, which can neutralize the negative charges of colloidal particles and certain ions, thereby facilitating their aggregation and increasing the size of the flocs. This contributes to their removal through sedimentation during water treatment. On the other hand, the presence of a metal complex between the iron or aluminum ions released by the anode and the biomolecules present in MOSE is also possible. Pivokonsky et al. [61] demonstrated that these complexes exist at specific pH values, where surface Fe–peptide/protein complexes are predominantly formed by the coordinated binding of dissociated –COOH (–COO) groups on the surface of peptides and proteins with positively charged Fe-hydroxopolymers and Fe-oxide-hydroxides, which are necessary for coagulation.

3.4. Sludge Characterization

According to the conditions listed in Table 2, the physicochemical characteristics of the sludge obtained were studied using FTIR, TGA, DSC, and TEM-EDS. Figure 5 shows the FT-IR spectra of the electrocoagulation process using distilled water free from contaminants and MOSE (samples SMC1 to SMC4). In all spectra, a broad band is observed between 3400 and 3200 cm−1, attributed to the stretching vibration of O–H groups in hydrated metal hydroxides such as Fe(OH)3 or Al(OH)3, as well as to physically adsorbed water molecules. This signal is particularly intense in the experiments with the highest j (57.44 mA cm−2), indicating greater generation of hydroxyl species and greater structural moisture retention in the sludge [62]. In the 1630–1600 cm−1 region, a band of lower intensity is evident, which is associated with the angular deformation of the water molecule (H–O–H), confirming the surface hydration of the generated products.
On the other hand, the 1000–500 cm−1 region shows that with iron electrodes (Figure 5a,b), broad bands are evident between 600 and 500 cm−1, associated with Fe–O vibrations characteristic of amorphous or poorly crystallized oxides, such as ferrihydrite, lepidocrocite or goethite. These bands are more intense at high j (Figure 5b), which is consistent with the formation of a greater number of ferric species at higher intensities. In contrast, in the experiments with aluminum electrodes (Figure 5c,d), the bands in this region are less intense and broader, which is characteristic of amorphous aluminum hydroxides, which lack a defined crystalline order and exhibit low-resolution bands [63].
Taken together, these spectra indicate that the type of metal electrode and the current intensity are the main factors influencing the formation and chemical structure of the inorganic sludge. Iron generates products with a more defined spectral profile, characterized by clear Fe–O bands, whilst aluminum forms more amorphous and highly hydrated matrices. The current intensity also influences the intensities of the O–H and metal–oxygen bands, reflecting a high production of metal hydroxides. These results are consistent with previous studies on electrocoagulation without organic coagulants, in which the formation of metal sludges depends largely on the redox chemistry of the electrodes and the local pH generated by electrolysis [64].
Figure 5 shows the FT-IR spectra of the sludges obtained by electrocoagulation using MOSE and without contaminants (i.e., CaCO3 or MgCO3) (sample SC1 to SC4). Depending on the different operating conditions—such as j, electrode type (Fe or Al) and extract volume—various functional groups and metal–organic complexes are present. The intense broad band around 3300 cm−1 corresponds to the stretching vibrations of the O–H and N–H groups associated with the alcohols, phenols and plant proteins present in the extract, being more pronounced in the samples with an iron anode (Figure 5a,b) due to the formation of ferric hydroxides with high adsorbent capacity [30]. The region between 2915 and 2840 cm−1 corresponds to the C–H stretching of aliphatic chains, indicating the presence of lipid and protein residues. The dominant peak at 1630 cm−1 reflects C=O (type I amides) or C=N vibrations derived from denatured proteins that are more prominent in the samples treated with greater intensity (Figure 5a,d), indicating greater coagulation because of electrical oxidation. The bands between 1380 and 1410 cm−1 are associated with COO groups and suggest the formation of metal–carboxylate complexes, particularly in the presence of Fe3+ and Al3+ generated by the electrodes, as well as organic acids and proteins in the extract [65]. The region between 1030 and 1100 cm−1 corresponds to C–O stretching vibrations, characteristic of alcohols, ethers and polysaccharides, confirming the presence of plant biopolymers in the sludge.
Finally, the bands below 600 cm−1 are attributed to Fe–O and Al–O vibrations, which are most intense at 32.89 mA cm−2 j, 25 mL of MOSE, with iron cathode and anode (SC1), and at 57.44 mA cm−2 j, 12.5 mL of MOSE, with iron cathode and anode (SC2) (Figure 5a and Figure 5b, respectively), indicating the formation of ferric oxides/hydroxides such as Fe(OH)3 and FeOOH [62,63]. Experimental conditions, such as a higher j (i.e., 57.44 mA cm−2) and a larger extract volume of MOSE (25 mL), directly influence sludge formation and composition (Figure 5c,d).
Figure 5 shows the FT-IR spectra of the sludge obtained via the EC/MOSE process in the presence of CaCO3 and MgCO3 (samples C1 to C4), revealing significant structural modifications compared to systems SMC1, SMC2, SMC3, SMC4 (without the contaminant and MOSE) and SC1, SC2, SC3, SC4 (without the contaminant and with MOSE). For example, the intense band between 3400 and 3200 cm−1 present in all samples is attributed to O–H stretching of hydroxyl groups and the N–H stretching of amides, typical of the biomolecules constituting MOSE [66]. These peaks exhibit a shift compared with contaminant-free systems with or without MOSE due to the participation of these groups in complexes with Ca2+ and Mg2+ (Figure 5) [62,63]. The bands between 2950 and 2850 cm−1 correspond to the C-H stretching vibrations, typical of plant lipids and proteins [67]. In contrast, the peaks located from 1500 to 1400 cm−1 correspond to symmetric deformation vibrations of carboxylate groups (COO) and to the presence of metal carbonates [68]. This finding suggests interaction between hardness ions and the functional groups of the plant extract, as well as co-precipitation of metal species.
Moreover, in samples C3 and C4 (containing CaCO3) (Figure 5c,d), the appearance of a band around 1420 cm−1 is characteristic of the asymmetric vibration mode of the carbonate ion, confirming the retention of this contaminant in the form of precipitated CaCO3 [69]. Similarly, in C1 and C2 (containing MgCO3) (Figure 5a,b), the relative intensity of this region is lower, but a band at ~880 cm−1 can be observed, corresponding to the out-of-plane bending mode of MgCO3, which is consistent with previous studies on the removal of Mg2+ by electrocoagulation [64]. In all cases, the signals in the 1100–1030 cm−1 region continue to indicate C–O vibrations of polysaccharide alcohols and ethers in the extract, albeit with lower intensity, due to their participation in the formation of complexes with metal ions or to spectral shifts induced by the presence of Ca2+ and Mg2+. Finally, the signals below 600 cm−1 reflect the formation of metal–oxygen bonds being more pronounced in the samples in which iron electrodes are used (Figure 5a,b), where characteristic vibrations of Fe–O and ferric carbonates are detected, and more faint in the aluminum associated samples (Figure 5c,d), where they could be attributed to Al–O and amorphous aluminum carbonate [70,71].
In summary, these results suggest that sludge production involves a complex chemical interaction between the metal species generated in situ and the functional compounds in the plant extract, resulting in a sludge matrix rich in proteins, organic acids, metal hydroxides, and polysaccharides in varying proportions [72]. A close relationship is evident in both the removal analysis and the FT-IR signals, where the iron anode removes a higher concentration of Mg2+, whilst the aluminum anode and MOSE remove a higher concentration of Ca2+, which are attributed to the loss of signal intensities corresponding to the biomolecules present in MOSE.
Figure S5 displays the TGA analyses of the sludges obtained via the EC/MOSE process in the presence of CaCO3 and MgCO3 (samples C1 to C4) and the sludges obtained by electrocoagulation using MOSE and without contaminants (i.e., CaCO3 or MgCO3) (Samples SC1 to SC4), respectively (Figure S6). They have similar weight loss ranges. The first zone shows a weight loss that is attributed to the loss of water and volatile organic compounds present between 25 °C and 140 °C [62] due to the moisture present and the organic components of MOSE. The second zone, from 140 °C to 350 °C, is attributed to the decomposition of hemicellulose, which is abundant in plant organisms. The third zone, from 200 °C to 450 °C, is attributed to the decomposition of cellulose, another component commonly found in lignocellulosic systems, such as MO seeds. Finally, the fourth zone, from 450 °C to 560 °C, is attributed to the decomposition of lignin, a primary component in plant organisms [63,64].
Similarly, Figure S7 shows the Differential Scanning Calorimetry (DSC) analysis of all C, SC, and SMC samples. These signals are observed approximately at 300 °C and 500 °C. However, the sludges C1, C2, SC1, and SC2, which were obtained using an iron anode, show a signal at approximately 400 °C. This could be attributed to the oxidation of iron, which may occur in the presence of O2 [65], derived from functional groups present in MOSE (i.e., –COOH, –OH). Furthermore, a signal is also evident in the SMC samples (without MOSE and contaminant) at approximately 700 °C, which is attributed to the presence of metal ions released by the sacrificial anodes. This signal shifts to >700 °C in the SC samples (without contaminant), indicating that through the interaction of biomolecules and metal ions, a biomolecule–metal complex is formed, which is more thermostable. This is due to the formation of metal–biomolecule complexes in which the metal ions released by the anode (Fe3+, Al3+) interact directly with functional groups (–COOH, –NH2, –OH) in MOSE, enabling the formation of surface complexes of Fe–peptide/protein and Al–biopolymer. This complexation occurs through the coordinated binding of dissociated carboxyl groups (–COO) and other polar groups of biomolecules with electrochemically generated metal centers [73,74]. Finally, this same signal shifts to 900 °C in the C samples due to the formation of the biomolecule–metal–contaminant (Ca or Mg) complex, making these samples even more thermostable.
Figure 6 shows transmission electron microscopy (TEM) micrographs of the sludges formed. Figure 6a,b show that sample C1, obtained from the EC/MOSE system using an iron (Fe–Fe) anode and cathode, exhibits a structure composed of amorphous aggregates and dense regions of particulate matter distributed within a less dense matrix. The irregular aggregates appear to be bound together by a lighter, fibrous matrix due to the coexistence of organic products from MOSE, such as polysaccharides, denatured proteins, and tannins, alongside inorganic phases formed by iron hydroxides or oxides [72]. Furthermore, the structure is denser and amorphous, with areas appearing as intertwined layers or gelatinous aggregates with a laminar morphology. This can be interpreted as the formation of amorphous Fe(OH)3 or poorly crystallized ferrihydrite, a process that has been extensively documented in electrocoagulation systems using iron anodes [41,75]. These laminar structures would be due to the coprecipitation of organic compounds functionalized with carboxylate and phenolic groups, which act as chelating agents, a finding consistent with the FT-IR results (Figure 5). The simultaneous presence of fine particles, dense dark zones (rich in iron) and semi-transparent regions suggests that the sludge generated under these conditions contains a mixed organic–inorganic matrix. This combination has been described in electrocoagulation systems using natural coagulants, where metal–biopolymer interaction favors the formation of materials with adsorbent potential and high surface reactivity [16]. Taken together, TEM micrographs suggest that the formation of the sludge in sample C1 depends not only on the formation of metal hydroxides but also on the complex interactions with the plant extract components incorporated into the sludge microstructure.
The TEM images of the C2 sample (Figure 6c,d) obtained by electrocoagulation with an iron cathode and anode, MOSE, and MgCO3 as the contaminant show a more complex, structurally dense morphology than the C1 sample. A conglomerate of amorphous and hemispherical particles with varying electron densities can be observed, along with some laminar or translucent, plate-like structures that may correspond to biopolymeric residues from MOSE. The scattered dark areas are due to the formation of aggregates of iron-rich particles, associated with Fe oxides or hydroxides such as ferrihydrite or amorphous lepidocrocite, consistent with the results of past studies on EC with iron and natural coagulants [76]. Also, areas of high resolution can be clearly observed that allow the identification of structures with possible crystal ordering with parallel stripes seen in some regions, which indicate the presence of partially crystalline domains corresponding to goethite (α-FeOOH) or magnetite (Fe3O4) phases, which can be generated at high current intensities as in this sample (57.449 mA cm−2 j) in the presence of organic ligands that control nucleation [77,78]. Additionally, the presence of structures with intercalated layers can be interpreted as evidence of mixed precipitates between iron and compounds derived from the plant extract, forming organic–inorganic hybrids.
No clearly defined morphologies attributable to MgCO3 were observed in the micrographs of sample C2 (Figure 6c,d), probably because Mg2+ was incorporated as an amorphous or solubilized species during the process, forming co-precipitates with Fe(OH)3, as has been ascribed to mixed-metal removal systems [41,75]. Taken together, these micrographs confirm that sample C2 has a more condensed microstructure with a higher proportion of dense regions, probable formation of semi-crystalline nuclei, and a more complex organization of the sludge, attributable to higher current intensity and the synergistic effect of the contaminant with the products of EC and MOSE. This suggests a greater degree of retention and transformation of metal species, which implies improved adsorption capacity or physical–chemical stability of the material, as reported for bio-assisted systems [79,80].
Figure 6e,f show the TEM analysis of sample C3, revealing a dense, morphologically differentiated microstructure compared to that of samples treated with iron electrodes. A laminar-like structure can be observed, composed of thin, overlapping layers with a foliated appearance or resembling partially rolled plates. This morphology is characteristic of materials with an amorphous or semi-crystalline structure, which is attributed to the formation of amorphous aluminum hydroxides (Al(OH)3) or to phases such as poorly ordered boehmite, which are easily generated in EC systems with an Al anode and moderate pH [81]. In contrast, it also shows dense domains of higher contrast, formed by aggregates of irregular particles with poorly defined edges, which could correspond to co-precipitates of Al with CaCO3 since the system contained CaCO3 as a contaminant. The increase in contrast in these regions suggests a higher electron density, possibly associated with insoluble salts such as Al–CO3 or Ca–Al–OH type structures, which are formed by shifting the solubility equilibrium of CaCO3 in the presence of acid species and electrolysis [82]. Unlike the iron samples, there are no spherical nanoparticle-like structures or crystalline stripes here. This is consistent with the amorphous nature of aluminum hydroxides, which tend to form extensive colloidal matrices that can retain organic material from MOSE by hydrogen bonding or electrostatic interactions.
The laminar structure observed in Figure 6a could also be related to polysaccharide residues in the extract that, in interaction with Al3+ species, form hybrid gels capable of trapping pollutant particles, as documented in past research in other bio-assisted systems [82]. Compared to samples C1 and C2 (Fe–Fe) (Figure 6a,b), this micrograph suggests lower crystallinity and a more compact structure, resulting from differences in the coagulant nature of the metal, oxidation potential, and interactions with the contaminant and the plant extract. These results reinforce the understanding that the choice of anode and the type of hardness significantly influence the microstructure and final composition of the electrocoagulated floc.
Finally, TEM analysis of the C4 sample (Al–Al, MOSE, CaCO3 pollutant, high j) reveals a dense, highly aggregated structure with predominantly amorphous morphology (Figure 6g,h). There are regions of higher contrast with cross-cross sheets and dark areas that could correspond to co-precipitates of aluminum hydroxide and calcium carbonate, with no clear evidence of crystallization. Additionally, the extract is stabilized by Al3+. This microstructure suggests a highly cross-linked system, attributed to the synergy between aluminum and the components of the plant extract at the j under investigation [72].
The TEM images of the C1 to C4 samples show a clear evolution in the structure, degree of aggregation, and type of morphological organization of the sludge obtained by electrocoagulation, dictated by the type of electrodes used (Fe or Al), the contaminant (Mg2+ or Ca2+), and the j applied. However, sample C1 (Fe–Fe, MgCO3, low current intensity) exhibits a microstructure characterized by sparse aggregates and fine particles of nearly spherical shape embedded in a matrix with a fibrous or filamentous appearance. Also, no crystalline structures or defined morphologies of magnesium carbonate can be observed, suggesting its dissolution or transformation into amorphous species, possibly co-precipitated with iron hydroxides.
In contrast, sample C2 (Fe–Fe, MgCO3, high j) exhibits greater density and compaction, with regions of enhanced electronic contrast and indications of internal ordering (parallel stripes), which are compatible with the semi-crystalline phases of iron oxides, such as ferrihydrite or goethite. The high j favors the nucleation of these structures and enhances their interaction with the compounds in MOSE. On the other hand, the C3 sample (Fe–Al, CaCO3, low j) exhibits a distinctly different morphology, such as an amorphous, laminar-type matrix with dense plates that suggest the formation of aluminum hydroxide gels. Despite the presence of Ca2+, there are no typical structures of CaCO3, which could indicate its partial dissolution or incorporation into the amorphous co-precipitates of Al. Finally, the C4 sample (Al–Al, CaCO3, high j) exhibits the highest density and the most extensive structural cross-linking among all the samples. Highly entangled aggregates can be observed, featuring compact amorphous zones that reflect an organic–inorganic network stabilized by Al3+ and polymeric components of the plant extract. The combination of CaCO3, aluminum as the anode, and high j yields a much tighter microstructure with no apparent signs of crystallization.
These interactions modify the surface of the metal sludges and incorporate the biomolecules into the coagulant’s structure, enabling the coagulant to retain or adsorb them and thus increase its mass, so that it can settle more quickly and be removed more effectively. Ca2+ and Mg2+ ions not only precipitate as carbonates or hydroxides but also co-precipitate within the organic–inorganic hybrid matrix. Furthermore, the adsorption of pollutants is not only enhanced by the formation of hybrid sludges on the surface of these materials but can also create bridges between the biopolymers in the natural extract of Moringa oleifera (e.g., proteins, polyphenols, and lipids) and the metal hydroxide particles.
The results of the EDS (Figure 7 and Figures S8–S11) analysis critically complement the morphological characterization observed by TEM, enabling the identification of the elemental composition of the EC sludges in each sample. In the C1 sample (Fe–Fe, MgCO3 pollutant), a high proportion of carbon (58.64%) and oxygen (20.79%) stands out, which agrees with the TEM micrographs, where an amorphous matrix with a fibrous, dispersed appearance is evident, corresponding to organic–inorganic materials. The presence of Fe (1.24%) and Mg (1.05%) suggests low retention of metal species and a structure dominated by plant extract residues, possibly accompanied by poorly precipitated MgCO3.
In the C2 sample (Fe–Fe, same experimental conditions but higher j), a notable change is observed. The Fe content increases to 57.08%, while carbon decreases to 21%. This relationship indicates high precipitation of ferric species, such as Fe(OH)3 or FeOOH, and a displacement of the organic fraction, consistent with TEM micrographs showing dense, agglomerated structures with semi-crystalline domains. The compact morphology observed is a direct reflection of the high iron load, as evidenced by the EDS analysis.
In the C3 sample (Fe–Al, CaCO3 pollutant, low j), a high content of carbon (50.9%), oxygen (18.83%), and calcium (25.18%) is maintained, with moderate levels of Fe and Al. This composition indicates the formation of a hybrid matrix, likely composed of plant extract, calcium carbonate, and electrode oxidation products, consistent with the laminar and amorphous structures observed in TEM. The high Ca fraction also suggests that the contaminant is partially retained as salts or amorphous co-precipitates (Ca–OH or transformed CaCO3), contributing to the observed morphology.
Finally, the C4 sample (Al–Al, CaCO3, high j) presents a composition dominated by aluminum (31.04%), chlorine (30.17%), and sodium (10.8%), with a very low carbon content (4.72%). This sample exhibits a clearly inorganic, colloidal structure, as observed in TEM, with dense, amorphous aggregates that lack evident organization. The high presence of Cl and Na would be related to ionic migration from the electrolyte during high-intensity electrolysis. The low Ca signal (1.3%) suggests that the contaminant is significantly displaced or not precipitated, unlike the C3 sample.

4. Conclusions

From the analysis of hardness removal using electrocoagulation coupled with MOSE, the following could be concluded:
  • The characterization of MOSE confirmed the presence of proteins, polyphenols, flavonoids, and polysaccharides, which provide functional groups such as –OH and –COOH capable of interacting with ions and electrode-derived metal species. The combined evidence suggests that Moringa oleifera contributes both functional chemistry and structural complexity to the flocs, thereby enhancing hardness removal performance.
  • Sludge characterization by FT-IR, TGA, TEM, and EDS revealed that its formation involves not only the precipitation of inorganic hydroxides but also the formation of organic–inorganic hybrid complexes, in which biomolecules extracted from solution combine with Fe3+ and Al3+ species and co-precipitate with Ca2+ and Mg2+. These interactions lead to heterogeneous, compact flocs with high adsorptive capacity, confirming the synergistic effect of the plant extract on electrocoagulation efficiency.
  • Using an ANN, it was possible to identify that the interactions between the established variables (electrode material, moringa extract concentration, current density, and initial hardness concentration) do not have a linear relationship, as evidenced by the low prediction error. The integration of ANN-GA enabled identification of optimal operational conditions that maximize hardness removal while minimizing energy consumption, extract dosage, and reaction time.
  • Mg hardness can be more efficiently removed compared to Ca hardness due to the ionic interactions with MOSE and the hydroxyl ions formed at the anode.

Supplementary Materials

The following supporting information can be downloaded at: https://www.mdpi.com/article/10.3390/w18161983/s1, Table S1. Mean, minimal, and maximum values of the collected experimental data for training the ANN model; Table S2. Experimental validation of the ANN-GA model; Figure S1. Exploratory data analysis for the amount of contaminant removed under different conditions: (a) contaminant species, (b) time, (c) cathode type, (d) anode type, (e) extract, (f) extract volume, (g) current density, and (h) current density; Figure S2. Predictions from the developed random forest model versus observed removal; Figure S3. ANN architecture; Figure S4. Experimental validation of the ANN model; Figure S5. TGA analysis of the flocs from the EC process with MO extract at different experimental conditions: (a) [MgCO3] = 400 mg L−1, j = 32.89 mA cm−2, 25 mL MO extract, iron cathode and anode, (b) [MgCO3] = 400 mg L−1, j = 57.449 mA cm−2, 12.5 mL MO extract, iron cathode and anode, (c) [CaCO3] = 400 mg L−1, j = 32.89 mA cm−2, 25 mL MO extract, iron cathode and anode j = 32.89 mA cm−2, 12.5 mL MO extract, iron cathode and aluminum anode, (d) [MgCO3] = 400 mg L−1, j = 57.449 mA cm−2, 25 mL MO extract, aluminum cathode and anode; Figure S6. TGA analysis of the flocs from the EC process with MO extract without CaCO3 and MgCO3 at different experimental conditions: (a) j = 32.89 mA cm−2, 25 mL MO extract, iron cathode and anode, (b) j = 57.449 mA cm−2, 12.5 mL MO extract, iron cathode and anode, (c) j = 32.89 mA cm−2, 25 mL MO extract, iron cathode and anode j = 32.89 mA cm−2, 12.5 mL MO extract, iron cathode and aluminum anode, (d) j = 57.449 mA cm−2, 25 mL MO extract, aluminum cathode and anode; Figure S7. DSC analysis of the flocs from the EC process with MO extract and with (C) and without (SC) contaminant (CaCO3 and MgCO3) at different experimental conditions: (a) j = 32.89 mA cm−2, 25 mL MO extract, iron cathode and anode, (b) j = 57.449 mA cm−2, 12.5 mL MO extract, iron cathode and anode, (c) j = 32.89 mA cm−2, 25 mL MO extract, iron cathode and anode j = 32.89 mA cm−2, 12.5 mL MO extract, iron cathode and aluminum anode, (d) j = 57.449 mA cm−2, 25 mL MO extract, aluminum cathode and anode; Figure S8. EDS of sludge C1: Fe(s)|Mg2+(aq), MOSE (25 mL)|Fe(s) j = 32.89 mA cm−2.; Figure S9. EDS of sludge C2: Fe(s)|Mg2+(aq), MOSE (12.5 mL)|Fe(s) j = 57.44 mA cm−2; Figure S10. EDS of sludge C3: Al(s)| Ca2+(aq), MOSE (12.5 mL)|Fe(s) j = 32.89 mA cm−2; Figure S11. EDS of sludge C4: Al(s)| Mg2+(aq), MOSE (25 mL)|Al(s) j = 57.44 mA cm−2.

Author Contributions

Conceptualization, L.F.C. and O.M.R.-N.; methodology, J.M., A.R.P.-B. and P.J.E.-M.; software, A.R.P.-B. and J.M.; validation, A.V.-R., L.F.C. and O.M.R.-N.; formal analysis, N.V.-E. and B.S.M.-V.; investigation, D.M.P.-M. and F.G.M.-L.; resources, A.V.-R., L.F.C. and O.M.R.-N.; data curation, D.M.P.-M. and F.G.M.-L.; writing—original draft preparation, N.V.-E. and B.S.M.-V.; writing—review and editing, O.M.R.-N., A.G. and E.R.B.; visualization, A.V.-R. and O.M.R.-N.; supervision, A.V.-R., L.F.C. and O.M.R.-N.; project administration, A.V.-R. and L.F.C.; funding acquisition, A.V.-R., L.F.C. and O.M.R.-N. All authors have read and agreed to the published version of the manuscript.

Funding

This research was funded by SECIHTI, grant number CBF-2025-G-918.

Data Availability Statement

Original contributions presented in this study are included in the article and Supplementary Materials. Further inquiries can be directed to the corresponding authors.

Acknowledgments

Neali Valencia-Espinoza, Daniel M. Paredes-Molina, Brenda S. Morales-Verdín, Alain R. Picos-Benítez, Alejandro Vega-Rios, Locksley F. Castañeda, O.M. Rodriguez-Narvaez, and Alain S. Conejo-Dávila would like to thank SECIHTI for the fellowship awarded. Also, Locksley F. Castañeda would like to thank SECIHTI for the grant awarded (CBF-2025-G-918).

Conflicts of Interest

Author Erick Bandala was employed by the company NanBioRenewables LLC. 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.

Abbreviations

The following abbreviations are used in this manuscript:
MOSEMoringa oleifera seed extract
ECelectrocoagulation
C/Fcoagulation–flocculation
MOMoringa oleifera
EC/MOSE EC with MOSE
TGAThermogravimetric analysis
FT-IRFourier-transform infrared
TEMTransmission Electron Microscopy
EDSEnergy-Dispersive Spectroscopy
AIartificial intelligence
ANNsArtificial Neural Networks
LM-BPLevenberg–Marquardt Backpropagation
RMSEroot mean squared error
MAPEmean absolute percentage error
GAGenetic algorithm
TEtype of electrode
MEmoringa extract concentration
jcurrent density
DCinitial hardness concentration
[MgCO3]resresidual concentration of MgCO3
MOCPMoringa oleifera coagulant protein

References

  1. Hori, M.; Shozugawa, K.; Sugimori, K.; Watanabe, Y. A survey of monitoring tap water hardness in Japan and its distribution patterns. Sci. Rep. 2021, 11, 13546. [Google Scholar] [CrossRef] [Scilit]
  2. Warade, H.C.; Maske, S.R.; Markad, S.S.; Ansari, F.; Borkar, T.C. Experimental Analysis of Water Hardness and Alkalinity. Int. J. Sci. Res. Eng. Manag. 2025, 9, 1–9. [Google Scholar] [CrossRef] [Scilit]
  3. Siahaan, A.A.; Asrol, M. Development of a machine learning model for predicting hardness in the water treatment pharmaceutical industry. Int. Ind. Eng. Manag. 2023, 14, 138–146. [Google Scholar] [CrossRef] [Scilit]
  4. Ketharani, J.; Hansima, M.A.C.K.; Indika, S.; Samarajeewa, D.R.; Makehelwala, M.; Jinadasa, K.B.S.N.; Weragoda, S.K.; Rathnayake, R.M.L.D.; Nanayakkara, K.G.N.; Wei, Y.; et al. A comparative study of community reverse osmosis and nanofiltration systems for total hardness removal in groundwater. Groundw. Sustain. Dev. 2022, 18, 100800. [Google Scholar] [CrossRef] [Scilit]
  5. Su, M.; Zhang, Y.; Liu, S.; Wang, Y.; Li, T. Challenges and solutions for nanofiltration membranes in water treatment. Front. Chem. Eng. 2025, 7, 1695014. [Google Scholar] [CrossRef] [Scilit]
  6. Nassrullah, H.; Aburabie, J.; Mohammed, S.; Hilal, N.; Hashaikeh, R. A review of the design, applications, and mechanisms of electrically assisted reverse osmosis and nanofiltration processes. J. Mater. Chem. A Mater. 2025, 13, 30843–30869. [Google Scholar] [CrossRef] [Scilit]
  7. Xia, J.; Rao, T.; Ji, J.; He, B.; Liu, A.; Sun, Y. Enhanced Dewatering of Activated Sludge by Skeleton-Assisted Flocculation Process. Int. J. Environ. Res. Public Health 2022, 19, 6540. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  8. Yuan, S.; Zhang, S.; Tang, X. Research progress on flocculation-based technology for the enhancement of sludge dewatering: A review. Sep. Sci. Technol. 2024, 59, 1183–1201. [Google Scholar] [CrossRef] [Scilit]
  9. Patel, S.K.; Shukla, S.C.; Natarajan, B.R.; Asaithambi, P.; Dwivedi, H.K.; Sharma, A.; Singh, D.; Nasim, M.; Raghuvanshi, S.; Sharma, D.; et al. State of the art review for industrial wastewater treatment by electrocoagulation process: Mechanism, cost and sludge analysis. Desalin. Water Treat. 2025, 321, 100915. [Google Scholar] [CrossRef] [Scilit]
  10. Hyrycz, M.; Ochowiak, M.; Krupińska, A.; Włodarczak, S.; Matuszak, M. A review of flocculants as an efficient method for increasing the efficiency of municipal sludge dewatering: Mechanisms, performances, influencing factors and perspectives. Sci. Total Environ. 2022, 820, 153328. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  11. Al-Marri, J.S.; Abouedwan, A.B.; Ahmad, M.I.; Bensalah, N. Electrocoagulation using aluminum electrodes as a sustainable and economic method for the removal of kinetic hydrate inhibitor (polyvinyl pyrrolidone) from produced wastewaters. Front. Water 2023, 5, 1305347. [Google Scholar] [CrossRef] [Scilit]
  12. Ryan, D.R.; Maher, E.K.; Heffron, J.; Mayer, B.K.; McNamara, P.J. Electrocoagulation-electrooxidation for mitigating trace organic compounds in model drinking water sources. Chemosphere 2021, 273, 129377. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  13. Moussa, D.T.; El-Naas, M.H.; Nasser, M.; Al-Marri, M.J. A comprehensive review of electrocoagulation for water treatment: Potentials and challenges. J. Environ. Manag. 2017, 186, 24–41. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  14. Aryanti, P.T.P.; Nugroho, F.A.; Phalakornkule, C.; Kadier, A. Energy efficiency in electrocoagulation processes for sustainable water and wastewater treatment. J. Environ. Chem. Eng. 2024, 12, 114124. [Google Scholar] [CrossRef] [Scilit]
  15. Yusmaini, N.A.; Suzaimi, N.D.; Abuhabib, A.; Almanassra, I.W.; Bagastyo, A.Y.; Adnan, F.H.; Ghani, R.A.; Hamzah, S. Electrocoagulation strategies for oily wastewater treatment: A review on process efficiency and optimization. Int. J. Environ. Sci. Technol. 2026, 23, 227. [Google Scholar] [CrossRef] [Scilit]
  16. Laney, B.; Rodriguez-Narvaez, O.M.; Apambire, B.; Bandala, E.R. Water Defluoridation Using Sequentially Coupled Moringa oleifera Seed Extract and Electrocoagulation. Groundw. Monit. Remediat. 2020, 40, 67–74. [Google Scholar] [CrossRef] [Scilit]
  17. Barakat, M.M.M.; Soliman, M.S.S.; Mubarak, M.F. Improving electrocoagulation performance by adding environmentally friendly materials. Sci. Rep. 2025, 15, 32422. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  18. Trigueros, D.E.G.; Hinterholz, C.L.; Fagundes-Klen, M.R.; Veit, M.T.; Formentini-Schmitt, D.M. Statistical evaluation of the coagulation-flocculation process by using Moringa oleifera seeds extract to reduce dairy industry wastewater turbidity. Bioresour. Technol. Rep. 2023, 23, 101579. [Google Scholar] [CrossRef] [Scilit]
  19. Akoulih, M.; Tigani, S.; Byoud, F.; El Rharib, M.; Saadane, R.; Pierre, S.; Chehri, A.; El Ghachtouli, S. Electrocoagulation-based AZO DYE (P4R) Removal Rate Prediction Model using Deep Learning. Procedia Comput. Sci. 2024, 236, 51–58. [Google Scholar] [CrossRef] [Scilit]
  20. Igwegbe, C.A.; Obi, C.C.; Onyechi, C.C.; Davoud, B.; Białowiec, A.; Onukwuli, O.D. Integration of experimental and intelligent modeling for optimizing iron electrocoagulation-flocculation recovery of aquafarm effluent. Desalin. Water Treat. 2024, 320, 100832. [Google Scholar] [CrossRef] [Scilit]
  21. Mathaba, M.; Banza, J.C. A comprehensive review on artificial intelligence in water treatment for optimization. Clean water now and the future. J. Environ. Sci. Health Part A 2023, 58, 1047–1060. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  22. Fan, M.; Hu, J.; Cao, R.; Ruan, W.; Wei, X. A review on experimental design for pollutants removal in water treatment with the aid of artificial intelligence. Chemosphere 2018, 200, 330–343. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  23. Picos-Benítez, A.R.; López-Hincapié, J.D.; Chávez-Ramírez, A.U.; Rodríguez-García, A. Artificial intelligence based model for optimization of COD removal efficiency of an up-flow anaerobic sludge blanket reactor in the saline wastewater treatment. Water Sci. Technol. 2017, 75, 1351–1361. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  24. Bagheri, M.; Mirbagheri, S.A.; Bagheri, Z.; Kamarkhani, A.M. Modeling and optimization of activated sludge bulking for a real wastewater treatment plant using hybrid artificial neural networks-genetic algorithm approach. Process Saf. Environ. Prot. 2015, 95, 12–25. [Google Scholar] [CrossRef] [Scilit]
  25. Halkijevic, I.; Licht, K.; Kosar, V.; Bogdan, L. Degradation of the neonicotinoid pesticide imidacloprid by electrocoagulation and ultrasound. Sci. Rep. 2024, 14, 8836. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  26. Medina-Ganem, L.F.; Valencia-Espinoza, N.; Ayoko, G.A.; Bandala, E.; Conejo-Davila, A.S.; Vega-Rios, A.; Goonetilleke, A.; Rodriguez-Narvaez, O.M. The Influence of Moringa oleifera Biomass and Extraction Methods on Biogenic Synthesis of Iron Nanoparticles for Inhibition of Microbial Pollutants. Sustain. Chem. 2026, 7, 4. [Google Scholar] [CrossRef] [Scilit]
  27. Gray, F.; Anabaraonye, B.; Shah, S.; Boek, E.; Crawshaw, J. Chemical mechanisms of dissolution of calcite by HCl in porous media: Simulations and experiment. Adv. Water Resour. 2018, 121, 369–387. [Google Scholar] [CrossRef] [Scilit]
  28. Duan, Y.; Chen, B.; Li, Y. Experimental Evaluation of Authigenic Acid Suitable for Acidification of Deep Oil and Gas Reservoirs at High Temperatures. Processes 2023, 11, 3002. [Google Scholar] [CrossRef] [Scilit]
  29. Wang, X.; Guo, N.; Gan, L.; Liu, J.; Wei, X.; He, T. Sequential determination of calcium chemical phases in gypsum-associated fluorite ores using ICP-OES. RSC Adv. 2026, 16, 4383–4391. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  30. Valencia-Espinoza, N.; Abreu-Naranjo, R.; Medina-Ganem, L.F.; Medina-Ganem, R.E.; Méndez-Landin, F.G.; Vega-Rios, A.; Quevedo-Castro, A.; Picos-Benítez, A.R.; Bandala, E.; Rodríguez-Narvaez, O.M. Functionalized Agave Bagasse Hydrochar for Reactive Orange 84 Removal: Synthesis, Characterization, and ANN–GA Optimization. Processes 2026, 14, 10. [Google Scholar] [CrossRef] [Scilit]
  31. Sergeev, A.; Baglaeva, E.; Shichkin, A.; Buevich, A. The statistical analysis of training data representativeness for artificial neural networks: Spatial distribution modelling of heavy metals in topsoil. Earth Sci. Inform. 2024, 17, 3493–3509. [Google Scholar] [CrossRef] [Scilit]
  32. Rodríguez-Narvaez, O.M.; Pandita, B.; Goyal, O.; Rallapalli, S.; Ranasinghe, M.I.; Conejo-Dávila, A.S.; Bandala, E.R.; Goonetilleke, A. Efficacy of biochar as a catalyst for a Fenton-like reaction: Experimental, statistical and mathematical modeling analysis. J. Water Process Eng. 2025, 70, 107014. [Google Scholar] [CrossRef] [Scilit]
  33. Phu, T.K.C.; Nguyen, P.L.; Phung, T.V.B. Recent progress in highly effective electrocoagulation-coupled systems for advanced wastewater treatment. iScience 2025, 28, 111965. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  34. Xu, H.T.; Zhang, N.; Li, M.R.; Zhang, F.S. Comparison of the ionic effects of Ca2+ and Mg2+ on nucleic acids in liquids. J. Mol. Liq. 2021, 344, 117781. [Google Scholar] [CrossRef] [Scilit]
  35. Ingin, Y.P.; Mahringer, D.; El-Athman, F. Hardness properties of calcium and magnesium ions in drinking water. Appl. Food Res. 2024, 4, 100600. [Google Scholar] [CrossRef] [Scilit]
  36. Hakizimana, J.N.; Gourich, B.; Chafi, M.; Stiriba, Y.; Vial, C.; Drogui, P.; Naja, J. Electrocoagulation process in water treatment: A review of electrocoagulation modeling approaches. Desalination 2017, 404, 1–21. [Google Scholar] [CrossRef] [Scilit]
  37. Bejjany, B.; Lekhlif, B.; Eddaqaq, F.; Dani, A.; Mellouk, H.; Digua, K. Treatment of the surface water by electrocoagulation-electroflotation process in internal loop airlift reactor: Conductivity effect on turbidity removal and energy consumption. JMES 2017, 8, 2757–2768. [Google Scholar]
  38. Tegladza, I.D.; Xu, Q.; Xu, K.; Lv, G.; Lu, J. Electrocoagulation processes: A general review about role of electro-generated flocs in pollutant removal. Process Saf. Environ. Prot. 2021, 146, 169–189. [Google Scholar] [CrossRef] [Scilit]
  39. Zeppenfeld, K. Electrochemical removal of calcium and magnesium ions from aqueous solutions. Desalination 2011, 277, 99–105. [Google Scholar] [CrossRef] [Scilit]
  40. Ghanbarizadeh, P.; Parivazh, M.M.; Abbasi, M.; Osfouri, S.; Dianat, M.J.; Rostami, A.; Dibaj, M.; Akrami, M. Performance enhancement of specific adsorbents for hardness reduction of drinking water and groundwater. Water 2022, 14, 2749. [Google Scholar] [CrossRef] [Scilit]
  41. Medina-Collana, J.T.; Reyna-Mendoza, G.E.; Montaño-Pisfil, J.A.; Rosales-Huamani, J.A.; Franco-Gonzales, E.J.; Córdova García, X. Evaluation of the Performance of the Electrocoagulation Process for the Removal of Water Hardness. Sustainability 2023, 15, 590. [Google Scholar] [CrossRef] [Scilit]
  42. Muhammad, M.H.; Yusoff, M.H.M.; Rosazlina, R.; Shafie, M.H. A review on Moringa oleifera polysaccharides: Extraction, purification, structure-activity, bioactivities and application. Int. J. Biol. Macromol. 2025, 323, 147089. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  43. Akhbari, A.; Bonakdari, H.; Ebtehaj, I. Evolutionary prediction of electrocoagulation efficiency and energy consumption probing. Desalin. Water Treat. 2017, 64, 54–63. [Google Scholar] [CrossRef] [Scilit]
  44. Bhagawati, P.B.; H S., K.K.; B., L.; Malekdar, F.; Sapate, S.; Adeogun, A.I.; Chapi, S.; Goswami, L.; Mirkhalafi, S.; Sillanpää, M. Prediction of electrocoagulation treatment of tannery wastewater using multiple linear regression based ANN: Comparative study on plane and punched electrodes. Desalin. Water Treat. 2024, 319, 100530. [Google Scholar] [CrossRef] [Scilit]
  45. Kumar, A.; Basu, D. Optimization and prediction of SO42− removal in electrocoagulation process with rotating electrodes using Taguchi and ANN approach. J. Environ. Chem. Eng. 2025, 13, 116934. [Google Scholar] [CrossRef] [Scilit]
  46. da Silva Ribeiro, T.; Grossi, C.D.; Merma, A.G.; dos Santos, B.F.; Torem, M.L. Removal of boron from mining wastewaters by electrocoagulation method: Modelling experimental data using artificial neural networks. Miner. Eng. 2019, 131, 8–13. [Google Scholar] [CrossRef] [Scilit]
  47. Hasani, G.; Daraei, H.; Shahmoradi, B.; Gharibi, F.; Maleki, A.; Yetilmezsoy, K.; McKay, G. A novel ANN approach for modeling of alternating pulse current electrocoagulation-flotation (APC-ECF) process: Humic acid removal from aqueous media. Process Saf. Environ. Prot. 2018, 117, 111–124. [Google Scholar] [CrossRef] [Scilit]
  48. Mousazadehgavan, M.; Hajalifard, Z.; Basirifard, M.; Afsharghoochani, S.; Mirkhalafi, S.; Kabdaşlı, I.; Hashim, K.; Nakouti, I. The Critical Role of Artificial Intelligence in Optimizing Electrochemical Processes for Water and Wastewater Remediation: A State-of-the-Art Review. ACS ES&T Water 2025, 5, 2793–2811. [Google Scholar] [CrossRef] [Scilit]
  49. Khataee, A.A.; Khataee, A.A.; Fathinia, M.; Vahid, B.; Joo, S.W. Kinetic modeling of photoassisted-electrochemical process for degradation of an azo dye using boron-doped diamond anode and cathode with carbon nanotubes. J. Ind. Eng. Chem. 2013, 19, 1890–1894. [Google Scholar] [CrossRef] [Scilit]
  50. Picos-benítez, A.R.; Martínez-vargas, B.L.; Duron-torres, S.M.; Brillas, E.; Peralta-hernández, J.M. The use of artificial intelligence models in the prediction of optimum operational conditions for the treatment of dye wastewaters with similar structural characteristics. Process Saf. Environ. Prot. 2020, 143, 36–44. [Google Scholar] [CrossRef] [Scilit]
  51. Jung, Y.; Jung, Y.; Kwon, M.; Kye, H.; Abrha, Y.W.; Kang, J.W. Evaluation of Moringa oleifera seed extract by extraction time: Effect on coagulation efficiency and extract characteristic. J. Water Health 2018, 16, 904–913. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  52. Putra, R.S.; Amri, R.Y.; Ayu, M. Turbidity removal of synthetic wastewater using biocoagulants based on protein and tannin. AIP Conf. Proc. 2020, 2242, 040028. [Google Scholar] [CrossRef] [Scilit]
  53. Francisco, J.P.; Silva, J.B.G.; Roque, O.C.C.; Nascentes, A.L.; Silva, L.D.B. Evaluation of the effect of the seed extract of Moringa oleifera lam over the efficiency of organic filters in wastewater treatment of dairy cattle breeding. Eng. Agric. 2014, 34, 143–152. [Google Scholar] [CrossRef] [Scilit]
  54. Azoulay, K.; Bencheikh, I.; Mabrouki, J.; Samghouli, N.; Moufti, A.; Dahchour, A.; El Hajjaji, S. Adsorption mechanisms of azo dyes binary mixture onto different raw palm wastes. Int. J. Environ. Anal. Chem. 2023, 103, 1633–1652. [Google Scholar] [CrossRef] [Scilit]
  55. Mejía Carrillo, P.W.; Urquia Collantes, K.; Cabello Torres, R.J.; Valdiviezo Gonzales, L.G. Evaluación de la Moringa oleifera en el tratamiento de aguas con alta turbidez y carga orgánica. Ing. Agua 2020, 24, 119–127. [Google Scholar] [CrossRef] [Scilit]
  56. Al-Jadabi, N.; Laaouan, M.; El Hajjaji, S.; Mabrouki, J.; Benbouzid, M.; Dhiba, D. The Dual Performance of Moringa oleifera Seeds as Eco-Friendly Natural Coagulant and as an Antimicrobial for Wastewater Treatment: A Review. Sustainability 2023, 15, 4280. [Google Scholar] [CrossRef] [Scilit]
  57. Kakkar, S.; Dharavat, N.; Pammi, S.V.N. A Moringa oleifera, a natural coagulant, as a potential future approach for sustainable water purification: A patent based study. Results Eng. 2025, 27, 106630. [Google Scholar] [CrossRef] [Scilit]
  58. Mutar, Z.H.; Abdullah, S.R.S.; Al-Baldawi, I.A. Correlating the polysaccharide and protein contents of five plant-derived coagulants with turbidity removal. J. Ecol. Eng. 2025, 26, 231–241. [Google Scholar] [CrossRef] [PubMed]
  59. Wang, L.; Fei, T.; Li, X.; Sun, Q.; Liu, X.; Wang, L. Improved protein extraction from Moringa oleifera seeds using deep eutectic solvents: Mechanistic insights and protein characterization. Food Hydrocoll. 2026, 174, 112402. [Google Scholar] [CrossRef] [Scilit]
  60. Gunalan, S.; Thangaiah, A.; Rathnasamy, V.K.; Janaki, J.G.; Thiyagarajan, A.; Kuppusamy, S.; Arunachalam, L. Microwave-assisted extraction of biomolecules from moringa (Moringa oleifera Lam.) leaves var. PKM 1: A optimization study by response surface methodology (RSM). Kuwait J. Sci. 2023, 50, 339–344. [Google Scholar] [CrossRef] [Scilit]
  61. Pivokonsky, M.; Safarikova, J.; Bubakova, P.; Pivokonska, L. Coagulation of peptides and proteins produced by Microcystis aeruginosa: Interaction mechanisms and the effect of Fe-peptide/protein complexes formation. Water Res. 2012, 46, 5583–5590. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  62. Jeyakumar, N.; Narayanasamy, B.; Balasubramanian, D.; Viswanathan, K. Characterization and effect of Moringa oleifera Lam. antioxidant additive on the storage stability of Jatropha biodiesel. Fuel 2020, 281, 118614. [Google Scholar] [CrossRef] [Scilit]
  63. Varol, E.A.; Mutlu, Ü. TGA-FTIR Analysis of Biomass Samples Based on the Thermal Decomposition Behavior of Hemicellulose, Cellulose, and Lignin. Energies 2023, 16, 3674. [Google Scholar] [CrossRef] [Scilit]
  64. Kristanto, J.; Azis, M.M.; Purwono, S. Multi-distribution activation energy model on slow pyrolysis of cellulose and lignin in TGA/DSC. Heliyon 2021, 7, e07669. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  65. Darabian, L.M.; Gonçalves, G.R.; Schettino, M.A.; Passamani, E.C.; Freitas, J.C.C. Synthesis of nanostructured iron oxides and study of the thermal crystallization process using DSC and in situ XRD experiments. Mater. Chem. Phys. 2022, 285, 126065. [Google Scholar] [CrossRef] [Scilit]
  66. Sanjaya, W.B.T.; Widayanti, R.; Nishijima, K.; Wihadmadyatami, H.; Kustiati, U.; Aliffia, D.; Aviana, A.P.; Kusindarta, D.L. Dataset on phytochemical profiling of Moringa oleifera leaves ethanolic extract using spectrophotometry UV-Vis, TLC, FTIR, and GCMS: Neuroregenerative potential, IC50 determination, and proliferation assay evaluation. Data Brief 2025, 63, 112256. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  67. Chandni Ahmad, S.S.; Saloni, A.; Bhagat, G.; Ahmad, S.; Kaur, S.; Khan, Z.S.; Kaur, G.; Abdi, G. Phytochemical characterization and biomedical potential of Iris kashmiriana flower extracts: A promising source of natural antioxidants and cytotoxic agents. Sci. Rep. 2024, 14, 24785. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  68. Kumar, K.A.; Bisoi, A.; Yeshwanth, M.; Shobham, N.; Jujaru, M.; Panwar, J.; Gupta, S. Unveiling the dye adsorption capability of Moringa oleifera functionalized hybrid porous MOF–GO composites: In vitro and in silico ecotoxicity assessment via antibacterial and molecular docking studies. Environ. Sci. 2024, 10, 1938–1963. [Google Scholar] [CrossRef] [Scilit]
  69. Darwish, N.; Ashani, M.M.; Mehairi, A.; Lewis, I.A.; Husein, M.M. Synthesis of uniform core-shell calcium hydroxide-calcium carbonate biocidal particles via encapsulation into dry ice. Can. J. Chem. Eng. 2025, 103, 4774–4785. [Google Scholar] [CrossRef] [Scilit]
  70. Darvishi, S.; Ensafi, A.A.; Mousaabadi, K.Z. Design and fabrication of electrochemical sensor based on NiO/Ni@C-Fe3O4/CeO2 for the determination of niclosamide. Sci. Rep. 2024, 14, 7576. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  71. Paramanik, P.; Samal, K.; Debbarma, S.R. Effects of Electrode Composition on Electrocoagulation of Rice Mill Effluent. Water Environ. Res. 2026, 98, e70330. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  72. Choy, S.Y.; Prasad, K.M.N.; Wu, T.Y.; Raghunandan, M.E.; Ramanan, R.N. Utilization of plant-based natural coagulants as future alternatives towards sustainable water clarification. J. Environ. Sci. 2014, 26, 2178–2189. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  73. Castro-Muñoz, R. Advances in deep eutectic solvents as extracting media toward heavy metals from natural, processed and commercialized food products. Food Chem. 2025, 486, 144599. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  74. Zhang, X.; Guo, Y.; Liu, Y.; Wang, F.; Hu, L.; Shi, J.; Song, M.; Yin, Y.; Cai, Y.; Jiang, G. Natural metal-containing nanoparticles as an important form of metals in their biogeochemical cycle and biological effect. Water Res. 2026, 293, 125440. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  75. Santos, A.J.D.; De Lima, M.D.; Da Silva, D.R.; Garcia-Segura, S.; Martínez-Huitle, C.A. Influence of the water hardness on the performance of electro-Fenton approach: Decolorization and mineralization of Eriochrome Black T. Electrochim. Acta 2016, 208, 156–163. [Google Scholar] [CrossRef] [Scilit]
  76. Gareev, K.G. Diversity of Iron Oxides: Mechanisms of Formation, Physical Properties and Applications. Magnetochemistry 2023, 9, 119. [Google Scholar] [CrossRef] [Scilit]
  77. Furcas, F.E.; Mundra, S.; Lothenbach, B.; Angst, U.M. Speciation Controls the Kinetics of Iron Hydroxide Precipitation and Transformation at Alkaline pH. Environ. Sci. Technol. 2024, 58, 19851. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  78. Song, B.; van der Weijden, R.D.; Liu, C.; Lei, Y. Electrochemical In Situ Production of Magnetite for the Removal of Se from Wastewater. ACS ES T Water 2024, 4, 4556–4567. [Google Scholar] [CrossRef] [Scilit]
  79. Gutierrez Herrera, J.C.; Martínez Ovallos, C.A.; Agudelo-Castañeda, D.M.; Paternina-Arboleda, C.D. Exploring Moringa oleifera: Green Solutions for Sustainable Wastewater Treatment and Agricultural Advancement. Sustainability 2024, 16, 9433. [Google Scholar] [CrossRef] [Scilit]
  80. Yang, Y.; Li, Y.; Ma, P.; Chen, Y.; Xu, S. Unraveling synergistic mechanisms of enhanced electrocoagulation sludge dewatering using modified sludge-based biochar. J. Water Process Eng. 2024, 65, 105697. [Google Scholar] [CrossRef] [Scilit]
  81. Yazıcı Karabulut, B. Electrochemical Coagulant Generation via Aluminum-Based Electrocoagulation for Sustainable Greywater Treatment and Reuse: Optimization Through Response Surface Methodology and Kinetic Modelling. Molecules 2025, 30, 3779. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  82. Balbinoti, J.R.; Jorge, R.M.M.; dos Santos Junior, R.E.; Balbinoti, T.C.V.; de Almeida Coral, L.A.; de Jesus Bassetti, F. Treatment of low-turbidity water by coagulation combining Moringa oleifera Lam and polyaluminium chloride (PAC). J. Environ. Chem. Eng. 2024, 12, 111624. [Google Scholar] [CrossRef] [Scilit]
Figure 1. Illustration of the experiments carried out in this research.
Figure 1. Illustration of the experiments carried out in this research.
Water 18 01983 g001
Figure 2. Comparison of Ca2+ and Mg2+ ions hardness removal between sacrificial anodes of aluminum and iron at j = 32.89 and 57.44 mA cm−2 for different experimental conditions: (a) EC with 12.5 mL of NaCl, (b) EC with 25 mL of NaCl, (c) EC with 12.5 mL of MOSE, and (d) EC with 25 mL of MOSE.
Figure 2. Comparison of Ca2+ and Mg2+ ions hardness removal between sacrificial anodes of aluminum and iron at j = 32.89 and 57.44 mA cm−2 for different experimental conditions: (a) EC with 12.5 mL of NaCl, (b) EC with 25 mL of NaCl, (c) EC with 12.5 mL of MOSE, and (d) EC with 25 mL of MOSE.
Water 18 01983 g002
Figure 3. (a) Conditions required to perform the EC/MOSE; (b) experimental data for ANN training.
Figure 3. (a) Conditions required to perform the EC/MOSE; (b) experimental data for ANN training.
Water 18 01983 g003
Figure 4. Experimental validation of the optimal conditions obtained using the ANN-GA model.
Figure 4. Experimental validation of the optimal conditions obtained using the ANN-GA model.
Water 18 01983 g004
Figure 5. FT-IR analysis of the sludge from the EC process at different experimental conditions. (a) SMC1: Fe(s)|water|Fe(s) j = 32.89 mA cm−2; SC1: Fe(s)|MOSE (25 mL)|Fe(s) j = 32.89 mA cm−2; C1: Fe(s)|Mg2+(aq), MOSE (25 mL)|Fe(s) j = 32.89 mA cm−2; (b) SMC2: Fe(s)|water|Fe(s) j = 57.44 mA cm−2; SC2: Fe(s)|MOSE (12.5 mL)|Fe(s) j = 57.44 mA cm−2; C2: Fe(s)|Mg2+(aq), MOSE (12.5 mL)|Fe(s) j = 57.44 mA cm−2; (c) SMC3: Al(s)|water|Fe(s) j = 32.89 mA cm−2; SC3 Al(s)|MOSE (12.5 mL)|Fe(s) j = 32.89 mA cm−2; C3: Al(s)| Ca2+(aq), MOSE (12.5 mL)|Fe(s) j = 32.89 mA cm−2; (d) SMC4: Al(s)| water|Al(s) j = 57.44 mA cm−2; SC4: Al(s)|MOSE (25 mL)|Al(s) j = 57.44 mA cm−2; C4: Al(s)| Mg2+(aq), MOSE (25 mL)|Al(s) j = 57.44 mA cm−2.
Figure 5. FT-IR analysis of the sludge from the EC process at different experimental conditions. (a) SMC1: Fe(s)|water|Fe(s) j = 32.89 mA cm−2; SC1: Fe(s)|MOSE (25 mL)|Fe(s) j = 32.89 mA cm−2; C1: Fe(s)|Mg2+(aq), MOSE (25 mL)|Fe(s) j = 32.89 mA cm−2; (b) SMC2: Fe(s)|water|Fe(s) j = 57.44 mA cm−2; SC2: Fe(s)|MOSE (12.5 mL)|Fe(s) j = 57.44 mA cm−2; C2: Fe(s)|Mg2+(aq), MOSE (12.5 mL)|Fe(s) j = 57.44 mA cm−2; (c) SMC3: Al(s)|water|Fe(s) j = 32.89 mA cm−2; SC3 Al(s)|MOSE (12.5 mL)|Fe(s) j = 32.89 mA cm−2; C3: Al(s)| Ca2+(aq), MOSE (12.5 mL)|Fe(s) j = 32.89 mA cm−2; (d) SMC4: Al(s)| water|Al(s) j = 57.44 mA cm−2; SC4: Al(s)|MOSE (25 mL)|Al(s) j = 57.44 mA cm−2; C4: Al(s)| Mg2+(aq), MOSE (25 mL)|Al(s) j = 57.44 mA cm−2.
Water 18 01983 g005
Figure 6. TEM analysis of the sludge obtained from the EC process with MOSE for different experimental conditions: (a,b) C1: Fe(s)|Mg2+(aq), MOSE (25 mL)|Fe(s) j = 32.89 mA cm−2; (c,d) C2: Fe(s)|Mg2+(aq), MOSE (12.5 mL)|Fe(s) j = 57.44 mA cm−2; (e,f) C3: Al(s)|Ca2+(aq), MOSE (12.5 mL)|Fe(s) j = 32.89 mA cm−2; (g,h) C4: Al(s)|Mg2+(aq), MOSE (25 mL)|Al(s) j = 57.44 mA cm−2.
Figure 6. TEM analysis of the sludge obtained from the EC process with MOSE for different experimental conditions: (a,b) C1: Fe(s)|Mg2+(aq), MOSE (25 mL)|Fe(s) j = 32.89 mA cm−2; (c,d) C2: Fe(s)|Mg2+(aq), MOSE (12.5 mL)|Fe(s) j = 57.44 mA cm−2; (e,f) C3: Al(s)|Ca2+(aq), MOSE (12.5 mL)|Fe(s) j = 32.89 mA cm−2; (g,h) C4: Al(s)|Mg2+(aq), MOSE (25 mL)|Al(s) j = 57.44 mA cm−2.
Water 18 01983 g006
Figure 7. Energy-dispersive spectroscopy (EDS) of the sludges. (a) C1; (b) C2; (c) C3; (d) C4.
Figure 7. Energy-dispersive spectroscopy (EDS) of the sludges. (a) C1; (b) C2; (c) C3; (d) C4.
Water 18 01983 g007
Table 1. Genetic algorithm properties.
Table 1. Genetic algorithm properties.
ParameterValue
Number of variables4
Initial population size20
Crossover probability0.8
Elite count2
Children2
Crossover typeScattered
Mutation probability0.2
Lower bounds (MO Extract, Electrode, CD, time and Hardness)12.5, 32.89, 40, 0.0
Upper bounds (MO Extract, Electrode, CD, time and Hardness)25, 57.44, 0, 416, 100
Table 2. Optimized conditions for EC/MOSE.
Table 2. Optimized conditions for EC/MOSE.
Time (Mins)ContaminantWith (+) or Without (−) MOSEMOSE Volume (mL per 100 mL of Solution)AnodeCathodeCurrent Density (mA cm−2)
2MgCO3+25FeFe32.89
4MgCO3+25FeFe32.89
6MgCO3+25FeFe32.89
8MgCO3+25AlAl57.44
10MgCO3+12.5FeFe57.44
20MgCO3+12.5AlFe32.89
30MgCO3+25AlAl57.44
40MgCO3+25AlAl57.44
2MgCO3+25FeFe32.89
Table 3. Possible optimal operational conditions for the EC process.
Table 3. Possible optimal operational conditions for the EC process.
Electrode TypeMOSE
(mL per 100 mL−1)
Current Density
(mA cm−2)
Time
(Min)
FeFe12.549.165.3
Table 4. Summary of the key biochemical composition of MOSE.
Table 4. Summary of the key biochemical composition of MOSE.
Compounds PresentMain FeatureReference
Cationic proteinsMain coagulant
Molecular weight: 6.5–48 kDa
Isoelectric point: 9–11° C
Functional groups: amino (–NH2) and carboxyl (–COOH)
[59]
PolysaccharidesLong chain with multiple hydroxyl functional groups (–OH)[42]
Polyphenols and flavonoidsHydroxyl (–OH) and carboxyl (–COOH) groups that can act as chelating agents and/or contribute to adsorption[60]
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

Valencia-Espinoza, N.; Morales-Verdin, B.S.; Paredes-Molina, D.M.; Mendez-Landin, F.G.; McGree, J.; Picos-Benítez, A.R.; Espinoza-Montero, P.J.; Vega-Rios, A.; Goonetilleke, A.; Castañeda, L.F.; et al. Analysis and Characterization of Sludge Produced by Natural Extract-Facilitated Electrocoagulation for Hardness Removal. Water 2026, 18, 1983. https://doi.org/10.3390/w18161983

AMA Style

Valencia-Espinoza N, Morales-Verdin BS, Paredes-Molina DM, Mendez-Landin FG, McGree J, Picos-Benítez AR, Espinoza-Montero PJ, Vega-Rios A, Goonetilleke A, Castañeda LF, et al. Analysis and Characterization of Sludge Produced by Natural Extract-Facilitated Electrocoagulation for Hardness Removal. Water. 2026; 18(16):1983. https://doi.org/10.3390/w18161983

Chicago/Turabian Style

Valencia-Espinoza, Neali, Brenda S. Morales-Verdin, Daniel M. Paredes-Molina, Fabricio G. Mendez-Landin, James McGree, Alain R. Picos-Benítez, Patricio J. Espinoza-Montero, Alejandro Vega-Rios, Ashantha Goonetilleke, Locksley F. Castañeda, and et al. 2026. "Analysis and Characterization of Sludge Produced by Natural Extract-Facilitated Electrocoagulation for Hardness Removal" Water 18, no. 16: 1983. https://doi.org/10.3390/w18161983

APA Style

Valencia-Espinoza, N., Morales-Verdin, B. S., Paredes-Molina, D. M., Mendez-Landin, F. G., McGree, J., Picos-Benítez, A. R., Espinoza-Montero, P. J., Vega-Rios, A., Goonetilleke, A., Castañeda, L. F., Bandala, E. R., & Rodriguez-Narvaez, O. M. (2026). Analysis and Characterization of Sludge Produced by Natural Extract-Facilitated Electrocoagulation for Hardness Removal. Water, 18(16), 1983. https://doi.org/10.3390/w18161983

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