Sie sind auf Seite 1von 27

It is a class of differential equations involving

more than one independent variable.


Elliptic PDE: if B2 4AC < 0
Parabolic PDE: if B2 4AC = 0
Hyperbolic PDE: if B2 4AC > 0

These three types of PDE are associated with


equilibrium states, diffusion states, and
oscillating systems, respectively.
As an example, we will deal with a special
type of elliptic equation called Helmholtzs
equation, which is written as

over a domain D = {(x, y)|x0 x xf , y0 y yf } with some


boundary conditions of

is called Poissons equation if g(x, y) = 0 and


it is called Laplaces equation if g(x, y) = 0 and f (x, y) = 0.
ELLIPTIC PDE

we divide the domain into Mx sections, each


of length x = (xf x0)/Mx along the x-axis
and into My sections, each of length y = (yf
y0)/My along the y-axis, respectively, and
then replace the second derivatives by the
three-point central difference approximation
ELLIPTIC PDE

so that, for every interior point (xj, yi ) with 1 i My 1 and 1 j


Mx 1, we obtain the finite difference equation

where

These equations can somehow be arranged into a system of


simultaneous equations with respect to the (My 1)(Mx 1)
variables {u1,1, u1,2, . . . , u1,Mx1, u2,1, . . . , u2,Mx1, . . .
,uMy1,1, uMy1,2, . . . , uMy1,Mx1},
ELLIPTIC PDE

we first need to shape the equations and the boundary conditions into
the following form:

where
ELLIPTIC PDE

Laplaces EquationSteady-State Temperature


Distribution.

For 0 x 4, 0 y 4

with the boundary conditions


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 = # of subintervals along x axis
% My = # of subintervals along y axis
% tol : error tolerance
% MaxIter: the maximum # of iterations
x0 = D(1); xf = D(2); y0 = D(3); yf = D(4);
%solve_poisson in Example dx = (xf - x0)/Mx; x = x0 + [0:Mx]*dx;
f = inline(0,x,y); g = inline(0,x,y); dy = (yf - y0)/My; y = y0 + [0:My]*dy;
x0 = 0; xf = 4; Mx = 20; y0 = 0; yf = 4; My = 20;
bx0 = inline(exp(y) - cos(y),y); %(E9.1.2a) Mx1 = Mx + 1; My1 = My + 1;
bxf = inline(exp(y)*cos(4) - exp(4)*cos(y),y); %(E9.1.2b) %Boundary conditions
by0 = inline(cos(x) - exp(x),x); %(E9.1.3a)
for m = 1:My1, u(m,[1 Mx1])=[bx0(y(m)) bxf(y(m))]; end %left/right side
byf = inline(exp(4)*cos(x) - exp(x)*cos(4),x); %(E9.1.3b)
D = [x0 xf y0 yf]; MaxIter = 500; tol = 1e-4; for n = 1:Mx1, u([1 My1],n) = [by0(x(n)); byf(x(n))]; end %bottom/top
[U,x,y] = poisson(f,g,bx0,bxf,by0,byf,D,Mx,My,tol,MaxIter); %initialize as the average of boundary values
clf, mesh(x,y,U), axis([0 4 0 4 -100 100])
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
An example of a parabolic PDE is a one-
dimensional heat equation describing the
temperature distribution u(x, t) (x is position,
t is time) as
for 0 x xf , 0 t T

In order for this equation to be solvable, the boundary conditions


u(0, t) = b0(t) & u(xf , t) = bxf (t) as well as the initial condition
u(x, 0) = i0(x) should be provided
PARABOLIC PDE

To apply the finite difference method, we


divide the spatial domain [0, xf ] into M
sections, each of length x = xf/M, and divide
the time domain [0, T ] into N segments, each
of duration t = T/N, and then replace the
second partial derivative on the left-hand
side and the first partial derivative on the
right-hand side of the above equation by the
central difference approximation
PARABOLIC PDE

This can be cast into the following algorithm, called the explicit
forward Euler method, which is to be solved iteratively:

To find the stability condition of this algorithm, we substitute a


trial solution

Since we must have || 1 for nondivergence, the stability


condition turns out to be
PARABOLIC PDE

function [u,x,t] = heat_exp(a,xf,T,it0,bx0,bxf,M,N)


