IBP101305 VALIDATION OF PIG OPERATIONS THROUGH PIPELINES Pipeline Sueli Tiomno Tolmasquim \ Angela O. Nieckele 2 2005 Conference & Exposition

Copyright 2004, Institute Brasileiro de Petroleo e Gas - IBP Este Trabalho Tecnico foi preparado para apresentagao na Rio Pipeline Conference & Exposition 2005, realizada no periodo de 17 a 19 de outubro de 2005, no Rio de Janeiro. Este Trabalho Tecnico foi selecionado para apresentagao pelo Comite Tecnico do evento, seguindo as infonnagoes contidas na sinopse submetida pelo(s) autor(es). O conteudo do Traballio Tecnico, corno apresentado, nao foi revisado pelo IBP. Os organizadores nao irao traduzir ou corrigir os textos recebidos. O material confonne, apresentado, nao necessariamente reflete as opinioes do Instituto Brasileiro de Petroleo e Gas, sens Associados e Representantes. E de conhecimento e aprovagao do(s) autor(es) que este Traballio Tecnico seja publicado nos Anais da Rio Pipeline Conference & Exposition 2005.

Resumo

Na industria do petroleo, a passagem de pigs em dittos tern sido largamente aplicada com diferentes propositos: limpeza do tubo, inspccao. rcmocao de llquido e scparacao de produtos, entre outros. A eficiencia e scguranca de uma opcracao com pig demandam que diversos parametros operacionais, tais como pressoes maximas e mlnimas no duto e velocidade de movimcntacao do pig, sejam bem avaliados durante a etapa de planejamento e mantidos dentro de detenninados limites durante o acompanhamento da opcracao. Tendo como objetivo a obtcncao de uma ferramenta eficiente para ajudar no controle e projeto das opcracocs de passagem de pigs, desenvolveu-se urn codigo numerico baseado no metodo de difcrcncas finitas, o qual pennite a simulacao de escoamentos transientes de dois fluidos, podendo estes ser llquido-llquido, gas-gas ou liquido-gas. Modules para controle automation das variaveis do processo foram incluldos, visando a previsao do escoamento mediante diferentes estrategias para a lea near uma opcracao eficiente. Para validar o metodo, comparou-se os resultados obtidos com o simulador com dados de urn caso real de esvaziamento de urn trecho do oleoduto OSPAR, pertencente a Petrobras, com 30” de diametro e extensao de 60 km, obtendo-se uma boa concordance.

Abstract

In the oil industry, pigging operations in pipelines have been largely applied for different purposes: pipe cleaning, inspection, liquid removal and product separation, among others. An efficient and safe pigging operation requires that a number of operational parameters, such as maximum and minimum in the pipeline and pig velocity, to be well evaluated during the planning stage and maintained within stipulated limits while the operation is accomplished. With the objective of providing an efficient tool to assist in the control and design of pig operations through pipelines, a numerical code was developed, based on a finite difference scheme, which allows the simulation of two fluid transient flow, like liquid-liquid, gas-gas or liquid-gas products in the pipeline. Modules to automatically control process variables were included to employ different strategies to reach an efficient operation. Different test cases were investigated, to corroborate the robustness of the methodology. To validate the methodology, the results obtained with the code were compared with a real liquid displacement operation of a section of the OSPAR oil pipeline, belonging to Petrobras, with 30” diameter and 60 km length, presenting good agreement.

1. Introduction

Pipelines are frequently serviced with the utilization of pigs. In general terms, a pig is a solid plug that is introduced in the pipeline to be serviced. Fluid is pumped upstream of the pig to provide the necessary to set the device in motion, and to perform the desired task, i.e., removing deposits on the pipe wall, remove water from the pipeline or driving an inspection tool. The use of pigs has become a standard industry procedure. A great variety of pig models is available for each particular application. A difficulty often faced by the engineer when designing a pigging operation is the lack of reliable tools for the prediction of the many variables related to the motion of the pig through the pipeline. Most of the available knowledge is based on field experience. Hence, selecting the best pig, estimating its

