XWAVES
X Window Simulation of Wave Equations


XWAVES is a C program which illustrates the behaviors of three common wave equations, differing in the relation between the frequency w and the wave number k. First is the simple wave equation with w proportional to k; this is the equation is obeyed by free photons. Second is the Klein-Gordon equation with w proportional to the sqrt(k^2+m^2) with m a constant representing a particle mass, say that of the electron or a pion. Finally is the equation for long wavelength water waves, which obey w proportional to sqrt(k).

The program starts with wave packets cycling around the periodic boundary conditions. The equation is that for light, and the wave packets move with the same velocity as the short waves of which they are composed.

If you now click on the "mesons" button, the mass term of the Klein-Gordon equation is turned on. Note how the short components now move faster than the packets. This illustrates how the group velocity of a wave equation can differ from the phase velocity. For the Klein-Gordon equation, the phase velocity exceeds the speed of light, but this is not a problem because information is carried only by wave packets, which move at the group velocity. The latter is always less than the speed of light.

Selecting the water button shows a similar effect. In this case the group velocity is exactly one half the phase velocity. This follows from the frequency going as the square root of the wavelength. This is my favorite example of an interesting result following from dimensional analysis.

Mathematically, the phase velocity v_p of a wave equation is given by the relation

v_p = w / k
while the group velocity v_g is
v_g = dw / dk
Only for the simple wave equation are these equal.

The program has a variety of other buttons to play with. The "quit," ``pause,'' and ``slow'' buttons do the obvious things. A mouse click in the wave portion of the window will insert a disturbance, much like throwing a rock into a pond. The "damp" button slowly damps out any waves present, while "vacuum" settles the system immediately. The "reverse" button reverses the motion of all waves. The "right" button eliminates all left moving waves. Pressing "packet" restores the initial two packet state.

The "blob" gadget changes the display so the waves run around a spherical blob rather than along the periodic line. The "drift" button lets that blob drift around and bounce off the window walls. It has no effect when not in the blob display mode. A highly excited drifting blob with the slow button seems like a blend of Matisse with a lava lamp.

For each one of the three equations, try calming the state with the vacuum button and then exciting a pulse with a mouse click. Observe how the light equation gives a pulse dividing into oppositely moving pieces that move without changing shape. With the meson equation, an oscillating central region emits at first short wavelengths followed by longer ones. With water, the long waves are the first to leave the excitation region.

Some technical details: The waves are displayed using the Xlib routine XPolyFill() with 256 points on the wave surface. To avoid discretization errors, the evolution is calculated in momentum space and then a fast Fourier transform gives the position space coordinates. You can easily obtain other wave equations by modifying the routine makedispersion().

Author:

Michael Creutz

Related Data and Programs:

MANDELBROT, a FORTRAN90 program which generates an ASCII PPM image of the Mandelbrot set;

MDDISK is a C program which displays a molecular dynamics simulation of a fluid as a collection of soft disks, using X Windows and Motif.

REACTOR_SIMULATION is a FORTRAN90 program which is a simple Monte Carlo simulation of the shielding effect of a slab of a certain thickness in front of a neutron source. This program was provided as an example with the book "Numerical Methods and Software."

SHOWME is a C program which uses the X Window library to display triangulatons.

X_WINDOW_DISPLAY, a discussion of the issues involved when an X Window program on a remote machine needs to know how to get graphics information back to your local display.

XFIRES is a C program which simulates the occurrence of fires and regrowth in a forest, displaying the results using X Windows.

XISING is a C program which simulates the occurrence of ferromagnetism in a material, displaying the results using X Windows.

XGED is a C program which can edit graphs visually; it uses the X Window library to display the graph, and to detect the user's input.

X_WINDOW is a C++ example directory which demonstrates some simple uses of the X Window library.

Source code:

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


Last revised on 23 March 2008.