θ-Scheme of Finite Element Method for Heat Equation ∗
Wenqiang Feng †
Abstract
This is my MATH 574 course project report. In this report, I give some details for implement-
ing the Finite Element Method (FEM) via Matlab and Python with FEniCs. This project mainly
focuses on θ-Method for the initial boundary heat equation.
1 The Model Problem
Consider the initial boundary value problem for the heat equation:
ut − ∆u = f (x, t), (x, t) ∈ Ω × (0, T ]
u = 0, (x, t) ∈ ∂Ω × (0, T ] (1)
= u 0 (x), x ∈ Ω,
u(·, 0)
where Ω = [0, 1] × [0, 1]. The initial data u 0 (x) and the function f (x, t) are such that the solution
is given by
u(x, y, t) = e−t sin(πx) sin(πy).
2 A Full Discretization scheme: The θ-Method
n+1 n
u −u
n+1 n
h τ h , vh + a θuh + (1 − θ)uh , vh = θf (t n+1 ) + (1 − θ)f (t n ), vh
(2)
u 0 = Πu 0 .
h
So, we get
uhn+1 − uhn , vh + τa θuhn+1 + (1 − θ)uhn , vh = τ θf (t n+1 ) + (1 − θ)f (t n ), vh .
Since
N
X
uhn = αjn φj (x),
j=1
then
X N XN XN XN
αjn+1 φj (x) − αjn φj (x), φi (x) + τa θ αjn+1 φj (x) + (1 − θ) αjn+1 φj (x), φi (x)
j=1 j=1 j=1 j=1
= τ θf (t n+1 ) + (1 − θ)f (t n ), φi (x) , i = 1, 2, · · · , N .
∗ Key words: FEM, Pure Dirichlet boundary condition, Heat equation.
† Department of Mathematics,University of Tennessee, Knoxville, TN, 37909, wfeng@[Link]..edu
1
Therefore,
Mα n+1 − Mα n + θτSα n+1 + (1 − θ)τSα n = θτF n+1 + (1 − θ)τF n
where
N
X N
X
M= φj (x), φi (x) , M = ∇φj (x), ∇φi (x) , Fin = (f (t n ), φi (x)) .
j=1 j=1
Hence
(M + θτS) α n+1 = (M − (1 − θ)τS) α n + θτF n+1 + (1 − θ)τF n .
1. When θ = 0, it is first-order explicit/forward Euler Scheme.
2. When θ = 1, it is first-order implicit/backward Euler Scheme.
3. When θ = 1/2, it is second-order Crank-Nicolson/ Trapezoidal Scheme.
3 Numerical Results
We use the the following test problem which has the exact solution
u(x, y, t) = e−t sin(πx) sin(πy).
So,
u(x, y, 0) = sin(πx) sin(πy),
and
f (x, y, t) = (2π2 − 1)e−t sin(πx) sin(πy).
Figure 1: The initial data(left) and the exact solution at T = 1(right) .
2
Table 1: Errors of the computed solution (nx=ny=512)with implicit/backward Euler Scheme.
#T step ku − uh kL∞ order
q=1 20 4.9128E-04
40 2.3917E-04 1.0271
80 1.1481E-04 1.0416
Figure 2: The numerical solution at T = 1 with implicit/backward Euler Scheme.
Table 2: Errors of the computed solution (nx = ny = 64)with explicit/forward Euler Scheme.
#T step ku − uh kL∞ order
q=1 20 8.6611E+67 divergence
40 5.9872E+129 divergence
80 1.0251E+242 divergence
80 1.0251E+242 divergence
160 4.5052E-17 convergence