1 Mestre, Engenheira Mecanica - Petrobras Transports S.A. 2 PhD, Engenheira Mecanica - Professora Associada - Dept. Eng. Mecanica - PUC/Rio Rio Pipeline Conference & Exposition 2005 speed, required driving and the amount of back and forward bypass of fluid, often involve some guesswork and, consequently, a degree of uncertainty. The pipeline network all over the world is getting older and at the same time the concern to enviromnent is greatly increasing. Herewith, the pipeline operators are investing in inspection and maintenance with the objective to extend lifetime of their pipelines. As a result for the execution of repairs sometimes, here is the necessity to evacuate the entire pipeline or sections between pump stations, keeping valves and accessories installed. In many cases, oil is displaced from the pipeline by injection of inert gas, employing a sealing pig in the interface of the fluids. The pig velocity is directly related to the sealing efficiency of the pig, demanding that the liquid flow rate be maintained within certain limits and the pipeline operating , avoiding slack flow. The operation design shall also account for the influence of the profile at the expected pressures along the pipeline considering its behavior when flowing gas in a section of the pipeline and liquid in another section. Figure 1 illustrates a typical sealing pig. The pig is formed by piston-type cups attached to a cylindrical body. In order to produce efficient sealing, pigs have nominal diameters larger than the pipe diameter. Gas pumped upstream of the pig provides the necessary pressure difference to overcome the contact force at the wall, to displace the liquid downstream of the pig and to accelerate the pig.

Figure 1 - Schematic view of a sealing pig.

A literature survey reveals very few papers dealing with the motion of pigs in pipelines. Webb et al (1987) investigated the use of an inert gas to displace oil from a long pipeline, and mention the control of the oil flow by an outlet valve. Santos et al. (1997) modeled the pig dynamics for pig-lift applications. Vianes Campo and Racliid (1997), Nguyen et al (2001) and Kim et al (2003) studied the dynamics of pigs through pipelines using the method of characteristics and Nieckele at al (2001) using the finite difference method. Nieckele at al (1998, 2000) investigated the dewatering operation in a riser for an isothermal and non-isothennal situation, based on the finite difference method. To be able to reach an efficient operation, a method was developed by Tolmasquim (2004) to automatically control process variables. Tolmasquim & Nieckele (2005) analyzed several test cases to verify the efficiency of the methodology considering a PID (Proportional, Integral and Derivative) controller. Therefore, the objective of the present work is to validate the code developed, by simulating the transient oil displacement of a pipeline employing a sealing pig and comparing with field data.

2. Mathematical Modeling

The motion of a pig inside a pipeline during an operation to displace oil by the injection of nitrogen can be obtained by the of the fluid flow problem coupled with a model to predict the pig motion. The upstream fluid is a gas, while the downstream fluid is a liquid. Both are considered to be Newtonian. At the present work, the fluid flow is isothermal. The pipeline is inclined in relation to the horizontal direction, with angle a. Pipe deformation due to pressure variations along the flow is considered. The governing equations for the fluid are the continuity and momentum equations. The mass conservation equation can be written as (Wylie and Streeter, 1978).

dP dP pa" dV pci1 V dA —+V—+-— = 0 (1) Of Sr ^ Sr ^ Sr where F, P and. ! are the velocity, pressure and cross section area, respectively. The fluid properties are: density p and speed of sound a. 2 is given by 2 = 1 p cr 2 ((D/Dref) where D and Dref are the pipeline diameter and the reference diameter determined at patm. The pipe deformation due to pressure is accounted by the coefficient Cd, given by ((/-r) Dref/(2 e £), where e is the pipe wall thickness, E the Young's modulus of elasticity of the pipe material, and i' the Poisson's ratio. The linear momentum equation can be written as

