Calculation method for the amount of contaminant oil during sequential transportation through product oil pipelines

A considerable amount of oil contamination is caused by the presence of the trailing oil. This paper aims to simulate and analyze the influences of trailing oil on the quality of oil products in undulating sections. By studying the formation mechanism of mixed oil at inclining pipeline sections and the influences of velocity and oil batches on incline sections, as well as both ups and downs, the correlation is obtained between replacement time of different batches and velocity at various sections. By applying FLUENT 14.5, the maximum time of volume fraction of contaminant oil from 1% to 99% is simulated at cross-sections among different pipeline sections. Aiming at the relationship between oil product replacement time and change time of mixing section volume fraction and flow velocity, the mixing increment of undulating section relative to straight section is obtained. Combining with the empirical mixing length calculation equation, the equation for calculating mixing length considering terrain undulation is obtained. Combined with the actual operation data of Lan-Chengyu’s product oil pipeline, the error of the new mixed oil length calculation equation and actual oil mixing is 0.7966%. Excessive cutting amount of mixed oil will result in the waste of refined oil, and the less cutting amount will cause pollution of refined oil. The new mixed oil length calculation equation can more accurately guide the oil mixing cutting work at the oil station.


Introduction
According to the difference of oil qualities between two batches in product oil pipelines, the contaminant oil is formed, of which the latter one is referred to as trailing oil. Mass transfer of the sub-laminar layer could be restricted by oil viscosity of different batches, thus causing the velocity gradients variation, which would, in turn, faster the formation of contaminant oil. During batch transportation, the boundary layer of former oil gradually infiltrates into the later one, and the trailing oil would be formed.
Due to the difference of density, when the lighter oil of low density replaces the heavier one, the oil may remain on the surface of a heavier oil. Especially in undulated pipelines, heavy oil might be deposited at a low point, where the trailing oil is in existence, and the replacement of heavy oil by light oil would aggravate the formation of contaminant oil. Meanwhile, in hilly areas, when heavy oil replaces light oil in downward sections or when the light one replaces heavy one in upward sections, due to the influence of gravity and connective diffusion, the contaminant oil would enormously form. Figure 1 shows the topographic map of a section of the Lanzhou-Chengdu-Chongqing pipeline. Taylor (1953) found that when mixed oil flows slowly through a tube with a small diameter, it could spread through the cross-section due to the molecular diffusion and velocity variation. Taylor pointed out that the change of velocity is crucial during the mass axial diffusion, and it could be calculated by Fike's model. Krantz and Wasan (1974) modified Taylor's method and found that axial dispersion would be more intense when the velocity is close to laminar flow at the straight pipeline sections. Moreover, the roughness of the pipeline would also contribute to the axial dispersion. Austin and Palfrey (1963) also pointed out Taylor's model might indicate a slight error in accordance with trailing oil at high Reynold number. Besides, they found that the turbulence model at low Reynold number ignores the influence of viscosity close to the wall and came up with an equation to calculate the length of the mixed oil interface. Scott and Dullien (1962) found out that diffusive transfer is the main cause of mixed oil by tremendous experiments. Rachid et al. (2002aRachid et al. ( , 2002b predicted the mixing volume between batches by combining the diameter of the pipeline and time and came up with a more practical axial diffusion index. Wang et al. (2009) conducted both thermal and hydraulic simulation of batch pipelines and described the thermal and hydraulic model under the unsteady state. Menter and Egorov (2010) described the turbulence mechanism in pipeline flow simulation based on the scale adaptive simulation method. Liang and Xin (2015) optimized the batch transportation scheme in order to reduce the amount of mixed oil under the conditions of different transportation sequence, gravity, and temperature of western pipelines, and simulated the subsequent oil product concentration and the subsequent changes of oil products in different sections. Li et al. (2017) tended to reduce contaminant oil and relevant cost based on dynamic volume fraction. Wang and Wang (2019) studied the influence of elbow pipe during batch transportation. It could be seen from the above researches that viscosity is the main cause of the formation of trailing oil; however, their researches only focus on the trunk lines, without considering dead oil area in auxiliary valve rooms, as well as the influence of dead oil.
Therefore, Patrachari and Johannes (2012) and Botros et al. (2016) studied dead oil at dead-leg sections; however, their model could be modified by considering the contamination of trailing oil at dead-legs. Sunagatullin et al. (2019) studied the quality evaluation of light oil products in pipelines and determined the indicators. Li et al. (2019) established a mixed oil film diffusion model based on the smooth particle hydrodynamics method. The oil film diffusion process was simulated, and the effects of the oil viscosity coefficient and particle density on oil film diffusion were analyzed.  used molecular dynamics simulation methods to study the concentration distribution of different components, the orientation of oil molecules at the interface, the morphology of the oil-water interface, and the diffusion behavior of water molecules. Based on Fick's diffusion law, He et al. (2019) considered the physical properties of oil products and the effects of turbulence and proposed a new model for calculating the diffusion coefficient. This model can better describe the phenomenon of tailing oil in the mixed segment. Liu et al. (2019b) research on the formation mechanism of trailing oil at dead-legs, which indicates approximately 6%-14% more contamination at dead sections. Liu et al. put forward a new contamination model, which proved to be accurate with on-site data. Nevertheless, their models did not consider the fluctuation of pipelines in hilly regions, especially the effects on trailing oil. At present, some scholars have proposed to use artificial intelligence to predict pipeline parameters (Liu et al., 2020a(Liu et al., , 2020bLu et al., 2020;Qiao et al., 2019. Therefore, this paper would analyze the formation mechanism of trailing oil in both inclining and undulated pipelines. Based on computational fluid dynamics (CFD), the data of contamination at different velocities could be obtained. Then, multiple non-linear fitting with replacement time, the length of dead-legs and velocity is conducted, so as to obtain the length of trailing oil. Based on Liu et al.'s (2019b) contamination model, the model could be further modified to calculate the length of contaminant oil.

