Numerical approximation of the Poisson equation
Grado en Ing. Civil y Territorial
(Univ. Polit´ecnica de Madrid)
The heat equation on a plate
Consider a plate as follows
Letu(x1,x2,x3,t) be the temperature at the point (x1,x2,x3)∈
plate, and timet>0.
Assume that the cross section is so small that we can consider the
plate as a bidimensional object in a domainx ∈Ω,
u(x1,x2,x3,t) =u(x1,x2,t).
The following equation describes the heat behavior
∂u
∂t(x1,x2,t)− ∂2u ∂x2 1
(x1,x2,t)− ∂2u ∂x2 2
(x1,x2,t) = 0, (x1,x2)∈Ω,
or, abreviated
ut−(ux1x1+ux2x2) = 0, (x1,x2)∈Ω, t >0,
or, more usually
The Laplace operator ∆
In dimesiond = 1,
∆u =uxx, x ∈(0,L),
In dimensiond = 2,
∆u =ux1x1+ux2x2 = div (∇u), (x1,x2)∈Ω,
In dimensiond = 3,
∆u =ux1x1+ux2x2+ux3x3 = div (∇u), (x1,x2,x3)∈Ω,
The heat equation can be written in any dimension as
ut−∆u = 0, x∈Ω⊂Rd, t>0.
If there is a heat source described by a functionf(x,t), then
ut−∆u =f(x,t), x∈Ω⊂Rd, t>0.
If the heat flow remains stationary (ut = 0), as for large time, then
we have thePoisson equation
Boudary conditions
To obtain a unique solution, we have to include conditions at the boudary
u(x) =g(x), x∈∂Ω.
The complete system of equations is given by
−∆u(x) =f(x), x ∈Ω⊂R2,
u(x) =g(x), x∈∂Ω,
Two different approaches
1 Finite differences for the Poisson equation
−∆u(x) =f(x), x∈Ω⊂R2,
u(x) = 0, x∈∂Ω,
2 Fourier method for Laplace equation
−∆u(x) = 0, x∈Ω⊂R2,
u(x) =g(x), x∈∂Ω,
Finite differences approximation
We focus on a rectangle and cosiderx= (x1,x2) = (x,y)
−∆u(x,y) =f(x,y), (x,y)∈Ω⊂R2, u(x,y) = 0, (x,y)∈∂Ω,
Space mesh
Take a partition ofx∈[0,L1] andy ∈[0,L2] with steph
Defineui,j(t)∼u(xi,yj),and replace
−uxx(x,y) by
−ui−1,j+ 2ui,j −ui+1,j
h2
−uyy(x,y) by
Then, we have the system
−ui−1,j−ui,j−1+4ui,j−ui+1,j−ui,j+1
h2 =fi,j, i,j = 1,2, ...,N−1,
u0,j =uN,j = 0, j = 0,1, ...,N
ui,0=ui,N = 0, i = 0,1, ...,N.
wherefi,j ∼f(xi,yj).
Matrix formulation
Renumbering the nodes
The final system reads
KU =F,
where
K = 1
h2
B −I 0 0 ... 0 0
−I B −I 0 ... 0 0
... ... ... ... ... ... ...
0 0 0 0 ... −I B
∈ M(N−1)(M−1)×(N−1)(M−1)
B =
4 −1 0 0 ... 0 0
−1 4 −1 0 ... 0 0
... ... ... ... ... ... ...
0 0 0 0 ... −1 4
∈ M(N−1)×(N−1)
I =
1 0 0 0 ... 0 0
0 1 0 0 ... 0 0
... ... ... ... ... ... ...
0 0 0 0 ... 0 1
∈ M(N−1)×(N−1)
Matlab code
N = 40; h = 1/N; x = h:h:1-h; y = h:h:1-h; n=N-1; % space mesh
B=4*diag(ones(1,n))-diag(ones(1,n-1),1)-diag(ones(1,n-1),-1); K = zeros(n2); % matrix formulation−uxx−uyy
for j=0:n-2
K(i*n+1:(i+1)*n,i*n+1:(i+1)*n)=B;
K(i*n+1:(i+1)*n,(i+1)*n+1:(i+2)*n)=-eye(n); K((i+1)*n+1:(i+2)*n,i*n+1:(i+1)*n)=-eye(n); end
K((n-1)*n+1:n*n,(n-1)*n+1:n*n)=B; K = K/h2; [xx yy] = meshgrid(x,y); f=(xx-1).*(yy-1); % force
sm=f(1,:)’;
for i=2:n % vector formulation
Numerical solution
The Fourier method in a circle
ρ
≤
R
The Fourier method to obtain solutions
We search for solutions of the form,
u(ρ, θ) =ϕ(θ)T(ρ)
RemarkIfϕ(x) is solution of the eigenvalue problem
ϕ00(θ) +λϕ(θ) = 0, ϕ(θ) 2π-periodic,
for someλ≥0, then
u(ρ, θ) = (ρ/R)
√ λϕ(θ)
is a solution of the Laplace equation ∆u = 0.
The eigenvalues of this problem areλk =k2 with k = 0,1,2,3, ...
and the associated eigenfunctions are
ϕ0= 1, ϕk = sin(kθ), ψk = cos(kθ), k ≥1.
Therefore, all these functions are solutions of the Laplace equation
u0(ρ, θ) = 1,
Case
R
= 1
first eigenfunction second eigenfunction third eigenfunction
solution solution solution
eigenfunction eigenfunction eigenfunction
eigenfunction eigenfunction eigenfunction
solution solution solution
Matlab code
dt=1/20; % angle mesh step
theta=0:dt:2*pi; % angle mesh
dr=1/10; % rho mesh step
rho=0:dr:2; % rho mesh
k=3; % number of eigenvalue
[rr,tt]=meshgrid(rho,theta); % (ρ, θ) coordinates of the mesh
u= ((rr/2).k).∗sin(k∗tt);
xx=rr.∗cos(tt); yy =rr.∗sin(tt); % cartesian coordinates
Boundary condition at
ρ
= 1
Assume that we can write the boundary datag(θ) as
g(θ) =c0+
N
X
k=1
cksin(kθ) + N
X
k=1
dkcos(kθ),
for some coefficientsck,dk ∈R. Then
u(ρ, θ) =c0+
N
X
k=1
ckρksin(kθ) + N
X
k=1
ckρkcos(kθ),
is a solution of the full system: Laplace equation and boundary condition.
As we know, anyL2(0,1)-function can be approximated with a finite number of terms of the Fourier series and this allows to find approximations of Laplace solutions.