# Creating Stunning Visualizations of Interference Patterns

Written on

## Chapter 1: Introduction to Interference Patterns

During my recent exploration of photonics for an assignment, I set out to generate a 2D representation of the interference pattern from Young's double-slit experiment. I even attempted a 3D version for fun, but time constraints limited my ability to create an animation. Today, we will complete this endeavor.

The process we will follow includes:

- Generating the 2D screen output of the double-slit experiment.
- Creating the 3D surface plot of the phenomenon.
- Developing the animation.

### Section 1.1: Setting Up the Double Slit Parameters

To begin, we need to define the parameters for the double slit and the incident waves:

- Wavelength (λ) = 500 nm
- Slit width (a) = 5 µm
- Distance to screen (d) = 1 cm
- Initial light intensity (I₀) = 1
- Screen dimensions = 2 mm x 2 mm

This information is based on "Fundamentals of Photonics" by Saleh & Teich.

For the light intensity screen image, we must utilize the following intensity formula.

Let’s implement this formula in MATLAB:

clear all;

I0 = 1;

lambda = 500 * (10^-9); % 500nm wavelength

a = 5e-06; % 5µm

d = 1e-2; % 1cm

Q = 2 * atand((a/2) / d); % Calculate theta angle

% Screen dimensions

x = 0:2.0000e-05:0.002; % 2mm

y = 0:2.0000e-05:0.002; % 2mm

[X,Y] = meshgrid(x,y);

Next, we implement the intensity function:

f = 2 * I0 * (1 + cos(X * 2 * pi * Q / lambda)); % Light intensity formula

Visualizing the screen output:

imagesc(f);

### Section 1.2: Visualizing the 3D Surface Plot

In this step, we adjust some parameters for a clearer 3D surface visualization of the double-slit experiment. We introduce a scaling factor (K) to enhance the surface's appearance:

K = 10^5;

d = K * (10^-5);

d_y = d / 2;

interval = d / 110;

x = 0:interval:d;

y = -d_y:interval:d_y;

lambda = K * 500 * (10^-9);

k = (2 * pi) / lambda;

w = (2 * pi) / lambda;

[X,Y] = meshgrid(x,y);

Defining the circular waves:

R1 = (X.^2 + (Y + (2.5 * K * (10^-6))).^2)^(1/2);

R2 = (X.^2 + (Y - (2.5 * K * (10^-6))).^2)^(1/2);

Defining the propagation waves:

u1 = K * cos(k * R1);

u2 = K * cos(k * R2);

Z = u1 + u2;

Visualizing the 3D plot:

surf(X,Y,Z);

## Chapter 2: Creating the Animation

Now for the exciting part—let's create the animation!

K = 10^5;

d = K * (10^-5);

d_y = d / 2;

res = 110; % Adjust resolution by changing the number of points

interval = d / res;

x = 0:interval:d;

y = -d_y:interval:d_y;

lambda = K * 500 * (10^-9);

k = (2 * pi) / lambda;

[X,Y] = meshgrid(x,y);

R1 = (X.^2 + (Y + (2.5 * K * (10^-6))).^2)^(1/2);

R2 = (X.^2 + (Y - (2.5 * K * (10^-6))).^2)^(1/2);

u1 = K * cos(k * R1);

u2 = K * cos(k * R2);

Z = K * cos(k * R1) + K * cos(k * R2);

% Loop for each frame of the animation

for k = 1:res

hold on;

surf(X(:,k:k+1),Y(:,k:k+1),Z(:,k:k+1));

grid on;

whitebg('white'); % Set background color

set(gcf,'Position',[10 50 1000 700]);

view([-2,-1.5,3]); % Set perspective

hold off;

Mov(k) = getframe;

axis([0 0.6 0 inf]);

end

In the movie() function, the first parameter indicates how many times to repeat the animation, while the second parameter specifies the frames per second (fps).

movie(Mov,5,40);

Congratulations! You have successfully created a simple animation of wave interference. I hope you found this guide enjoyable and informative.

For further questions or discussions, feel free to reach out!

The first video demonstrates how to study the interference pattern using MATLAB, showcasing practical applications and methodologies.

The second video is a tutorial lecture on interference in MATLAB, providing deeper insights into the concepts discussed.