advection_ftcs_pde, a MATLAB code which solves the advection PDE dudt + c * dudx = 0 in one spatial dimension, with a constant velocity c, and periodic boundary conditions, using the FTCS method, forward time difference, centered space difference.
We solve for u(x,t), the solution of the constant-velocity advection equation in 1D,
du/dt + c du/dx = 0over the interval:
0.0 <= x <= 1.0with constant velocity:
c = 1with periodic boundary conditions:
u(0,t) = u(1,t) for all tand initial condition
u(x,0) = (10x-6)^2 (8-10x)^2 for 0.6 <= x <= 0.8 = 0 elsewhere.
We use a method known as FTCS (forward time, centered space):
The advection velocity is constant in time and space. Therefore, (given our periodic boundary conditions), the solution should simply move smoothly from left to right, returning on the left again. However, the FTCS numerical method is unstable for this advection problem. Hence, the numerical solution will include erroneous oscillations which spread and blow up over time. There are more sophisticated methods for the advection problem, which do not exhibit this instability.
The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.
Plots: