Sie sind auf Seite 1von 99

ESCUELA MILITAR DE INGENIERIA

CARRERA DE INGENIERIA PETROLERA


MODELOS DE SIMULACION Y LABORATORIO

CAPITULO 2

FUNDAMENTO MATEMATICO

PRESENTADO POR:
Msc.Ing. GABRIEL PEREZ ORTIZ
INTRODUCCION

Los modelos matemticos y estructurales


para la construccin de simuladores en la
actualidad son fundamentales para poder
definir los parmetros necesarios para la
correcta discretizacion e interpretacin de
datos en cualquier simulador.
ETAPAS DE UN SIMULADOR ESTRUCTURAL
ECUACIONES DE DIFUSIVIDAD
Mtodos de resolucin de
Ecuaciones de Difusividad
Ecuaciones algebraicas lineales

Ecuaciones algebraicas no lineales

Mtodos para una variable


Mtodos para multivariable

7
Ecuaciones Algebraicas

Lineales No lineales

Metodos
Numericos
Interval
Halving False
(o bisection) Position Ridder
(o regula falsi)
Succesive
Secant Muller
Substitution
(o fixed-point)

Wegstein Newton
Metodos Raphson
Analiticos
Brent
Broyden

Homotopy
Dogleg step
Hook step

Para problemas multidimensionales

8
Ecuaciones algebraicas lineales

Analysis of System LAE

Consistent, independent equations


If equations are not contradictory and not simply multiplies of
the other, then solution to LAE problems will be unique.
Example: 3 x 2 y 4
Systems of Linear Algebraic Equations 2x y 1

Inconsistent equations
If equations are contradictory, then no solution exists.
General Representation
Example: 2 x y 2
a11 x1 a12 x2 a1n xn b1 2x y 1

a21 x1 a22 x2 a2 n xn b2

an1 x1 an 2 x2 ann xn bn
Analysis of System LAE (2)
as are constant coefficients, bs are constants, x are
the unknown variables, and n is the number of
Dependent equations
equations If equations are multiplies of others, many solutions can be
found
Example: 4 x 2 y 4
2x y 2

Ill-conditioned equations
If a small change in any of the coefficients will change the
solution set from unique to either infinite or empty, the
system of LAE is called to be ill-conditioned.
Numerical solution will be difficult
Example: (4 ) x 2 y 4
2x y 1

9
Ecuaciones algebraicas lineales

Gauss Elimination Algorithm

Step 1: Forward elimination until we get the upper (or lower)


triangular matrix of LAE coefficients
Step 2: Backward substitution
Gauss Elimination - Concept
m
1. Add a multiple Ri
of row onto rowR j to form a new row R j
R j m Ri R j
If two equations have a point in common, then that point also
satisfies any linear combination of the two equations.
r r1 , r2 , , rn 2. Repeat (1) until we get an upper (or lower) triangular matrix of
Suppose that are the solutions to linear LAE coefficients;
equations
S : a o a1 x1 a 2 x 2 a n x n 0 3. Apply back substitution to solve for each variable
T : bo b1 x1 b2 x 2 bn x n 0

r r1 , r2 , , rn
then also satisfies the linear combination of these
linear equations:
m1S m2T Pitfalls of the Gauss Elimination
m1ao m1a1 x1 a2 x2 m1an xn m2bo m2b1 x1 m2b2 x2 m2bn xn 0

When does the Gauss elimination get solution?


When inverse of exists A x b
x A 1b

When equations are consistent and independent


Satisfy the following rank condition: rank( A) dim( A)

Limitation of algorithm
When pivot element equals zero
When pivot element is significantly smaller than the coefficient
being used to eliminate (or Ill-conditioned)
Round-off errors

10
Ecuaciones algebraicas lineales

LU Decomposition - Concept

A matrix A is decomposed (or factorised) into lower and upper


matrix factors, for example if A is a 3x3 matrix:
11 0 0 u11 u12 u13 a11 a12 a13
A L.U 21 22 0 . 0 u 22 u 23 a 21 a 22 a 23
31 32 33 0 0 u 33 a 31 a 32 a 33

Methods to find LU factors


Gauss elimination (Doolittle form)
Direct computation
u ii 1
Crout form ( u ii) ii
Cholesky form ( ) Motivation for LU Decomposition

Solve the LAE Problems in a more efficient way

Algorithm for solving an LAE Problem using the LU


Decomposition

Find the LU factor of the A matrix: A = LU


Algebraic problem is transformed from Ax = b to LUx = b
Define y = Ux
Solve for y using the forward substitution
Solve for x using the backward substitution

11
Ecuaciones algebraicas lineales

LU Decomposition
using Gauss Elimination
Suppose we try to find LU factors of the following matrix:
4 12 8 4
1 7 18 9
A
2 9 20 20

3 11 15 14
1 0 0 0
1 0 0
L 21
Initialization: Let U = A and 31 32 1 0

41 42 43 1 Step 2: Rows 1 and 2 are unchanged. Rows 3 and 4 are
transformed by
a3 2 3 4 12 8 4
a 21 1 32
Step 1: Row 1 is unchanged, and rows 2-4 are modified by: 21 a2 2 4 to yield:
0 4 16 8
a11 4 U
0 0 4 12
to give: 4 12 8 4 a31 1 42
a4 2 1

0 4 16 8 31 a2 2 2 0 0 1 7

U a11 2
0 3 16 18 a 41 3 Step 3: The fourth row is modified to complete the forward
41 eliminating stage by:
0 2 9 11 a11 4
4 12 8 4
a4 3 1 0 4 16 8
43 to yield: U
a3 3 4 0 0 4 12

0 0 0 4

Hence, the LU factors are:


1 0 0 0 4 12 8 4
0.25 1 0 0 0 4 16 8
L ; U
0.5 0.75 1 0 0 0 4 12

0.75 0.5 0.25 1 0 0 0 4

12
Ecuaciones algebraicas lineales

LU Decomposition
using Crout Method
Based on equating the elements of the product LU with the
corresponding elements of A , where the diagonal elementsUof
are 1s . For a 3 x 3 matrix
11 0 0 1 u12 u13 a11 a12 a13
22 0 0 1 u 23 a21 a22 a23
21
31 32 33 0 0 1 a31 a32 a33