dV d V 1 dP f F F V — '----!----- g sin a (2) dt S.v 2D 2 Rio Pipeline Conference & Exposition 2005 where g is gravity, a is the angle of the pipe axis with the horizontal direction and f the hydrodynamic friction coefficient factor, which depends on the Reynolds number Re = p | V| D/p where pf is the absolute viscosity. In the turbulent regime the friction factor is also a function of the relative pipe roughness e/D. To simplify the solution, the friction factor is approximated by its fully developed expression. For a laminar regime, Re < 2000, it is specified as f= 64/ Re. For the turbulent regime, Re > 2500, the friction factor is approximated by Miller’s correlation (Fox and McDonald, 2001), f = 0.25 { log [(e/D)/3.7+5.74/Re0'9]}"2 Between Re = 2000 and 2500, it was assumed a linear variation of the friction factor with the Reynolds number. The coupling of the pig motion with the fluid flow in the pipeline is obtained through a balance of acting on the pig, together with an equation that represents the fluid pressure drop across the bypass holes in the pig (Azevedo et al., 1996). The force balance on the pig can be written as

dVp m = (P1 - P2) A - m g sin a - Fat (Vp) (3) where, Vp is the pig velocity, m the pig mass, P1 and P2 the pressure on the upstream and downstream faces of the pig, and the term Fat(Vp) represents the contact force between the pig and the pipe wall. The contact force Fat(Vp) depends on xp, the pig axial coordinate, indicating that the contact force can be allowed to vary along the pipe length. When the pig is not in motion, the contact force varies from zero to the maximum static force Fstat, in order to balance the pressure force due to the fluid flow. Further, since the pig may resist differently to being pushed forward or backward, the maximum static force for a negative pressure gradient is , while for a positive pressure gradient is Ffo . Once the pig is set in motion by the flow, the contact force assumes the constant value, Fdin, representing the dynamic friction force that is generally different from the static force. As in the previous situation, two different values for the dynamic contact force are allowed, F^g and Fdy ons, depending on the direction of the pig motion.

-FZ(xp) if Fat (Vp) =F (xp) whern - FSag (xp) ^ F (xp) ^ FSpZ°tS(xp) if Pp^0 and F^ (Vp) =1 F(4) Fn (xp) if Vp >0

2.1 Moving Coordinates Since the pig moves in the computational domain, it is convenient to employ a coordinate system r that stretches and contracts in the pipe, depending on the pig position. The fluid flow conservation equation must then be written for the new coordinate system (Monteiro et al., 1998) as

P a2 pa2V(A "0 " 4 P) + V 4p + dn lPJ f Ahn dr f \V\ (5) 1 [- g sin a J 2D _ 4 p_

The absolute velocity V is equal to V + ug , where V is the relative velocity and ug = (dx/dt) n is the grid velocity. hn=(dx/drj)t is the metric which relates the two coordinates.

2.2 Fluid Properties The gas is considered to behave as an ideal gas. Therefore for an isothermal flow,

p = P / a2 where a = Rgas Tref (6) where Rgas is the gas constant, Tref the reference and z the compressibility factor. For the liquid, the following relationship between density and pressure was considered,

P = Pref + (P - fref)/ a ^ (7) where pref is the reference density evaluated the reference pressure Pref, and a is the isothermal sound speed.

3 Rio Pipeline Conference & Exposition 2005

For both fluids, the fluid absolute viscosity was considered as a function of pressure in accordance to the following expression

Rf = Rref exp[c^, p (P Pref)] (8) where, pref is the absolute viscosity evaluated at the reference pressure Prf with coefficient cRP.

2.3 Initial and Boundary Conditions The operation investigated here, begin with the pipeline filled with liquid and with no flow. Therefore, the initial condition corresponds to a zero velocity along the pipeline, and a hydrostatic pressure distribution, which is obtained from the following expression beginning from the known pressure at the highest elevation of the pipeline.

{Ps Pref ) + prefgkz (e -(g/k)! a2 _ 1 Ps + ds = Pref + (9) e(gdz))a 2 (gkz )/a'

3. Process Control

The main goal of the systems developed to control processes consists in maintaining certain variables of the process within desired operational limits. This control can operate in an opened or closed loop. At the present work, a closed loop was employed, where the value of the desired variable is used to re-feed the system, in order to compensate external and internal perturbations of an industrial process, as illustrated in Figure 2. The controller compares the desired value with the measured value, and if there is a discrepancy between these values, the controller manipulates its output in order to eliminate the error. For example, if the measured pig velocity is not the desired value, the opening of a valve at the outlet of the pipeline is altered, in order to maintain the process variable within the desired value, compensating external perturbations and non linearities of the system. There are situations where it is necessary to control simultaneously two variables of the process. Figure 2b illustrates this situation, where the smallest output from the two controllers is employed to re-feed the system.

Input Input desired Output desired A Output A CONTROLLER A CONTROLLER PROCESS min(A, B) Input PROCESS desired B CONTROLLER B Output B

MEASUREMENT

MEASUREMENT A

MEASUREMENT B a) b) Figure 2 - Control system in a closed loop. (a) one variable (b) two variables

