Está en la página 1de 10

EJEMPLO

Considere el problema de determinar la distribucin de calor en estado estable, en


una placa cuadrada metlica delgada, con las dimensiones 0.5 m por 0.5 m.
Conservamos dos fronteras adyacentes a 0C , mientras el calor en las otras dos
fronteras aumenta linealmente de 0C en una esquina a 100C en el sitio donde
ambos lados se encuentran. Si ponemos los lados con las condiciones de frontera
cero a lo largo de los ejes x y y el problema se expresa as

2 2
(, ) + (, ) = 0
2 2

Para ( x, y ) en el conjunto R {( x, y ) / 0 x 0.5,0 y 0.5} , con las condiciones de


frontera u (0, y ) 0, u ( x, 0) 0, u ( x, 0.5) 200 x, u (0.5, y ) 200 y ,m=n=4.

Desarrollo

1 Analizar el ejercicio

2 2
(, ) + (, ) = 0 Ecuacin de Lapace
2 2

0 0.5
0 0.5

(, ) = 1() = 0
(, ) = 2() = 200
(, ) = 3() = 0
(, ) = 4() = 200

0.5 0
= , = 0.125
4

0.5 0
= = 0.125
4
2 Aplicamos el algoritmo

2 2
2 [( ) + 1] , (+1, + 1, ) ( ) (,+1 + ,1 ) = 2 ( , 1 )

Reemplazando los valores el algoritmo se reduce
(i,j) 4, +1, 1, ,+1 ,1 = 0

4, +1, 1, ,+1 ,1 = 0
41,1 2,1 0,1 1,2 1,0 = 0
(1,1)
41,1 2,1 0 1,2 0 = 0
41,1 1,2 2,1 = 0
4, +1, 1, ,+1 ,1 = 0
42,1 3,1 1,1 2,2 2,0 = 0
(2,1)
42,1 3,1 1,1 2,2 0 = 0
1,1 + 42,1 2,2 3,1 = 0
4, +1, 1, ,+1 ,1 = 0
43,1 4,1 2,1 3,2 3,0 = 0
(3,1)
43,1 25 2,1 3,2 0 = 0
2,1 + 43,1 3,2 = 25
4, +1, 1, ,+1 ,1 = 0
41,2 2,1 0,2 1,3 1,1 = 0
(1,2)
41,2 2,1 0 1,3 1,1 = 0
1,1 + 41,2 1,3 2,1 = 0

4, +1, 1, ,+1 ,1 = 0
(2,2)
1,2 2,1 + 42,2 2,3 3,2 = 0

4, +1, 1, ,+1 ,1 = 0
2,2 3,1 + 43,2 3,3 4,2 = 0
(3,2)
2,2 3,1 + 43,2 3,3 50 = 0
2,2 + 43,2 3,1 3,3 = 50
4, +1, 1, ,+1 ,1 = 0
41,3 2,3 0,3 1,4 1,2 = 0
(1,3)
41,3 2,3 0 25 1,2 = 0
1,2 + 41,3 2,3 = 25
4, +1, 1, ,+1 ,1 = 0
42,3 3,3 1,3 2,4 2,2 = 0
(2,3)
42,3 3,3 1,3 50 2,2 = 0
1,3 2,2 + 42,3 3,3 = 50
4, +1, 1, ,+1 ,1 = 0
43,3 4,3 2,3 3,4 3,2 = 0
(3,3)
43,3 75 2,3 75 3,2 = 0
2,3 3,2 + 43,3 = 150
3 Organizamos nuestras ecuaciones

41,1 1,2 2,1 = 0


1,1 + 42,1 2,2 3,1 = 0
2,1 + 43,1 3,2 = 25
1,1 + 41,2 1,3 2,1 = 0
1,2 2,1 + 42,2 2,3 3,2 = 0
2,2 + 43,2 3,1 3,3 = 50
1,2 + 41,3 2,3 = 25
1,3 2,2 + 42,3 3,3 = 50
2,3 3,2 + 43,3 = 150
1,1
4 1 0 1 0 0 0 0 0 0
1 4 1 0 1 0 0 0 0 2,1 0
0 1 4 0 0 1 0 0 0 3,1 25
1 1 0 4 0 0 1 0 0 1,2 0
0 1 1 0 4 0 1 1 0 2,2 = 0
0 0 1 0 1 4 0 0 1 3,2 50
0 0 0 1 0 0 4 1 0 1,3 25
0 0 0 0 1 0 1 4 1 2,3 50
(0 0 0 0 0 1 0 1 4 ) (3,3 ) (150)