Algorithm
Step 1: Set 1 1 a1 1 , then solve for the remaining elements in
the first row ofU and the first columnL of .
Step 2: Find 22 , then solve for the remainder of the second
row ofU and the second column of L
Continue for the rest
General Formula for Crouts Method

General formula for the first column of L, the first row of U and the
diagonal element of U
a1 j
i1 ai ,1; u1 j ; uii 1
11
General formula for the j-th row of L and the j-th column of U:
For j= 2, 3, , n-1; i = j, j+1, , n; and k = j+1, j+2, , n
j 1
ij aij ik u kj
k 1

j 1
a jk jiuik
i 1
u jk
jj
j 1
nn ann nk u kn
General formula for the last row of L k 1

13
Ecuaciones algebraicas lineales

LU Decomposition
using Choleskys Method

The matrixA is symmetric and positive definite.


L U
T
T
A LL

For a 3 x 3 matrix: x1 0 0 x1 u1 2 u1 3 a1 1 a1 2 a1 3
0 0 u 2 3 a 2 1 a 2 2 a 2 3
2 1 x2 x2
3 1 3 2 x3 0 0 x3 a 3 1 a 3 2 a 3 3

Algorithm:x (a )1 / 2
1 11
Find , then solve for the remaining
L elements in the
first row U
x 2 of and the first column of .
Find , then solve for the remainder
L of the second row ofU
and the second column of
Continue for the rest.
Generalization of Choleskys Method
For the k-th row
i 1
aki ij kj
j 1
ki i 1,2, , k 1
ii
k 1
xk akk 2kj
j 1

14
1 4 5 x1 0 0 x1 u12 u13 1 4 5

A 4 20 32 21 x 2 0 . 0 x 2 u 23 4 20 32
5 32 64 31 32 x3 0 0 x3 5 32 64

First row of U and first column of L


x1 .x1 a11 x1 1; x1 .u12 a12 u12 4; x1 .u13 a13 u13 5
21 .x1 a 21 21 4; 31 .x1 a 31 31 5

Note that due the symmetric: a1 j a j1 j1 u1 j MATLABs Cod e


