#### Abstract

Fuel consumption has been increasing in recent years, especially that of diesel and jet fuel. For this reason, the necessity to build new plants to reduce their sulfur content has arisen. Sometimes, just revamping existing plants is feasible, but determining which pieces of equipment are in the appropriate condition to be reused is also necessary. In order to select the equipment, it is essential to have information about the wall thickness of vessels. Sometimes, the information is limited; consequently, the application of advanced statistical techniques is needed. The Bayesian Data Analysis (BDA) used in this study has the goal of determining a more accurate, unobserved thinning rate distribution for existing heat exchangers, taking into consideration all the information available about the thinning rate of the heat exchangers that cool down the effluent of the hydrotreating reactors in Mexican oil refineries. The information obtained from BDA was compared with existing shell wall thickness obtaining favorable results.

#### 1. Introduction

Middle distillates (e.g., jet fuel, diesel, or kerosene) are widely used as fuel in motor vehicles (e.g., cars, buses, and trucks), in airplanes, and in some industrial machines (e.g., locomotives, ships, and farm equipment) [1]. Diesel engines are about 40% more fuel-efficient than comparable gasoline engines [2]. Nevertheless, they suffer from associated contaminants, such as NO_{x} and SO_{x} emissions, that are dangerous to human health. Sulfur, a natural part of crude oil from which diesel fuel is derived, is one of the key causes of particulates, or soot, in diesel [3]. In Mexico, the environmental regulation [4] has established a maximum limit of 15 wppm in total sulfur content for middle distillates. To produce middle distillates with low sulfur content, Pemex (the Mexican state-owned petroleum company) decided to launch the ULSD project (Proyecto DUBA in Spanish) in all Mexican oil refineries. This project consists of building new units and revamping others. To decide which units are adequate for revamping, it is necessary to estimate the cost. This estimate has to include the new equipment being added because of the modernization of the process and because of the expiration of the vessels. In this sense, having the capacity to accurately estimate the vessels’ remaining life is important. In the middle distillates’ hydrotreating units, the heat exchangers that preheat the feed to the reactor using the effluent stream from the same reactor are the vessels that undergo the fastest deterioration. In the hydrodesulfurization process, these heat exchangers can suffer deterioration from atmospheric corrosion (externally, when the coating cannot completely protect the external surface) and by ammonium bisulfide corrosion (internally, when ammonium salts are formed) [5–7].

The hydrodesulfurization and hydrodenitrogenation are carried out through the following reactions [8–14]:

In addition to hydrogen sulfide and ammonia, water vapor, in the form of CO_{2} and CO, is also produced [8–14]:

The environment also induces HCl production if the middle distillate contains organic salts [8–14]:

According to the chemical reactions described above, the gaseous stream that flows out of the reactor contained H_{2}S, NH_{3}, and HCl, which can precipitate acid salts such as NH_{4}Cl and NH_{4}HS, which cause corrosion in heat exchangers.

According to the paper published in 2016 by NACE titled “International Measures of Prevention, Application, and Economics of Corrosion Technologies Study” [15], the global cost of corrosion is estimated to be 3.4% of the global GDP. This study also indicates that the cost of corrosion tends to be higher in developing countries than in developed countries (Table 2-2 in Reference [15]) perhaps due to fewer specialists in this area and fewer resources focused on the prediction, monitoring, prevention, and maintenance of these structures.

In order to monitor the corrosion damage in vessels and pipes, ultrasonic inspection systems are used. These systems help measure the wall thickness in plates and pipes in the downstream oil industry sector. The devices used for the ultrasonic monitoring (UT) are sensitive to errors, such as time of flight, variation of speed of sound (test block of similar material), material grade, material heat treatment, and operational temperature of the equipment or pipe [16]. These errors in the digital thickness gauge reading, in addition to other human errors, can affect the accuracy and the repeatability of the results. Measurement errors are random, additive, independent, and identically distributed [17, 18]. While considering that the bias of the measurement is very close to zero and assuming sizing uncertainty of the magnitude of what is measured, it means that the dimensions of the corrosion defect are measured with an error independent of their values; measurement error could be described using a normal distribution with a mean of zero and variance (). Mathematically, it can be written as follows:

