advection_pde


advection_pde, a Python code which solves the advection partial differential equation (PDE) dudt + c * dudx = 0 in one spatial dimension and time, 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 = 0
      
over the interval:
        0.0 <= x <= 1.0
      
with constant velocity:
        c = 1
      
with periodic boundary conditions:
        u(0,t) = u(1,t) for all t
      
and 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.

Licensing:

The information on this web page is distributed under the MIT license.

Languages:

advection_pde is available in a MATLAB version and an Octave version and a Python version.

Related Data and codes:

allen_cahn_pde, a Python code which sets up and solves the Allen-Cahn reaction-diffusion system of partial differential equations (PDE) in 1 space dimension and time.

diffusion_pde, a Python code which solves the diffusion partial differential equation (PDE) dudt - mu * d2udx2 = 0 in one spatial dimension, with a constant diffusion coefficient mu, and periodic boundary conditions, using FTCS, the forward time difference, centered space difference method.

gray_scott_pde, a Python code which solves the partial differential equation (PDE) known as the Gray-Scott reaction diffusion equation, displaying a sequence of solutions as time progresses.

spiral_pde, a Python code which solves a pair of reaction-diffusion partial differential equations (PDE) over a rectangular domain with periodic boundary condition, whose solution is known to evolve into a pair of spirals.

wave_pde, a Python code which uses finite differences in space, and the method of lines in time, to set up and solve the partial differential equations (PDE) known as the wave equations, utt = c uxx.

References:

  1. Willem Hundsdorfer, Jan Verwer,
    Numerical solution of time-dependent advection-diffusion-reaction equations,
    Springer, 2003
    ISBN: 978-3-662-09017-6

Source Code:


Last revised on 17 March 2026.