fd1d_advection_diffusion_steady


fd1d_advection_diffusion_steady, a FORTRAN90 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, 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 MIT 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 codes:

fd1d_advection_diffusion_steady_test

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

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

Reference:

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

Source Code:


Last revised on 23 June 2020.