Double-Slit Experiment Simulation

This post is about simulating the double-slit experiment using a water tank simulation in Matlab. The simulation is really used to create a rain drop animation, but I modified it slightly to do the double-slit experiment.

In the video I show the rain drop simulation, the double-slit and an interesting case where I let a drop pulsate and reflect off circles. The waves behave much like light, behind the circles we have shadows. It makes for cool images any way:

The reason for doing this project was to attempt to modify a very simple algorithm and get something quite complex out of it. I started with a droplet simulation described:

The reason I thought of the double-slit experiment is because light is thought of as particles and waves (like drops in a water tank). I have previously created a post on how I create a 1-dimensional wave using vertical springs, check it out: This project is in 2 dimensions and it is actually much simpler to implement than my spring solution.

The program starts off with an empty matrix, and like the game of life, if things happens on the board, the surrounding cells will be affected. The update stage is done to a temporary matrix and this is copied over the primary, just like in the game of life.

The droplet code create waves that propagates through the medium in all directions. The waves are odd, because they are discretized. So I added a smoothing filter to the matrix, just for visualization.

The beauty of the code is that we don’t use any ray tracing or describe any circles, it’s all embedded in the way the matrices are used.

In the double-slit experiment we use a laser beam, a double-slit plate and a wall at a certain distance from the plate. The laser beam illuminates the plate and because of the wave-particle nature of light, the light waves from each slit will spread and interfere with itself forming interference patterns on the wall. Light will interact and cancel out itself.

One way to demonstrate this effect is to use a water tank, a double-slit and a plane wave. In order to get a plane wave from this experiment I thought that a plane wave bascially is a train of drops.

In my simulation the next to last column of the matrix is updated using a line controlled by a cosine. It is simply constantly creating plane waves.

To create the double slit I simply set the matrix elements to zero for each iteration. I use a mask matrix to do this. I have defined the intervals of the slits in slit1 and slit2:

mask         = ones(n, n); %keep all elements

mask(1:slit1(2), slit1(1)) = 0;
mask(slit1(2)+slit1(3):slit2(2), slit1(1)) = 0;
mask((slit2(2)+slit2(3)):end, slit2(1)) = 0;

We also need to add a boundary, otherwise we will get weird reflections:

mask(:, 1)    = 0;
mask(:, end ) = 0;
mask(1, : )   = 0;
mask(end, : ) = 0;

The plane waves from the right were created using

Buffer1(1:n, end-1) = 5*cos(iteration/2);

where iteration is the step in the animation. I then update the matrix and switch between the buffers just like in the game of life. I also had to apply a gaussian filter for the visualization:

filter = fspecial('gaussian', 2, 1);

For each iteration, after the generation of the wave I apply the mask:

Buffer1 = Buffer1.*mask;

The update routine:

    for x = 2:n-2
        for y = 2:n-1

            Buffer2(x, y) = 0.5*( Buffer1(x-1, y) + Buffer1(x+1, y) +...
                Buffer1(x, y+1) + Buffer1(x, y-1) )...
                - Buffer2(x, y);
            Buffer2(x, y) = Buffer2(x, y) * damping;


tmp = imfilter(Buffer2, filter, 'replicate');


%switch buffers
    tmp     = Buffer1;
    Buffer1 = Buffer2;
    Buffer2 = tmp;

Damping is 0.99 in all my visualizations.

See more about the experiment:

Leave a Reply

Your email address will not be published. Required fields are marked *