function [L,U] = Cholesky(A)
1 0 0 1 4 5 1 4 5
%
4 x 0 . 0 x 2 u 23 4 20 32
2 % A is assumed to be symmetric
5 32 x3 0 0 x3 5 32 64 %
[n,m] = size(A);
L = zeros(n,n);
for k=1:n,
Second row of U and second column of L L(k,k) = sqrt(A(k,k)-L(k,1:k-1)*L(k,1:k-1)');
for i=k+1:n,
( 4).(4) x 22 20 x 2 2; L(i,k) = (A(i,k) - L(i,1:k-1)*L(k,1:k-1)')/L(k,k);
end
( 4).(5) x 2 u 2 3 32 u 2 3 6; end
U = L';
(5).(4) 3 2 x 2 32 2 1 6;

We get:
1 0 0 1 4 5 1 4 5 (5).(5) (6).(6) x32 64 x33 3;
4 2 0 . 0 2 6 4 20 32
1 0 0 1 4 5
5 6 x3 0 0 x3 5 32 64
L 4 2 0 ; U 0 2
6
5 6 3 0 0 3

15
Ejemplo
3x1+2x2=4
2x1+x2=1

Inversa de la matriz
Ax=b x=A-1 b x1=-2 x2=5
Descomposicin de Gauss

[32 21] [41 ]


f1=f1-2f2

[-12 10] [ 21 ]
f1=-f1

[12 01 ] [ -21 ]
f2=-2f1+f2

[10 01 ] [ -25 ]
16
Ecuaciones algebraicas lineales

Iterative Methods: Concept

Basic Idea
To solve the i-th equation in the system for the i-th variable by
converting the given system to be suitable for finding the solution in
the iterative manner.

Algorithm Ax b
Transform to x Cx d so that we can solve iteratively
x for
as x ( k ) Cx ( k 1) d.

Stopping Conditions
To stop the iterations when the norm of the change in the solution
vector from one iteration to the next is sufficiently small.
To stop the iterations when the norm of the residual vector is below
a specified tolerance. Variations of Algorithm

Jacobi Method
Ax b x Cx d
Based on the transformation of to , in which the
x
matrix C has zeros on the diagonal. The vector is updated using
the previous estimate for all componentsxof to evaluate the right
hand side of the equation (simultaneous updating).
Gauss-Seidel Method Ax b x Cx d
Based on the transformation of to , in which the
matrix C has zeros onx the diagonal as in Jacobi method, but each
component of the vector is updated immediately as each iteration
progresses (sequential updating).
Successive Over Relaxation (SOR) Method
Like
0 1
Gauss-Seidel method, but we introduce an additional
parameter , that may accelerate the convergence of iteration. For
, the method is known as successive under relaxation,
while for 1 2 is known as successive over relaxation.

17
Ecuaciones algebraicas lineales

Implementation for Different Methods

Jacobi Method x1k 0 0.5 0.5 x1k 1 0.5


k
Iterative Scheme: x
2 0 . 5 0 0.5 x 2k 1 3
x3 0.5 0.5
k
0 x3 1.5
k 1

Initial condition/guess: x o 0 0 0
T
k 1
x x 0 .001
k

Stopping criteria
Gauss-Seidel Method
Iterative Scheme x1n ew 0.5 x 2o ld 0.5 x3o ld 0.5
x 2n ew 0.5 x1n ew 0.5 x3o ld 3
x3n ew 0.5 x1n ew 0.5 x 2n ew 1.5
x o 0 0
SOR Method
T
0
Initial condition/guess
x x new old
0 .0 0 1
Stopping criteria
Example
a11 x1 a12 x 2 a13 x3 b1
a 21 x1 a 22 x 2 a 23 x 3 b2
a 31 x1 a 32 x 2 a 33 x3 b3

SOR Iterative Scheme x1n ew (1 ) x1o ld b1 a1 2 x 2o ld a1 3 x3o ld


a1 1

x 2n ew (1 ) x 2o ld
a2 2
b 2 a 2 1x1n ew a 2 3 x3o ld

x3n ew (1 ) x3o ld
a3 3
b
3 a3 1x1n ew a3 2 x 2n ew
1
It can be seen that if the iterative scheme for
, it becomes
Gauss-Seidel method. The parameter is selected to improve the
convergence of algorithm.

18
Simple Example of Transformation

2 x1 x 2 x3 1 x1 0.5 x2 0.5 x3 0.5


x1 2 x 2 x3 6 x2 0.5 x1 0.5 x3 3
x1 x 2 2 x3 3 x3 0.5 x1 0.5 x2 1.5

Ax b x Cx d

19
Ecuaciones algebraicas no lineales

Objetivo

Sea f(x) una funcin no lineal en x. Hallar el valor de x, x*, tal que
se cumple f(x*)=0.
x* se suele denominar el cero o raz de f(x)
x* se puede determinar por medios analticos (solucin
exacta) o por medios numricos (solucin aproximada)

La eleccin del mtodo numrico depende del problema a


resolver (estructura del problema, tipo de ecuaciones, precisin
requerida, rpidez del clculo,....).
Por tanto no existe un mejor mtodo universalmente aplicable.
Tipos de mtodos

Mtodos acotados (bracketing methods) Mtodos abiertos (open methods)

20
Mtodos acotados

Base: Una funcin cambia de signo en la proximidad de una raz

Una raz est acotada en el intervalo [a,b] si el signo de f(a) es


diferente al signo de f(b)

Mtodo de la biseccin (o intervalo medio)


Bisection Method Algoritmo

f(x) 1. Selecciona un intervalo [a,b] donde halla


f(b) un cero
[nuevo
punto] 2. Calcula el punto medio como nuevo punto
3. Comprueba si hay cambio de signo en
Mid-point
a [a,b]b x [a,p] o en [p,b]. Comprobacin: f(a)*f(p).
4. Si el producto es cero, entonces p es una
raz. Si no es cero volver al punto 2.
Next estimate of Bisection

f(a)

21
Ejemplo Mtodo biseccin (Intervalo medio) (SIMPSON)

x2 4 0

0,6 3,6
0,3 0,1.5 no cambia signo
1.5,3 2.25,3 no cambia signo
1.5,2.25 1.5,1.875 no cambia signo
1.875,2.25

22
Ecuaciones algebraicas no lineales

Mtodo de la posicin falsa

False-Position Method

f(x)
f(b)

[nuevo
a Intersection point b
punto] x Algoritmo
[a,b]

Next estimate of False-position 1. Selecciona un intervalo [a,b] donde halla


un cero
f(a) 2. Calcula un punto interseccin como nuevo
punto
f (a ) f (b) f (b)[a - b])
= m =b-
m- a m- b f (a) - f (b)

3. Comprueba si hay cambio de signo en


[a,p] o en [p,b]. Comprobacin: f(a)*f(p).
4. Si el producto es cero, entonces p es una
raz. Si no es cero volver al punto 2.

23
Ejemplo mtodo de la posicin falsa (Regula Falsi)

x 4 0
2

[0,6]
2
y + 4 = 6x x =
3
2
, 6
3
32 20 2 18
y+ = (x - ) x =
9 3 3 15
18
, 6
15

24
Ecuaciones algebraicas no lineales

Comparacin entre ambos mtodos.


Similaridades:
Ambos mtodos necesitan DOS valores iniciales
Requieren un procedimiento para determinar el
cambio de signo.
Acaban convergiendo a la raz con cierta tolerancia
Diferencias:
El clculo del nuevo punto estimado se hace con Convergence Rate
diferentes estrategias
En general el mtodo de la posicin falsa converge 10

ms rpido que el de la biseccin. 1

Relative Errors
Bisection method

False-position method

Number of iterations

25
Ecuaciones algebraicas no lineales

MTODOS ABIERTOS

Emplean una aproximacin funcional para obtener el nuevo valor estimado de la


raz (lnea recta, cuadrtica, polinomio)
Mtodos:
Punto-fijo (sustitucin sucesiva o directa)
Newton-Raphson (lnea recta empleando informacin del gradiente)
Secante (lnea recta empleando dos puntos)
Muller (aprox. cuadrtica empleando tres puntos)

26
Ecuaciones algebraicas no lineales

Metodos acotados vs. Mtodos abiertos

Mtodos acotados
La raz est situada en un intervalo (necesita dos puntos). Acaba
convergiendo dentro de una tolerancia.
Mtodos abiertos
Slo emplean un punto inicial (o dos puntos que no tienen por qu
contener a la raz) y una frmula para encontrar la raz. No siempre
convergen, pero cuando lo hacen son mucho ms rpidos que los mtodos
acotados.

27
Ecuaciones algebraicas no lineales

Sustitucin sucesiva
y Problema f(x)=0
y= x 1. Transformar a x=g(x)
2. Seleccionar un punto inicial x0
3. Calcular nuevo valor xi+1=g(xi)
y= g(x)
4. Repetir hasta llegar a la tolerancia requerida
Raiz

y
x2 x1 x0 x
y= x

Si:
y= g(x)
|g(x)|<1 El algoritmo converge linealmente
|g(x)|>=1 El algoritmo diverge

x3 x1 x0 x2 x

28
Ejemplo Mtodo punto fijo (Sustitucin directa/sucesiva)

x2 4 0
2 g' (x 0 ) = 3x 2 - 3 = 3 - 3 = 0 < 1
x = x -4+x Converge?
2 x0 1 xk+1 = xk (xk 2 - 3)
x = x(x - 3)
2 x1 = 1(12 - 3) = -2
g(x) = x(x - 3)
x 2 = -2((-2)2 - 3) = -2
x0 3
g' (x0 ) = 3x 2 - 3 = 3 * 9 - 3 = 24 > 1
Converge? x1 = 3(32 - 3) = 18
x 2 = 18(182 - 3) = 5778

29
Ecuaciones algebraicas no lineales
Problema g(x)=0
Newton Raphson
1. Seleccionar un punto inicial x0
2. Calcular g(xi) y g(xi)
3. Aplicar la tangente en ese punto y en el corte con el
eje de abcisas tenemos el nuevo punto estimado

g(xi)
xi+1=xi-
g(xi)
4. Repetir hasta llegar a la tolerancia requerida

y
g(x)
Necesita conocer la derivada de la
funcin
Convergencia cuadrtica (rpida)
Puede no converger (depende de la
funcin y de la estimacin inicial)
x2 x1 x0 x

30
Ejemplo Newton Method

x 4 0
2

x0 1 x0 3

( x0 4) ( x0 4)
2 2
x1 x0 x1 x0
2 x0 2 x0
(12 4) (32 4)
x1 1 1.5 x1 3 2.1666
2 1 23
(1.52 4) 23 (2.1666 2 4)
x2 1.5 x2 2.1666 2,006
2 1.5 12 2 2.1666

31
Ecuaciones algebraicas no lineales

Secante Problema g(x)=0


1. Seleccionar dos puntos iniciales x0,x1
2. Calcular la recta que pasa por esos puntos
3. El corte con el eje de abcisas da el nuevo punto
estimado. Volver a calcular la recta.
xi+1-xi
xi+1=xi- g (xi+1)
g (xi+1)-g (xi)

4. Repetir hasta llegar a la tolerancia requerida


y
g(x)
No Necesita conocer la derivada de
la funcin (la aproxima).
Necesita dos puntos iniciales.
Puede no converger.

x3 x2 x1 x0 x

32
Ecuaciones algebraicas no lineales

False-position Secant method


y y

x0 x3
x3 x2 x1 x x0 x2 x1 x

At the first iteration, both methods produce the same estimate. After
La primera iteracin da el mismo resultado, luego cada
that, each method has a different estimate.
uno obtiene un nuevo punto estimado diferente

33
Ecuaciones algebraicas no lineales

Mullers Method Mullers Algorithm

f(x) 1. Select three points [xo,f(xo)]; [x1,f(x1)] and [x2,f(x2)]


2. Compute the coefficients a, b and c
*
3. Apply a quadratic formula to calculate the next
x0 x1
x estimate of the zero
x2
2c
x3 x2 Real and complex root
Parabolic b b 2 4ac Can be located

Next estimate of Muller 4. Repeat step 2-3 until satisfying the convergent
criteria

Which point is discarded in Muller Algorithm

Two general strategies are typically used:


* Se computan obligando a que g(x) pase por
If only real roots are being located, we choose the two original
points that are nearest the new root estimate, x3 los 3 puntos seleccionados.
If both real and complex roots are being evaluated, a sequential
approach is employed. That is just like the secant method, x1, x2
and x3 take place of x0, x1 and x2.
g ( x) = a( x - xi )2 + b( x - xi ) + c

34
Ecuaciones algebraicas no lineales

Difficulties with multiple root problems


The fact that the function does not change sign at even multiple
roots. So, the bracketing strategy cannot be applied!
The fact that not only f(x), but also f(x), goes to zero at the root.
Possible problems for Newton-Raphson and Secant methods!
SOLUTION: Use the modified Newton-Raphson methods
Alternative one: If we have m multiple roots, the updated estimate
follows:
f ( xk )
xk 1 xk m
f ( xk )

Alternative two: Use the ratio of the function to its derivative, and
then apply the Newton-Raphson formula for this ratio function
f ( xk )
u ( xk )
f ( xk )
u ( xk ) f ( xk ) f ( xk )
xk 1 xk xk
u ( xk ) f ( xk )2 f ( xk ) f ( xk )
35
Ecuaciones algebraicas no lineales

Sistemas de ecuaciones algebraicas no lineales

f1 ( x1 , x2 , x3 ,..., xn ) 0
f 2 ( x1 , x2 , x3 ,..., xn ) 0
f 3 ( x1 , x2 , x3 ,..., xn ) 0

f n ( x1 , x2 , x3 ,..., xn ) 0

F(X ) 0

36
Ecuaciones algebraicas no lineales

Sustitucin sucesiva acelerada

La sobrerelajacin es una tcnica para acelerar la convergencia de mtodos


iterativos en la solucin de ecuaciones lineales. La idea es aplicarlo al mtodo de
sustitucin sucesiva.
Se dan pesos a los valores anteriores y a los previos con el fin de dar pasos
mayores hacia la solucin.

Xk+1=qXk+(1-q)g(Xk)

q=0 sustitucin sucesiva


q<0 aceleracin de la convergencia
0<q<1 estabilizacin de la convergencia por amortiguamiento

37
En los problemas de diagrama de flujo las variables de iteracin no estn todas muy acopladas ni todas
desacopladas, nos podemos encontrar:
1) Todas las especies dbilmente acopladas a travs de equilibrio L-V (no ideal)
2) Especies muy acopladas si participan en una reaccin
3) Si hay ms de una corriente de rasgado, hay un fuerte acoplamiento entre los flujos de cada
corriente de rasgado.
Cuando las variables estn desacopladas o dbilmente acopladas es necesario un parmetro de
aceleracin diferente para cada variable.

