This week we enter the realm of numerically solving partial differential equations (PDEs). We will focus on one of the most important PDEs of them all: the diffusion equation.
By using finite differences to discretise space, the diffusion equation can be converted into a system of ODEs. This provides an opportunity to link the finite-difference code you developed in Week 19 with the ODE time-steppers you developed in Week 14. For example, the euler_step
and solve_to
functions you created in Week 14 can be used to implement the explicit Euler method described in the Week 20 video.
Use the links below to find additional notes on
The goal of this week is to create a PDE solver that is capable of computing numerical solutions to diffusion equations of the form
The domain of the problem is given by . In this equation, is a parameter. The term represents a function that depends on the spatial coordinate , time , the solution , and a parameter .
The user should be able to specify which type of boundary conditions to impose (Dirichlet, Neumann, or Robin) as well as the method used to time step the equation (e.g. explicit Euler, RK, solve_ivp
).
If is independent of time, then the steady-state solutions of (1) are given by
which is exactly the equation you were solving in Week 19. Therefore, you can use your numerical solutions of (1) to determine the stability of the steady-state solutions computed from (2).
(Essential) Use the explicit Euler method to solve the linear diffusion equation without a source term
Set the boundary conditions to and and the initial condition to
The exact solution to the problem is given by
which you can use to test your code.
(Essential) Use the 4th-order Runge-Kutta method from Week 14 to solve the diffusion equation above.
Extend your code so that it can account for non-homogeneous Dirichlet boundary conditions and a source term in the diffusion equation. That is, your code should be able to solve
with boundary conditions , and initial condition . Use the supplementary notes to find exact solutions that you can use to test your code with.
Use your code to solve the dynamic Bratu problem
with , and initial condition . Take . Compute numerical solutions when and compare to the steady-state solution that you computed in the Week 19 exercises.
Update your code so that it can also account for Dirichlet, Neumann, and Robin boundary conditions with time-dependent coefficients.