Wave propagation and interference phenomenom simulation with Matlab
Young's double-slit experiment
- Animation, results, and observation
- Simulation & computation principles - Matlab code
- Details on theoritical & mathematical computations: interference phenomenom
Animation, results, and observation
See and observe the following animation:Figure is subdivised into 3 subplots (see using custom subplots),
- left: whole simulation, wave propgation + double-slit
- lower right: wave propagation after the slits
- upper right: receiving screen (top of previous plots), showing interferences. Line curve is from theoritical computation.
Simulation & computation principles - Matlab code
Simulation and computationnal aspects rely on finite difference method, see for example (french) this page and also for example (also french) introduction to Matlab programming, and more precisely TP 9: Simulation bidimensionnelle de la propagation d'une onde, Diffraction par une simple ou double fenteComputation, simulation, and animation is performed using Matlab, from the following script:
% New beginning... clean...
clear all;close all
tic
c=10;
% Grid
Lx=100;
Ly=100;
T=15;
deltax=Lx/200;
deltay=Ly/200;
deltat=sqrt(deltax^2+deltay^2)/(2*c)
deltat=0.9*deltat
gax=(c*deltat)^2/(deltax^2);
gay=(c*deltat)^2/(deltay^2);
xx=[0:deltax:Lx];nx=length(xx);
yy=[0:deltay:Ly];ny=length(yy);
tt=[0:deltat:T];nt=length(tt);
Reflection_parois=0; % if 1, reflection on boundaries
% else absorbing waves on boundaries
Largeurx=1;Nlgx=round(Largeurx/Lx*nx);
posfx=50;nfx1=round(posfx/Lx*nx);nfx2=nfx1+Nlgx;
LargeurFy=2;NFy=round(LargeurFy/Ly*ny);
posF1y=Ly/2-LargeurFy/2;posF2y=Ly/2+LargeurFy/2;
cF1y=round(posF1y/Ly*ny);cF1y=96;
cF2y=round(posF2y/Ly*ny);cF2y=104;
nF1y1=cF1y-NFy/2;nF1y2=nF1y1+NFy/2;
nF2y1=cF2y-NFy/2;nF2y2=nF2y1+NFy/2;
Fentex=[nfx1:nfx2];
Fentey=[1:nF1y1,nF1y2:nF2y1,nF2y2:ny];
% Source location
sx=round(nx/4);sy=round((nF1y2+nF2y1)/2);
% Source frequency: 2 Hertz
sfrq=2;
Mat=zeros(nx,ny,nt);
% Mat Indexes, without boundaries:
i=[2:nx-1];j=[2:ny-1];
Mat(i,j,2)=Mat(i,j,1)+...
gax/2*(Mat(i-1,j,1)+Mat(i+1,j,1)-2*Mat(i,j,1))+...
gay/2*(Mat(i,j-1,1)+Mat(i,j+1,1)-2*Mat(i,j,1));
for k=3:nt-1
Mat(i,j,k+1)=2*Mat(i,j,k)-Mat(i,j,k-1)+...
gax*(Mat(i-1,j,k)+Mat(i+1,j,k)-2*Mat(i,j,k))+...
gay*(Mat(i,j-1,k)+Mat(i,j+1,k)-2*Mat(i,j,k));
Mat(sx,sy,k+1)=sin(2*pi*sfrq*k*deltat);
if (Reflection_parois==0)
Mat(1,:,k+1)=Mat(2,:,k);
Mat(nx,:,k+1)=Mat(nx-1,:,k);
Mat(:,1,k+1)=Mat(:,2,k);
Mat(:,ny,k+1)=Mat(:,ny-1,k);
end
Mat(Fentex,Fentey,k+1)=0;
end
m=max(max(max(Mat)))
% Double-slit plot
Mat(Fentex,Fentey,:)=1;
% Plot command area:
% 3 subplots:
% - left: whole simulation: wave propgation + double-slit
% - lower right: wave after passing through the slits
% - upper right: receiving screen, showing interferences
fig=figure(1);clf;whitebg('w');
set(fig,'position',[0 0 640 480]);
% Initialising Film variable
% to contain all frames and to make finally a... film...
Film=[];
ecranx=200;
Interf=squeeze(Mat(ecranx,:,:));
MatEcran=Mat;
MatEcran(ecranx,:,:)=5;
MatEcranSup=MatEcran(101:end,:,:);
% Theoritical result, see below
lbd=c/sfrq; % wave length
k=2*pi/lbd; % wave number
D=Lx/2;
D=(ecranx-max(Fentex))/200*Lx
d=(nF2y1-nF1y2)/200*Ly;
w=k*d/D;
for kk=1:1:nt
subplot('position',[0.05 0.2 0.45 0.6])
pcolor(squeeze(MatEcran(:,:,kk)));
shading interp,axis off
caxis([-0.4 0.4])
subplot('position',[0.55 0.05 0.4 0.4])
pcolor(squeeze(MatEcranSup(:,:,kk)));
shading interp
caxis([-0.003 0.003]);
axis off
subplot('position',[0.55 0.55 0.4 0.4])
axis off;hold on
% The very theory:
plot(xx,(.75e-6)*(cos(w*(xx-49))).^2,'-r','linewidth',2);
plot(xx,Interf(:,kk).^2)
axis([xx(30) xx(end-30) 0 1e-6])
title('{\bf \''Ecran}','fontsize',16,'interpreter','Latex')
%Film=[Film getframe(fig)];
pause(0.05)
end
%movie2avi(Film,'Film.avi','compression','none','fps',15)
Details on theoritical and mathematical computations: interference phenomenom
(0,-.4)
\psline[linewidth=1.5pt](0,-.2)(0,.2)
\psline[linewidth=1.5pt](0,.4)(0,3)
\psline[linecolor=blue]{<->}(-.4,-.3)(-.4,.3)
\rput[r](-.6,0){\blue$d$}
\psline[linecolor=blue]{<->}(0,-2)(4,-2)
\rput[r](2,-2.3){\blue$D$}
\psline[linewidth=1.5pt](4,-3)(4,3)
\psline(0,-.3)(4,1.5)(0,.3)
\rput(2,1.15){$d_1$}\rput(2,.3){$d_2$}
\psline[linestyle=dashed](-.25,0)(4.5,0)
\psline[linecolor=blue]{->}(4.2,0)(4.2,1.5)
\rput[l](4.3,.8){\blue$x$}
\end{pspicture}\]](Young-double-slit-interference-experiment-IMG/1.png)
Amplitude
where
This sum can be written
then, as is common with complex exponentials, factorising with the mean argument:
![\[\begin{array}{ll}
A(x)
&=I_0e^{i\omega t}e^{-ik(d_1+d_2)/2}\Bigl[ e^{ik(d_2-d_1)/2}+e^{ik(d_2-d_1)/2}\Bigr]\\[.8em]
&=I_0e^{i\omega t}e^{-ik(d_1+d_2)/2}\times 2\cos\left( k\dfrac{d_2-d_1}{2}\right)
\enar\]](Young-double-slit-interference-experiment-IMG/11.png)
Then, the intensity of a light field is proportionnal to the square of the modulus of its amplitude:
We have geometrically, with above notations,
![\[\begin{array}{ll}
d_1&=\sqrt{\left( x-\dfrac{d}{2}\rp^2+D^2} \\[1em]
d_2&=\sqrt{\left( x+\dfrac{d}{2}\rp^2+D^2}
\enar\]](Young-double-slit-interference-experiment-IMG/14.png)
Assuming that the distance
![\[\begin{array}{ll}
d_1&=\sqrt{x^2-dx+\dfrac{d^2}{4}+D^2}\\[1em]
&=D\sqrt{1+\dfrac{x^2}{D^2}-\dfrac{d}{D^2}x+\dfrac{d^2}{4D^2}}\\[1em]
&\simeq D\left( 1+\dfrac{x^2}{2D^2}-\dfrac{d}{2D^2}x\rp\\
&\simeq D+\dfrac{x^2}{2D}-\dfrac{d}{2D}x
\enar\]](Young-double-slit-interference-experiment-IMG/17.png)
and the same for
Finally, at first order,
so that, intensity on the screen is given by
Intensity is finally proportionnal to:
![\[\psset{xunit=1cm,yunit=2cm,arrowsize=7pt}
\begin{pspicture}(-5,-.3)(5.5,1.4)
\psline[linewidth=1pt]{->}(-5,0)(5.5,0)
\psline[linewidth=1pt]{->}(0,-.2)(0,1.4)
\psplot[plotpoints=200,linecolor=red,linewidth=1.5pt]{-5}{5}{x 180 mul 3.14 div cos 2 exp}
\end{pspicture}\]](Young-double-slit-interference-experiment-IMG/22.png)
which is coded in the Matlab simulation and can be observed on top of the page