38
Ecuaciones algebraicas no lineales

El mtodo de Wegstein es muy bueno para particiones en las que hay una nica
corriente de rasgado. O cuando hay reciclo sin estar los componentes muy acoplados
(presencia de reaccin)

39
Ecuaciones algebraicas no lineales

Newton Raphson
En lugar de la derivada emplea el jacobiano (matriz de derivadas parciales)
La estimacin del nuevo conjunto de races se computa mediante la
siguiente ecuacin:

X i 1 X i J 1 ( X i ) F ( X i )

f1 f1 f1

x1 x1,i
x2 x2,i
xn xn ,i

f 2 f 2 f 2 Cmo resolveras la ecuacin
Jacobiano J ( X ) x1 x2 xn anterior sin tener que calcular la
i x1,i x2,i xn ,i
inversa de la matriz jacobiana?


f f n f n
n
x1 x2 xn
x1,i x2,i xn ,i

40
Ecuaciones algebraicas no lineales

Newton Raphson- procedimiento de resolucin

J ( X i )( X i 1 X i ) F ( X i )

Resuelve un sistema J ( X i ) X F ( X i ) AX b
de ecuaciones lineales!

Actualiza el valor hasta que X ( X i 1 X i )


X es tan pequeo como se
haya requerido X i 1 X i X
Ventajas:
a) Buena convergencia (cuadrtica)
b) Bueno para diagramas de flujo con mucha interaccin, ya que esta interaccin se tiene en cuenta
en el Jacobiano.
Desventajas:
a) Requiere unas estimaciones iniciales buenas
b) Como las funciones no se conocen explcitamente, el Jacobiano se aproxima de forma numrica.