Methods and models
Equations (1) and (2) are the modified contamination models by Liu et al. (2019b), which consider the influence of dead-legs based on Austin's (Austin, 1963;Neutrium, 2019) model. When Reynolds number is beyond critical Reynolds number, the equation could be modified as (Liu et al., 2019b) C ¼ 11:75d 0:5 L 0:5 Re À0:1 þ 9½0:21lnðNÞ þ 0:96V (1) When Reynolds number is below the critical Reynolds number, the equation could be modified as (Liu et al., 2019b) C ¼ 18384d 0:5 L 0:5 Re À0:9 e 2:18d 0:5 þ 9½0:21lnðNÞ þ 0:96V ( 2) where C is the length of contaminated oil, m; L is the length of the pipeline, m; d is the diameter of the pipeline, m; Re is the Reynolds number; N is the number of dead-legs, V is the velocity. However, the influence of terrain is not shown in the above equations, especially for the formation of trailing oil. The critical Reynolds number is (Liu et al., 2019a) Re j ¼ 1000e 2:72d 0:5 After simulation and data analysis, Matlab is applied to fit multiple nonlinear functions with factors of replacement time, undulated sections and velocity, then the model could be further modified to calculate the length of mixed oil based on Liu's model (Liu et al., 2019c;Su et al., 2019). This paper simulates the contaminated oil during batch transportation of the Lan-Chengyu's product oil pipeline. Based on the on-site production data, the main parameters are shown in Table 1.
Trailing oil is formed during batch transportation when the latter oil tries to replace the former oil adhered to the wall (Liu et al., 2019d;Peng et al., 2019a). Thus, the formation is greatly affected by the viscosity of the wall, especially at the laminar sub-layer , so that wall functions cannot be used to simulate in FLUENT, but to choose the near-wall model to calculate simulating wall. Therefore, the multi-phase model and hexahedral mesh are applied to generate the VOF model (Chen et al., 2020;Liu et al., 2019e;Peng et al., 2018).
The pipeline model in Figure 2 is built by FLUENT with a diameter of 508 mm to simulate the batch transportation at the concave section, where the latter oil is replacing the former one. Figure 2 shows the schematic diagram of the concave pipeline.
According to the result, at 7 s, the latter oil has already flowed through two-thirds of the pipeline section; therefore, the grid independence is validated at this point of time to compare the volume fraction of oil at the lowest point of pipeline section (Peng et al., 2019b;Yong et al., 2019Yong et al., , 2017. The grid is generated at a number of 1137402, 1741208, 2177564, 3568320, respectively, and the independence is verified (see Figure 3 and Table 2).
The result shows that the volume fraction of the oil slightly changes with the increase of grid number from 1137402 to 3568320, which indicates that the model could be verified with grid independence at the number of 1137402. In addition, the time interval is set at 0.001 s (Table 3).

Results and discussion
Formation mechanism of contamination at inclining pipeline section Downward pipeline. Figure 4 shows the diagram of the cross-section position of the inclining pipeline.  For instance, the diesel drains gasoline during batch transportation at the speed of 1 m/s; the distribution of these two oils at different time intervals is shown in Figure 5, where the blue one represents diesel, while the red one represents gasoline.
At 11 s, the gasoline in the pipeline is isolated as an individual area due to the effect of buoyancy, which would result in more contact area and then cause further contamination during transportation. At 20 s, the individual area tends to be further isolated into two sections. As a conclusion, contamination tends to be isolated as multiple sections by the effect of buoyancy, when diesel drains gasoline at the downward pipeline section.
At the beginning of the drainage, shown in Figure 6, the volume fraction of gasoline decreases sharply. When trailing oil is formed, by the effect of buoyancy, the diesel oil behind could isolate contamination into several sections, which would result in the fluctuation of volume fraction of gasoline at cross-section 4.
Upward pipeline. Figure 7 shows the volume fraction of gasoline at cross-section 4 of straight pipeline and upward pipeline. From Figure 7, it is indicated that when diesel replaces gasoline, contamination in the upward pipeline would be less affected than that in the straight pipeline.
The oil in the dead-leg will flow out due to gravity, and the two kinds of liquids will form a lock exchange flow at the junction. At this time, the main factor causing the contamination is the convective transmission. When about half of the preceding batch is replaced in the dead-leg, the influence of convection is gradually reduced, and diffusion transfer begins to play a role. After turbulent diffusion, the following batch gradually flows into the dead-leg and the liquid is slowly replaced. In these two processes, the time of turbulent diffusion is  obviously longer than that of convection, and the forward batch from the dead-leg will form trailing oil in the main pipe run.

Influence of velocity on the trailing oil in inclining pipeline
When diesel drains gasoline during batch transportation in the downward pipeline, the contamination at cross-section 4 with different velocities at different times is shown in Figure 8. From this figure, with the increase of velocity, the drainage of gasoline would be faster. The volume fraction of gasoline at cross-section 4 of the downward pipeline with different velocities varying with time is shown in Figure 9. The cause of fluctuation of volume  contamination. The contamination might decrease because of the increase in velocity and turbulence diffusion. When diesel replaces gasoline during batch transportation, the length and quantity of contamination would decrease with the increase of velocity, and the volume fraction would be weaker along with time.

Formation mechanism of contamination in the undulating pipeline
With the upward and downward of pipelines during the transportation of oil products, the concave or convex sections might be shaped, which would greatly influence the formation of trailing oil. In order to compare, the dip would be taken with an angle of 30 , no matter for upward or downward pipeline.
Concave pipeline. Figure 10 shows the diagram of the cross-section position of the concave pipeline. At the speed of 1 m/s, the drainage of gasoline by diesel is simulated with times, as shown in Figure 11.
The volume fraction of gasoline at cross-section 5, cross-section 6, and cross-section 7 of the downward section of the concaving pipeline is shown in Figure 12. The regulation is close to what has been demonstrated in Figure 11. At the initial state, the volume fraction of gasoline decreases sharply. The effect of buoyancy would facilitate the formation of trailing oil, with the increasing thickness of contamination. Then it would deposit at the lowest point. With time goes by, the fluctuation of the curve would be even with the further drainage of diesel behind and becomes flat.
The volume fraction of gasoline at cross-section 7, cross-section 8, and cross-section 9 of the upward section of the concaving pipeline is shown in Figure 13. It is known that with the sudden decrease in all curves after 5 s, the only fluctuation is at the lowest point. Although gasoline might be drained by diesel to the upward pipeline section, however, at a certain velocity, the drainage is in restriction.
Convex pipeline. Figure 14 shows the diagram of the cross-section position of the convex pipeline. Figure 15 shows the relationship between time and volume fraction of gasoline at cross-section 11 of the convex pipeline and at cross-section 6 of the concave pipeline. At the speed of 1 m/s, the volume fraction decreasing from 1 to 0 is within 9 s at the crosssection of concave pipeline, and the length of contamination is 9 m; the volume fraction decreasing from 1 to 0 is within 13 s at the cross-section of convex pipeline, and the length of  contamination is 13 m. At the same velocity and batch transportation, the quantity of contamination of the convex pipeline is larger than that of the concave pipeline. Figure 16 shows the relationship between time and volume fraction of gasoline at crosssection 13 of the convex pipeline and at cross-section 8 of the concave pipeline. The volume fraction of gasoline at the cross-section of the concave pipeline is larger than that of the convex pipeline, for gasoline would deposit at the low point and be drained by diesel to the upward pipeline section to form the trailing oil. Meanwhile, the length of trailing oil might be shorter when diesel drains gasoline in batches of upward pipeline section of the convex pipeline, thus causing less contamination. In all, when diesel drains gasoline in batch transportation, the contamination mainly formed in the downward pipeline section of the concave pipeline with longer trailing oil  and more contamination, while in convex pipeline, contamination also happens in the downward pipeline section, with shorter trailing oil and less contamination instead. Whether it is concave pipeline or convex pipeline, the quantity of contamination is larger than that of the straight pipeline.

Influence of velocity on trailing oil in an undulating pipeline
Concave pipeline. Figure 17 shows the concentration of contamination in the concave pipeline at 4 s, 7 s, and 10 s, respectively, with both speeds of 1 m/s and 1.4 m/s. It can be seen that, with the increase of velocity, the drainage would be fast with a short length of contamination. However, when the velocity of the flow is low, the drainage would be weakened by the effect of buoyancy, and gasoline would concentrate at the lowest point, and as a result, it would take time to fully drain the gasoline with a long length of contamination. From Figure 18, at the initial state, all curves would go down sharply; when trailing oil is formed, the curves become even, the remaining volume fraction of gasoline decreases. The earlier the fluctuation happens, the smaller the peak value is. At 1.8 m/s, the fluctuation almost disappears, for the turbulence diffusion would become intense with the increase of velocity. Therefore, the drainage of diesel would be strong enough, with less concentration of contamination at the lowest point.
By analyzing the simulation of gasoline drainage by diesel behind in batch transportation at different velocities, it indicates that the replacement of oil would be faster with the increase of velocity. Moreover, the contamination would be less at the lowest point, with a shorter length and less quantity. Convex pipeline. It is shown in Figure 19, at the same cross-section, the volume fraction of gasoline from 100% to 0% decreases sharply with the increase of velocity, namely, the shorter the drainage time is, the shorter the length of contamination is, so as with less quantity. In all, when diesel drains gasoline in batch transportation, no matter of concave pipeline or convex pipeline, the drainage becomes faster with the increase of velocity. The larger the velocity is at the concave pipeline, the lesser the contamination is at the lowest point, thus causing the shorter length of trailing oil and less quantity; meanwhile, the larger the velocity is at the convex pipeline, the shorter the length of contamination is and less quantity.

Equation correction
In actual calculation of the length of contamination, due to the definition of contamination itself and cutting requirement, the equation considers the volume fraction of former oil when it is more than 1%, and it is also applicable for the modified equation, with the ignorant of the influence of trailing oil which is less than 1%. When diesel replaces gasoline, the influence of inclining pipeline could be ignored, while for the declining pipeline, the influence should be considered in the calculation of contamination. Non-linear fitting is conducted between time and velocity, and it is shown as follows where t 1 is the replacement time of latter oil in the undulating pipeline; V is the oil velocity in the pipeline, m/s. In the simulation of the declining pipeline at oil speed of 1 m/s during transportation, it takes 29 s for the volume fraction of contamination to grow from 1% to 99%. And then set DL 1 as the equivalent length of contamination in the straight pipeline for the declining section at the same time interval DL 1 ¼ ð29V À t 1 VÞn 1 ¼ ð29V À 31:043V À1:376 Þn 1 where n 1 is the number of downward pipelines. Conducting non-linear fitting between time and velocity in the undulating pipeline, the equations are obtained as t 2 ¼ 24:307V À2:444 (6) where t 2 is the replacement time of latter oil in the concave pipeline, s; t 3 is the replacement time of latter oil in the convex pipeline, s. In the simulation of the concave pipeline at oil speed of 1 m/s during transportation, it takes 24 s for the volume fraction of contamination to grow from 1% to 99%; meanwhile, for the convex pipeline, the time would be at most 14 s. And then set DL 2 as the equivalent length of contamination in the straight pipeline for the concave section at the same time interval. And then set DL 3 as the equivalent length of contamination in the straight pipeline for the convex section at the same time interval DL 2 ¼ ð24V À t 2 VÞn 2 ¼ ð24V À 24:307V À1:444 Þn 2 (8) where n 2 is the number of concave pipelines; n 3 is the number of convex pipelines. The correction equations for calculating the length of the contamination for the undulating section are equations (10) and (11).
The above equations yield results that are closer to real data, so they provide a greater guide for accurate cutting of contamination, which has practical significance.

Conclusions
1. The oil adhered to the walls, forming a laminar bottom, is the main factor for the formation of trailing oil. The diesel in the upward pipe can move the gasoline faster when the  turbulent diffusion and the combined force of gravity and buoyancy are combined in the axial direction, so the gasoline volume fraction of the upward pipe drops faster. 2. In the transportation process, if the diesel oil is in the position of higher gravitational potential energy relative to gasoline, the mixing length and the mixing amount are larger than that of straight pipeline; if the gasoline is in the position of higher gravitational potential energy, the mixing length and the mixing amount are smaller than that of straight pipeline. 3. When diesel drains gasoline in batch transportation, no matter of concave pipeline or convex pipeline, the drainage becomes faster with the increase of velocity. The larger the velocity is at the concave pipeline, the lesser the contamination is at the lowest point, thus causing the shorter length of trailing oil and less quantity; meanwhile, the larger the velocity is at the convex pipeline, the shorter the length of contamination is and less quantity. 4. Based on the simulation results, we modified the Liu's model for calculating the contamination length. The equations include the influence of the trailing oil formed by the undulating sections on the contamination length, which makes the equations more consistent with real data.

Declaration of conflicting interests
The author(s) declared no potential conflicts of interest with respect to the research, authorship, and/or publication of this article.

Funding
The author(s) disclosed receipt of the following financial support for the research, authorship, and/or publication of this article: This work was supported by the Sichuan Applied Basic Research Project (2019YJ0352) and Sichuan Provincial Natural Resources Research Project (KJ-2019-11).