Here is a simple water ripple simulation showing single slit wave diffraction. The following Mathematica code solves the wave equation with damping using the finite difference method. You can read more about this algorithm on Hugo Elias’ website. (Note: technically this simulation should use Neumann boundary conditions but I decided it was simplier to demonstrate using Dirichlet boundary conditions).

`(* runtime: 18 seconds, c is the wave speed and b is a damping factor *) n = 64; c = 1; b = 5; dx = 1.0/(n - 1); Courant = Sqrt[2.0]/2;dt = Courant dx/c; z1 = z2 = Table[0.0, {n}, {n}]; Do[{z1, z2} = {z2, z1}; z1[[n/2, n/4]] = Sin[16Pi t]; Do[If[0.45 < i/n < 0.55 || ! (0.48 < j/n < 0.52), z2[[i, j]] = (2(1 - 2Courant^2)z1[[i, j]] + Courant^2(z1[[i - 1, j]] + z1[[i + 1, j]] + z1[[i, j - 1]] + z1[[i, j + 1]]))/(1 + b dt) - z2[[i, j]]], {i, 2, n - 1}, {j, 2, n - 1}]; ListPlot3D[z1, Mesh -> False, PlotRange -> {-1, 1}], {t, 0, 1, dt}];`

### Links

- Water Figures – beautiful high-speed camera splashes by Fotoopa
- LSSM – POV-Ray animations using this same technique, by Tim Nikias Wenclawiak
- POV-Ray Ripples – another one by Rune Johansen
- Water Ripples – Delphi program by Jan Horn
- Waves – C++ program by Maciej Matyka
- Fluid Animations – amazing animations by Ron Fedkiw, with Eran Guendelman, Andrew Selle, Frank Losasso, et al.
- Free Surface Fluid Simulations – impressive simulations using the Lattice-Boltzmann method with level sets, by Nils Thuerey, author of Blender’s fluid package
- Fluid v1.0 – C++ program for fluid surfaces by Maciej Matyka, uses Marker And Cell (MAC) method
- ball in water – nice 3D POV-Ray animation by Fidos
- Splash – analytical Mathematica plot by Dr. Jim Swift
- Smoke Animations – by Jos Stam, Henrik Jensen, Ron Fedkiw, et al.
- Fire Animations – by Duc Nguyen, Henrik Jensen, Ron Fedkiw

Frankly i did not understand the algorithm althogh i got the idea of how you transfer of data from one buffer frame to the next .

For example the arrays of integers ?Of what size?

And why do you have this sort of code….Buffer2(x, y) = (Buffer1(x-1,y)

Buffer1(x+1,y)

Buffer1(x,y+1)

Buffer1(x,y-1)) / 2 – Buffer2(x,y)

I did not understand what this exactly is ….although it looks like the coordinates of previous pts. are taken by the next array …

And similarly the spreading code …Smoothed(x,y) = (Buffer1(x-1, y) +

Buffer1(x+1, y) +

Buffer1(x, y-1) +

Buffer1(x, y+1)) / 4

AWESOME!