FD1D_ADVECTION_DIFFUSION_STEADY
Finite Difference Method
Steady 1D Advection Diffusion Equation


FD1D_ADVECTION_DIFFUSION_STEADY is a C program 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, creating graphics files for processing by GNUPLOT.

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

        v du/dx - k d^2u/dx^2
      
over the interval:
        0.0 <= x <= 1.0
      
with boundary conditions
        u(0) = 0, u(1) = 1.
      

We do this by discretizing the interval [0,1] into NX nodes. We write the boundary conditions at the first and last nodes. At the i-th interior node, we replace derivatives by differences:

This becomes a set of NX linear equations in the NX unknown values of U.

The exact solution to this differential equation is known:

        u = ( 1 - exp ( r * x ) ) / ( 1 - exp ( r ) )
      
where r = v * l / k;

Licensing:

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

Languages:

FD1D_ADVECTION_DIFFUSION_STEADY is available in a C version and a C++ version and a FORTRAN90 version and a MATLAB version.

Related Data and Programs:

FD1D_ADVECTION_FTCS, a C program 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 forward time, centered space (FTCS) difference method.

FD1D_ADVECTION_LAX, a C program 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, a C program 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.

Reference:

  1. Charles Hall, Thomas Porsching,
    Numerical Analysis of Partial Differential Equations,
    Prentice-Hall, 1990,
    ISBN: 013626557X,
    LC: QA374.H29.

Source Code:

Examples and Tests:

List of Routines:

You can go up one level to the C source codes.


Last revised on 03 May 2014.