fd1d_advection_diffusion_steady, a Fortran77 code which applies the finite difference method (FDM) 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^2over the interval:
0.0 <= x <= 1.0with 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:
The exact solution to this differential equation is known:
u = ( 1 - exp ( r * x ) ) / ( 1 - exp ( r ) )where r = v * l / k;
The computer code and data files described and made available on this web page are distributed under the MIT license
fd1d_advection_diffusion_steady is available in a C version and a C++ version and a Fortran90 version and a MATLAB version and an Octave version.
fd1d_advection_diffusion_steady_test
fd1d_advection_ftcs, a Fortran90 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 Fortran90 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 Fortran90 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.