fd1d_advection_diffusion_steady, a C 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^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.
fd1d_advection_diffusion_steady_test
FD1D_ADVECTION_FTCS, a C 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 C 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 C 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.