41
Ecuaciones algebraicas no lineales

Mtodo de Broyden
No calcula el jacobiano, lo aproxima empleando valores previos de x y f(x).
W es la aproximacin a la negativa de la inversa del jacobiano.
Es una extensin del mtodo de la secante (o mtodo quasi-Newton)

X i 1 X i W i F ( X i )

pi X i 1 X i min W i +1 - W i
y i f ( X i 1 ) f ( X i ) W i pi = y i

( p W y ) p W i
i i i iT
W i 1 W i iT
p W i yi

42
Ventajas:
Slo requiere una pasada por el diagrama de flujo en cada
Tiene en cuenta de forma aproximada la interaccin entre variables. Bueno para
diagramas de flujo con alta interaccin.
Desventajas:
Convergencia ms lenta que Newton. Necesita ms pasos que el mtodo de Newton
pero el costo computacional de cada mtodo es

Muy utilizado si el nmero de ecuaciones no es muy grande (<100)


Utilizado para convergencia de reciclos en diagramas de flujo.

Para los mtodos de Newton o Broyden es deseable escoger el mnimo nmero de variables de
corriente que rasgan todos los lazos (es decir buscar el menor nmero de ecuaciones).
Si todos los bucles estn rasgados la eleccin de las corrientes de rasgado no influye mucho en la
convergencia de estos dos mtodos.

43
Ecuaciones algebraicas no lineales

MATLAB Built in Function (1)

The built in fzero function (Optimization Toolbox) is a hybrid


method that combines bisection, secant and reverse quadratic
interpolation to a find the root of f(x) = 0

Syntax:

x = fzero(fun,x0)

X0 can be scalar or a two element vector


If x0 is a scalar, fzero tries to create its own bracket
If x0 is a two element vector, fzero uses the vector as a bracket

MATLAB Built in Function (2)

The built in fsolve function (Optimization Toolbox) is an M-file


function to solve a system of nonlinear equations:
f1 ( x1 , x 2 , , x n ) 0
f 2 ( x1 , x 2 , , x n ) 0

f n ( x1 , x 2 , , x n ) 0
Syntax:

x = fsolve(fun,x0)

x0 is a vector of initial estimate of the roots

44
Ecuaciones algebraicas no lineales

fsolve
Solve a system of nonlinear equations

for x, where x is a vector and F(x) is a function that returns a vector


value.
Syntax

x = fsolve(fun,x0) x = fsolve(fun,x0,options)
x = fsolve(fun,x0,options,P1,P2, ... )
[x,fval] = fsolve(...)
[x,fval,exitflag] = fsolve(...)
[x,fval,exitflag,output] = fsolve(...)
[x,fval,exitflag,output,jacobian] = fsolve(...)

45
ANALISIS NUMERICO

INTEGRACION NUMERICA
AGENDA

Introduccin
Mtodo Trapezoidal
Mtodo de Simpson
Mtodo Trapezoidal Compuesto
Mtodo de Simpson Compuesto
Introduccin
Si pn(x) aproxima la funcin f(x) en un intervalo de inters, puede
esperarse que al integrar pn(x) tambin aproxime la integral
correspondiente a f(x)

xn
x0
f ( x)dx est dado por el rea bajo la curva de f(x)
xn
x0
p n ( x)dx est dado por el rea bajo la curva de pn(x)

Los errores que se cometen en diferentes segmentos del intervalo


tienden a cancelarse entre s
Si la aproximacin polinomial es buena, la aproximacin de la integral
ser excelente
Mtodo Trapezoidal
Se divide el intervalo [a, b] en n intervalos de igual amplitud cuyos valores
extremos sonx x i( b a ) para quedar en x0 = a y xn = b.
i 0
n
Si n = 1, el intervalo de integracin [a, b] queda como x0 = a, x1 = b
La aproximacin polinomial de f(x) es una lnea recta y la aproximacin a la
integral es el rea del trapezoide bajo la recta.
xn
Para integrar x0 p1 ( x) dx
se eligen las diferencias finitas hacia
delante y se tiene
p1(x) = p1(x0+sh) = f(x0) + s f(x0)
Se remplaza p1(x) en la integral y se
tiene

f (x ) sf ( x0 )dx
b x1
a
f ( x)dx
x0
0
Mtodo Trapezoidal
Para integrar el lado derecho es necesario tener la integral en trminos
de la nueva variable s dada por la expresin x = x0 + sh,
La diferencial de x en trminos de s queda dx = h ds, ya que x0 y h son
constantes.
Para que los limites x0 y x1 queden en trminos de s, se sustituyen por x
en x = x0 + sh y se despeja s, lo que da respectivamente
x0 = x0 + sh de donde s = 0
x1 = x0 + sh de donde s = 1, y resulta:

f (x ) sf ( x0 )dx h f ( x ) sf ( x0 )ds
x1 1
0 0
x0 0

Al integrar se tiene
s2 f ( x0 )
h f ( x0 ) sf ( x0 )ds h sf ( x0 )
1
f ( x0 ) h f ( x0 )
1


0
0
2 2
como f(x0) = f(x0 + h) f(x0), se llega finalmente a:
h
f ( x0 ) f ( x1 )
b
a
f ( x) dx
2
que es el algoritmo del mtodo trapezoidal. Note que el lado derecho de la
ecuacin es el rea del trapezoide de altura h y lados de longitud f(x0) y f(x1)
Mtodo Trapezoidal
a) Aproxime el rea A1 bajo la curva de la funcin dada por la tabla en el
intervalo a = 500, b = 1800.
h=1800 - 500, x0 = 500, x1 = 1800
Puntos 0 1 2 3 4 5
1300
F(x) 9 13,4 18,7 23 25,1 27,2
A1 (9 23) 20800
X 500 900 1400 1800 2000 2200
2
h = 5 - 0, x0 = 0, x1 = 5
b) Aproximar
5 5
A2 0
(2 3x)dx A2
2
((2 3(0)) (2 3(5))) 47.5

c) Aproximar h = 4 - (-2), x0 = -2, x1 = 4


