Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Resolucin numrica de
Ecuaciones en Derivadas Parciales
ndice
Introduccin a las EDP
Resolucin de ecuaciones parablicas
Por diferencias adelantadas
Por diferencias atrasadas
El mtodo de Crank-Nicolson
Resolucin de ecuaciones hiperblicas
Resolucin de ecuaciones elpticas
Mtodo de las diferencias finitas
Mtodo de los Elementos Finitos
Resolucin de EDP no lineales
Ecuaciones en Derivadas Parciales 3/61
@u @u @ 2u @ 2u
F .x1; : : : ; xn; u; @x ; : : : ; @x ; @x @x ; @x @x ; : : :/ D 0.
1 n 1 1 1 2
Una solucin de una EDP es una funcin que resuelve la ecuacin, o que la
convierte en una identidad cuando se sustituye en la ecuacin.
@2 u
uxx D 2 .x; y/:
@x
1
Por Karl Hermann Amandus Schwarz, Prusia 1843-Alemania 1921.
6/61
Ejemplos de EDP
2 2
Una EDP no lineal de primer orden: ux C uy D 0.
de las de segundo orden con dos variables independientes, con esta forma
Auxx C Buxy C C uyy C F ux ; uy ; u; x; y D 0:
Parablica si B 2 4AC D 0:
Hiperblica si B 2 4AC > 0:
Elptica si B 2 4AC < 0:
0 x
a b
Figure 8.1 Mesh for the Finite Difference Method. The lled circles represent known
Los puntos slidos son conocidos: definen las condiciones iniciales y de
initial and boundary conditions. The open circles represent unknown values that must be
contorno; los puntos huecos los que calcular el procedimiento.
determined.
El problema continuo
its approximation at (xse
i , tconvierte as
j ) by wij . Let M en
and uno
N be discreto con un
the total number nmero
of steps in the xfinito
and t de
directions,
ecuaciones and let ho=no
lineales, a)/M and k = T /N be the step sizes in the x and t directions.
(b lineales.
The discretization formulas from Chapter 5 can be used to approximate derivatives in
11/61
queda
D 1
wiC1;j 2wij C wi 1;j wi;j C1 wij ;
h2 k
con un error de truncamiento local dado por O.k/ C O.h2/.
j+1
i1 i i+1
Las condiciones de contorno y las iniciales dan valores a wi0; i D 0; : : : ; M y 13/61
w0j y wMj ; j D 0; : : : ; N .
La matriz A es m m, donde m D N 1.
Dk
Se puede probar que el mtodo es estable si, para D > 0, h2
< 12 .
16/61
function w=heatbd(xl,xr,yb,yt,M,N)
% Ecuacin del calor por diferencias avanzadas
% Entrada: [xl,xr], tiempo[yb,yt], pasos M, tiempos N
f=@(x)sin(2*pi*x).^2;
l=@(t)0*t;
r=@(t)0*t;
D=1;
h=(xr-xl)/M; k=(yt-yb)/N; m=M-1; n=N;
sigma=D*k/h/h;
a=diag(1+2*sigma*ones(m,1))+diag(-sigma*ones(m-1,1),1);
El programa anterior: a=a+diag(-sigma*ones(m-1,1),-1);
lside=l(yb+(0:n)*k); rside=r(yb+(0:n)*k);
w(:,1)=f(xl+(1:m)*h);
for j=1:n
w(:,j+1)=a\(w(:,j)+sigma*[lside(j); zeros(m-2,1); rside(j)]);
end
w=[lside; w; rside];
x=(0:m+1)*h; t=(0:n)*k;
mesh(x,t,w)
view(60,30);axis([xl xr yb yt -1 1])
end
18/61
0.5
-0.5
-1
0
0.2
0.4
1
0.6 0.8
0.6
0.8 0.4
0.2
1 0
El mtodo CrankNicolson
Este mtodo formulado en 1947 por John Crank, Reino Unido, 1916-2006, y
Phyllis Nicolson, Reino Unido, 1917-1968 es una combinacin de los dos
anteriores, explcito e implcito, con un error O.h2/ C O.k 2/.
Haciendo otra vez D Dk= h2, la ecuacin del calor se puede reordenar as
h i
al Differential 2wi;j 1 D wi C1;j
2wijEquations 2wij C wi 1;j C wi C1;j 1 2wi;j 1 C wi 1;j 1 ,
oorbien
ww +C
i 1;j
i1,j +C
(2 .2 22/w
)wij ij w Dw
i C1;j =
wi+1,j wi1,j 1C
i 1;j 1 +.2
(2 2/w
2 )w C+
i;ji,j11 wi C1;j 1 , 1 ,
wi+1,j
lo que leads
which llevatoa the
la grfica
templatede nudos
shown afectados
in Figure 8.7. de esta figura.
j+1
i1 i i+1
Figure 8.7 Mesh points for CrankNicolson Method. At each time step, the open circles
are the unknowns and the lled circles are known from the previous step.
T
21/61
donde 22 C 2 0 0
3
::: ::
6 2 C 2 : 7
AD6 ::: 7;
0 2 C 2 0
4 :: ::: ::: :::
5
:
0 0 2 C 2
y
22 2 0 0
3
::: ::
6 2 2 : 7
BD6 ::: 7:
0 2 2 0
4 :: ::: ::: :::
5
:
0 0 2 2
r=@(t)0*t;
D=1;
0.5
h=(xr-xl)/M; k=(yt-yb)/N; m=M-1; n=N; close all
sigma=D*k/h/h;
a=diag(2+2*sigma*ones(m,1))+diag(-sigma*ones(m-1,1),1);
0
a=a+diag(-sigma*ones(m-1,1),-1);
b=diag(2-2*sigma*ones(m,1))+diag(sigma*ones(m-1,1),1);
b=b+diag(sigma*ones(m-1,1),-1); -0.5
lside=l(yb+(0:n)*k); rside=r(yb+(0:n)*k);
w(:,1)=f(xl+(1:m)*h);
for j=1:n -1
sides=[lside(j)+lside(j+1); zeros(m-2,1); rside(j)+rside(j+1)]; 0
w(:,j+1)=a\(b*w(:,j)+sigma*sides); 0.2
end 0.4
1
w=[lside; w; rside]; 0.6 0.8
x=(0:m+1)*h; t=(0:n)*k; 0.6
0.8 0.4
mesh(x,t,w) 0.2
1 0
view(60,30);axis([xl xr yb yt -1 1])
end El mtodo es estable para cualesquiera h > 0 y k > 0,
con D > 0.
23/61
u t t D c 2uxx
0 x
a b
Figure 8.1 Mesh for the Finite Difference Method. The lled circles represent known
Los puntos son .xi ; tj /,conditions.
initial and boundary
dondeThexiopen D circles
a Crepresent j D j values
ih y tunknown k, con pasos h y k.
that must be
determined. a la solucin u.xi ; tj / se representa mediante wij .
La aproximacin
Para discretizar la ecuacin de onda u t t D c 2uxx las segundas derivadas se 25/61
2
2
wi1 D 1 wi0 C kg.xi / C wi 1;0 C wi C1;0 ;
2
que es donde entra la informacin de la velocidad inicial g.x/.
La ecuacin de inicio es
2 3
w00
w11 w10 g.x1 / 6 0 7
2 3 2 3 2 3
4 :: 5 D A 4 :: 5 C k 4 :: 5 C 6 ::: 7 :
: 1 : : 1 2
6 7
2 2 6 7
wm1 wmo g.xm / 4 0 5
wmC1;0
ED ru:
Figure 8.12 Mesh for nite difference solver of Poisson equation with Dirichlet b
con M D m 1 intervalos en laconditions.
direccin horizontal
(a) Original y NwithDdouble
numbering system n subscripts.
1 en (b)vertical.
Numbering syste
(8.39) for linear equations, with single subscripts, orders mesh points across rows.
34/61
Las ecuaciones en los wij son lineales por lo para determinarlos hay que
construir un sistema de mn incgnitas con una matriz A mnmn.
35/61
wmn vmn
yt
x y Coeficiente nmero q
i j i C .j 1/m
i C1 j i C 1 C .j 1/m
i 1 j i 1 C .j 1/m
i j C1 i C jm
i j 1 i C .j 2/m
1.8
1.6
1.4
1.2
0.8
0.6
0.4
0.2
0
2
1.8 1
1.6 0.8
1.4 0.6
0.4
1.2
0.2
1 0
39/61
1.2
0.8
0.6
0.4
0.2
-0.2
1
0.8 1
0.6 0.8
0.4 0.6
0.4
0.2
0.2
0 0
40/61
Seguiremos el principio de actuacin del mtodo2 de Galerkin aplicado a la carefully, because we will be using this material during the entire course.
42/61
1.1 The physical domain
ecuacin elptica con las condiciones de Dirichlet que siguen The first thing we have to describe is the geometry (the physical setting
You have a sketch of it in Figure 1.1.
SD
SN
donde la solucin, u.x; y/, se define sobre una regin R en un plano limitado Figure 1.1: The domain and the Dirichlet and Neumann bou
por una borde o frontera S, continua por tramos de Dirichlet y Neumann. is a closed polygonal curve . (There is not much difference if we suppo
Si las funciones 1.x; y/; 2.x; y/; : : : ; P .x; y/ son una base del subespacio
L2.R/, la condicin de ortogonalidad tiene esta forma
u C ru f p dx dy D 0
R
o
u C ru p dx dy D f p dx dy;
R R
para cada 1 p P . A esta forma se le denomina forma dbil de la ecuacin
elptica.
44/61
La derivada direccional es @u
@n
D ru n x y , donde .nx ; ny / es el vector
; n
unitario normal hacia afuera en la frontera S de R.
@u
Z
p dS ru rp dx dy C rup dx dy D f p dx dy: (1)
S @n R R R
3
La funcin v se denomina de prueba.
45/61
P P
s ! s ! s
X X
vq rq rp dx dy C r vq q p dx dy D f p dx dy
R qD1 R qD1 R
46/61
P
i !
Z
vq rq rp dx dy rq p dx dy D f p dx dy;
R R R
qD1
y
s
bp D f p dx dy
R
functions of x, y that live on triangles in the plane. For concreteness, let the region R
rectangle, and form a triangulation with nodes (x , yj ) chosen from a rectangular grid.
Qu funciones explcitas se pueden elegir para losi elementos finitos p ?
will reuse the M N grid from the previous section, shown in Figure 8.16(a), where
47/61
set m = M + 1 and n = N + 1. As before, we will denote the grid step size in the x an
directions as h and k, respectively. Figure 8.16(b) shows the triangulation of the rectang
Utilizaremos B-splines lineales4 por tramos basadas en tringulos en un plano.
region that we will use.
Aqu se ve una triangularizacin de la regin R rectangular mallada M N .
Figure 8.16 Finite element solver of elliptic equation with Dirichlet boundary conditions.
(a) Mesh is same as used for nite difference solver. (b) A possible triangulation of the region. Ea
Esta triangularizacin .m D M C 1; n D N C 1/ da lugar a P D mn funciones
interior point is a vertex of six different triangles.
lineales for tramos, p , cada una de las cuales toma el valor 1 en un punto de la
malla y 0 en los mn 1 restantes.
4
Recordemos, las B-splines (basis splines) son curvas hechas con trozos polinmicos de grado p .
48/61
Cada p .x; y/ es derivable, excepto en los bordes o aristas de los tringulos, por
lo que son funciones de L2.R/ integrables de Riemann.
Para ello, si definimos el baricentro de una regin del plano como el punto
N y/
.x; N donde
x dx dy y dx dy
xN D R ; yN D R :
R 1 dx dy R 1 dx dy
Si R es un tringulo de vrtices .x1; y1/, .x2; y2/ y .x3; y3/ su baricentro es
x1 C x2 C x3 y1 C y2 C y3
xN D ; yN D :
3 3
Tendremos en cuenta que el valor medio de una funcin lineal L.x; y/ en una
regin
N y/,
plana R es L.x; N el valor en el baricentro. En otras palabras,
R L.x; y/ dx dy D L.x;N y/
N rea.R/.
50/61
El desarrollo en serie de Taylor de una funcin de dos variables dice que
@f @f
f .x; y/ D f .x;
N y/
N C @x
N y/.x
.x; N N C
x/ @y
N y/.y
.x; N N
y/
2 2
CO .x N ; .x
x/ N
x/.y N .y
y/; N
y/
N 2 ; .x N 2 :
D L.x; y/ C O .x x/ N
x/.y N .y
y/; y/
En consecuencia,5
N 2 ; .x N 2 dx dy
f .x; y/ dx dy D L.x; y/ dx dy C O .x x/ N
x/.y N .y
y/; y/
R R R
cumplen que 1.x1; y1/ D 1, 1.x2; y2/ D 0, 1.x3; y3/ D 0, 2.x1; y1/ D 0,
2.x2; y2/ D 1 y 2.x3; y3/ D 0 y f .x; y/ es una funcin continua y derivable
dos veces, con " #
1 1 1
d D det x1 x2 x3
y1 y2 y3
entonces
a/ el tringulo T tiene un rea igual a jd j=2
b/ r1 .x; y/ D y2 d y3 ; x3 d x2
.x2 x3 /2 C .y2 y3 /2
c/ r1 r1 dx dy D
T 2jd j
.x1 x3 /.x2 x3 / .y1 y3 /.y2 y3 /
d/ r1 r2 dx dy D
T 2jd j
4
e/ f 1 2 dx dy D f .x;N y/jd
N j=18 C O.h / D f 12 dx dy
T T
f/ f 1 dx dy D f .x; N j=6 C O.h4 /;
N y/jd
T
N y/
donde .x; N es el baricentro de T y h D dime.T /.
Para obtener A, consideremos el .xi ; yj / en el interior en Equations
8.3 Elliptic esta figura
| 411 hexagonal
52/61
5
(xi 1,y j ) 6 4 (xi+1,y j )
1 3
(xi 1,y j 1) 2 (xi ,y j 1)
8.17 Detail of the (i, j) interior point from Figure 8.16(b). Each interior point (xi , yj )
que no est enFigure
la frontera S del rectngulo mallado considerado. Est rodeado
is surrounded by six triangles, numbered as shown. The B-spline function i+(j1)m is linear,
de seis tringulos. Lavalue
takes the funcin B-spline
1 at the center, iC.j
and is zero outside of thesees
1/m
triangles. y toma el valor 1 en el
six lineal
De la misma forma,
k hk
Ai C.j 1/m;i 1C.j 1/m D h 18
r.B 6 / C r.B1 /
hk
Ai C.j 1/m;i 1C.j 2/m D 18
r.B1 / C r.B2 /
h hk
Ai C.j 1/m;i C.j 2/m D k 18
r.B 2 / C r.B3 /
k hk
Ai C.j 1/m;i C1C.j 1/m D h 18
r.B 3 / C r.B4 /
hk
AiC.j 1/m;i C1Cj m D 18
r.B4 / C r.B5 /
k hk
Ai C.j 1/m;i Cj m D h 18
r.B5 / C r.B6 /
54/61
Para los elementos finitos en la frontera, i C.j 1/m no pertenece a L20.R/ por lo
que se usan Ai C.j 1/m;iC.j 1/m D 1 y bi C.j 1/m D g.xi ; yj / para garantizar la
condicin de Dirichlet vi C.j 1/m D g.xi ; yj / en el punto frontera .xi ; yj /.
55/61
1.5
0.5
0
2
1
0.8
1.5 0.6
0.4
0.2
1 0
1.5
0.5
0
2
1
0.8
1.5 0.6
0.4
0.2
1 0
57/61
u t C uux D Duxx ;
0 x
a b
Figure 8.1 Mesh for the Finite Difference Method. The lled circles represent known
Los puntosinitial
slidos son los
and boundary queThedefinen
conditions. lasrepresent
open circles condiciones iniciales
unknown values that must y
be de contorno
determined.
(conocidos); los huecos, los que calcular el mtodo.
its approximation at (xi , tj ) by wij . Let M and N be the total number of steps in the x and t
Si wij es directions,
la aproximacin
and let h = (bde la solucin
a)/M and k = T en
/N be.xthei ; step
tj /,sizes
aplicando
in the x anddiferencias
t directions.
The discretization formulas from Chapter 5 can be used to approximate derivatives in
a xuand
atrasadas the i yt centradas en los applying
directions. For example, otros trminos de u t Cformula
the centered-difference uux DforDuthe xx se tiene
second que
derivative to the x variable yields
wij wi;j 1 wiC1;j wi 1;j D
k
C w ij 1 2h D h2
w i C1;j 2w ij C w i 1;j :
uxx (x, t) 2 (u(x + h, t) 2u(x, t) + u(x h, t)), (8.4)
h
with error h2 uxxxx (c1 , t)/12; and the forward-difference formula for the rst derivative
59/61
Reordenando,
h
wij C 2h wij wi C1;j wi 1;j wi C1;j 2wij C wi 1;j wi;j 1 D 0;
F .z ; : : : ; z / D z l.tj / D 0
las ecuaciones 1 y m son F 1.z1; : : : ; zm/ D z1 r.tj / D 0:
m 1 m m
function w=Burgers(xl,xr,tb,te,M,N)
% Ecuacin de Burges; diferencias atrasadas; In [xl,xr], tiempo[tb,te], M, N
alfa=5; beta=4; D=0.05;
f=@(x) 2*D*beta*pi*sin(pi*x)./(alfa+beta*cos(pi*x));
l=@(t) 0*t; r=@(t) 0*t;
m=M+1; n=N; close all
h=(xr-xl)/M; k=(te-tb)/N; sigma=D*k/h/h;
w(:,1)=f(xl+(0:M)*h); w1=w;
for j=1:n
for it=1:4
DF1=diag(1+2*sigma*ones(m,1))+diag(-sigma*ones(m-1,1),1);
El cdigo que lo hace es: DF1=DF1+diag(-sigma*ones(m-1,1),-1);
DF2=diag([0;k*w1(2:m-1)/(2*h)],1)-diag([k*w1(2:m-1)/(2*h);0],-1);
DF=DF1+DF2;
F=-w(:,j)+(DF1+DF2/2)*w1;
DF(1,:)=[1 zeros(1,m-1)]; DF(m,:)=[zeros(1,m-1) 1];
F(1)=w1(1)-l(j); F(m)=w1(m)-r(j);
w1=w1-DF\F; % Newton-Raphson
end
w(:,j+1)=w1;
end
x=xl+(0:M)*h; t=tb+(0:n)*k; mesh(x,t,w)
end