Design of Artificial Neural Network for Prediction of Hydrogen Sulfide and Carbon Dioxide Concentrations in a Natural Gas Sweetening Plant

Gas sweetening is a fundamental step in gas treatment processes for environmental and safety concerns. One of the most extensively used and largely recognized solvents for gas sweetening is methyl diethanolamine (MDEA). One of the most crucial metrics for measuring the effectiveness of gas treatment units is the amount of acid gas that has been treated with MDEA solution. As a result, it should be regularly monitored to avoid operational issues in downstream processes and excessive energy consumption. In this study, the artificial neural network (ANN) ap - proach was followed to predict the H 2 S and CO 2 sour gases concentrations of sweetening process. The model was built using dataset gathered from a real operation plant in Iraq, collected from February 2019 to February 2020, and used as input to the neural network. The data include H 2 S and CO 2 concentrations of the feed gas, temperature, pressure, and flow rate of the unit. The designed ANN model showed good accuracy in modeling the process under investigation, even for a wide range of parameter variability. The testing outcomes demonstrated a high coefficient of determination ( R 2 ) of greater than 0.99, while the overall training performance showed a low mean squared error (MSE) of less than 0.0003.


INTRODUCTION
More than 40% of the world's natural gas reserves are very sour, containing substantial amounts of sulfur and CO 2 , increasing to 60% for Middle Eastern gas reserves (Al-Jadir and Siperstein 2019), Rafati 2019, Kadhim et al. 2021). Given that these gases can create corrosive acids that harm pipes, it is recommended that natural gas contain no more than two mol% carbon dioxide and four ppm hydrogen sulfide (Alqaheem 2021). If the hydrogen sulfide (H 2 S) level of the natural gas surpasses 5.7 mg per cubic meter, the gas is typically regarded as soured Stewart and Arnold (2011). H 2 S is a colorless, corrosive, water-soluble, highly toxic, and flammable acid gas that has the characteristic of the foul odor of rotten eggs (Georgiadis et al. 2020). One of the principal greenhouse gases, carbon dioxide (CO 2 ), accumulates continuously in the atmosphere and has a negative impact on the ecosystem, especially because of the global warming phenomena. Among many other industrial operations, CO 2 is emitted during the creation of electricity and the processing of natural gas.
Because of the harm that CO 2 , H 2 S, and other NG contaminants may do to people, machinery, and the environment, these dangers are becoming more and more concerning. You can categorize natural gas as sweet or sour. It contains nitrogen, CO 2 , O 2 , isopentane, n-pentane, hexane, and H 2 , as well as methane, ethane, propane, isobutene, and n-butane. Helium, hydrogen sulfide, and mercaptans are some additional gases that contribute to the gas' distinctive odor. The primary pollutants in NG are CO 2 and H 2 S; these pollutants can be captured using amine solvents, absorption apparatus, and membranes. By using the distillation and absorption processes, additional pollutants, such as carbonyl sulfide, mercaptans, ethane, pentane, etc., are often eliminated (Sanni et al. 2022).
Various gas-sweetening techniques must be used depending on the type and amount of acid gas impurities that need to be eliminated (Alardhi et al. 2022 To get rid of carbon dioxide and hydrogen sulfide, utilize amine solutions. The majority of onshore gas sweetening operations employ a method simply referred to as the "amine process." With this method, the gas containing hydrogen sulfide and/or carbon dioxide is pushed through a tower containing an amine solution. Similar to how glycol absorbs water, the amine solution is attracted to carbon dioxide and hydrogen sulfide. Diethanolamine and Monoethanolamine (MEA) are the two main amine solutions that are employed (DEA) (Stewart and Arnold 2011). A popular chemical absorbent used in refineries to remove acid gases is diethanolamine (DEA), which is classified as secondary, and methyl diethanolamine (MDEA), which is classified as tertiary. These solvents have several positive qualities, including low vapor pressure, low energy requirements, corrosiveness, high capacity, and high stability. Additionally, unlike DEA, MDEA is designed to remove H 2 S selectively when the goal is to collect it in the presence of CO 2 , whereas its reaction rate with CO 2 is minimal.
There are numerous limitations to traditional methods for chemical engineering challenges, such as nonlinear systems and modeling highly complex. However, in a number of real-world applications, artificial neural networks (ANN) have been shown to be capable of solving complex problems. Due to their capacity to somewhat mimic human problem-solving behavior, which is challenging to replicate utilizing the logical, analytical techniques of expert systems and conventional software technologies, ANNs represent one of the artificial intelligence paradigms that are currently undergoing the most rapid development. The flexibility and capacity of ANNs to simulate both linear and nonlinear systems without the need for an existing empirical model underlies their broad use. Due to this, the ANN has the edge over conventional fitting techniques in several chemical applications. The main objective of this research is to predict the concentration of sour gases and assessment the gas-sweetening process subject to different operating conditions. The ultimate goals of an assessment of the sour gas concentrations of the unit operating with a toxic gas are: (1) to satisfy the quality of the sweet gas, (2) to provide data that can be used to make decisions regarding safety measures and to ensure the environmentally safe release gas containing H 2 S and CO 2 . Furthermore, to protect workers and nearby residents. (3) Assessment of a toxic gas concentration release requires an evaluation of potential adverse health effects and an analysis of the hazard zone around the facility for different release scenarios. In this regard, the ANN will be used as a prediction tool to estimate H 2 S and CO 2 concentrations after the natural gas sweetening process.

Sulfur removal and absorption of feed gas
The process flow is shown in Figure 1. The feed gas from the gas booster section enters this section under a temperature of 40-45°C and a pressure of 4.0 MPa. After the separation filter removes the small solid particles, the liquid droplets are still possibly entrained in the gas. The feed gas and the MDEA, with a percentage of 36-38 wt%, enter the amine absorption tower. The feed gas interacts with the amine solvent's lean solution as it moves from the bottom to the top of the unit. Lean amine inlets are provided on the 18 th , 20 th , and 24 th tray layers of the main absorption tower for adjusting the absorber operation to adapt to the changes in feed gas quality and ensure the quality indexes of sweet wet gas. After the sweet wet gas is separated from the liquid on the top of the main absorber by the sweet gas scrubber, it is then passed to the user.

Flashing of rich amine
The bottom of the amine absorber discharges the rich amine that has absorbed the acid gas. It enters the rich amine flash vessel after being pressure-adjusted by the liquid level control valve at the base of the absorption tower. The flash vessel's solution and the dissolved condensate in it are separated, and the condensate is skimmed out of the solution system. Flashing off the solution in the vessel causes some of the dissolved hydrocarbon gas to release. Most of the H 2 S gas is separated from the flash gas as it flows from bottom to top and contacts the lean amine as it flows from top to bottom. The flash gas from the top of the flash vessel then goes to the low-pressure flare knockout drum.

Amine regeneration
Utilizing the liquid level control valve, the rich amine is pumped out of the depths of the rich amine flash vessel. Through the lean/rich solution heat exchanger, with the lean amine that is being delivered from the amine regenerator tower's base, it exchanges heat (HE), with its temperature rising to about 100 ℃. After that, it enters the amine regenerator tower, flowing top to bottom and coming into touch with the steam, moving bottom to top inside the column in a count-current manner. This process allows the hydrocarbons, H 2 S, and CO 2 to be removed from the rich solution. The lean amine is pumped to the amine absorber (absorption tower), completing the circulation of the whole solution system. The regenerator reboiler provides the heat required by the regeneration. Acid gas goes into the Flare system or the Sulfur recovery unit. Hot lean amine goes out from the bottom of the amine regenerator. After its temperature is reduced to about 88 ℃ by exchanging heat with the rich amine in the lean/rich amine exchanger, it is sent to the amine gathering tank, which is then pumped by the hot lean amine pump to the lean amine air cooler. After cooling, part of the lean amine enters the lean amine filter to remove the mechanical impurities, then enter the activated carbon filter and lean amine solids filter for filtering and removing deterioration and degradation products from the solution. After filtering, the lean amine goes into the amine flash vessel and the amine recycling pump. The lean amine to the lean amine recycles pump is pumped to the absorption tower, completing the recycling of the whole solution system.

Chemical reactions and feed gas specification
Regarding the mass transfer rates, the reaction rates of H 2 S with MDEA are practically immediate. Contrarily, compared to the rate of mass transfer of CO 2 , the reaction rates of CO 2 with MDEA are limited and slow. The kinetic selectivity for H 2 S is caused by this differential in reaction rates Pacheco and Rochelle (1998). The tertiary amine MDEA, having the chemical formula (C 2 H 4 OH) 2 NCH 3 , has a sluggish reaction with CO 2 but a nearly immediate reaction with H 2 S. Principal process responses comprise: • hydrogen sulfide and the reaction: • the reaction with carbon dioxide: However, the above two reactions are reversible. Moreover, Table 1 gives the composition of the natural gas obtained using gas chromatography.

ISSUES WITH GAS SWEETENING PLANTS
Gas sweetening units have numerous issues, some of which are brought on by inadequate knowledge of the relevant process parameters. With the aid of artificial neural network models, the problems can be predicted. Following is a list of some problems brought on by rich amine conditions: Gas is not sweet, dirty degraded amine, excessive energy consumption, and excessive corrosion Rahmanpour et al. (2015).

MODELING USING ARTIFICIAL NEURAL NETWORKS
One of the artificial intelligence methods, known as an artificial neural network (ANN), was inspired by the neural networks in the human nervous system (Agwu et al. 2020). Since the 1980s, artificial intelligence research has greatly benefited from the use of neural networks, which have several applications in data processing, classification, performance approximation, and numerical control (Ram et al. 2019). Similar to how synapses interact in the brain, nodes in such networks' mathematical structures stand in for neurons and layers for their interconnected layers. Since their conception, ANNs have been widely accepted, yet, as computing power increased, ANNs began to earn more notoriety. This use has aided the ANN algorithms' scientific advancement, which began with single-layer perceptrons before switching to multilayer perceptrons; after that, the backpropagation algorithm was introduced, which led to many new types of ANNs (Anagnostis et al. 2020).

Data collection
A good performance of the sweetening unit depends on the proper optimization of operating parameters (Pandey 2005). In this regard, five input key process parameters, H 2 S and CO 2 concentrations, temperature, pressure, and flow rate of input gases data, were collected from a local refinery in Iraq over a one-year period. The raw dataset from this system consists of 243 data points sampled from February 2019 to February 2020. The considered output parameters are H 2 S and CO 2 concentrations after the gas sweetening process. The minimum and maximum values of each parameter and the units of measurement are shown in Table 2. The plant can process sour gas with 1.2 MMTPA of aromatics with eight trains of natural gas sweetening units (41 MMSCF/D). It has absorption and stripping towers and uses MDEA as a solvent.

Normalization and Implementation of ANN
Due to the slightly disparate scales of the different variables in the dataset, a min-max normalization approach was applied to the training data to bring all features to the same scale. Normalization is a crucial step in the control of bias in linear regression modeling. Regardless of how important a variable is to the prediction, if the scales of the two variables are substantially different, the regression analysis will be more heavily influenced by the item with the larger scale (Chawade et al. 2014, Al Jarrah 2022). Using Equation 3, the data were where: -the normalized value; X min and X min are the minimum and maximum values of , respectively (Al Jarrah 2022).
In this paper, the neural network toolbox of MATLAB software was used to predict the H 2 S and CO 2 concentrations of the gas sweetening process. Table 3 lists the parameters selected for the ANN model. The models were trained and tested using the dataset defining the procedure. In order to minimize the loss, expressed as the Mean Squared Error (MSE) between predictions and actual values, the training objective was to identify the model's internal parameters. Equation 4 was applied to the MSE calculations. Before starting the program, the dataset was loaded, shuffled, and split into training (70% of the dataset), validation (15% of the dataset), and testing (15% of the dataset). where: n -the number of data sets for which the MSE is computed, Out experimental -the value of the analyzed parameter obtained from the experimental work, Out predicted -the ANN predicted value.
The number of hidden layers ranged from one to six hidden layers, and it is observed that increasing the number of hidden layers improves the accuracy of the model prediction. However, it increases the computation time for learning drastically.

Framework of ANN
The current study used the ANN approach to forecast the output parameters (H 2 S and CO 2 concentrations) based on how input parameters operate (temperature, pressure, flow rate, H 2 S, and CO 2 concentrations). Figure 2 displays the multilayer feed-forward artificial neural network's created configuration.
Determining a training algorithm to utilize is the first step in creating the neural network model. Because it enables the network to adopt, the backpropagation network -a potent multilayer, feed-forward neural network was used in the current study. They can train a network on a common set of input/output pairs and get good results without training the network on all possible input/ output pairs thanks to the backpropagation network's generalization characteristic. One or more hidden layers of sigmoid neurons, followed by an output layer of linear neurons, are common components in feed-forward networks. The network can learn both linear and nonlinear relationships between input and output vectors thanks to its multiple layers of nonlinear transfer function neurons. In contrast to the desired output, as shown during the training phase, Figure 3 displays the network's actual output. As a result, the network's weights were updated by propagating the resulting error backward. The proposed intelligent network can be utilized to provide an alternative method to predict the H 2 S and CO 2 concentrations of the sweeting process. Additionally, this intelligent approach predicts more quickly than traditional simulation parameters or even mathematical methods. As shown in Figure 4, the intelligent system is prepared to anticipate performance after training based on the learned learning parameters that have been saved. The training method normally consists of steps: (1) build the network object after putting together the training data; (2) prepare your network; (3) model the network's reaction to fresh inputs. The steps that must be taken to build a suitable network are shown in Figure 5.

Function, number of neurons, and hidden layers for optimal training
In MATLAB, the ANN toolbox has different backpropagation training algorithms. The feed-forward learning strategy is utilized in conjunction with quick processing algorithms, such as TRAINBR, TRAINBFG, TRAINOSS, and TRAINLM, as a technique for numerical optimization. The MSE and R 2 were used to compare. With the testing data, it was discovered that the training function TRAINLM produces the best results. The TRAINLM algorithm is an iterative technique for finding the minimum of a multivariate error function, expressed as the sum of squares of the difference between the actual and target outputs.
An ANN is made up of hundreds of single units, also known as artificial neurons or processing elements, which are linked together by coefficients (weights) to construct the layers that Figure 2. An artificial neural network with multiple layers that are configured make up the neural structure. The interconnection of the neurons in a network is what gives brain calculations of their capacity. The accuracy of the prediction produced depends on how well the neurons are interconnected in the networks. The transfer functions of a neural network's neurons, the learning rule, and the architecture itself all affect how active it is. Another illustration of a hidden layer in an ANN design is the layer that sits between the input and output layers. Therefore, the most important variables influencing predictive performance are the number of hidden layers and the number of neurons in each hidden layer. Most of the previous studies did not propose any criteria to find out the optimal number of neurons and hidden layers. The purpose of this study was to elucidate the significance of the number of neurons and hidden layers by addressing this topic. The size of neurons has changed thanks to the established  ANN model (i.e., 5, 10, 15, 20, 25, 30, 35, and 40). Additionally, the quantity of concealed layers has altered (i.e., 1 to 6). In ANN models, we adjusted the neurons and hidden layers until the performance was optimal. Figure 6 highlights the outcomes of trial and error to establish the ideal number of neurons. Where the number of hidden layers is changed gradually from 1 to six hidden layers. Hence, the results show that increasing the number of hidden layers reduces the MSE by increasing the time response of the training process. Moreover, the optimum number of neurons in the hidden layer aff ects the performance. It is apparent that increasing the number of neurons reduces the MSE. However, increasing the number of neurons to more than 15 will not aff ect the performance in the degree of increasing the time, as illustrated in Figure 7.
Moreover, the performance of selecting the optimum number of the learning algorithm is crucial to improve the prediction process during testing. Moreover, the optimal ANN architecture for H 2 S and CO 2 in this study is presented in Figure 8. Figure 9 shows the outcome of the training performance of the objective (H 2 S and CO 2 concentrations) with the mean square error and the quantity of training network epochs. Once the lowest errors in the testing and verifi cation curves are almost identical based on the epoch numbers, the training is considered successful. As shown in Figure 9, the result of the H 2 S concentration of sweetening gas converged to a mean square error of 2.0023e-06 at the 252-iteration for the 5-15-2 network architecture. Because of its greater ability to forecast outcomes for the aim of the gas sweetening process, the 5-15-2 design is therefore regarded as the ideal neural network for the current challenge (H 2 S and CO 2 concentrations). In addition, a comprehensive comparison to choose the best learning algorithm has been accomplished, and this study shows that the Levenberg Marquardt algorithm act perfectly during the training phase compared to other learning algorithms, as shown in Figure 10. According to indications, the training results meet the following requirements: The testing curve and verifi cation curve are not substantially dissimilar from one another, the mean square error is low, and there was minimal overfi tting during the training phase. Moreover, Figure 11 shows the scatter plots of ANN predicted output sour gases concentrations (H 2 S and CO 2 ) of the actual data obtained from the gas sweetening plant for the training, testing, and validation sets, and, generally, the overall model, respectively. The value is close to 100 percent, which shows that the artifi cial neural network method used to create the prediction model performed very well.

CONCLUSIONS
Because of the advantages to the environment, natural gas, which is now one of the major energy carriers, will play a larger role among energy sources in the future. The amine sweetening plant of a case study refi nery was simulated by ANN, and a model was used to simulate the absorption process. The model was validated through actual industrial data, and results showed that the model had high accuracy. This study demonstrates how ANN may be used to create precise prediction models for the operational variables of a natural gas sweetening plant for industrial use. In addition to the basic benefi ts indicated for ANN as an input/output modeling tool, the projected data in this study demonstrated good accuracy performance from artifi cial neural networks. The developed ANN model was constructed using the best possible architecture, which included: 5-15-2 architecture is considered the best neural network with one hidden layer for the specifi ed architecture. The R 2 was higher than 0.99 in the testing results, and the entire training had a low MSE of less than 0.0003, proving that ANN models can successfully predict the amounts of sour gases in a natural gas sweetening facility. The pace of learning and prediction could be increased by integrating the generated ANN model with other optimization methods.