%solve a u_xx = u_t for 0 <= x <= xf, 0 <= t <= T
% Initial Condition: u(x,0) = it0(x)
% Boundary Condition: u(0,t) = bx0(t), u(xf,t) = bxf(t)
% M = # of subintervals along x axis
% N = # of subintervals along t axis
dx = xf/M; x = [0:M]*dx;
dt = T/N; t = [0:N]*dt;
for i = 1:M + 1, u(i,1) = it0(x(i)); end
for n = 1:N + 1, u([1 M + 1],n) = [bx0(t(n)); bxf(t(n))]; end
r = a*dt/dx/dx, r1 = 1 - 2*r;
for k = 1:N
for i = 2:M
u(i,k+1) = r*(u(i + 1,k) + u(i-1,k)) + r1*u(i,k); %Eq.(9.2.3)
end
end
PARABOLIC PDE

for the first partial derivative on the right-hand side of Equation

If the values of uk0 and ukM at both end points are given from the
Dirichlet type of boundary condition, then the above equation will
be cast into a system of simultaneous equations:
PARABOLIC PDE

function [u,x,t] = heat_imp(a,xf,T,it0,bx0,bxf,M,N)


%solve a u_xx = u_t for 0 <= x <= xf, 0 <= t <=
T
% Initial Condition: u(x,0) = it0(x)
% Boundary Condition: u(0,t) = bx0(t), u(xf,t) =
bxf(t)
% M = # of subintervals along x axis
% N = # of subintervals along t axis
dx = xf/M; x = [0:M]*dx;
dt = T/N; t = [0:N]*dt;
for i = 1:M + 1, u(i,1) = it0(x(i)); end
for n = 1:N + 1, u([1 M + 1],n) = [bx0(t(n));
bxf(t(n))]; end
r = a*dt/dx/dx; r2 = 1 + 2*r;
for i = 1:M - 1
A(i,i) = r2; %Eq.(9.2.9)
if i > 1, A(i - 1,i) = -r; A(i,i - 1) = -r; end
end
for k = 2:N + 1
b = [r*u(1,k); zeros(M - 3,1); r*u(M + 1,k)] +
u(2:M,k - 1); %Eq.(9.2.9)
u(2:M,k) = trid(A,b);
end
PARABOLIC PDE

The CrankNicholson Method


PARABOLIC PDE

parabolic PDE is a two-dimensional heat


equation describing the temperature
distribution u(x, y, t)((x, y) is position, t is
time) as

In order for this equation to be solvable, we should be provided with


the boundary conditions
PARABOLIC PDE

which seems to be attractive, since it can be formulated into a


tridiagonal system of equations with respect to uk+1i+1,j , uk+1i,j , and
uk+1i1,j . But, why do we treat uxx and uyy with discriminationthat
is, evaluate one at time tk and the other at time
tk+1 in a fixed manner? In an alternate manner, we write the
difference equation for the next time point tk+1 as
PARABOLIC PDE

This formulation, proposed by Peaceman and Rachford [P-1], is


referred to as the alternating direction implicit (ADI) method and
can be cast into the following algorithm:

with
PARABOLIC PDE
one-dimensional wave equation for the
amplitude function u(x, t)(x is position, t is
time) as

In order for this equation to be solvable, the boundary


conditions u(0, t) = b0(t) and u(xf , t) = bxf (t) as well as the initial
conditions u(x, 0) = i0(x) and u/t|t=0(x, 0) = i0(x) should be
provided.
HYPERBOLIC PDE

In the same way as with the parabolic PDEs,


we replace the second derivatives on both
sides of Equation by their three-point central
difference approximation as

which leads to the explicit central difference method:


HYPERBOLIC PDE

A Hyperbolic PDE: One-Dimensional Wave (Vibration). Consider a


one-dimensional hyperbolic PDE

for 0 x 2, 0 y 2, and 0 t 2

with the initial conditions and boundary conditions


HYPERBOLIC PDE

%solve_wave function [u,x,t] = wave(a,xf,T,it0,i1t0,bx0,bxf,M,N)