1,1 4.7414
2,1 10.7759
3,1 17.9310
1,2
8.1897
2,2
3,2 20.4310
1,3 35.9483
2,3 17.2414
(3,3 ) 35.7759
55.4310
Programa N 1 poisson(f,g,bx0,bxf,by0,byf,D,Mx,My,tol,MaxIter)
function [u,x,y] = poisson(f,g,bx0,bxf,by0,byf,D,Mx,My,tol,MaxIter)
%solve u_xx + u_yy + g(x,y)u = f(x,y)
%over the region D = [x0,xf,y0,yf] = {(x,y)|x0 <= x <= xf, y0 <= y <= yf}
% with the boundary Conditions:
% u(x0,y) = bx0(y), u(xf,y) = bxf(y)
% u(x,y0) = by0(x), u(x,yf) = byf(x)
%Mx=#ofsubintervals along x axis
%My=#ofsubintervals along y axis
% tol : error tolerance
% MaxIter: the maximum # of iterations
x0 = D(1); xf = D(2); y0 = D(3); yf = D(4);
dx = (xf - x0)/Mx; x = x0 + [0:Mx]*dx;
dy = (yf - y0)/My; y = y0 + [0:My]'*dy;
Mx1=Mx+1;My1=My+1;
%Boundary conditions
for m = 1:My1, u(m,[1 Mx1])=[bx0(y(m)) bxf(y(m))]; end %left/right side
for n = 1:Mx1, u([1 My1],n) = [by0(x(n)); byf(x(n))]; end %bottom/top
%initialize as the average of boundary values
sum_of_bv = sum(sum([u(2:My,[1 Mx1]) u([1 My1],2:Mx)']));
u(2:My,2:Mx) = sum_of_bv/(2*(Mx + My - 2));
for i = 1:My
for j = 1:Mx
F(i,j) = f(x(j),y(i)); G(i,j) = g(x(j),y(i));
end
end
dx2 = dx*dx; dy2 = dy*dy; dxy2 = 2*(dx2 + dy2);
rx = dx2/dxy2; ry = dy2/dxy2; rxy = rx*dy2;
for itr = 1:MaxIter
for j = 2:Mx
for i = 2:My
u(i,j) = ry*(u(i,j + 1)+u(i,j - 1)) + rx*(u(i + 1,j)+u(i -
1,j))...
+ rxy*(G(i,j)*u(i,j)- F(i,j)); %Eq.(9.1.5a)
end
end
if itr>1&max(max(abs(u - u0))) < tol, break; end
u0=u;

end
Utilizando el programa N 1 poisson(f,g,bx0,bxf,by0,byf,D,Mx,My,tol,MaxIter)

1) Guardamos el cdigo N1 poisson.m

2) Para ejecutar necesitamos abrir otro archivo .m e ingresar los valores de las
funciones

Para el ejemplo anterior

2 2
(, ) + (, ) = 0
2 2

Para ( x, y ) en el conjunto R {( x, y ) / 0 x 0.5,0 y 0.5} , con las condiciones de


frontera u (0, y ) 0, u ( x, 0) 0, u ( x, 0.5) 200 x, u (0.5, y ) 200 y ,m=n=4.

(, ) = 0

(, ) = 0

0 ; 0

(0, ) = 0 = 0

(, ) = = 200

(, 0) = 0 = 0

(, ) = = 200
3) Copiamos lo anterior y lo pegamos en la hoja de trabajo

4)finaliza en los resultados


Programa N 2 Poisson(xl,xr,yb,yt,M,N)

function w=Poisson1(xl,xr,yb,yt,M,N)
% Ecuacion de Poisson por diferencias finitas
% Entrada: [xl,xr], tiempo[yb,yt], pasos M, tiempos N
f=@(x,y) -(cos(x+y)+cos(x-y)); g1=@(x) cos(x); g2=@(x) 0;
g3=@(y) cos(y); g4=@(y) -cos(y);
m=M+1; n=N+1; mn=m*n; close all
h=(xr-xl)/M; h2=h^2; k=(yt-yb)/N; k2=k^2;
x=xl+(0:M)*h; y=yb+(0:N)*k;
A=zeros(mn,mn); b=zeros(mn,1);
for i=2:m-1
for j=2:n-1
A(i+(j-1)*m,i-1+(j-1)*m)=1/h2; A(i+(j-1)*m,i+1+(j-1)*m)=1/h2;
A(i+(j-1)*m,i+(j-1)*m)=-2/h2-2/k2;
A(i+(j-1)*m,i+(j-2)*m)=1/k2; A(i+(j-1)*m,i+j*m)=1/k2;
b(i+(j-1)*m)=f(x(i),y(j));
end
end
for i=1:m
j=1; A(i+(j-1)*m,i+(j-1)*m)=1; b(i+(j-1)*m)=g1(x(i));
j=n; A(i+(j-1)*m,i+(j-1)*m)=1; b(i+(j-1)*m)=g2(x(i));
end
for j=2:n-1
i=1; A(i+(j-1)*m,i+(j-1)*m)=1; b(i+(j-1)*m)=g3(y(j));
i=m; A(i+(j-1)*m,i+(j-1)*m)=1; b(i+(j-1)*m)=g4(y(j));
end
v=A\b;
w=reshape(v(1:mn),m,n);
mesh(x,y,w')
Utilizando el programa N2 Poisson1(xl,xr,yb,yt,M,N)

1) Guardamos el cdigo N1 Poisson1.m

2) Para ejecutar necesitamos abrir otro archivo .m e ingresar los valores de las
funciones

Para el ejemplo anterior

2 2
(, ) + (, ) = 0
2 2

Para ( x, y ) en el conjunto R {( x, y ) / 0 x 0.5,0 y 0.5} , con las condiciones de


frontera u (0, y ) 0, u ( x, 0) 0, u ( x, 0.5) 200 x, u (0.5, y ) 200 y ,m=n=4.

2 = (, ) = 0

(, ) = 1() = 0

(, ) = 2() = 200

(, ) = 3() = 200

(, ) = 4() = 0

= #

= #

Procedimiento

1) Abrimos el archivo Poisson1; por cada ejercicio es necesario ingresar las


condiciones (funciones) de contorno en las partes puntilladas
3)guardamos los cambios
4) En la hoja de operaciones ingresamos w=Poisson1(xl,xr,yb,yt,M,N)

También podría gustarte