are made, and it also uses mass conservation, momentum conservation, and real .... make one system partial differential equation type non-linier hyperbolic in.
Modelling and Numerical Solution of a Gas Flow in Pipeline Using Crank-Nicolson Method Baity Jannaty, Zusnita Meyrawati, Prof. DR. Basuki Widodo, M.Sc. (1)
Abstract Gas pipeline network are systems with long pipe series. The length of this network can reach thousands of kilometers. Whereas gas distribution pass through a pipeline means connecting pipes from production center to the gas storages. Because of that, at the system of gas distribution pipeline network is equipped with compression stations and many other devices like valves and regulators. These types of systems work at high pressure and use compression stations to supply enough energy for the gas in order to be moved along the distances which will be pass through. When gas flows, it suffers energy and pressure losses due to the friction between the gas and the inner walls of pipeline, but also due to the heat transfer between gas and the environment around the pipeline. While the gas pipeline is the most important components of the gas distribution pipeline network since it defines the major dynamic characteristics. So that, it needs to know the gas behavior in this system of distribution network. In this project, the model of gas flow in a pipeline is inspected to know how the gas behavior in the distribution network system is. In order that, assumptions and problem confines are made, and it also uses mass conservation, momentum conservation, and real gas equation of state. The model which is obtained is a system of parabolic linear partial differential equation (PDE) second order. Furthermore, that model is solved numerically using Crank-Nicolson method and simulated using Matlab. The results of this simulation show that if given a pressure of 50 bar at the inlet, at the end of the pipe elevation of 3000 m, and the flow rate of 50 m3/s, as well as using other parameters value that has been determined, then the pressure will decrease periodically. It is seen from the value of the pressure at the outlet of 33.485 bar. The pressure value at the outlet will change if the parameter values changed. From the simulation results a few cases, it appears that the value of the pressure at the outlet is influenced by the values of parameters, including flow rate and also height at the end of the pipe.
Keywords : gas flow, gas pipeline, Crank-Nicolson method
I.
Introduction Gas is one of alternative source energy that can be choose because oil reserve in this world attenuated. Distribution and gas transportation are common to do in many country in this world, especially in country that has gas source. On the previous research, there were modelled gas flow on pipeline with assume that gas flow on steady state, where the pressure condition, flow velocity, and temperature not change to time. On some condition, this
assumption give good result. But on the real condition, there are many situation where the gas flow was unsteady. Cause by some condition, there are compressor’s failure, addition or reduction source, treatment or replacement tool, and leakage of pipe. If this condition happen, it will cause changes of flow parameters, like pressure, flow velocity, and gas temperature. In this condition, model of steady gas flow not appropriate again. So, it need to develop some mathematical model that represents gas flow on pipeline that unsteady (transient). So, the mathematical model was made based on guess of operation condition in real world. On the develop of this model, there are two probability, on one side we want accurate model, and on the other side, we want simple model to make easy and fast solution. So, there must be a compromise between two model to get model that can explain gas flow behavior with accurate but has easy and fast solution. In this project, gas flow model on gas pipe network made with emphasize on pipeline. Because pipeline is principal element in this system. Model derived from mass conservation equation, momentum conservation equation, and real gas condition equation. Then that model finished by Crank-Nicholson method. The solution from this model visualized by matlab.
II.
Problem Statement
1. Derive mathematical model from gas flow from pipeline. 2. Get numerical solution from gas flow modelling on pipeline. 3. Visualize numerical calculation result from the model using Matlab program. III.
Mathematical Modelling
Equation of unsteady gas flow in pipeline derived from mass conservation equation, momentum conservation equation, energy conservation equation, and gas equation of state. We can develop from that equation some mathematical model of gas flow equation in pipeline based on real condition. This project based on model of unsteady gas flow that developed by Zhou and Adewumi (1995) that has some assumption : 1. Pipe of transmission straight and horizontal 2. Area of pipe constant 3. Gas flow in one dimension 4. Flow in the isothermal condition (temperature along pipeline constant) 5. Flow of fluid is gas in one phase (dry gas) 6. Expansion of wall of pipe can be ignored 7. There are friction for unsteady condition 8. Velocity of voice (c) assume constant 9. Nothing work done by gas during flow 10. Density of gas assumes constant
But in this project, pipes not horizontal, but has inclination angle. Because flow assumes isothermal, that is nothing disturbance from external so the temperature inside pipeline constant, then energy conservation equation useless for build the mathematical model in here. So, based on that assumption, mathematical model develop for explain unsteady gas flow behavior in pipeline, there are mass conservation equation, momentum conservation equation, and real gas flow equation that can be written again here ; (1)
𝜕𝜌 𝜕 (𝜌𝑣) = 0 + 𝜕𝑡 𝜕𝑥 𝜕 𝜕 (𝜌𝑣𝑆) + (𝑝𝑆 + 𝜌𝑣 2 𝑆) + |𝜏|𝜋𝐷 + 𝜌𝑆𝑔𝑠𝑖𝑛𝜃 = 0 𝜕𝑡 𝜕𝑥 𝑝=𝜌
𝑍𝑅𝑢 𝑇𝑒𝑚𝑝 = 𝜌𝑍𝑅𝑔 𝑇𝑒𝑚𝑝 𝑀
With 𝑅𝑔 =
(2)
(3)
𝑅𝑢 𝑀
Three equations above make one system partial differential equation type non-linier hyperbolic in first order with three state variable, that is pressure, density, and velocity. 𝑍𝑅𝑢 𝑇𝑒𝑚𝑝
With use voice velocity = √
𝑀
, real state gas equation in (3) become :
𝑝 = 𝑐2𝜌
(4)
Request of gas by consument usually represents by mass flow velocity (𝑞). So in here, velocity (𝑣) replaced by mass flow velocity that defined by : 𝑞 = 𝜌𝑣𝑆 = 𝜌𝑄 = 𝜌𝑛 𝑄𝑛
(5)
For first simplification, with use equation (4) and (5), mass and momentum conservation equation can state as function from flow velocity in normal condition 𝑄𝑛 (𝑥, 𝑡) and pressure 𝑝(𝑥, 𝑡). So equation (1) can be written again become : 𝜕𝑝 𝑐 2 𝜌𝑛 𝜕𝑄𝑛 =− 𝜕𝑡 𝑆 𝜕𝑥
(6)
Otherwise, for equation (2), with use Fanning factor (𝑓) on equation (4) and mass flow equation on equation (5), we get : |𝜏| =
𝑓𝜌𝑣 2 𝑓𝑞 2 = 2 2𝜌𝑆 2
(7)
So, from equation (2) and (7), we get : 𝜕𝑞 𝜕 𝑞2 𝑓𝑞 2 + (𝑆𝑝 + ) + 𝜋𝐷 + 𝜌𝑆𝑔𝑠𝑖𝑛𝜃 = 0 𝜕𝑡 𝜕𝑥 𝑆𝜌 2𝜌𝑆 2
(8)
1
With use definition from pipe area, 𝑆 = 4 𝜋𝐷2 , then equation (8) become : 𝜕𝑄𝑛 𝑆 𝜕𝑝 2𝑓𝑐 2 𝜌𝑛 𝑄𝑛 2 𝑆𝑔𝑠𝑖𝑛𝜃 =− − − 𝑝 𝜕𝑡 𝜌𝑛 𝜕𝑥 𝐷𝑆 𝑝 𝜌𝑛 𝑐 2
(9)
So, from equation (6) and (9), we get first simplification for model : 𝜕𝑝 𝑐 2 𝜌𝑛 𝜕𝑄𝑛 =− 𝜕𝑡 𝑆 𝜕𝑥 2 𝜕𝑄𝑛 𝑆 𝜕𝑝 2𝑓𝑐 𝜌𝑛 𝑄𝑛 2 𝑆𝑔𝑠𝑖𝑛𝜃 =− − − 𝑝 𝜌𝑛 𝜕𝑥 𝐷𝑆 𝑝 𝜌𝑛 𝑐 2 { 𝜕𝑡
(10)
Next simplification from model can derived from hypothesis that boundary condition not change quickly and capacity from gas line relatively big so 𝑞 can be assumed constant to distance and time. In this problem, first condition from equation (10) can be eliminated from model. Then, with express again that model as function from flow velocity in normal condition 𝑄𝑛 (𝑥, 𝑡) and pressure 𝑝(𝑥, 𝑡). We get this equation : 𝜕𝑝 1 𝜕𝑞 2𝑓𝑐 2 𝜌𝑛 2 𝑄𝑛 2 𝑔𝑠𝑖𝑛𝜃 =− − − 𝑝 𝜕𝑥 𝑆 𝜕𝑡 𝐷𝑆 2 𝑝 𝑐2 From assumption, given that 𝑞 constant to distance and time, then : 2𝑓𝑐 2 𝜌𝑛 2 𝑄𝑛 2 𝑔𝑠𝑖𝑛𝜃 − − 𝑝 𝐷𝑆 2 𝑝 𝑐2 With use equation
𝜕𝑝2 𝜕𝑥
𝜕𝑝
= 2𝑝 𝜕𝑥 , we get :
𝜕𝑝 𝜕𝑝2 1 𝜕𝑞 2𝑓𝑐 2 𝜌𝑛 2 𝑄𝑛 2 𝑔𝑠𝑖𝑛𝜃 𝜕𝑝 ( )( ) = (− − − 𝑝) (2𝑝 ) 2 2 𝜕𝑥 𝜕𝑥 𝑆 𝜕𝑡 𝐷𝑆 𝑝 𝑐 𝜕𝑥 𝜕𝑝2 4𝑓𝑐 2 𝜌𝑛 2 𝑄𝑛 2 2𝑔𝑠𝑖𝑛𝜃 2 =− − 𝑝 𝜕𝑥 𝐷𝑆 2 𝑐2
(11)
When equation (11) derived partially to 𝑥, we get : 𝜕 2 𝑝2 𝜕 4𝑓𝑐 2 𝜌𝑛 2 𝑄𝑛 2 2𝑔𝑠𝑖𝑛𝜃 2 = (− − 𝑝 ) 𝜕𝑥 2 𝜕𝑥 𝐷𝑆 2 𝑐2 𝜕 2 𝑝2 8𝑄𝑛 𝑓𝑐 2 𝜌𝑛 2 𝜕𝑄𝑛 2𝑔𝑠𝑖𝑛𝜃 𝜕𝑝2 =− − 𝜕𝑥 2 𝐷𝑆 2 𝜕𝑥 𝑐2 𝜕𝑥
(12)
Substitute equation (6) to equation (12), then : 𝜕 2 𝑝2 8𝑄𝑛 𝑓𝜌𝑛 𝜕𝑝 2𝑔𝑠𝑖𝑛𝜃 𝜕𝑝2 = − 𝜕𝑥 2 𝐷𝑆 𝜕𝑡 𝑐2 𝜕𝑥
(13)
With use relation
𝜕𝑝2 𝜕𝑡
𝜕𝑝
= 2𝑝 𝜕𝑡 , equation (13) become :
𝜕 2 𝑝2 16𝑄𝑛 𝑓𝜌𝑛 𝜕𝑝2 2𝑔𝑠𝑖𝑛𝜃 𝜕𝑝2 = 2 − 𝜕𝑥 2 𝑐 𝜌𝜋𝐷3 𝜕𝑡 𝑐2 𝜕𝑥 Finally, with use relation 𝑄𝜌 = 𝑄𝑛 𝜌𝑛 , then simplification from two model can be state : 𝜕 2 𝑝2 2𝑔𝑠𝑖𝑛𝜃 𝜕𝑝2 16𝑄𝑛 𝑓𝜌𝑛 𝜕𝑝2 + = 2 𝜕𝑥 2 𝑐2 𝜕𝑥 𝑐 𝜌𝜋𝐷3 𝜕𝑡
(14)
With assume 𝛼 and 𝛽 is a constant value, then equation (14) become linear model respect to 𝑝2 . And second assumption that is 𝑄(𝑥, 𝑡) is a mean from flow velocity along gas flow in each time interval ∆𝑡 . From that assumption, we get gas flow model in pipeline in form partial differential equation linear parabolic second order respect to 𝑝2 in each ∆𝑡 is : 𝜕 2 𝑝2 𝜕𝑝2 𝜕𝑝2 +𝛽 =𝛼 𝜕𝑥 2 𝜕𝑥 𝜕𝑡 16𝑄𝑛 𝑓𝜌𝑛 2𝑔𝑠𝑖𝑛𝜃 𝑤𝑖𝑡ℎ 𝛼 = 2 𝑎𝑛𝑑 𝛽 = 3 { 𝑐 𝜌𝜋𝐷 𝑐2
IV.
(15)
Numerical solution
4.1 Initial condition and boundary condition from this project defined below : 1. Dirichlet requirement (16) 𝑝(0,0) = 𝑝0 (17) 𝑝(0, 𝑡) = 𝑝0 ; t > 0 (18) 𝑄(𝑥, 𝑡) = 𝑐𝑜𝑛𝑠𝑡𝑎𝑛𝑡; 0 ≤ 𝑥 ≤ 𝐿 2. Neumann requirement 𝜕𝑝 | =0 (19) 𝜕𝑡 𝑥=0 𝜕𝑄 (20) | =0 𝜕𝑡 0≤𝑥≤𝐿 For the calculation of the pressure at each point in time t = 0 along the pipeline can be expressed by Equation (21) for a case where a pipeline has an inclination angle and by Equation (22) for horizontal pipelines. 𝑝(𝑥, 0) = √(𝑝0 2 −
𝜎 𝛽𝑥 (𝑒 − 1)) 𝑒 −𝛽𝑥 𝛽
𝑝(𝑥, 0) = √𝑝0 2 − 𝜎𝑥 𝑓
(22)
2𝜌𝑐𝑄 2
With 𝜎 = 𝐷 (
𝑆
(21)
) and 𝛽 =
2𝑔𝑠𝑖𝑛𝜃 𝑐2
While the value Z calculated from an initial condition using the algorithm shown in Figure 1 In this study, based on empirical equations that have been proposed by Segeler, Ringler, and Kafka, the Z value is calculated using the equation : 𝑝𝑟𝑎𝑡𝑎−𝑟𝑎𝑡𝑎 𝑍 =1− (23) 390 1
With 𝑝𝑟𝑎𝑡𝑎−𝑟𝑎𝑡𝑎 = 2 [𝑝(0, 𝑡) + 𝑝(𝐿, 𝑡)]
Figure 1. Algorithm for calculate Z and p(L,t) 4.2 Numerical Scheme With suppose 𝑝2 = 𝑢, then gas flow model on equation (15) can be written again below : 𝜕 2𝑢 𝜕𝑢 𝜕𝑢 + 𝛽 = 𝛼 𝜕𝑥 2 𝜕𝑥 𝜕𝑡
(24)
In the equation, each condition can be approximated by finite difference schemes. By applying the Crank-Nicolson method approach to model the gas flow as shown in Equation (8), (9) and (10), it will get the numerical scheme as follows : 2∆𝑡 − 𝛽∆𝑥∆𝑡 −4∆𝑡 + 4𝛼∆𝑥 2 2∆𝑡 + 𝛽∆𝑥∆𝑡 ( ) 𝑢 + ( ) 𝑢𝑗,𝑛 + ( ) 𝑢𝑗+1,𝑛 𝑗−1,𝑛 2 2 2∆𝑥 ∆𝑡 2∆𝑥 ∆𝑡 2∆𝑥 2 ∆𝑡 2∆𝑡 − 𝛽∆𝑥∆𝑡 −4∆𝑡 − 4𝛼∆𝑥 2 2∆𝑡 + 𝛽∆𝑥∆𝑡 +( ) 𝑢 + ( ) 𝑢 + ( ) 𝑢𝑗+1,𝑛+1 = 0 (25) 𝑗−1,𝑛+1 𝑗,𝑛+1 2∆𝑥 2 ∆𝑡 2∆𝑥 2 ∆𝑡 2∆𝑥 2 ∆𝑡 Equation (25) multiply by
∆𝑡 𝛼
so we get :
2∆𝑡 2 − 𝛽∆𝑥∆𝑡 2 −4∆𝑡 2 − 4𝛼∆𝑥 2 ∆𝑡 2∆𝑡 2 + 𝛽∆𝑥∆𝑡 2 ( ) 𝑢 + ( ) 𝑢 + ( ) 𝑢𝑗+1,𝑛+1 = 𝑗−1,𝑛 𝑗,𝑛+1 2𝛼∆𝑥 2 ∆𝑡 2𝛼∆𝑥 2 ∆𝑡 2𝛼∆𝑥 2 ∆𝑡 2∆𝑡 2 − 𝛽∆𝑥∆𝑡 2 −4∆𝑡 2 + 4𝛼∆𝑥 2 ∆𝑡 2∆𝑡 2 + 𝛽∆𝑥∆𝑡 2 −( ) 𝑢𝑗−1,𝑛 − ( ) 𝑢𝑗,𝑛 − ( ) 𝑢𝑗+1,𝑛 = 0 2𝛼∆𝑥 2 ∆𝑡 2𝛼∆𝑥 2 ∆𝑡 2𝛼∆𝑥 2 ∆𝑡 Then, we get numerical scheme for 𝑗 = 1,2,3, … , 𝐽 and = 0,1,2, … , 𝑁 :
(𝑎 − 𝑏)𝑢𝑗−1,𝑛+1 + (−2𝑎 − 2)𝑢𝑗,𝑛+1 + (𝑎 + 𝑏)𝑢𝑗+1,𝑛+1 = (−𝑎 + 𝑏)𝑢𝑗−1,𝑛 + (2𝑎 − 2)𝑢𝑗,𝑛 + (−𝑎 − 𝑏)𝑢𝑗+1,𝑛 2∆𝑡 2
∆𝑡
𝛽∆𝑥∆𝑡 2
(26)
∆𝑡
With 𝛼 = 2𝛼∆𝑥 2 ∆𝑡 = 𝛼∆𝑥 2 and 𝛽 = 2𝛼∆𝑥 2 ∆𝑡 = 2𝛼∆𝑥
V.
Included Description For simulation, we use this parameter : 𝐷 = 0.6 𝑚 𝑇𝑒𝑚𝑝 = 278 𝐾 𝑝(0, 𝑡) = 50 𝑏𝑎𝑟 5 𝑇 = 3600 𝑠 𝐿 = 10 𝑚 𝜌 = 0.73 𝑘𝑔/𝑚3 𝑣 = 28 𝑚/𝑠 𝑓 = 0.003 𝑅𝑔 = 392 𝑚2 /𝑠 2 𝐾 a. For 𝑄0 = 50𝑚3 /𝑠 and H=3000 m b. For 𝑄0 = 50𝑚3 /𝑠 and H=500 m
p(L)= 33,485bar ; error=0,00075822 c. For 𝑄0 = 50𝑚3 /𝑠 and H=7800 m
p(L)= 19,1293bar; error=0,00185209
p(L)=44,1291bar ; error=0,00013069
VI.
Conclusion
Based on the discussion of the previous chapter, it can be concluded that: 1. The mathematical model that describes the behavior of the flow of gas in a pipeline can be stated as follows: 𝜕 2 𝑝2 𝜕𝑝2 𝜕𝑝2 +𝛽 =𝛼 𝜕𝑥 2 𝜕𝑥 𝜕𝑡 16𝑄𝑛 𝑓𝜌𝑛 2𝑔𝑠𝑖𝑛𝜃 𝑤𝑖𝑡ℎ 𝛼 = 2 𝑎𝑛𝑑 𝛽 = 3 { 𝑐 𝜌𝜋𝐷 𝑐2 2. From simulation and numerical solution obtained with the assistance of Matlab program, it appears that the value of the pressure at the outlet is affected by the value parameters, including flow rate and altitude at the end of the pipe. While the magnitude of the error, in addition affected by the value of the parameter, is also influenced by the discrete process. The more discrete process, then the value of the error is getting smaller.
VII. References Widodo, Basuki. 2012. Pemodelan Matematika. ITS Press: Surabaya. Gonzalez, Alberto H., dkk. 2008. Modeling and Simulation of a Gas Distribution Pipeline Network. Journal of Applied Mathematical Modelling, 1584–1600. Lurie, Michael V. 2008. Modeling of Oil Product and Gas Pipeline Transportation. Weinheim: WileyVCH Verlag GmbH & Co. KGaA. McCain, William D. Jr. 1990. The Properties of Petroleum Fluids. Oklahoma: PennWell Publishing Company. Segeler, C.G., Ringler, M.D., dan Kafka, E.M. 1969. Gas Engineers’ Handbook. New York: AGA. Smith, G.D. 2005. Numerical Solution of Partial Differential Equations. Oxford: Clarendon Press. Streeter, V.L. dan Wylie, E.B. 1990. Diterjemahkan oleh Prijono, A. Mekanika Fluida Jilid I Edisi 8. Jakarta: Erlangga. Sulistyarso, Harry B. 2007. Aplikasi Suatu Model Aliran Gas Transient pada Kasus Line Packing untuk Lapangan Gas. Disertasi, Departemen Teknik Perminyakan, Institut Teknologi Bandung. Sulistyarso, Harry B., dkk. 2004. Solusi Model Aliran Gas Dalam Pipa pada Kondisi Line Packing Menggunakan Skema Richtmyer. Proceedings ITB Sains & Teknik, Vol. 36A, No. 2, 159177.