%Simulation with LightPipes for Matlab.
%March 2014. F.A. van Goor.
%roundhole.m
%Diffraction at a round hole.
clear all;

m=1;
nm=1e-9*m;
mm=1e-3*m;
cm=1e-2*m;

lambda=632.8*nm;
size=10*mm;
N=300;
a=1*mm;
dz=20*cm;
z0=20*cm;
F=LPBegin(size,lambda,N);
F=LPGaussHermite(0,0,1.0,size/2.0,F);
F=LPCircAperture(a,0,0,F);
figure('Position',[20 100 1492 462]);
for i=0:8
   z=z0+i*dz;
   FresnelNumber=a*a/z/lambda;
   if (FresnelNumber >= 10)
        F1=LPFresnel(z,F);
   else
        F1=LPForvard(z,F);
   end
   I=LPIntensity(1,F1);
   subplot(2,5,i+1);
   subimage(I);
   Str=sprintf('z=%4.1f cm   FN=%4.2f',z/cm,FresnelNumber)
   title(Str);
   axis off;
end