Quantifying these kinds of errors shall be important if one wants to estimate the remaining life of the pipes and vessels more accurately and reliably. For example, the wall thickness sometimes seems to be increasing over time, something which is completely absurd, but this is the result of the inclusion of errors in the measurement process. Besides the measurement errors, another problem that presents itself in the examination of the vessels is related to the sampling inspection. Usually, it is not possible to monitor, or, at least, to measure, the wall thickness for the entire vessel, so, consequently, only some points of the vessels are measured. The selected points are established by the owner or by a mutual agreement between the owner and the inspector. Bear in mind that sampling inspection is a concept used in quality control and, according to ISO-2859 “Sampling Procedures for inspection by attributes” [19], sampling inspection requires the producer to submit lots, products, or raw materials at a quality which is at or better than a mutually agreed level. Applying this concept to mechanical integrity, it means that the company that makes the inspection must execute this task with a certain degree of confidence (in agreement with the owner). However, for the owner, the problem is determining the correct degree of confidence in the inspection to get the best technical-economical benefit. In summary, getting a very high confidence level in the inspection could be very expensive and very difficult because, in addition to having the correct device with high resolution and a very highly qualified inspector, it is sometimes also necessary to shut down a plant to perform a good inspection. Usually, in order to avoid shutting down a process unit, the owner decides to make a sampling inspection of a vessel. It means that partially inspecting a vessel can be enough to estimate, with some confidence, its remaining lifespan. In order to establish which part of the vessel needs to be monitored, it is necessary to determine the points most susceptible to corrosion. The API-510 Standard “Pressure Vessel Inspection Code: In-Service Inspection, Rating, Repair and Alteration” [20] named the points to be measured in vessels “Condition Monitoring Locations (CMLs).” In short, the point is that, with limited data, it is possible to estimate the corrosion rate of the equipment. Bayes’ theorem is a useful tool for estimating the corrosion rate when it is not possible to collect a large amount of data with its variability. For this reason, in this study, a methodology is presented to estimate the corrosion rate in shell and tube heat exchangers that preheat the feed of the reactor in a hydrotreating unit using Bayes’ rule, and the information collected in some HDS plants was distributed in all Mexican oil refineries.

#### 2. Theoretical Framework

##### 2.1. Bayes’ Theorem and the Application in Predictions

The classic methods of estimation are based on information that gives a random sample. These methods read into probabilities like relative frequencies [21]. Another estimation method is based on the Bayesian methodology. The purpose of this method comes from the Bayes’ rule [21–23]:where(i) denotes the posterior probability of parameters after taking into account the observed data .(ii) corresponds to the vector of the new data observed.(iii)is the prior probability distribution. It is the probability distribution of parameters before , and it is described by the vector of hyperparameters .(iv) is the vector of hyperparameters, mathematically expressed as .(v) is the probability of observing , given . This is the likelihood function.(vi) is the marginal distribution of . This is a normalization factor that symbolizes the evidence and represents the probability that the data follows the chosen model under marginalization over all the parameter values, mathematically denoted as follows: .

This posterior distribution is a conditional probability conditioned on randomly observed data. Therefore, it is considered a random variable because the true value of is uncertain. Nonetheless, this posterior distribution can rarely be used directly in engineering applications. In order to apply this distribution, it is necessary to obtain the posterior predictive distribution, which denotes the new unobserved set of data points given a set of existing observations () and the hyperparameters ; thus, it reflects how the new data behave. If the data can be expected to have a distribution , the posterior predictive distribution is represented by the following expression [23, 24]:

#### 3. Bayes’ Theorem on the Estimation of the Remaining Life in Heat Exchangers

