fd1d_advection_ftcs


fd1d_advection_ftcs, an Octave 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 FTCS method, forward time difference, centered space difference.

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.
      

We use a method known as FTCS:

The FTCS method is unstable for the advection problem. One purpose of this example is to demonstrate that fact.

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. Instead, because of the instabilities, we see that the solution quickly becomes dominated by erroneous oscillations.

There are more sophisticated methods for the advection problem, which do not exhibit this behavior.

Licensing:

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

Languages:

fd1d_advection_ftcs is available in a C version and a C++ version and a Fortran90 version and a MATLAB version and an Octave version.

Related Data and Programs:

fd1d_advection_ftcs_test

fd1d_advection_diffusion_steady, an Octave code which applies the finite difference method to solve the steady advection diffusion equation v*ux-k*uxx=0 in one spatial dimension, with constant velocity v and diffusivity k.

fd1d_advection_lax, an Octave code which applies the finite difference method to solve the time-dependent advection equation ut = - c * ux in one spatial dimension, with a constant velocity, using the Lax method to treat the time derivative.

fd1d_advection_lax_wendroff, an Octave code which applies the finite difference method to solve the time-dependent advection equation ut = - c * ux in one spatial dimension, with a constant velocity, using the Lax-Wendroff method to treat the time derivative.

fd1d_burgers_lax, an Octave code which applies the finite difference method and the Lax-Wendroff method to solve the non-viscous time-dependent Burgers equation in one spatial dimension.

fd1d_burgers_leap, an Octave code which applies the finite difference method and the leapfrog approach to solve the non-viscous time-dependent Burgers equation in one spatial dimension.

fd1d_bvp, an Octave code which applies the finite difference method to a two point boundary value problem in one spatial dimension.

fd1d_heat_explicit, an Octave code which uses the finite difference method and explicit time stepping to solve the time dependent heat equation in 1D.

fd1d_heat_implicit, an Octave code which uses the finite difference method and implicit time stepping to solve the time dependent heat equation in 1D.

fd1d_heat_steady, an Octave code which uses the finite difference method to solve the steady (time independent) heat equation in 1D.

fd1d_predator_prey, an Octave code which implements a finite difference algorithm for predator-prey system with spatial variation in 1D.

fd1d_wave, an Octave code which applies the finite difference method to solve the time-dependent wave equation utt = c * uxx in one spatial dimension.

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 22 June 2023.