fd1d_advection_lax_wendroff


fd1d_advection_lax_wendroff, a Python code which applies the finite difference method (FDM) to solve the time-dependent advection equation ut = - c * ux in one spatial dimension, with a constant velocity, using the Lax-Wendroff method for the time derivative, creating a graphics file using matplotlib.

The Lax-Wendroff method is a modification to the Lax method with improved accuracy.

We solve the constant-velocity advection equation in 1D,

        du/dt = - c du/dx
      
over the interval:
        0.0 <= x <= 1.0
      
with periodic boundary conditions, and with a given initial condition
        u(0,x) = (10x-4)^2 (6-10x)^2 for 0.4 <= x <= 0.6
               = 0 elsewhere.
      

For our simple case, 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. While the Lax method produces an artificial smearing of the solution because of an artificial viscosity effect, this behavior is much reduced for the Lax-Wendroff method.

Licensing:

The computer code and data files described and made available on this web page are distributed under the MIT license

Languages:

fd1d_advection_lax_wendroff is available in a C version and a C++ version and a FORTRAN90 version and a MATLAB version and a Python version.

Related Data and codes:

fd1d_heat_explicit, a Python code which uses the finite difference method (FDM) and explicit time stepping to solve the time dependent heat equation in 1D.

fd1d_heat_implicit, a Python code which uses the finite difference method (FDM) and implicit time stepping to solve the time dependent heat equation in 1D.

fd2d_heat_steady, a Python code which uses the finite difference method (FDM) to solve the steady (time independent) heat equation in 2D.

Reference:

  1. George Lindfield, John Penny,
    Numerical Methods Using MATLAB,
    Second Edition,
    Prentice Hall, 1999,
    ISBN: 0-13-012641-1,
    LC: QA297.P45.

Source Code:


Last revised on 07 January 2015.