a = 1; %solve a u_xx = u_tt for 0<=x<=xf, 0<=t<=T
it0 = inline(x.*(1-x),x); i1t0 = inline(0); %(E9.4.2a) % Initial Condition: u(x,0) = it0(x), u_t(x,0) = i1t0(x)
bx0t = inline(0); bxft = inline(0); %(E9.4.2b) % Boundary Condition: u(0,t)= bx0(t), u(xf,t) = bxf(t)
xf = 1; M = 20; T = 2; N = 50; % M = # of subintervals along x axis
[u,x,t] = wave(a,xf,T,it0,i1t0,bx0t,bxft,M,N); % N = # of subintervals along t axis
figure(1), clf dx = xf/M; x = [0:M]*dx;
mesh(t,x,u) dt = T/N; t = [0:N]*dt;
figure(2), clf for i = 1:M + 1, u(i,1) = it0(x(i)); end
for n = 1:N %dynamic picture for k = 1:N + 1
plot(x,u(:,n)), axis([0 xf -0.3 0.3]), pause(0.2) u([1 M + 1],k) = [bx0(t(k)); bxf(t(k))];
end end
r = a*(dt/dx)^ 2; r1 = r/2; r2 = 2*(1 - r);
u(2:M,2) = r1*u(1:M - 1,1) + (1 - r)*u(2:M,1) + r1*u(3:M + 1,1) ...
+ dt*i1t0(x(2:M)); %Eq.(9.3.6)
for k = 3:N + 1
u(2:M,k) = r*u(1:M - 1,k - 1) + r2*u(2:M,k-1) + r*u(3:M + 1,k - 1)...
- u(2:M,k - 2); %Eq.(9.3.3)
end
HYPERBOLIC PDE

we consider a two-dimensional wave


equation for the amplitude function u(x, y, t)
((x, y) is position, t is time) as

In order for this equation to be solvable, we should be provided with


the boundary conditions

three-point central difference approximation as


HYPERBOLIC PDE

A Hyperbolic PDE: Two-Dimensional Wave (Vibration) Over a Square


Membrane. Consider a two-dimensional hyperbolic PDE

for 0 x 2, 0 y 2 and 0 t 2

with the zero boundary conditions and the initial conditions


HYPERBOLIC PDE

function [u,x,y,t] = wave2(a,D,T,it0,i1t0,bxyt,Mx,My,N)


%solve a(u_xx + u_yy) = u_tt for D(1) <= x <= D(2), D(3) <= y <= D(4), 0 <= t <= T
% Initial Condition: u(x,y,0) = it0(x,y), u_t(x,y,0) = i1t0(x,y)
% Boundary Condition: u(x,y,t) = bxyt(x,y,t) for (x,y) on Boundary
% Mx/My = # of subintervals along x/y axis
%solve_wave2 % N = # of subintervals along t axis
it0 = inline(0.1*sin(pi*x)*sin(pi*y/2),x,y); %(E9.5.3) dx = (D(2)- D(1))/Mx; x = D(1)+[0:Mx]*dx;
i1t0 = inline(0,x,y); bxyt = inline(0,x,y,t); %(E9.5.2) dy = (D(4)- D(3))/My; y = D(3)+[0:My]*dy;
a = .25; D = [0 2 0 2]; T = 2; Mx = 40; My = 40; N = 40; dt = T/N; t = [0:N]*dt;
[u,x,y,t] = wave2(a,xf,T,it0,i1t0,bxyt,Mx,My,N); %Initialization
u = zeros(My+1,Mx + 1); ut = zeros(My + 1,Mx + 1);
for j = 2:Mx
for i = 2:My
u(i,j) = it0(x(j),y(i)); ut(i,j) = i1t0(x(j),y(i));
end
end
adt2 = a*dt*dt; rx = adt2/(dx*dx); ry = adt2/(dy*dy);
rxy1 = 1- rx - ry; rxy2 = rxy1*2;
u_1 = u;
for k = 0:N
t = k*dt;
for i = 1:My + 1 %Boundary condition
u(i,[1 Mx + 1]) = [bxyt(x(1),y(i),t) bxyt(x(Mx + 1),y(i),t)];
end
for j = 1:Mx + 1
u([1 My + 1],j) = [bxyt(x(j),y(1),t); bxyt(x(j),y(My + 1),t)];
end
if k = = 0
for i = 2:My
The solution of a two-dimensional for j = 2:Mx %Eq.(9.3.13)
u(i,j) = 0.5*(rx*(u_1(i,j - 1) + u_1(i,j + 1))...

hyperbolic PDE: vibration of a square + ry*(u_1(i - 1,j)+u_1(i + 1,j))) + rxy1*u(i,j) + dt*ut(i,j);


end

membrane
end
else
for i = 2:My
for j = 2:Mx %Eq.(<eqnr>9.3.10)</eqnr>
u(i,j) = rx*(u_1(i,j - 1)+ u_1(i,j + 1))...
+ ry*(u_1(i - 1,j) + u_1(i + 1,j)) + rxy2*u(i,j) -u_2(i,j);
end
end
end
u_2 = u_1; u_1 = u; %update the buffer memory
mesh(x,y,u), axis([0 2 0 2 -.1 .1]), pause
end

Das könnte Ihnen auch gefallen