3.1. PID Controller A PID controller generates its output proportionally to the error between the desired and measured quantity, the integral of the error and the derivative of the error. Its output u(t) is given by the following expression (Isermann, 1981)

1 t de (t) ] u(t) = K [e (t) + ~ 1 e (r) dT + TD dt TI 0 (10) where, e(t) is the error and the multiplier factors K, TI and TD are known as the controller gain, the integral time and derivative time, respectively. The controller error can be defined as (Campos,1999)

e(t) = (VP(t) - SP) x AC ; AC = 1 or -1 (11) where VP(t) is the process variable, SP is the set point to control the process variable and AC is the controller action. 4 Rio Pipeline Conference & Exposition 2005

This action can be direct or reverse. For a controller with a direct action, when the process variable increases, the output of the controller also increase, i.e., the variable is maintained at the set point or above it. The controller with reverse action decreases its output when the process variable increases, therefore, maintaining the variable at or below its set point.

4. Numerical Method

The set formed by equations represented by Eq. (5), together with the appropriate boundary and initial conditions, require a numerical method to obtain the desired time-dependent pressure and velocity fields. These equations were discretized by a finite difference method. A staggered mesh distribution was selected to avoid unrealistic oscillatory , as recoimnended by Patankar, (1980). The equations were integrated in time using a totally implicit method. The space derivatives were approximated by the central difference method around the mesh point. The resulting coefficient matrix is penta-diagonal, and can be easily solved by a direct penta-diagonal algorithm. The total nmnber of grid points inside the pipe was maintained constant in the numerical calculations of the flow field upstream and downstream of the pig, as well as for the pig dynamics calculations. However, as the pig moves along the pipe, it is convenient to rearrange the node distribution. The number of grid points upstream and downstream of the pig was made proportional to the length of the pipe at each side of the pig. Further, the mesh was concentrated near the pig, to better resolve the flow variables at this location.

5. Study Case

The OSPAR pipeline lias 117 km of length, with an intermediate pumping station at Harare (km 60). Its main purpose is to take oil from the Sao Francisco do Sul Terminal (SFS) to the refinery. The oil was removed from the pipeline by the injection of nitrogen, with a 40 kg separator pig. flexipig type. Due to the pipeline profile, the oil displacement was from REPAR to SFS, in the opposite direction of the normal operational direction. Liquid nitrogen was stored in a low pressure cryogenic cylinder. Leaving the cylinder, the nitrogen pressure was raised to the desired level, it was vaporized and then injected in pipeline. To avoid high pressure at the positions of low altitude, especially near SFS, the 30” valve at Harare was kept closed and the aligmnent was done through an 8” valve, in order to introduce a pressure drop at the station while maintaining the downstream pressure near to the atmospheric pressure and increasing the controllability of the system. The simulation was carried on from REPAR to Harare (Figure 3), where the pipeline length is 60 km, with diameter of 30 in, rouglmess = 0.04572 rmn. Young's modulus of elasticity = 2.1 xlO5 MPa, Poisson's ratio = 0.3. The wall thickness varied from 9.53 rmn to 14.3 rmn. The maximum allowable operation pressure, MAOP, is also illustrated in Figure 3. The oil properties were: Pref = 1 atm, p = 828 kg/m 3 a 1218 m/s; g, = 2.6 cP, while the nitrogen properties were: Rgas = 296.9 N-m/kg-K; Pref= 1 atm; Tref= 20°C, z = 1.04 and g, = 1.5/ ML N-s/nf. The pig contact forces were all the same ( f T? = f?°?= Fmg = f'"is )• but they varied with the pipe thickness from 85 kN to 83 kN.

Height (m)1000

REPAR Lenght (Km) HARARE — Simplified profile — MAOP

Figure 3 - REPAR-Itarare topography and maximum allowable operation pressure 5 Rio Pipeline Conference & Exposition 2005

The pressure variation with time, acquired by the SCADA (Supervisory, Control And Data Acquisition) system, was defined as the inlet boundary condition (Figure 4). At the pipeline section exit at Harare, there was no flow information available. Therefore, the level variation of the oil receiving tank at SFS (Figure 5), also acquired by the SCADA system, was utilized to define the outflow boundary condition. The oil mass flow rate was obtained by the following expression

m = p (Np - NT(j) !{t - Zq) (12) where Nj e .\V are the tank level at time t and previous time Zn, p is the density. It should be mentioned here that no noise was eliminated from the data to define the simulation boundary conditions.

14

12 /" Pressure 10 "\ 1 (kgf/cm2) ...» -• 8 / '• ** * »♦

1 6 *

4 1

2

0 0 10000 20000 30000 40000 50000 60000 70000 Time(s) Figure 4 - Time pressure variation at REPAR

7

6

5

Tank level 4 (m) 3

2

1

0 0 10000 20000 30000 40000 50000 60000 70000 Time (s) Figure 5. Time Variation of the SFS oil receiving tank level

Figure 6 presents the comparison between the pressure measured at Harare and the pressure obtained with the present simulation. It can be seen a very good agreement only after 50000 s, after the flow is more stable. The discrepancy observed is due to the fact that the simulation was performed with only one phase present inside the pipeline. However, during the beginning of the operation the pipeline was operating in slack flow. Only after 50000s, the column collapsed, and the pipeline remained tide until the pig reached Harare. A steep pressure variation can be observed near 40000 s. At this time instant, the oil mass flow rate was high so that the nitrogen pressure at the entrance was sufficient to displace the pig. However, the pig got stuck at a low level point of the topography, until the pressure was recovered at REPAR. This behavior can be seen at both Figures 6 and 7, where the oil tank is kept constant from 40000s to 50000s, indicating that there was no flow. A comparison of the measured nitrogen mass flow rate with the numerical results obtained here is shown in Figure 7. Two observations must be made: The numerical negative mass flow rate can be explained by the presence of 6 Rio Pipeline Conference & Exposition 2005 slack flow, which was not considered with the present model. Second, the instantaneous mass flow rate data was indirectly obtained from the pump rotation, leading to large uncertainty. In spite of these facts, the comparison can be considered as reasonable. Finally, the pig position with time is compared at Figure 8. Although, there is a small number of measured data, the agreement between the numerical and experimental data can be considered quite good.

6. Final Remarks

To guarantee an efficient and safe pigging operation, maximum and minimum pressures in the pipeline as well as pig velocity must be maintained within stipulated limits. With the objective of providing an efficient tool to assist in the control and design of pig operations through pipelines, a numerical code was developed, based on a finite difference scheme, which allows the simulation of gas-liquid transient flows in the pipeline. Modules based on the PID controller methodology to automatically control process variables were included to employ different strategies to reach an efficient operation. Both inlet and outlet valves opening can be controlled. The results obtained with the code were compared with a real liquid displacement operation of a section of the OSPAR oil pipeline, belonging to Petrobras, with 30” diameter and 60 km length, presenting good agreement.

Presssure (kgf/cm2)

(s)

O Measured — Numerical

Figure 6 - Pressure at Harare. Comparison between simulated and field data.

Mass flow rate (kg/s)

10000 20000 30000 40000 50000 60000 70000

♦ Measured Numerical

Figure 7 - Mass flow rate at REPAR. Comparison between simulated and field data. 7 Rio Pipeline Conference & Exposition 2005

Length (km)

10000 20000 30000 40000 50000 60000 70000 Time (s) ♦ Measured ----- Numerical

Figure 8 - Pig position with time. Comparison between simulated and field data.

7. Acknowledgement

The second author thanks CNPq for the support during the development of this work.

8. References

AZEVEDO, L.F.A., BRAGA, A.M.B. & Gomes M.G.F.M. Study of Pig Motion in Pipelines. I ENCIT-VILATCYM, Flohanopolis. SC, Brazil, vol. Ill, pp. 1423-1428, 1996. CAMPOS, M.V. Sintonia de Controladores PID. Comunicagdo Tecnica CT-DIPRIN-034/1999. Rio de Janeiro: CENPES/DIPRIN/SEPROJ, 1999. FOX, R.W. and MCDONALD, A.T. Introdugdo a Mecdnica dos Fluidos, Livros Tecnicos e Cientificos Editora, 5a. Ed., 2001. ISERMANN, R. Digital Control Systems, Revised and enlarged translation ofDigitale Regelsysteme 1977, Germany: Sphnger-Verlag Berlin Heidelberg NewYork, 1981 KIM, D.K.; CHO, S.H.; PARK, S.S.; RHO, Y.W.; YOO, H R.: NGUYEN, T.T.; KIM, S B. Verification of the Theoretical Model for Analyzing Dynamic Behavior of the Pig from Actual Pigging. Korean Society of Mechanical Engineers KSMEInternational Journal, v. 17, n. 9, p. 1349-1357, 2003. MONTEIRO, C„ NIECKELE, A.O., BRAGA, AM. and AZEVEDO, L.F.A. Simulation of Transient Pig Motion Through Liquid and Gas Pipeline, IV Congresso Norte Nordeste de Engenharia Mecdnica, Fortaleza, CE, 1998. NIECKELE, A.O., AZEVEDO, L.F.A., BRAGA, A.M.B. Simulation of Fluid Flow and Pig Dynamics in Dewatering Operations in Pipeline”. In: Encontro Nac. Ciencias Termicas - ENCIT, Rio de Janeiro, V.2, pp. 1025-1030, 1998. NIECKELE, A.O., AZEVEDO, L.F.A., BRAGA, A.M.B., 2000,“Temperature Influence in Dewatering Operations in a Riser”. In: Congresso Nacional de Engenharia Mecanica - CONEM 2000, Natal, RN. codigo MC8862, CD-ROM. NIECKELE, A.O., AZEVEDO, L.F.A., BRAGA, A.M.B. Transient Pig Motion Through Pipelines Journal of Energy Resources Technology ofASME, Vol. 123, pp.260-269, 2001. NIECKELE, A.O., TOLMASQUIM, S.T. Design and Control of Pig Operations Through Pipelines, In: Congresso Brasileiro de Engenharia Mecdnica, Ouro Preto, MG, 2005. NGUYEN, T.T.; KIM, S B.: YOO, H.R.; RHO, Y.W. Modeling and Simulation for Pig Flow Control in Natural Gas Pipeline”. Korean Society of Mechanical Engineers, KSME International Journal, v. 15, n. 8, p. 1165-1173, 2001. PATANKAR, S.V. Numerical Heat Transfer and Fluid Flow Hemisphere Publishing Corporation, 1980. SANTOS, O.G., ALHANATI, J.S. & BORDALO, S.N. Modeling and Performance of Pig-Lift, XIV COBEM SP, Brasil, COB260, CD-ROM, 1997 TOLMASQUIM, S.T. Projeto e Controle da Operagdo de Passagem de Pigs em Dutos, Dissertagao de Mestrado, Dept. Eng. Mecanica da Pontificia Universidade Catolica do Rio de Janeiro - PUC-RJ, 2004. VIANES CAMPO, E. & RACHID, F.B., Modeling of Pig Motion Under Transient Fluid Flow”, XIV COBEM, SP, Brasil, 1997. WEBB, S.; BOGUCZ, E.; LEVY, E.; BARRET, M.; SNYDER, C.; WATERS, C. Evacuation of a Residual Oil Pipeline by Inert Gas Displacement Society of Petroleum Engineers - SPE: Production Engineering, pp.45-50, 1987. WYLIE, E. B.; STREETER, V. L. Fluid Transients in Systems. Prentice Hall, Inc., 1993. 8