Streamline calculations. Lecture note 2 February 26, 2007 1 Recapitulation from previous lecture Definition of a streamline x(τ) = s(τ), dx(τ) dτ = v(x,t), x(0) = x 0 (1) Divergence free, irrotational flow in 2D: v can be expressed as the gradient of a potential: v = φ (2) where φ is the real part of the (analytic) complex potential The streamlines are level curves of ψ(x,y): F(z) = φ(x,y) + iψ(x,y) (3) ψ(x,y) = const (4) Divergence free flow in 2D: Streamline are still level curves of a streamfunction. An explicit formula for the streamfunction is ( ) dvy ψ(x,y) = v x dy v y dx + dy dx dy For divergence free flow in 3D, two independent streamfunctions will exist, such that their intersection describe a streamline. The streamfunctions in 3D seems to be more complicated and less useful in applications than the stream function in 2D. 1
2 Integration (continued from previous lecture) Linear system of equations Note: In this section we assume that the velocity is independent of time, i.e., v(x,t) = v(x). Then path lines and streamlines are the same; hence, it is not significant to distinguish between τ and t in Equation (1). Thus in this section, we use x(t) to represent a streamline, which is consistent with the notation used in text books on ordinary differential equations. Assume that v : R n R n is linear in space, such that the equation for the streamline becomes, dx dt = v = Ax + b x(0) = x 0, (5) where A is a constant n n matrix, and b is a constant n 1 vector. Assume further, that A has n linearly independent eigenvectors ξ i, with corresponding eigenvalues λ i, i = 1,...,n. Note: if A does not have a set of n linearly independent eigenvectors, it is more involved, but still possible to find an analytic solution. We now define the matrices λ 1 0 0 T = [ ] 0 λ 2 0 ξ 1... ξ n, D =......, (6) 0 0 λ n corresponding to the eigenvalue decomposition AT = T D. By using the substitution x = T x, Equation (5) becomes T d x dt = AT x + b x(0) = T 1 x 0 x 0, (7) and a decoupled equation in x is obtained by multiplication by T 1, d x dt = D x + T 1 b x(0) = x 0 (8) The last equation can be written in component form d x i dt = λ i x i + α i, x i (0) = x 0 i, i = 1,...,n, (9) which are easily integrated. The true solution x(t) is recovered by x(t) = T x(t) (10) 2
Example Let x = [x,y] T and v = [ x 2y +1,3x+4y 1] T and x 0 = [2, 3] T. Then [ ] [ ] 1 2 1 A =, b =, (11) 3 4 1 and λ 1 = 1, λ 2 = 2, ξ 1 = [1, 1] T, and ξ 2 = [2, 3] T. Hence, [ ] [ ] [ ] 1 2 T = T 1 3 2 1 0 = D =. (12) 1 3 1 1 0 2 Then T 1 b = [ ] 1, x 0 0 = T 1 x 0 = [ ] 0 1 (13) and letting x = [ x, ỹ], we have ] d x [ x + 1 dt = 2ỹ x(t) = [ C5 e t ] 1 C 6 e 2t, (14) and x(0) = x 0 = [ ] 0 1 x(t) = [ e t ] 1 e 2t, (15) and finally x(t) = T x(t) x(t) = [ e t + 2e 2t ] 1 e t 3e 2t + 1 (16) See Figure 1 Numerical integration Methods for numerical integration of initial value problems (IVP) for ordinary differential equations (ODE) include : Taylor series Euler s method Heun s method Runge-Kutta methods Adam s methods The methods can be further classified with respect to 3
6 4 2 0 2 4 6 6 4 2 0 2 4 6 Figure 1: Field plot for v = [ x 2y + 1,3x + 4y 1] T. A streamline s(τ) is started at s(0) = s 0 = [2, 3] and traced backward in time to the point s( 0.5). Single-step / multi-step method Explict / implicit method. We will here consider a second order Runge-Kutta method, for the model problem: dx dt = f(x) x(0) = x 0. (17) Since the right-hand side in general don t need to be a velocity, we have used f(x) instead of v(x). Choose a fixed time step t. We will compute a numerical solution at discrete points t i, i = 1,...,N, such that t i+1 t i = t. The approximate solution at time t i, is denoted x i. Integration of (17) 4
now gives x(t) = x 0 + t 0 f(x)dt x(t n+1 ) = x(t n + t) = x 0 + Approximate tn+1 x n + x n + t n tn+1 t n f(x)dt f(x n+1/2 )dt We then have the numerical scheme: tn x n+1/2 x n + (t n+1/2 t n ) dx dt 0 = x n + t 2 f(x n) tn+1 f(x)dt + f(x)dt t n (18) tn x n+1 = x n + tf(x n + t 2 f(x n)) (19) Note: Matlab has a variety of solvers for initial value promblems for ordinary differential equations, e.g. ode45 and ode23, which have automatic error control. A minimal MATLAB implementation Example Let v = [cos(xy),x], and x 0 = [ 1,1]. See Figure 2. A minimal MATLAB implementation for this velocity field could be: function rktest() [t, y] = rk2(@vel, [0,3], [-1; 1], 0.01); return function y=vel(x) y(1,1)=cos(x(1,1)*x(2,1)); y(2,1)=x(1,1); return function [tout, yout] = rk2(yprime, tspan, y0, dt) t0=tspan(1); 5
2.5 2 1.5 1 0.5 0 0.5 1 1.5 2 2.5 2.5 2 1.5 1 0.5 0 0.5 1 1.5 2 2.5 Figure 2: Field plot for v = [cos(xy),x]. A streamline s(τ) is started at s(0) = s 0 = [ 1,1], and traced to the point s(3). tn=tspan(2); N = floor((tn-t0)/dt) + 1; tout = linspace(t0,tn,n) ; h=tout(2)-tout(1); yout = zeros(n,size(y0,1)); yout(1,:) = y0 ; y=y0; for i=2:n k=yprime(y); y = y + h*yprime(y + (h/2)*k); yout(i,:) = y ; end return 3 Reservoir simulation Reservoir simulation is the numerical solution of the partial differential equations describing the flow in a porous media. Ideally, the flow equations could be derived from conservation of mass and momentum (and energy for compressible flow) for an infinitesimal 6
volume of fluid. This would lead to the Navier-Stokes equations, which relates change of volume to pressure change and viscous forces. However, for flow in porous media (like an oil reservoir), these equation would become impossible to solve since we typically don t now the exact shape of the pores. We therefore employ an average concept, using the Darcy s law, which will replace the momentum equation. Darcy s law is a phenomologically derived constitutive equation. The equation was originally formulated by Henry Darcy based on the results of experiments on the flow of water through beds of sand. 3.1 Two phase immiscible flow We will consider a simple model problem, where we consider two immiscible phases oil and water. Darcy s law then reads where q α = k rα µ α K( P α ρ α g), α = o,w, (20) q α are the specific discharge vectors (commonly denoted the Darcy velocity) K is the permeability tensor k rα are the realtive permabilities, µ α are the viscosities, ρ α are the densities, g is the gravity vector, P α are the phase pressures. The Darcy velocity is related to the average particle velocity v α for phase α through q α = φv α, (21) See Figure 3. Let S α denote the fraction of the volume occupied by phase α at a given point in the reservoir. 7
Figure 3: Cross section of a porous medium. White areas indicates pores, whereas the cross hatched area denotes the matrix. To obtain the average particle velocity normal to the cross section, we devide the total fluid flux through the pores (white area) by the area of the pores (white area). To obtain the Darcy velocity, we devide the flux by the total area of the cross section (sum of white area and cross hatched area). Conservation of mass is applied over a control volume V, to derive the continuity equation. The conservation principle for volume V says that Accumulated Fluid + Flow out of V = Injected fluid (22) Mathematically this is expressed as (φρ α S α )dv + (ρ α q t α ) nds = Q α (23) V V t (φρ αs α ) + (ρ α q α ) = Q α, (24) where Q α is the source term for phase α. In addition, we have the constitutive relations (equations of state). S w + S o = 1 (25) P o P w = P c (S w ) (26) ρ α = ρ α (P w ) (27) µ α = µ α (P w ) (28) k rα = k rα (S w ) (29) In addition, the porosity and the permeability must be known: φ = φ(x,t) (30) K = K(x,t) (31) 8
By inserting the Darcy velocity in (24), a formulation of the flow equations common for use with finite difference methods is obtained: t (φρ αs α ) + ( ρ α k rα µ α K( P α ρ α g)) = Q α, α = o,w (32) This is a system of two nonlinear equations in two unknowns, e.g., P w and S w. These equations can be solved numerically by finite difference methods. A pressure/saturation formulation We will reformulate the last equations into one pressure equation (elliptic) and one saturation equation (hyperbolic). In this way, it will be easier to discover the porperties of the equations, and we can obtain a faster numerical solution procedure. To obtain the pressure equation, we begin with expanding the time derivatives in (32), where φ t ρ αs α + φ ρ α t S S α α + φρ α + (ρ α q t α ) = Q α (33) φ t S 1 ρ α α + φs α ρ α t + φ S α + 1 (ρ α q t ρ α ) = Q α α ρ α (34) φ t S P α α + φs α c α + φ S α + 1 (ρ α q t t ρ α ) = Q α, α ρ α (35) c α = 1 ρ α ρ α P α (36) Adding the two equations in (35), and using (25), we get ( ) φ t + φ P w P o S w c w + S o c o + t t 1 (ρ w q ρ w ) + 1 (ρ o q w ρ o ) = Q w + Q o, (37) o ρ w ρ o where we have eliminated the time derivatives of the saturations. This last equation is denoted the pressure equation. We now start by deriving the saturation equation. Define λ α = k rα µ α (38) 9
Introduce the total velocity q, q = q w + q o = λ w K( P w ρ w g) λ o K( P o ρ o g) (39) We will first express the water velocity in terms of the total velocity. From Darcy s law we have q o = λ o K( P o ρ o g) K P o = 1 λ o q o + ρ o Kg (40) q w = λ w K( P w ρ w g) K P w = 1 λ w q w ρ w Kg (41) adding these equations gives K P c = 1 λ o q o + 1 λ w q w + (ρ o ρ w )Kg (42) By using (39) to eliminate q o, we get ( 1 + 1 ) q λ o λ w = 1 q + K P c + (ρ w ρ o )Kg (43) w λ o By defining we get h w (S w ) = λ oλ w λ o + λ w (44) f w (S w ) = λ w, λ o + λ w (45) q w = f w q + h w K( P c + (ρ w ρ o )g) (46) Saturation equation. By inserting (46) into Equation (24) t (φρ ws w ) + (ρ w (f w q + h w K( P c + (ρ w ρ o )g))) = Q w (47) 3.2 Simplified two-phase flow To ease the discussion of what follows, we simplfy the the problem by assuming, Incompressible fluids (ρ w, ρ o are constant) Time independent porosity ( φ/ t = 0) No capillary pressure (P o = P w = P) No gravity (g = 0) 10
The flow equations (37) and (47) now simplifies to q = Q w ρ w + Q o ρ o (48) φ S w t + (f w q) = Q w ρ w (49) Defining λ t = λ w + λ o, and using Equation (39), we have q = q w + q o = λ w K P λ o K P = λ t K P, (50) and the pressure equation (48) can be written ( λ t K P) = Q w ρ w + Q o ρ o (51) It follows from (48) that q = 0, away from sources and sinks. In this case the saturation equation (49) becomes φ S w t + q f w = 0 (52) 3.3 Simplification using streamlines and time-of-flight Within streamline simulation, the streamline parameter τ is denoted the time-of-flight (TOF). In some applications of streamline simulation, arrival times of particles along streamlines will be important. Since these particles travel with the average particle velocity, and not with the Darcy velocity, we will relate the time of flight to the average particle velocity. Hence, we define streamlines s(τ) = x(τ) and TOF by We also have: τ(s) = dx dτ = q(x,t), x(0) = x 0 (53) φ dx dτ = ds dτ = ds dτ ds dτ = q φ s 0 = ds dτ (54) (55) φ q ds (56) From the previous equation, we also have the differential form q s = φ τ, (57) 11
We now return to Equation (52). Using the previous relation and the definition of a directional derivative, we get q f w = q f w s = φ f w τ (58) Hence, by using streamlines and time-of-flight, we can simplify (52) as S w t + f w(s w ) τ = 0 (59) Note the two different meanings of t and τ in the last equation. We have simplified the saturation equation to a 1D hyperbolic equation along streamlines. References 12