The 1D diffusion equation
The initial-boundary value problem for 1D diffusion
Step 1: Discretizing the domain
The discrete solution
Step 2: Fulfilling the equation at the mesh points
Step 3: Replacing derivatives by finite differences
Step 4: Formulating a recursive algorithm
The mesh Fourier number
The finite difference stencil
The computational algorithm for the Forward Euler scheme
The Python implementation of the computational algorithm
Moving finite difference stencil
Demo program
Forward Euler applied to an initial plug profile
Forward Euler applied to a Gaussian profile
Backward Euler scheme
Let's write out the equations for \( N_x=3 \)
Two classes of discretization methods: explicit and implicit
The linear system for a general \( N_x \)
\( A \) is very sparse: a tridiagonal matrix
Detailed expressions for the matrix entries
The right-hand side
Naive Python implementation with a dense \( (N_x+1)\times(N_x+1) \) matrix
A sparse matrix representation will dramatically reduce the computational complexity
Computing the sparse matrix
Backward Euler applied to a plug profile
Backward Euler applied to a Gaussian profile
Crank-Nicolson scheme
Averaging in time is necessary in the Crank-Nicolson scheme
Crank-Nicolsoon scheme written out
Crank-Nicolson applied to a plug profile
Crank-Nicolson applied to a Gaussian profile
The \( \theta \) rule
The Laplace and Poisson equation
We can solve 1D Poisson/Laplace equation by going to infinity in time-dependent diffusion equations
Extensions
Analysis of schemes for the diffusion equation
Properties of the solution
Example
High frequency components of the solution are very quickly damped
Damping of a discontinuity; problem
Damping of a discontinuity; model
Damping of a discontinuity; Backward Euler scheme
Damping of a discontinuity; Backward Euler simulation \( F=\half \)
Damping of a discontinuity; Forward Euler scheme
Damping of a discontinuity; Forward Euler simulation \( F=\half \)
Damping of a discontinuity; Crank-Nicolson scheme
Damping of a discontinuity; Crank-Nicolson simulation \( F=5 \)
Fourier representation
Analysis of the finite difference schemes
Analysis of the Forward Euler scheme
Results for stability
Analysis of the Backward Euler scheme
Analysis of the Crank-Nicolson scheme
Summary of accuracy of amplification factors; large time steps
Summary of accuracy of amplification factors; time steps around the Forward Euler stability limit
Summary of accuracy of amplification factors; small time steps
Observations