6
4 A3 ((1 2(2) 3(2) 2 ) 1 2(4) 3(4) 2 ) 198
A3 (1 2 x 3x )dx 2
2 2

h = /2 0, x0 = 0, x1 = /2
d) Aproximar
/2
/2 A4 ( sen(0) sen( / 2)) / 4
A4 0
sen( x)dx 2
Mtodo de Simpson
Si n = 2; el intervalo [a, b] se divide en dos sub-intervalos, se tendrn tres
abscisas dadas por x0 = a, x2 = b
ba b a 1
x1 x0 1 a (b a )
2 2 2 2
Se aproxima f(x) con una parbola, polinomio de 2do grado p2(x), la
aproximacin a la integral es el rea bajo el segmento de parbola entre
f(x0) y f(x2) como muestra la figura.
b x2
a
f ( x)dx x0
p 2 ( x)dx
x2
Para integrar x0
p 2 ( x)dx

se usa la formula de Newton en


diferencias finitas hacia adelante
para expresar p2(x)

s( s 1)
p 2 ( x) p 2 ( x 0 sh) f ( x 0 ) sf ( x 0 ) 2 f (x 0 )
2!
Mtodo de Simpson
Al sustituir p2(x) y expresar toda la integral en trminos de la nueva variable s,
queda
b x2 2
a
f ( x)dx x0
p 2 ( x)dx h p 2 ( x0 sh)ds
0

2 2 s ( s 1) 2
0
p 2 ( x0 sh)ds h ( f ( x0 ) sf ( x0 )
0 2!
f ( x0 ))ds

2
s2 s3 2 s2 2 1
h sf ( x0 ) f ( x0 ) f ( x0 ) f ( x0 ) h 2 f ( x0 ) 2f ( x0 ) 2 f ( x0 )
2 3! 4 0 3
Por definicin de la 1ra y 2da diferencia hacia adelante se tiene
f(x0) = f(x0 + h) f(x0) = f(x1) f(x0) y
2f(x0) = f(x0 + 2h) 2f(x0 + h) + f(x0) = f(x2) 2f(x1) + f(x0)

que sustituidas en la ltima ecuacin dan lugar a


h
f ( x0 ) 4 f ( x1 ) f ( x2 )
b
a
f ( x)dx
3
que es el algoritmo de Simpson.
Mtodo de Simpson
Resolver por el mtodo de Simpson el ejemplo anterior
1800 500
a) h 650
x0=500, x1= x0+h=500+650 = 1150, x2 = 1800
2
f(x0) = 9 f(x1) = 16.08 f(x2) = 23
f(x1) se obtiene interpolando con un polinomio de segundo grado
650
A2
5
(2 3x)dx A1 (9 4(16.08) 23) 20869.33
0 3
50
b) h 2.x50 = 0 x1 = 0+2.5 = 2.5 x2 = 5
2 2.5
A2 (2 3(0) 4(2 3(2.5)) 2 3(5)) 47.5
4
3
(1 2 x 3x )dx
A3 2
2

c) 4 (2) x = -2 x = -2 + 3 = 1 x = 4
h 3 A3 30(1 2(2) 1 3(2) 2 4(1 2(12) 3(1) 2 ) 1 2(4) 3(4) 2 ) 90
2 3
/2
A4
0
sen( x)dx

d) x0 = 0 x1 = 0+/4 = /4 x2 = /2
0

h 2 /4
2 4 A4 ( sen(0) 4sen( / 4) sen( / 2)) 1.0023
3
Mtodo Trapezoidal Compuesto
Cuando el intervalo es amplio, en vez de aproximar la integral de f(x) en [a,
b] por una recta, conviene dividir [a, b] en n sub-intervalos y aproximar
cada uno por un polinomio de primer grado. Una vez hecho esto, se
aplica la formula trapezoidal a cada sub-intervalo y se obtiene el rea de
cada trapezoide, de tal modo que la suma de todas ellas da la
aproximacin al rea bajo la curva f(x).

b x1 x2 xn b
I
a
f ( x)dx
a x0
p ( x)dx
1 x1
p 2 ( x)dx ...
xn 1
p n ( x)dx

donde pi(x) es la ecuacin de la recta que pasa por los puntos (xi-1, f(xi-1)), (xi, f(xi)).
Mtodo Trapezoidal Compuesto
Entonces puede escribirse como sigue

x1 x0 x x1 x xn1
I ( f ( x0 ) f ( x1 )) 2 ( f ( x1 ) f ( x2 )) ... n ( f ( xn1 ) f ( xn ))
2 2 2

Si todos los sub-intervalos son del mismo tamao h, esto es, si xi+1 - xi = h, para i =
0, 1, , (n-1), entonces la ecuacin anterior puede anotarse as

h
I ( f ( x0 ) 2 f ( x1 ) 2 f ( x2 ) ... 2 f ( xn1 ) f ( xn ))
2
Que puede escribirse con la notacin de sumatoria como sigue
n 1
h
I ( f ( x0 ) 2 f ( xi ) f ( xn ))
2 i 1
Mtodo Trapezoidal Compuesto
Aproximar el rea bajo la curva de la funcin dada en forma tabular, entre
x = -1 y x = 4.

Puntos 0 1 2 3 4 5
X -1 0 1 2 3 4
F(x) 8 10 10 20 76 238

Tomando todos los puntos de la tabla, se puede aplicar cinco veces el


mtodo trapezoidal. Como todos los intervalos son del mismo tamao (h
= 1), se usa la ecuacin directamente

1
A (8 2(10 10 20 76) 238) 239
2
Mtodo de Simpson Compuesto
Como para cada aplicacin de la regla de Simpson se requieren dos sub-
intervalos, a fin de aplicarla n nmero de veces, se divide el intervalo [a,
b] en un nmero de sub-intervalos igual a 2n.

Cada par de sub-intervalos se aproxima por un polinomio de segundo grado


(parbola), de tal manera que la suma de las reas bajo cada segmento de
parbola sea la aproximacin a la integracin deseada.
b x2 x4 x n b
I
a
f ( x)dx
a x0
p ( x)dx p 2 ( x)dx ...
1 x2 xn 2
p n ( x)dx
Mtodo de Simpson Compuesto
donde pi(x), i = 1, 2,..., n, es el polinomio de segundo grado que pasa por
tres puntos consecutivos. Al sustituir la ecuacin de Simpson en cada uno
de los sumandos se tiene

