This is a follow up to my previous post here
I'm solving the following 1D transport equation .
$$\frac{\partial C}{\partial t} = D\frac{\partial ^2 C}{\partial x^2}-v\frac{\partial C}{\partial x}$$
At the inlet (left boundary), Dirichlet boundary condition is applied $C(1) = C_L$ . (1 is the inlet node number)
At the outlet (right boundary), diffusive flux is ignored. $-D \frac{dC}{dx} = 0$
I'm comparing the absolute errors computed from the following implementations,
Discretizing the convection term using backward difference and diffusion using central difference approximation.
Discretizing the convection term using central difference and diffusion using central difference approximation.
After discretization in the spatial direction, the pde translates to a set of odes. The odes are solved using a stiff equation solver.
The results from the above 2 implementations are compared against the solution obtained from MATLAB's pdepe solver and absolute errors are computed.
The absolute error for the first implementation is illustrated in the following image (using a spatial discretization step of 0.25). The complete code can be found in the solution posted here
The absolute error for the second implementation is of the order 10^-13.
From what I understand, the truncation error of the backward difference is $O( \Delta x)$ and that of centered difference is $O(\Delta x^2)$ from Taylor series approximations of the first derivative. The errors obtained from the numerical scheme is of the order 0.04 for backward + central difference and 1e-13 for central alone. I am not able to clearly understand what leads to this drastic difference and how to check the errors computed to the truncation orders from the Taylor series.
I'd like to request for explanations on why this drastic difference occurs in absolute errors.
solutionDifference=abs(sol-C)
, whereC
contains the transient values ofC
obtained at every node from my implementation of backward + central/ central + central difference scheme ;sol
contains the results from MATLAB's pdepe solver. $\endgroup$