Let's consider the linear BVP describing the steady state concentration profile C(x)
in the following reaction-diffusion problem in the domain
.
The BVP can be stated as
C(x=0) = 1 | |||
(30) |
We are interested in solving the above equation using the FD technique. The first step is
to partition the domain [0,1] into a number of sub-domains or intervals of length h. So, if
the number of intervals is equal to n, then nh = 1. We denote by x_{i} the interval end points or
nodes, with
x_{1} =0 and
x_{n+1} = 1. In general, we have
x_{i} = (i-1)h,
.
Let us denote the concentration at the ith node by C_{i}.
The second step is to express the differential
operator d^{2}C/dx^{2} in a discrete form. This can be accomplished using finite difference
approximations to the differential operators. In this problem, we will use the approximation
(31) |
(32) |
Let's now derive the discretized equations. First of all,
we have two boundary conditions to be implemented. The boundary condition at
x=0 gives
C_{1} = 1 | (33) |
(34) |
So far, we have supplied 2 equations for the n+2 unknowns, the remaining n equations are obtained by
writing the discretized ODE for nodes
.
Application of Eq. 32 and the use of the boundary conditions lead to the following
system of linear equations for C_{i},
.
C_{1} = 1 | |||
C_{3} - (2+h^{2}) C_{2} + C_{1} = 0 | |||
C_{4} - (2+h^{2})C_{3} + C_{2} = 0 | |||
.................... | |||
C_{n+2} - (2+h^{2})C_{n+1} + C_{n} = 0 | |||
C_{n+2} - C_{n} = 0. | (35) |
We can express this
system compactly using matrices.
The
coefficient matrix, say ,
corresponding to the system of equations
given above is
(36) |
In Figure 5, the FD solution with h=0.1 and h=0.05 are presented along with the exact
solution to the BVP of Eq. 31. A very good agreement between the exact and the computed
solutions can be seen from there.
How does the FD scheme above converge to the exact solution as h is decreased? The absolute
error at the center of the domain (x=0.5) for three different values of h are plotted vs. h
in Figure 6 on a log-log plot. It can be seen from there that the error decreases as
O(h^{2}). Hence, the FD approximation used here has quadratic convergence. This is
because the discretization errors in the approximation of the first and second derivative operators
(see Eqs. 32 and 33) are O(h^{2}). Indeed, the convergence characteristics can be improved
by using more accurate discretization of the differential operators.