∂u

Partial Differential Equations

Your Progress in this Chapter

0%

0 / 12 units completed

Chapter Overview

Solution Of PDE by Full Descretization

Section 10.3 of 418 min4 code examples

The Full Discretization Method (often referred to as direct Finite Difference Methods for space-time grids) approaches partial differential equations (PDEs) by discretizing both the spatial and temporal dimensions simultaneously onto a discrete grid.

Unlike the Method of Lines—which retains continuous time to yield an ODE system—full discretization converts the PDE directly into a system of algebraic equations that can be solved step-by-step or via matrix inversion.

How It Works:

The 3-Step Process Consider the 1D transient heat equation:

ut=α2ux2\frac{\partial u}{\partial t} = \alpha \frac{\partial^2 u}{\partial x^2}
  1. Grid Generation: We partition space into steps of size \Delta x (x_i = i \Delta x) and time into steps of size \Delta t (t^n = n \Delta t). The discrete approximation to u(x_i, t^n) is denoted as u_i^n.
  1. Algebraic Substitution: Both the time derivative and spatial derivative are replaced with algebraic finite difference approximations. For example, using a forward difference in time and a central difference in space:
uin+1uinΔtαui+1n2uin+ui1n(Δx)2\frac{u_i^{n+1} - u_i^n}{\Delta t} \approx \alpha \frac{u_{i+1}^n - 2u_i^n + u_{i-1}^n}{(\Delta x)^2}
  1. Time Marching / Matrix Solution: Re-arranging the algebraic equation allows us to explicitly compute values at the next time level n+1 from known values at level n (Explicit Scheme), or solve a linear system A u^{n+1} = B u^n (Implicit Scheme).

## Explicit vs. Implicit Schemes

When discretizing space and time simultaneously, the evaluation point of the spatial derivative defines the nature of the solver: - Explicit Schemes (Forward Euler): Evaluate spatial derivatives entirely at the current time step $n$. Fast per iteration, but strictly bounded by stability constraints. - Implicit Schemes (Backward Euler / Crank-Nicolson): Evaluate spatial derivatives at the future time step n+1 (or a weighted blend). Unconditionally stable, but requires solving a system of linear equations at each time step.

Comparison: Full Discretization vs Method of Lines Feature | Method of Lines (MOL) | Full Discretization (FDM) Time Integration | Continuous (Handed to ODE solver) | Discrete (Fixed algebraic updates) Solvers | High-order adaptive ODE integrators | Custom time-stepping loops / Matrix solvers Error Control | Automated adaptive time-stepping | Manual step size selection (\Delta t, \Delta x) Implementation | Abstract function interfaces | Direct matrix-vector operations

Example 1: Explicit Method (FTCS Scheme)

The Forward-Time Central-Space (FTCS) scheme explicitly updates each grid point based on its immediate neighbors at the previous time level:

uin+1=uin+r(ui+1n2uin+ui1n),r=αΔt(Δx)2u_i^{n+1} = u_i^n + r \left(u_{i+1}^n - 2u_i^n + u_{i-1}^n \right), \quad r = \frac{\alpha \Delta t}{(\Delta x)^2}

Stability Warning: The 1D explicit FTCS scheme is stable if and only if r \le 0.5. Exceeding this limit causes catastrophic non-physical oscillations.

Example 1C#

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
Code is ready to run

Example 2: Implicit Crank-Nicolson Scheme

The Crank-Nicolson scheme is a second-order accurate implicit method formed by averaging the central differences at time steps n and n+1:

r2ui1n+1+(1+r)uin+1r2ui+1n+1=r2ui1n+(1r)uin+r2ui+1n-\frac{r}{2} u_{i-1}^{n+1} + (1 + r) u_i^{n+1} -\frac{r}{2} u_{i+1}^{n+1} = \frac{r}{2} u_{i-1}^n + (1 - r) u_i^n + \frac{r}{2} u_{i+1}^n

Expressed in matrix-vector form:

Aun+1=Bun\mathbf{A} \mathbf{u}^{n+1} = \mathbf{B} \mathbf{u}^n

where \mathbf{A} and \mathbf{B} are tridiagonal matrices. This scheme is unconditionally stable for any choice of \Delta t.

Example 2C#

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
Code is ready to run

Example 3: Implicit Scheme, with Finite Element for Spatial derivatives

When applying the Finite Element Method to time-dependent problems such as the 1D heat equation:

ut=α2ux2+f(x,t)\cfrac{\partial u}{\partial t} = \alpha \cfrac{\partial^2 u}{\partial x^2} + f(x,t)

applying the Galerkin spatial discretization yields a system of coupled ODEs in matrix form:

Mdudt+αKu=F\mathbf{M} \cfrac{d\mathbf{u}}{dt} + \alpha \mathbf{K} \mathbf{u} = \mathbf{F}

where: - \mathbf{M} is the Global Mass Matrix (M_{ij} = \int_\Omega \phi_i \phi_j \, dx), representing the temporal inertia/capacity. For 1D linear elements of length h, the local element mass matrix is \mathbf{m}_e = \cfrac{h}{6} \begin{bmatrix} 2 & 1 \\ 1 & 2 \end{bmatrix}. - \mathbf{K} is the Global Stiffness Matrix (K_{ij} = \int_\Omega \cfrac{d\phi_i}{dx} \cfrac{d\phi_j}{dx} \, dx), with local element stiffness matrix \mathbf{k}_e = \cfrac{1}{h} \begin{bmatrix} 1 & -1 \\ -1 & 1 \end{bmatrix}. - \mathbf{u}(t) is the vector of nodal temperature values evolving over time.

Using an implicit time-integration scheme (Backward Euler) for stability:

(M+ΔtαK)un+1=Mun+ΔtFn+1\left( \mathbf{M} + \Delta t \cdot \alpha \mathbf{K} \right) \mathbf{u}^{n+1} = \mathbf{M} \mathbf{u}^n + \Delta t \cdot \mathbf{F}^{n+1}

Example 3C#

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
Code is ready to run

Example 2: Implicit Scheme with Chebyshev Spectral Differentiation for Spatial Derivative

Constructing a Chebyshev differentiation matrix \mathbf{D}_N to compute high-accuracy spatial derivatives on Gauss-Lobatto collocation points x_k = \cos\left(\frac{k\pi}{N}\right):

Example 4C#

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
Code is ready to run