You are on page 1of 3

Universidad de Chile The numerical simulation of complex PDE problems

Facultad de Ciencias Fı́sicas y Matemáticas P. Frey, M. De Buhan


Year 2008 MA691 & CC60X

TP Scilab N◦ 3
The finite element method (I)

Exercice 1 : Solving a convection-diffusion problem using Scilab

We consider the following boundary-value problem :


Given f ∈ L2 (Ω), ε > 0 and λ ∈ R, find u : Ω = [0, 1] → R that solves
(
−εu00 (x) + λu0 (x) = f (x)
(1)
u(0) = u(1) = 0

We suppose f is sufficiently smooth so as to ensure the existence of a unique solution to this


problem. We will approximate this solution using a piecewise affine function.

Note. In a chemical context, the differential equation is supposed to represent the concentration
of a chemical species transported by a fluid at a velocity λ, the parameter ε representing then the
diffusivity of this species. The ratio λ/ε measures the importance of the convective phenomena with
respect to the diffusive ones. For large values of this ratio, the numerical reslution of this problem
becomes critical. The function f , that generally depends on u, is introduced to take into account
the creation and the deletion of the chemical species.

1. Variational formulation.
Show that if u ∈ H02 (Ω) is solution of the problem (1) it is also a solution of the following
variational problem :
Find u ∈ H01 (Ω) such that
Z Z Z
0 0 0
ε u (x)v (x) dx − λ u(x)v (x) dx = f (x)v(x) dx ∀v ∈ H01 (Ω) . (2)
Ω Ω Ω

Conversely, any smooth solution u of (2) is a solution of (1).


2. Finite element approximation.
We introduce a discretization of the domain Ω. For N ∈ N∗ , we pose h = 1/(N + 1) and we
define the points xj = jh and the intervals Ij =]xj , xj+1 [, j ∈ {0, . . . , N }. We denote P1 (Ij )
the set of polynomials of degree lesser than or equal to 1 on Ij and we consider the space
1
Vh,0 of the piecewise affine continuous functions on Ω :
1
= vh ∈ C 0 (Ω) , v|Ij ∈ P1 (Ij ) , v|∂Ω = 0 .

Vh,0

1
(i) We consider the shape functions {ϕj }1≤j≤N such that :
1
ϕj ∈ Vh,0 and ϕj (xi ) = δi,j , ∀i ∈ {1, . . . , N } .
1
Show that these functions {ϕj }1≤j≤N form a basis of Vh,0 .
1
(ii) We want to find an approximation uh ∈ Vh,0 of the unknown function u, solution of the
following variational problem :
1
Find uh ∈ Vh,0 such that
Z Z Z
0 0 0 1
ε uh (x)vh (x) dx − λ uh (x)vh (x) dx = f (x)vh (x) dx ∀vh ∈ Vh,0 , (3)
Ω Ω Ω

Compare problem (3) with problem (2).


Show that uh (xj ) = αj , where the αj is the j th component of uh in the basis {ϕj }1≤j≤N .
Consider the vector uh = (uh (x1 ), . . . , uh (xN ))t . Show that uh is the solution of the linear
system
Ah uh = bh
and indicate what are the coefficients of the matrix Ah and of the right-hand side term
bh .
(iii) Compute by hand the coefficients of the matrix Ah .
(Hint : use the decomposition : Ah = εBh + λCh .)
(iv) Show that for all x ∈ RN , hCh x, xi = 0. Deduce that the matrix Ah is invertible.

3. Numerical solution using Scilab.


(i) Write a Scilab function
function A=CalculMatA(N,eps,lambda)
to compute the coefficients of the matrix Ah , where the input arguments are N , ε and λ.
(ii) Write a Scilab function to construct the right-hand side bh :
function b=CalculRHS(N,f)
where the input arguments are N and the function f . Use an integration formula (see class
document) to compute integrals like
Z b
g(x) dx .
a

(iii) Compute the approximate solution uh of problem (3) for the values

ε = 0.01 λ = 1 f = 1 ,

and for the values n = 10 and n = 20.

4. A stabilization method.
We consider a modified version of problem (1) where the viscous terms have been reinforced :
  
 − ε + |λ| h u00 (x) + λu0 (x) = f (x)
2 (4)

u(0) = u(1) = 0

2
(i) Compute the solution uh of the problem (3) for the parameter values :

ε = 0.01 , λ = 1, f =1

and for the values n = 10 and n = 20.


(ii) Compare the solution with the solution uh of problem (2).

5. A non constant right-hand side term.


We consider f = cos(aπx), a ∈ R∗ and we fix the following set of parameters :

n = 20 , ε = 0.01 , λ = 1.

(i) Compute the solution uh for different values of the parameter a ∈ N∗ . Please comment.
(ii) Same question for the values a = 1/2, a = 3/2 with n = 60.

6. Exact solution of problem (1).


For x ∈ Ω we introduce the function :
Z x Z z 
Fθ (x) = exp(θz) f (y) exp(−θy) dy dz .
0 0

(i) Show that for every real values α, β, the function


1
u(x) = α + β exp(θx) − Fθ (x)
ε
is solution of the differential equation of problem (1).
(ii) Find the values of α and β such that the function u solves the problem (1) (with the
boundary conditions).
(iii) Show that
1
lim+ u(x) = sin(aπx) ,
ε→0 λaπ
for the function f (x) = cos(aπx), a ∈ R∗ .
(iv) On the same graph, plot the solution u of problem (1) and the solution uh solving
problem (3).