h1 h2
I ( f ( x0 ) 4 f ( x1 ) f ( x2 )) ( f ( x2 ) 4 f ( x3 ) f ( x4 )) ...
3 3
hn
( f ( xn2 ) 4 f ( xn1 ) f ( xn ))
3
Donde
h1 = x1 - x0 = x2 - x1
h2 = x3 - x2 = x4 - x3
.
hn = xn-1 - xn-2 = xn xn-1
Mtodo de Simpson Compuesto

Si h1 = h2 = = hn, la ecuacin anterior queda como sigue

h h
I ( f ( x0 ) 4 f ( x1 ) f ( x2 )) ( f ( x2 ) 4 f ( x3 ) f ( x4 )) ...
3 3
h
( f ( xn2 ) 4 f ( xn1 ) f ( xn ))
3
Usando la notacin de sumatoria queda de la siguiente manera
n 1 n2
h
I ( f ( x0 ) 4 f ( xi ) 2 f ( xi ) f ( x n ))
3 i 1 i 2
i 2 i 2

Donde i significa el incremento de i


Mtodo de Simpson Compuesto
Aproximar el rea bajo la curva del ejemplo anterior. Con los puntos dados
de la tabla, se puede aplicar la regla de Simpson dos veces; una vez con
los puntos (0), (1) y (2) y otra con los puntos (2), (3) y (4). Como la
integracin debe hacerse de x = -1 a x = 4, se integra entre los puntos (4)
y (5) con el mtodo trapezoidal y la suma ser la aproximacin buscada:
a) Mtodo de Simpson aplicado dos veces: h1 = h2 = h3 = h4 = 1, entonces
puede usarse la ecuacin de Simpson

1
A1 (8 4(10 20) 2(10) 76) 74.666
3
b) Mtodo trapezoidal aplicado a los puntos (4) y (5)

1
A2 (76 238) 157
2
por lo tanto, la aproximacin al rea es A = 74.666 + 157 = 231.666
Balance de Materiales en
Yacimientos de Gas y Gas
Condensado
Contenido

Gases Ideales
Gases Reales
Yacimientos de Gas y Gas Condensado
Analisis PVT
Balance de Materiales para Yacimientos de Gas
Balance de Materiales para Yacimientos de Gas Condensado
Gases Ideales
Volmenes iguales de diferentes gases ideales a la mismas condiciones P-
T contienen el mismo nmero de molculas
Moles: nmero de unidades de peso del componente igual a su peso
molecular. 1 lbmol de O2 es igual a 32 lbs de oxgeno
Un mol de cualquier gas ideal contiene el mismo nmero de molculas y
ocupa el mismo volumen a las mismas condiciones de P-T
El estado de un gas esta definido por p, V y T: Segn Boyle, Charles y
Avogadro:

pV p2V2
1 1

T1 T2

Presin abosulta = presin manomtrica + presin atmosfrica


Temperatura absoluta: R = F + 460
Ley de Gases Ideales
pV
nR
T
R 10.73 psi.ft3/lbmol.R

Las condiciones normales estn generalmente definidas como 14.7 psi y


60 F
1 mol de cualquier gas ideal a condiciones normales ocupa un volumen de
379 ft3 o 22.4 l
Gases Reales
A condiciones de yacimiento, los gases se desvian del comportamiento
ideal. El estado de un gas a tales condiciones esta definido a traves de la
ecuacin de estado (Van der Waals EoS):
a
p V 2 V b nRT

El termino a/V2 toma en cuenta las fuerzas intermoleculares reduciendo
la cantidad de movimiento de las particulas
El trmino b considera el volumen molecular de los gases
Otras EoS son: Radlich-Kwong, Peng-Robinson
Un mtodo alternativo para manejar el comportamiento no ideal esta
basado en el factor z:

Vr @ P T
z
Vi @ P T
Gases Reales
pVi nRT
Vr
p nRT
z
pVr znRT
El factor z es funcion de la presion y temperatura. Tipicamente, z=z(p), si
suponemos condiciones de agotamiento isotermico
Medicin de z

p=14.7 psi pyac

Vo
V

14.7Vo=nRT pVo=znRT

pV
z p
14.7Vo
Metodo
Grfico
Standing-
Katz
Ajuste Hall-Yarborogh

Tsc Tsc
2

psr exp 1.2 1


T T
zg 0.06125
Y

Referencias:

Hall, K.R., and Yarborough, L. A New Equation of State for Z


Factor Calculations The Oil and Gas Journal, June 18, 1973, pp
82-92
Yarborough, L., and Hall, K.R., How to Solve Equation of State
for Z-Factor, The Oil and Gas Journal, February 18, 1974, pp
86-88
Diagrama P-T
A B
Liquido Gas
C

80%

p [psi] 60%

40%
20%

Liquido+Gas
A: gas condensado
B: gas seco

T [F]
Diagrama P-T
Analisis PVT: Tipos de Muestras
Superficie: recombinacin de muestra del separador
Cabezal
Fondo: p<pdew
q g sep , g sep
q gtk , gtk

qc
q g sep
RGC sep
q c B o sep
Analisis PVT: Pruebas
Prueba CCE (Constant Composition Expansion)
p1>pdew p2=pdew P3<pdew p4<p3

Prueba CVD (Constant Volume Depletion)


Zi, Vg Zi, Vg
p1=pdew p2<pdew p2 p3<p2 p3

Vc Vc
Analisis PVT: Equipos
PDVSA-Intevep