After the explanation of the mathematical background described in Section 2, the narrative of its application is necessary. The first step in applying the Bayesian inference was to determine the prior distribution that denotes the beliefs about the variable before some evidence is taken into account. To propose this prior distribution, the wall thickness loss rate (WTLR) data was obtained from the low alloy steel shells of heat exchangers present in all the middle distillate units in Pemex refineries. For this criterion, it was taken into account that the characteristics of the middle distillates are roughly the same. Likewise, the shells of all heat exchangers studied are made from low alloy steel (Material Specification ASTM SA 387.GR-5 CL-1). All these vessels are also exposed to atmospheric corrosion inside the refineries, which means that the shells of the heat exchangers studied are exposed to both external corrosion and internal corrosion (usually ammonium bisulfide corrosion). The wall thickness was monitored by ultrasonic techniques in order to estimate the thinning. The wall thickness loss rate (WTLR) data were acquired from 38 shells of heat exchangers with at least 30 observation points for each one. For each shell analyzed, the thinning rate was fitted to a Generalized Extreme Value Distribution (GEVD); mathematical expression (8) describes the cumulative distribution function for GEVD [25]:where is the random variable and is the wall thickness loss rate and , and are the location parameter, scale parameter, and shape parameter, respectively. This probability function has already been applied successfully in corrosion topics [26–33]. In order to perform a statistical analysis, the availability of data are necessary, but this information is often too scarce for an estimation of the vessels’ remaining life. For example, in the case of pipelines, field studies with data regarding low-carbon steel pipeline corrosion in soil were published in 2010 by Velázquez et al. [32]. Velázquez et al. in 2010 [33], in another study, showed a field survey that helped analyze the distribution of the number of corrosion defects and their size (depth and length) in oil and gas pipelines [17]. For the sake of contributing to the corrosion field information accessible in the literature, Table 1 shows details of the wall thickness thinning rate data obtained for the 38 heat exchangers studied after fitting each one to a GEV distribution. These details describe the location, scale, and shape parameters of the fitted GEV distribution; the number of observations or number of thinning rates obtained from each heat exchanger; and the value returned by the Kolmogorov–Smirnov test [34]. This value is an indicator of the acceptance degree for the GEV distribution that represents the observed data [34]. It means that, in this case, GEV distribution that fits the observed data with low probability of error can be accepted if confidence levels are higher than 0.05 ( value higher or equal than 0.05) [34]. For the sake of schematization, Figure 1 illustrates the thinning rate data from heat exchanger number 36 (entry 36) and its fitting.

