Implicit Methods for Diffusion#
One of the issues we have with our diffusion implementation is that the timestep constraint:
can be very restrictive as \(\Delta x\) gets small.
Note
In astrophysical simulations, we are often combining advection and diffusion, and the diffusive timestep restriction can dominate, making our overall simulation computationally expensive.
For this reason, we often wish to use an implicit-in-time integration method for diffusion.
Going back to our original discretization, we would write the implicit update as:
If we define
then we can write this as:
This is a coupled set of algebraic equations for the new time state of \(\phi\)—a linear system.
Important
The implicit discretization is stable for all values of \(C\). But keep in mind that stability and accuracy are not the same thing.
There are several ways we can solve this:
direct solve : create a linear system of the form \({\bf A}{\bf x} = {\bf b}\) and solve for the new state using Gaussian elimination or something similar
iterative solve : apply relaxation to the system, just like we did with our elliptic equations.
Direct solve#
In order to write down the linear system, we need to understand our boundary conditions. Consider the left boundary. We’ll denote the cell just inside the domain as \(\phi_\mathrm{lo}\) and the ghost cell just outside of the domain as \(\phi_{\mathrm{lo}-1}\).
Homeogeneous Neumann : for Neumann boundary conditions, we want the gradient at the boundary to be zero. This means:
\[\frac{\phi_\mathrm{lo} - \phi_{\mathrm{lo}-1}}{\Delta x} = 0\]This is second-order accurate at the physical boundary, \(x_{\mathrm{lo}-1/2}\).
Inserting this into our implicit system above, we find that the update for the first zone inside the boundary is:
\[(1 + \alpha) \phi_\mathrm{lo}^{n+1} - \alpha \phi_{\mathrm{lo}+1}^{n+1} = \phi_\mathrm{lo}^n\]Dirichlet : for Dirichlet boundary conditions, we want the value at the physical boundary to be specified—we’ll call it \(\phi_A\). To second-order, that means that the average of the two zones on either side of the boundary should give us the desired value:
\[\frac{\phi_\mathrm{lo} + \phi_{\mathrm{lo}-1}}{2} = \phi_A\]Inserting this into our implicit update, we find that the update for the first zone inside the boundary is:
\[(1 + 3\alpha) \phi_\mathrm{lo}^{n+1} - \alpha \phi_{\mathrm{lo}+1}^{n+1} = \phi_\mathrm{lo}^n + 2 \alpha \phi_A\]
Similar constructions are used for the right boundary.
Putting this together, our linear system for implicit diffusion (assuming Neumann boundary conditions) appears as:
We note a few things:
This is a tridiagonal matrix. Efficient solution methods exist for this that take advantage of the sparsity pattern.
The ghost cells in our grid do not explicitly appear in the system
The matrix is diagonally dominant. This means that it will work well with iterative methods.