FD1D_ADVECTION_LAX is a FORTRAN77 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 for the time derivative, writing graphics files for processing by gnuplot.

The Lax method is an improvement to the FTCS method. The FTCS method is always unstable; nonphysical oscillations appear and grow. The Lax method is stable, if the time step is small enough; however, it does cause the wave to gradually spread out and flatten.

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.

The Lax method modifies the FTCS approximation to the time derivative:

• du/dt = (u(t+dt,x)-0.5*u(t,x-dx)-0.5*u(t,x+dx))/dt
• du/dx = (u(t,x+dx)-u(t,x-dx))/2/dx

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. Unlike in the case of the FTCS approach, we do not see unstable oscillations. However, instead, we definitely find the wave gradually flattening out.

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

### Languages:

FD1D_ADVECTION_LAX is available in a C version and a C++ version and a FORTRAN77 version and a FORTRAN90 version and a MATLAB version.

### Related Data and Programs:

FD1D_ADVECTION_FTCS, a FORTRAN77 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_BURGERS_LAX, a FORTRAN77 program 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_BVP, a FORTRAN77 program which applies the finite difference method to a two point boundary value problem in one spatial dimension.

FD1D_HEAT_EXPLICIT, a FORTRAN77program which uses the finite difference method and explicit time stepping to solve the time dependent heat equation in 1D.

FD1D_HEAT_IMPLICIT, a FORTRAN77 program which uses the finite difference method and implicit time stepping to solve the time dependent heat equation in 1D.

FD1D_HEAT_STEADY, a FORTRAN77 program which uses the finite difference method to solve the steady (time independent) heat equation in 1D.

FD1D_PREDATOR_PREY, a FORTRAN77 program which implements a finite difference algorithm for predator-prey system with spatial variation in 1D.

FD1D_WAVE, a FORTRAN77 program which applies the finite difference method to solve the time-dependent wave equation utt = c * uxx in one spatial dimension.

GNUPLOT, FORTRAN77 programs which illustrate how a program can write data and command files so that gnuplot can create plots of the program results.

### Reference:

1. George Lindfield, John Penny,
Numerical Methods Using MATLAB,
Second Edition,
Prentice Hall, 1999,
ISBN: 0-13-012641-1,
LC: QA297.P45.

### Examples and Tests:

Graphical output for this program was created using GNUPLOT. Data at selected time steps was written to a "data" file, and the appropriate GNUPLOT commands were written to a "command" file. The plot can be created by the command