A few reports on corrosion studies of carbon steel immersed in ammonium hydrosulfide solutions had been reported in the literature [35]. In the former, the electrochemical behavior of the carbon steel immersed in 0.1 M (NH_{4})_{2}S had been characterized using linear polarization and impedance spectroscopy techniques. Based on these findings, the corrosion current density and corrosion rate of the steel can be estimated [35] using the following equations [36]:where is the corrosion current density, *µ*A/cm^{2}; and are the slopes anodic and cathodic Tafel reactions when plotted on base 10 logarithmic, V/decade; *R*_{p} is the true polarization resistance, Ω·cm^{2}; *k* is a constant value depending of the units, 3.27 × 10^{−3} mm·g/*µ*A·cm·yr; EW is the equivalent weight, 27.92; is the density of the carbon steel, 7.86 g/cm^{3}.

Based on the linear polarization plots (Figure 1) reported in the literature [37], *β*_{a} and *β*_{c} parameters were determined at 0 h of immersion being 0.1 and 0.12 V, respectively. Unlike these parameters, the resistance used for calculating the corrosion rate [37] should be related with the rate-controlling step in the oxidation of the steel evaluated by fitting the EIS diagrams using an equivalent circuit and Boukamp program. It is noteworthy the oxidation of the steel involves the formation of iron sulfides depending on the immersion time. According to the EIS analysis is suggested a charge transfer resistance and the presence of different diffusional process through the sulfide film, e.g., iron ions and atomic hydrogen [37], as well as the bisulfide ions favoring the growth of the sulfide film. In order to compare the corrosion rates determined in the field only is considered the R_{2} contribution (2273 Ω·cm^{2}) at the beginning of the immersion (0 h) [37].

One of the great challenges in Bayesian inference is to find an adequate prior probability distribution. This distribution is obtained from past information and expresses the beliefs about the probability of the studied event before some evidence is taken into account. In this study, the prior distribution is proposed to be the GEV distribution, because in all the cases studied, it was fitted properly, and because, when all the data were fitted to a GEVD, it was also fitted with a low probability of rejection (Figure 2).

The probability distribution of each parameter is obtained from the distribution from all the GEV distribution parameters contained in Table 1. Figure 3 shows the results of fitting the histogram of these parameters. Analyzing these results, according to Figure 3, it is possible to state that the location parameter could be represented by a Generalized Pareto distribution scale parameter and the shape parameter could be represented by GEV distribution. The following equation represents the Generalized Pareto distribution that was already used in corrosion modeling [38]:where is the location parameter, is the scale parameter, and represents the shape parameter for Generalized Pareto distribution.

**(a)**

**(b)**

**(c)**

All these aforementioned parameters are called hyperparameters because they describe the parameters of the prior distribution (). In all cases, the theoretical distribution was chosen with high certainty ( value ≥ 0.05 in K–S test). Once the prior distribution is specified and the distributions of the parameters are also specified, the question about how to estimate the marginal distribution of ( in Equation (2)) emerged. In this study, a numerical approximation is applied via a grid (Chapter 6 in Reference [24]), where a fine grid of the vector of parameters is created. With this method, it is feasible to estimate the posterior distribution by defining the prior distribution through a grid of parameter values. In this method, it is not necessary to do any analytical integration; in other words, the denominator of Bayes’ rule is converted in a sum over many discrete parameter values in lieu of an integral. Mathematical expression (11) summarizes how this numerical estimation could be done [18]:

The sum in the denominator correlates with the finite number of discrete values of , and is the vector of observed data value.

The posterior distribution obtained is applied in order to get the posterior predictive distribution (Expression (3)), so that it will represent the probability of any possible value of the studied random variable. Applying the grid method, the predictive distribution can be obtained using Expression (12):where , , and are the probability mass function (probability of a discrete random variable) counterparts of the corresponding PDF file. In this study, is represented by the Generalized Extreme Value Distribution (Expression (4)) because it is expected that the new unobserved data follow this distribution. This expectation is supported by the fact that in all heat exchangers analyzed in this study, the GEVD is considered an acceptable distribution that represents the metal loss thinning rate. The same situation happens when all the data from all heat exchangers studied are used.

#### 4. Applications and Results

For the sake of estimating the remaining life in heat exchangers using the wall thickness thinning rate obtained by the predictive distribution at 80% and 90% of probability values, some real exemplifications were carried out. Two heat exchangers (HE-A and HE-B) that preheat the feed to the reactor in HDS units with enough information were used in the study in order to compare the results when it is considered that the thinning rate is constant over time (a practical common criteria in the industry when there is not enough information). The shells of those heat exchangers (HE-A and HE-B) are also made of low alloy steel (ASTM SA 387 GR-5 CL-1), with a diameter (*D*) of 889 mm (35 inches), an allowable stress of 91 MPa (13200 PSI), joint efficiency of 1, and an average wall thickness of 32.18 mm (1.26 inches) in shell and 27.71 mm (1.09 inches) in the elliptical heads. Expressions (13) and (14) allow determining the Maximum Allowable Operating Pressure (MAOP) [39, 40] for a safety operation in heat exchangers in the shell or cylinder (Expression (7)) and in the heads (Expression (8)) [41]:

In Equations (13) and (14), represents the allowable stress, is the joint efficiency, is the wall thickness, is the radius, is the inside diameter, and *K* = 0.66 that is obtained from Table 1-4-1 of ASME Section VIII Div. 1 [36]. From all these variables, the wall thickness is the only variable that tends to change (by diminishing) over time. The allowable stress is influenced by the operational temperature of the vessel, but, in this study, it is considered constant, because the purpose is to study the effects of corrosion.

In order to begin applying the Bayesian approach proposed in this paper, it is necessary to have the wall thickness from a specific time and the thinning rate (corrosion rate). In this context, Figures 4 and 5 represent the wall thickness histogram and their corresponding thinning rate for HE-A and HE-B in a given time. In Figures 4(b) and 5(b), they also include distribution obtained after applying the Bayesian Data Analysis (BDA) from the thinning rate observed and their corresponding fitted parameter, evaluating the fitting by Kolmogorov–Smirnov test, chi-squared test, and Anderson–Darling test. In the two cases, at least two of the tests were obtained with enough acceptance.

**(a)**

**(b)**

**(a)**

**(b)**

In order to verify the reliability of the method proposed in this study, it is necessary to compare the results obtained with the wall thickness values observed later. For example, in the case of Heat Exchanger A (HE-A), the following inspection campaign was carried out in 2009. This campaign did not have the same number of Condition Monitoring Locations (CMLs) that were obtained in 2004. This situation happens often when a vessel is inspected. In this case, there were only 35 CMLs inspected, as opposed to the 42 CMLs used in 2004 inspection. With this information, it would be necessary to estimate the wall thickness in the future. In the oil industry, often the future wall thickness is calculated considering that the thinning rate is constant over time (), that is, the wall thickness difference divided by the interval time of the inspections. Figure 6 illustrates the shell wall thickness in HE-A in 2009.

In order to apply the Bayesian approach developed in this study, the shell wall thickness was estimated using the 80% and 90% ( and ) probability values of the thinning rate distribution obtained. These values are shown in Table 2 for HE-A and HE-B.

For the sake of illustration, Figures 7 and 8 show the predictive shell wall thickness histograms using both 80% and 90% probability values of the predicted thinning rate ( and ) and the comparison with the observed wall thickness.

**(a)**

**(b)**

**(c)**

**(a)**

**(b)**

**(c)**

Using the results displayed in Figures 7 and 8, the same exercise can be repeated for longer periods of time for each heat exchanger. In addition to estimating the wall thickness in the future with all the information available for a specific time, the methodology developed in this study was also applied to a sample with a smaller number of observations. This was done in order to determine if performing a random sampling of a reduced number of observations has a significant impact on the estimation of future wall thickness. The mean and variance of the error distribution percentage are used as a reference to establish the convenience of this methodology. The results of all these exercises are summarized in Tables 3 and 4.

In the previous tables, it is possible to observe that when the number of observations is reduced, the proposed method in this paper can still be implemented with satisfactory results. For example, the mean and variance of the error percentage are quite close to those obtained with all the observations available (Figures 7 and 8). This fact confirms that the purpose of developing a reliable statistical method that can estimate the thinning rate with a relatively small quantity of information (at least twenty observation points) has been accomplished.

In Figures 7(a) and 8(a), one can notice that a greater thinning rate represented by the percentile 90 () motivates an overestimation of the damage causing a thinner wall thickness to be estimated. The bins that represent the wall thickness estimated with the percentile 90 are, on average, less than those represented by the bins that represent the wall thickness with the percentile 80 (), which means that the remaining life is lower when the percentile 90 is used. In the oil and gas industry, it is common to use the corrosion rate average to predict the vessel’s remaining life; however, the greater corrosion rates are the real threat to the pipes’ and vessels’ hermeticity. For that reason, using the percentiles 80 or 90 sounds more reasonable for the estimation of real exchangers than the average, which is close in value to the percentile 50. In our case, the best results were obtained using the percentile 80 of the thinning rate, and the mean values of the error (*µ*_{e}) in both cases (HE-A and HE-B) were closer to zero, even when the number of samples was reduced from 25 to 20 (Tables 3 and 4). The GEVD parameters obtained by the Bayesian approach ( in Tables 3 and 4 can be useful for estimating the remaining life of other heat exchangers that preheat a similar hydrocarbon mix.

Even though the oil and gas industry has developed several techniques to manage the materials’ deterioration (in our case, thinning corrosion) such as the RBI (Risk-Based Inspection) methodology [42], which involved concepts of probability of failure, consequence of failure and risk of process, it does not take into consideration the sensitivity of the number of Condition Monitoring Locations (CML) that are available in a piece of equipment. This factor is important because sometimes it is not possible to have the same number of CMLs or to monitor and record the same CML for different periods of time. A simple way to average the last corrosion rate is not always the correct tool because the corrosion rate is not constant over long periods of time as explained in the literature [29, 32, 43]. From a practical point of view, it is feasible to consider the corrosion rate constant only for close periods of time, but the corrosion rate must be quite representative of the phenomena. If one takes a greater thinning rate (e.g., thinning rate at the percentile 90 ( ), it will be necessary to replace equipment that is in a safe condition, provoking unnecessary spending. On the contrary, if a lower thinning rate is used, the possibility of having a risky event because of unsafe conditions increases. In this sense, this paper provides a methodology that can be used in order to manage the vessels’ integrity by taking into account a small number of available CMLs in the inspection history.

#### 5. Conclusions Remark

(i)In hydrotreating units, the thinning rate observed in the shell heat exchangers could be fitted to a Generalized Extreme Value distribution with high confidence and could be used as a prior distribution. Figures 1 and 2 in this paper illustrate this affirmation.(ii)Pareto Distribution and Generalized Extreme Value Distribution can be used to represent the hyperparameters of the prior distribution selected in this study.(iii)It is feasible to use a Bayesian approach with a grid technique in order to estimate the posterior distribution of the thinning rate in heat exchangers.(iv)The predictive distribution obtained satisfactorily represents the unobserved thinning rate distribution in heat exchangers, even when little information is available.(v)The application of a Bayesian approach proposed in this paper helps answer the key question about the amount of data required to find reliable estimations of the thinning rate data in the heat exchangers that preheat the feeding to a hydrotreating reactor.

#### Data Availability

The data used to support the findings of this study are available from the corresponding author upon request.

#### Conflicts of Interest

The authors declare that they have no conflicts of interest in this study.

#### Acknowledgments

The authors are grateful to CONACYT and ESIQIE-IPN for the economic support provided for this research. The authors are also grateful to PEMEX for the information provided.