Heriot-Watt University (http://www1.pet.hw.ac.uk/eiero)


GOES: Gas Original en Sitio

Vb 1 Swi
G
Bgi
Gas: EBM
cw Swi cf
GpB g WpBw G Bg - Bgi Bgi p We
1- Swi

zT
Bg vol gas en yac [bbl] Bg 0.00504 [bbl/SCF]
vol gas en sup [SCF] p

F G Eg Efw We

F GEt We
Mtodo Havlena-Odeh

F We GEt F-We
G

Et

F We F
G Et
1

Et Et
G
We
Et
Mtodo p/z

p p i G peq

C 1
z zi G p
C
z
cw Swi cf
C 1- p
1- Swi Gpeq G
w
Gpeq Gp 132800Wp [SCF]
Mw

C 1 reduccin Vp y expansin del Swi son despreciables


C 1 presin anormal
Propiedades del Gas Natural y
Gas Condesado
Ley de gases reales

pV znRT

FVF del gas

zT
Bg 0.00504 [bbl/SCF]
p
zT
Bg 0.02829 [ft3/SCF]
p
Compresibilidad Isotrmica

La Ley de gases reales es:


z
V nRT
p
Derivando con respecto a la presin obtenemos:

dV 1 dz
nRT 2
p z
dp p dp
1 dV 1 dz 1

V dp z dp p
1 dV 1 1 dz
cg
V dp p z dp
En el caso que z=1 (gas ideal):
1
cg
p
Definicin del Modelo Composicional

Zi: fraccin molar de cada componente en la corriente total


V: fraccin molar total en la fase gaseosa
L: fraccin molar total en la fase lquida
nc: nmero de componentes
ni: moles totales del componente i
niV: moles totales de componente i en la fase gaseosa
niL: moles totales de componente i en la fase lquida
n: moles totales
Relaciones
nc
n ni
i 1
nc nc
n L n iL nV n iV
i 1 i 1

ni n iL n iV
zi xi yi
n nL nV

z i Lx i Vy i
n n
L L V V
n n
L V 1
nc nc nc


i
zi xi y i
1 i i
1 1
Composicin Molecular

ZN i n gc Yi n g X i nc
ng, Yi
i
Zi
1
1
N


i
Yi
1
1
N

nc, Xi
i
Xi
1
1
Peso Molecular

En base a la composicin

Mg MiYi
Mc Mi X i
i

Mgc Mi Zi
i

En base a la gravedad especfica


Mg 28.96 g

Mgc 28.96 gc

44.29 c 6084
Mc
1.03 - c API - 5.9
A B

Gas Condensado
Liquido Gas
C
ujeo
burb

80%

p [psi] 60%

40%
20%

Liquido+Gas

cio
ro
T [F]

Vc (%)

pdew pi
Gas Condensado, p>pdew
Vc=0, no hay condensacin retrgrada
Metodos de recombinacin
basado en RGC
basado en Zi del separador de alta presin

Procedimiento (1,2 y 3 son comunes para ambos mtodos):


1. Calcular Mgc y gc en base a la RGC o Zi
2. Calcular Tsc y psc
3. Calcular zgc de Standing-Katz (zgc=f(Tsr,psr))
Mtodo basado en RGC Mtodo basado en Zi del separador

zT zT
4. Bg 0.02829 4. Bg 0.02829
p p

Vb 1 Swi Vb 1 Swi
5. GCOES 5. GCOES
Bgci Bgci
qgsep
RGC nG 379.4qc Bosep
6. fg 6. fg
c nG nL qgsep
RGC 132800 350 L
Mc 379.4qc Bosep ML

7. GOES GCOES fg 7. GOES GCOES fg

MLsep
8. COES
GOES
RGC
8. COES
GCOES
379.4
1 fg B
Lsep osep
Gas Condensado, p<pdew
Vc>0, hay condensacin retrgrada
Mtodos
F(p/zgc)
p/z2F
Prueba CVD
Mtodo F(p/zgc)

p pi ,T
p i ,T
n p ,g G p sep
ni n rem ,g
n p ,c N c ,W p
n rem ,c

n p n i n rem
G peq
np
379.4
G
ni
379.4
1 V c p V c c
n rem V b 1 S wi C
z gc RT Mc
Mtodo F(p/zgc)

G peq V 1 S wi C 1 V c p V c c
1 379.4 b
G G z gc RT Mc
p V c c p i G peq
1 Vc CRT 1
z gc Mc z gci G

p
F
z gc

p
F 1 Vc p Vc c CRT

z gc z gc Mc

p p i G peq
F
z 1 G
z gc gci
Mtodo F(p/zgc)

p p i G peq
F 1
z G
z gc gci

p
F

z gc

G peq
G

p: [psi], Vc: [fraccion], c: [lbm/ft3], Mc: [lbm/lbmol], T: [R], R=10.73 [(psi*ft3)(lbmol*R)]


Si p>pdew Vc=0 p p G
C i 1- peq
zgc zgci G

p p Vc c
Si C=1 F
z
1- Vc RT
gc zgc Mc

p p
Si p>pdew, C=1 F
z
gc zgc
Prueba CVD

Zi, Vg, Vc, zgc medidos a cada paso de presin

Procedimiento:
1. Calcular el volumen de gas condensado producido

Gp 379.4
V p Vph
zgc RT VceldaPVT

2. Calcular GPM del gas producido


1000 n Mi Zi
GPMC3
379.4 i 3 Li
4. Volumen de condensado producido
1 1
Nc GpGPMC3
2 42

5. Volumen de gas producido

1 n
Gps Gp ZC1 ZC2 Zi
2 i 3

6. Vph pini 1 n
GOES 379.4 Z
zgcini RT 1
C ZC2 Z
2 i 3 ini
i

Vph pini 1 GPMC3


7. COES 379.4
zgcini RT 2 42 ini
Correlaciones de Eaton-Jacobi

Ln GOES 4.5484 0.0831Ln RGC 0.4265Ln p


-0.3185Ln T

Ln COES 2.6098 0.9040Ln RGC 0.4894Ln p


-0.3008Ln T 0.2924Ln API

RGC: [SCF/STB], p: [psi], T: [F], GOES:[MSCF/Vph], COES:[STB/Vph],


Vph:[MMSCF]
Factor de Compresibilidad Bifasico: z2F

p<pdew
pVg
zgc
ng RT
gas
Vg, ng
p Vg Vc
condensado

z2F
ng nc RT

condensado
retrogrado
Vc, nc

zgcini p
de la prueba CVD se puede determinar z2F: z2F
Gpeq
pini 1
G

Gas Condensado: EBM
c S cf
Gpeq B2F W p Bw G B2F B2Fi B2Fi w w i p We
1 Sw i
c
Gpeq Gp 132800Nc
Mc

z2 F T
B2F 0.00504
p

F G E 2F Efw We

F GE t We
GRACIAS
POR SU ATENCION

Das könnte Ihnen auch gefallen