Diffraction Primer - 0      H. Q. Le  copyrighted

ECE 5368/6358                              han q le - copyrighted
Use solely for students registered for UH ECE 6358/5368 during courses - DO NOT distributed (copyrighted materials)

Segment 2

5. Illustration: grating diffraction

5.0 Introduction

Class demonstration & discussion.

Slit grating diffraction: Below is an array of slit.

Graphics[{Rectangle[{-3,0},{43,10}],Table[{White,Rectangle[{i,0},{i+0.4,10}]},{i,1,40}] }]

We will find out what it’s far field diffraction looks like. We will solve this problem one basic step at a time.

5.1 Review: Fraunhofer diffraction of a single slit:

From the above, we consider only one dimensional diffraction with normal incidence:  
                                       U[(OverHat[Ω])]~((sin(a k ξ))/(k ξ))                 (5.1.1)
where:                                 ξ=Sin[θ]
and θ is the far field angle in one dimension.

Source code: Fraunhofer single-slit diffraction

Block[{slit,RUN}
,Manipulate[
If[RUN== 1,
k=2 π ;
Manipulate[

slit=Graphics[{Thickness[0.01],Line[{{0,-15},{0,-a}}]
,Line[{{0,15},{0,a}}]}] ; 
Show[slit,
DensityPlot[Re[((E^(I k ((Sqrt[(x^2)+(z^2)])-t)))/(Sqrt[(x^2)+(z^2)]))](((Sin[(a k Sin[ArcTan[x/z]])])/(k Sin[ArcTan[x/z]]))),{z,30,45},{x,-15,15}, AspectRatio-> 2, PlotPoints-> {80,40}, ColorFunction-> "Rainbow"
,PlotRange-> All]
,Graphics[Inset["See HW for Fresnel zone wave",{20,0}
,BaseStyle->{14,Italic,FontFamily-> "Calibri"}
,Background->Hue[0.07,0.7,1]]]
,PlotRange-> {{0,45},{-15,15}}]
,{{a,1.},0.5,5},{t,0,1}]

,TextCell["Not running"
,Black,20,Italic,FontFamily->"Calibri",Background->GrayLevel[0.7]]]
,Button["FRAUNHOFER DIFFRACTION OF A SINGLE SLIT",BaseStyle->{24,Black, Bold,FontFamily-> "Calibri"}
,Background->Hue[0.4,1,1]]
,Row[{Button["Toggle box to start, and turn off when not running",BaseStyle->{16,White, Bold,FontFamily-> "Calibri"}
,Background->Black],Control[{{RUN,0,"->"},{0,1}}]
}]
]
]

Demo: Fraunhofer single-slit diffraction

5.2  Fraunhofer diffraction pattern of two slits

Consider 2 slits of width 2a, with centers at location
                                 x=-d/2 and x=d/2   (assume that 2a < d)
What is the far field?

Hint:                     U~(∮_A) (e^(-i k (x ξ+y η)))  dS =(∮_A) (e^(-i k x ξ))  dS     in 1 dimension.          
Instead of integrating:   (∫_(-a)^a)(e^(-i k x ξ))dx as above, we must do this:

(∫_(-a-d/2)^(a-d/2))(E^(-I k x ξ))\[DifferentialD]x +(∫_(-a+d/2)^(a+d/2))(E^(-I k x ξ))\[DifferentialD]x

FullSimplify[%]

Hence:                           U[(OverHat[Ω])]~((sin(a k ξ) )/(k ξ))cos(((d k ξ)/2))                 (5.2.1)
where:                                   ξ=Sin[θ]
and θ is the far field angle in one dimension.

Plot for λ=1, choose a range of value of d, such as 1.5 to 2.5, and keep a fixed at 0.25.

Source code: Young double-slit diffraction/interference

Block[{k,slit,RUN}
,Manipulate[
If[RUN== 1,
Manipulate[
k=2 π/λ ;
slit=Graphics[{Thickness[0.01],Line[{{0,-15},{0,-a-0.5d}}]
,Line[{{0,a-0.5d},{0,-a+0.5d}}]
,Line[{{0,15},{0,a+0.5d}}]}] ; 

{Plot[(((Sin[a k Sin[θ]] )/(k Sin[θ]))Cos[0.5*d k Sin[θ]])^2,{θ,-π/2,π/2}, PlotRange-> All] 
,
DensityPlot[(((Sin[a k Sin[θ]] )/(k Sin[θ]))Cos[0.5*d k Sin[θ]])^2,{θ,-π/2,π/2},{y,-1,1}, PlotRange-> All, ColorFunction-> GrayLevel, PlotPoints-> {50,2}]
,

Manipulate[Show[slit,
DensityPlot[Re[((E^(I k ((Sqrt[(x^2)+(z^2)])-t)))/(Sqrt[(x^2)+(z^2)]))]
(((Sin[(a k Sin[ArcTan[x/z]])])/(k Sin[ArcTan[x/z]]))Cos[0.5*d k Sin[ArcTan[x/z]]]),{z,35,45},{x,-15,15},  PlotPoints-> {40,60}, ColorFunction-> GrayLevel
,PlotRange-> All] 
(* ,Graphics[Inset["See HW for Fresnel zone wave",{20,0}
,BaseStyle->{14,Italic,FontFamily-> "Calibri"}
,Background->Hue[0.07,0.7,1]]] *)
,PlotRange-> {{0,45},{-15,15}}]
,{t,0,1} ]
}
,{{λ,1},0.5,2},{{a,0.4},0.25,2},{{d,2.},1.2,5}]

,TextCell["Not running"
,Black,20,Italic,FontFamily->"Calibri",Background->GrayLevel[0.7]]]
,Button["YOUNG DOUBLE-SLIT DIFFRACTION/INTERFERENCE",BaseStyle->{24,Black, Bold,FontFamily-> "Calibri"}
,Background->Hue[0.4,1,1]]
,Row[{Button["Toggle box to start, and turn off when not running",BaseStyle->{16,White, Bold,FontFamily-> "Calibri"}
,Background->Black],Control[{{RUN,0,"->"},{0,1}}]
}]
]
]

Demo: Young double-slit diffraction/interference

Short code for faster execution

a=0.25; 
Manipulate[ k=2 π/λ ;
DensityPlot[(((sin(a k Sin[θ]) )/(k Sin[θ]))cos(((d k Sin[θ])/2)))^2,{θ,-π/2,π/2},{y,-1,1}, PlotRange-> All, ColorFunction-> GrayLevel, PlotPoints-> {50,2}],{d,1.2,5},{λ,0.8,1.1}]

5.3 For N slits - Diffraction grating

Suppose we have N slits that are spaced periodically with d spacing. Can we calculate and plot the Fraunhofer diffraction pattern in the farfield?

Hint: you want to add:  
(∫_(-a)^a)(e^(-i k x ξ))dx +(∫_(-a+d)^(a+d))(e^(-i k x ξ))dx +(∫_(-a+2d)^(a+2d))(e^(-i k x ξ))dx+(∫_(-a+3d)^(a+3d))(e^(-i k x ξ))dx+...+(∫_(-a+N d)^(a+N d))(e^(-i k x ξ))dx
Or:                    (∑_(m=0)^N)(∫_(-a+m d)^(a+m d))(e^(-i k x ξ))dx                                 (5.3.1)
You can make a variable transformation:
                                      (Subscript[x, new])=x-m d                               (5.3.2)
 what becomes of the integral (∫_(-a+m d)^(a+m d))(e^(-i k x ξ))dx? (= (e^(-i m k d ξ))(∫_(-a)^a)(e^(-i k (Subscript[x, new]) ξ))d(Subscript[x, new]))
and the sum becomes:
                              (∑_(m=0)^N)(∫_(-a+m d)^(a+m d))(e^(-i k x ξ))dx=?  (fill in)
              (∑_(m=0)^N)(∫_(-a+m d)^(a+m d))(e^(-i k x ξ))dx=(∫_(-a)^a)(e^(-i k (Subscript[x, new]) ξ))d(Subscript[x, new])(∑_(m=0)^N)(e^(-i m k d ξ))
              (∑_(m=0)^N)(∫_(-a+m d)^(a+m d))(e^(-i k x ξ))dx=((2 sin(a k ξ))/(k ξ))(∑_(m=0)^N)(e^(-i m k d ξ))               (5.3.3)
Alternatively, you can do this:

k=. ;
(∫_(-a+m d)^(a+m d))(E^(-I k x ξ))\[DifferentialD]x

and the sum becomes:
                                (∑_(m=0)^N)(∫_(-a+m d)^(a+m d))(e^(-i k x ξ))dx=?   (fill in)                      
             (∑_(m=0)^N)(∫_(-a+m d)^(a+m d))(e^(-i k x ξ))dx=((2 sin(a k ξ))/(k ξ))(∑_(m=0)^N)(e^(-i m k d ξ))   (fill in)         
Use this theorem:         1+x+(x^2)+...+(x^N)=((1-(x^((N+1))))/(1-x)) 
to obtain an expression for the Fraunhofer far field.
                  U=(∑_(m=0)^N)(∫_(-a+m d)^(a+m d))(e^(-i k x ξ))dx =((2 sin(a k ξ))/(k ξ))((1-(e^(-i (N+1) k d ξ)))/(1-(e^(-i k d ξ))))  
                                                 =((2 sin(a k ξ))/(k ξ))((Sin[(((N+1)/2)) k d ξ])/(Sin[(1/2)k d ξ]))(e^(-i (N/2) k d ξ))       (5.3.4)
The function ((2 sin(a k ξ))/(k ξ)) is responsible for the “envelope” of the diffraction, and the term ((Sin[(((N+1)/2)) k d ξ])/(Sin[(1/2)k d ξ])) represents diffraction peaks.

HW

Plot for N=50. Keep d fixed at 1.2. Vary λ from 0.8 to 1.1. What do you observe? Discuss.

Source code: Transmission slit diffraction grating

Block[{k,slit,RUN}
,Manipulate[
If[RUN== 1,
Manipulate[
k=2 π/λ ;
slit=Graphics[{Thickness[0.01],Line[{{0,-15},{0,-a-0.5d}}]
,Line[{{0,a-0.5d},{0,-a+0.5d}}]
,Line[{{0,15},{0,a+0.5d}}]}] ; 

{Plot[(((Sin[a k (Sin[θ]-Sin[θi])])/(a k (Sin[θ]-Sin[θi])))((Sin[(((Ns+1)/2)) k d (Sin[θ]-Sin[θi])])/((Ns+1) Sin[(1/2)k d (Sin[θ]-Sin[θi])])))^2,{θ,-π/2,π/2}, PlotRange-> All
] 
,Show[PolarPlot[{(((Sin[a k (Sin[θ]-Sin[θi])])/(a k (Sin[θ]-Sin[θi])))((Sin[(((Ns+1)/2)) k d (Sin[θ]-Sin[θi])])/((Ns+1) Sin[(1/2)k d (Sin[θ]-Sin[θi])])))^2
,(((Sin[a k (Sin[θ]-Sin[θi])])/(a k (Sin[θ]-Sin[θi]))))^2 }
,{θ,-0.9*π/2,0.9*π/2}
 , PlotRange-> {{0.,1.2},{-1.2,1.2}}
,PlotStyle->{{ Thickness[0.01],Hue[0.05,1,1] }
,{Thickness[0.01],Dashed,Hue[0.8,1,0.7]}}]
,Graphics[{Red, Thickness[0.01],Arrow[{0.5*{-Cos[θi],-Sin[θi]},{0.,0.}}]}]
 , PlotRange-> {{-0.5,1.2},{-1.2,1.2}}]
,
DensityPlot[(((2 Sin[a k (Sin[θ]-Sin[θi])])/(k (Sin[θ]-Sin[θi])))((Sin[(((Ns+1)/2)) k d (Sin[θ]-Sin[θi])])/(Sin[(1/2)k d (Sin[θ]-Sin[θi])])))^2,{θ,-π/2,π/2},{y,-1,1}, PlotRange-> All, ColorFunction-> GrayLevel, PlotPoints-> {Max[51,4 Ns+1],2}
,AspectRatio->0.2]

}
,{{λ,1},0.5,2},{{a,0.25},0.25,2},{{d,2.},0.8,5}
,{Ns,1,30,1},{{θi,0.},-0.9*π/2.,0.9*π/2.}]

,TextCell["Not running"
,Black,20,Italic,FontFamily->"Calibri",Background->GrayLevel[0.7]]]
,Button["TRANSMISSION SLIT DIFFRACTION GRATING",BaseStyle->{24,Black, Bold,FontFamily-> "Calibri"}
,Background->Hue[0.4,1,1]]
,Row[{Button["Toggle box to start, and turn off when not running",BaseStyle->{16,White, Bold,FontFamily-> "Calibri"}
,Background->Black],Control[{{RUN,0,"->"},{0,1}}]
}]
]
]

Demo: Transmission slit diffraction grating

We see that the diffraction pattern is very intense whenever 
                                               (1/2)k d ξ=m π                               (5.3.5a)
 Or:                                          ((2 π)/λ) d Sin[θ]=2m π                     (5.3.5b)
                                                 d Sin[θ]=m λ                           (5.3.5c)
For non normal incident:          d (Sin[θ]-Sin[(Subscript[θ, inc])])=m λ            (5.3.5d)                                             
This (Eq. 5.3.5d) is the familiar grating equation.

Manipulate[ k=2 π/λ ;
Plot[(((Sin[a k Sin[θ]])/(a k Sin[θ]))((Sin[(((Ns+1.)/2)) k d Sin[θ]])/((Ns+1.) Sin[(1/2)k d Sin[θ]])))^2,{θ,-π/2,π/2}, PlotRange-> All],{d,1.2,3},{λ,0.8,1.1},{Ns,1,30,1}]

5.4 Phase grating

The above grating has a disadvantage: it blocks a lot of incident light power. In practice, people use reflective grating. Or if it must be transmission, people would use phase grating such that there is no loss, in other words, the diffracted power is approximately equal to the incident power. 
We consider a simple phase grating below. (Cf. class demonstration and discussion).

Consider a periodic phase modulation object:      (e^(i p π Cos[q x]))              (5.4.1)
 where p is the phase modulation amplitude (or modulation depth), q is the spatial frequency:
                                                                q ≡ ((2π)/Λ)                            (5.4.2)
where Λ is the period.
To calculate the diffraction pattern, we consider this relation:
                                   (e^(i p π Cos[q x])) = (∑_(m=-∞)^∞)(i^m) (Subscript[J, m])[p π] (e^(i m q x))              (5.4.3)
We consider an incident beam with a hard-aperture beam width w. For simimarity with the discussion above, we will just assume without loss of any generality that w is a multiple of period Λ, such that:
                                                                 w=N Λ                        (5.4.4)
Applying the Fraunhofer diffraction formula:
            (∫_(-w/2)^(w/2))  (e^(i m π Cos[q x]))(e^(-i k ξ x ))dx=(∑_(m=-∞)^∞)(i^m) (Subscript[J, m])[p π] (∫_(-w/2)^(w/2))  (e^(i m q x))(e^(-i k ξ x ))dx       (5.4.5)

(∫_(-w/2)^(w/2))  (E^(I (m q -k ξ) x))\[DifferentialD]x

((2 sin((1/2) w (m q-k ξ)))/(m q-k ξ))

((2 sin(FullSimplify[(1/2) w (m q-k ξ)/. q->  ((2π)/Λ) /. w-> N  Λ  /. k-> ((2π)/λ)]))/(FullSimplify[m q-k ξ /. q->  ((2π)/Λ)   /. k-> ((2π)/λ) ]))

One more step of simplification:       ((2 sin(π N (m-((Λ ξ)/λ))))/(((2 π m)/Λ)-((2 π ξ)/λ)))= (Λ/( π))  (( sin(π N (m-((Λ ξ)/λ))))/((m-((Λ ξ)/λ))))               
Hence:
       (∫_(-∞)^∞) (e^(-(x^2)/(w^2))) (e^(i m π Cos[q x]))(e^(-i k ξ x ))dx=(Λ/( π))(∑_(m=-∞)^∞)(i^m) (Subscript[J, m])[p π] (( sin(π N (m-((Λ ξ)/λ))))/((m-((Λ ξ)/λ))))        (5.4.6)

We see that for large N, (( sin(π N (m-((Λ ξ)/λ))))/((m-((Λ ξ)/λ)))) has a sharp peak at:
                                                 m-((Λ ξ)/λ)=0                                 (5.4.7a)
                                                 Λ Sin[θ]=m λ                            (5.4.7b)
For an incident beam angle (Subscript[θ, inc]):
                                       Λ (Sin[θ]-Sin[(Subscript[θ, inc])])=m λ                     (5.4.7c)
which is exactly the same grating equations as in (5.3.5d).
For farfield, m is limited by:
                                -1<Sin[θ]=((m λ )/Λ)+Sin[(Subscript[θ, inc])] ≤ 1             (5.4.8a)
Or:                  -(Λ/λ)(1+ sin((Subscript[θ, inc])))≤ m≤(Λ/λ)(1- sin((Subscript[θ, inc])))       (5.4.8b)

Source code: Transmission phase grating diffraction

Block[{mH,mL,norm,RUN}
,Manipulate[
If[RUN== 1,
Manipulate[
mH= Floor[(Λ/λ) (1.-Sin[θi])] ;
mL=  Ceiling[-(Λ/λ) (1.+Sin[θi])];
norm=Sum[  BesselJ[m,p π]^2,{m,mL,mH}];

{Button["Diff. order: "<>ToString[Range[mL,mH]],BaseStyle->{12,Italic, FontFamily-> "Calibri"}
,Background-> Hue[0.4,0.8,1]]
,Plot[10.*Log[10.,(Abs[Sum[(I^m)  BesselJ[m,p π]((Sin[Ns π (m-Λ (Sin[θ]-Sin[θi])/λ)])/(Ns π (m-Λ (Sin[θ]-Sin[θi])/λ))),{m,mL,mH}]])^2/norm],{θ,-0.99*π/2,0.99*π/2}, PlotRange-> {-60,0.}
,PlotStyle-> {Red} ] 
(* ,Plot[(Abs[Sum[(I^m)  BesselJ[m,p π]((Sin[Ns π (m-Λ (Sin[θ]-Sin[θi])/λ)])/(Ns π (m-Λ (Sin[θ]-Sin[θi])/λ))),{m,mbL,mbH}]])^2,{θ,1.01*π/2.,0.99*1.5*π}, PlotRange-> All
,PlotStyle-> {Thick,Blue} ] *)
,Manipulate[Show[PolarPlot[(Abs[Sum[(I^m)  BesselJ[m,p π]((Sin[Ns π (m-Λ (Sin[θ]-Sin[θi])/λ)])/(Ns π (m-Λ (Sin[θ]-Sin[θi])/λ))),{m,mL,mH}]])^2/norm
,{θ,-0.99*π/2,0.99*π/2}
 , PlotRange-> {{0.,pr},{-pr,pr}}
,PlotStyle->{{ Thickness[0.01],Hue[0.05,1,1] }
,{Thickness[0.01],Dashed,Hue[0.8,1,0.7]}}]
,Graphics[{Red, Thickness[0.01],Arrow[{pr*{-Cos[θi],-Sin[θi]},{0.,0.}}]}]
 , PlotRange-> {{-pr,pr},{-pr,pr}}]
,{{pr,0.2},0.05,1}]
,
DensityPlot[(Abs[Sum[(I^m)  BesselJ[m,p π]((Sin[Ns π (m-Λ (Sin[θ]-Sin[θi])/λ)])/(Ns π (m-Λ (Sin[θ]-Sin[θi])/λ))),{m,mL,mH}]])^2
,{θ,-0.99*π/2,0.99*π/2},{y,-1,1}, PlotRange-> All, ColorFunction-> GrayLevel, PlotPoints-> {Max[51,4 Ns+1],2}
,AspectRatio->0.2]

}
,{{λ,1.},0.5,2},{p,1.,-1.},{{Λ,2.5},0.8,10.}
,{{Ns,5},1,30,1},{{θi,0.},-0.9*π/2.,0.9*π/2.}
]

,TextCell["Not running"
,Black,20,Italic,FontFamily->"Calibri",Background->GrayLevel[0.7]]]
,Button["PHASE GRATING DIFFRACTION",BaseStyle->{24,Black, Bold,FontFamily-> "Calibri"}
,Background->Hue[0.4,1,1]]
,Row[{Button["Toggle box to start, and turn off when not running",BaseStyle->{16,White, Bold,FontFamily-> "Calibri"}
,Background->Black],Control[{{RUN,0,"->"},{0,1}}]
}]
]
]

Demo:  Transmission phase grating diffraction

HW: Digital (step function) phase grating diffraction

Block[{M},
Manipulate[
M=Ceiling[20./Λ] ;Show[ Graphics[{Hue[0.45,0.7,1],Table[{Rectangle[{(n-1) Λ,0.},{(n-1) Λ+η Λ,1.5+p}]
,Rectangle[{(n-1) Λ+η Λ,0.},{n Λ ,1.5-p}]},{n,1,M}]}
],PlotRange-> {{0,20.},{0.,2.5}}]
,{{η,0.5},0.,1},{{Λ,1.},0.5,3.},{p,1,0.}]
]

Hint: Apply the Fraunhofer diffraction formula to each period of the grating.
            (∫_0^(η Λ))  (e^(i p π))(e^(-i k ξ x ))dx +(∫_(η Λ)^Λ)  (e^(-i p π))(e^(-i k ξ x ))dx         (5.4.9)

FullSimplify[(∫_0^(η Λ))  (E^(I p π))(E^(-I k ξ x ))\[DifferentialD]x ]+FullSimplify[(∫_(η Λ)^Λ)  (E^(-I p π))(E^(-I k ξ x ))\[DifferentialD]x   ]

FullSimplify[-((I (E^(I p π)) (1-(E^(-I k η Λ ξ))))/(k ξ))-((I (E^(-I (p π+k (1+η) Λ ξ))) ((E^(I k Λ ξ))-(E^(I k η Λ ξ))))/(k ξ))]

This term is known as the “envelope”.

Multiply the term with ((1-(e^(-i N k Λ ξ)))/(1-(e^(-i k Λ ξ)))) where N is the number of grating period >= 1 for the diffraction peaks.

Source code: Transmission digital 1-step phase grating diffraction

Block[{k,mH,mL,norm,RUN,pr},
Manipulate[
If[INIT== 1,
DPGenvelope[{Λ_,η_,p_,k_,ξ_}]:=-((I (E^(-I p π)) (-(E^(-I k Λ ξ))+(E^(-I k η Λ ξ))+(E^(2 I p π)) (1-(E^(-I k η Λ ξ)))))/(Λ k ξ)) ;
INIT=0 
,TextCell["Not ready"
,Black,20,Italic,FontFamily->"Calibri",Background->GrayLevel[0.5]]];
Manipulate[
If[RUN== 1,

Manipulate[
k=((2. π)/λ) ;
mH= Floor[(Λ/λ) (1.-Sin[θi])] ;
mL=  Ceiling[-(Λ/λ) (1.+Sin[θi])];

{(* Button["Diff. order: "<>ToString[Range[mL,mH]],BaseStyle->{12,Italic, FontFamily-> "Calibri"}
,Background-> Hue[0.4,0.8,1]]
,*)
Plot[10.*Log[10.,Abs[(DPGenvelope[{Λ,η,p,k,Sin[θ]-Sin[θi]}]
*((Sin[0.5*Ns k Λ (Sin[θ]-Sin[θi])])/(Ns Sin[0.5*k Λ (Sin[θ]-Sin[θi])])))]^2],{θ,-0.99*π/2,0.99*π/2}, PlotRange-> {-60,20.}
,PlotStyle-> {Red} ] 
,Manipulate[(* pr=10.^(0.1 prdB)  ; *)
Show[PolarPlot[{Abs[(DPGenvelope[{Λ,η,p,k,Sin[θ]-Sin[θi]}]
*((Sin[((Ns/2.)) k Λ (Sin[θ]-Sin[θi])])/(Ns Sin[0.5*k Λ (Sin[θ]-Sin[θi])])))]^2
(* ,Abs[(DPGenvelope[{Λ,η,p,k,Sin[θ]-Sin[θi]}])]^2 *)}
,{θ,-0.99*π/2,0.99*π/2}
 , PlotRange-> {{0.,10.^(0.1 prdB)},{-10.^(0.1 prdB),10.^(0.1 prdB)}}
,PlotStyle->{{ Thickness[0.01],Hue[0.05,1,1] }
,{Thickness[0.01],Dashed,Hue[0.8,1,0.7]}}]
,Graphics[{Red, Thickness[0.01],Arrow[{10.^(0.1 prdB)*{-Cos[θi],-Sin[θi]},{0.,0.}}]}]
 , PlotRange-> {{-10.^(0.1 prdB),10.^(0.1 prdB)},{-10.^(0.1 prdB),10.^(0.1 prdB)}}]
,{{prdB,-10.},-30,0.}]
,
DensityPlot[Abs[(DPGenvelope[{Λ,η,p,k,Sin[θ]-Sin[θi]}]
*((Sin[((Ns/2.)) k Λ (Sin[θ]-Sin[θi])])/(Ns Sin[0.5*k  Λ (Sin[θ]-Sin[θi])])))]^2
,{θ,-0.99*π/2,0.99*π/2},{y,-1,1}, PlotRange-> All, ColorFunction-> GrayLevel, PlotPoints-> {Max[51,4 Ns+1],2}
,AspectRatio->0.2]

}
,{{λ,1.},0.5,2},{{p,0.5},0.,1.},{{Λ,2.5},0.8,10.}
,{{η,0.5},0.01,0.99}
,{{Ns,5},1,30,1},{{θi,0.},-0.9*π/2.,0.9*π/2.}
]
,TextCell["Not running"
,Black,20,Italic,FontFamily->"Calibri",Background->GrayLevel[0.5]]]
,Row[{Button["Toggle box to start, and turn off when not running",BaseStyle->{16,White, Bold,FontFamily-> "Calibri"}
,Background->Black],Control[{{RUN,0,"->"},{0,1}}]
}]
]
,Button["DIGITAL 1-STEP PHASE GRATING DIFFRACTION",BaseStyle->{24,Black, Bold,FontFamily-> "Calibri"}
,Background->Hue[0.4,1,1]]
,Row[{Button["Click once to initialize",BaseStyle->{16,White, Bold,FontFamily-> "Calibri"}
,Background->Red],Control[{{INIT,0,"->"},{0,1}}]
}]
]
]

Demo: Transmission digital 1-step phase grating diffraction

5.6 Apodization (HW)

HW. Diffraction grating with a Gaussian beam.

6. Illustration & exercise: far field diffraction pattern of a single "phase" slit

6.1 Review phase object

Consider a beam (e^(i k z)) going through a situation as shown below:

Answer: a phase difference:  (e^(i k n d)) vs. (e^(i k d)). The phase difference is:
                                          Δϕ=k d (n-1)

We can apply Fraunhofer diffraction theory to a phase object as well as an aperture (which can be considered as amplitude object). Thus we can talk about the diffraction like this:

6.2 Fraunhofer diffraction an object with a center phase delay term (e^(i ϕ))

Here we want to find the Fraunhofer diffraction of the case above, assuming the center object has a phase delay term (e^(i ϕ))

The Fraunhofer diffraction is: 
                U ~(∫_(-2a)^(-a)) (e^(-i k ξ x ))dx+(∫_(-a)^a)(e^(i ϕ)) (e^(-i k ξ x ))dx+(∫_a^(2a)) (e^(-i k ξ x ))dx

(∫_(-2a)^(-a)) (E^(-I k ξ x ))\[DifferentialD]x+(∫_(-a)^a)(E^(I ϕ)) (E^(-I k ξ x ))\[DifferentialD]x+(∫_a^(2a)) (E^(-I k ξ x ))\[DifferentialD]x

FullSimplify[((2 (E^(I ϕ)) sin(a k ξ))/(k ξ))-((I (E^(I a k ξ)) (-1+(E^(I a k ξ))))/(k ξ))-((I (E^(-2 I a k ξ)) (-1+(E^(I a k ξ))))/(k ξ))]

6.3 Intensity diffraction pattern

Plot the intensity diffraction pattern as a function of ϕ, using the following value: λ=1; a=0.5. What happens when ϕ=π, which is λ/2 delay (called half-wave)? Why?

Manipulate[k=2 π ;a=0.5 ;
Plot[Abs[(((2 sin(a k ξ) (2 cos(a k ξ)+(E^(I ϕ))-1))/(k ξ)))]^2,{ξ,-1,1}, PlotRange-> {0,5}],{ϕ,0,2 π}]

Manipulate[k=2 π ;a=0.5 ;
DensityPlot[Abs[(((2 sin(a k ξ) (2 cos(a k ξ)+(E^(I ϕ))-1))/(k ξ)))]^2,{ξ,-1,1},{z,-1,1}, PlotRange-> {0,5}, PlotPoints-> {30,2}, ColorFunction-> GrayLevel],{ϕ,0,2 π}]

Below is a polar plot

Manipulate[k=2 π ;a=0.5 ;
PolarPlot[Abs[(((2 sin(a k Sin[θ]) (2 cos(a k Sin[θ])+(E^(I ϕ))-1))/(k Sin[θ])))]^2,{θ,-π/2,π/2}, PlotRange-> {{0,4},{-1,1}}],{ϕ,0,2 π}]

6.4 A very well known application.

The same theory can be applied to the reflection case as well as the transmission case (see below). Can you think of any use (application) for this case?

Answer

7. Introduction to Digital Diffractive Optics

7.1 Discussion

See in class demonstration and discussion. 
Link to Introduction to Digital Diffractive Optics

7.2 Amplitude image with flat wavefront

A mask with certain transmission function can always be designed in principle (although not necessarily in practice) to project any desired image in the farfield.

7.2.1 Example

ECE6358=ImageData[ ];
{Ny,Nx}=Take[Dimensions[ECE6358],2] ;
ECE6358BW=Sqrt[Reverse[Table[Mean[ECE6358[[i,j]]],{i,1,Ny},{j,1,Nx} ] ]];
m0=Mean[Mean[ECE6358BW]] ;
ECE6358BW=ECE6358BW-m0 ;
ListDensityPlot[ECE6358BW, ColorFunction->GrayLevel, AspectRatio->(Ny/Nx)]

m0

FTECE6358=Fourier[ECE6358BW] ;
FT1=RotateRight[FTECE6358,Ceiling[Length[FTECE6358]/2.]];
FT2=Transpose[FT1];
FT3=RotateRight[FT2,Ceiling[Length[FT2]/2.]];
FT4=Transpose[FT3];

ListDensityPlot[Abs[FT4], ColorFunction->GrayLevel, PlotRange->{0.,0.2}]
ListDensityPlot[Log[Abs[FT4]], ColorFunction->GrayLevel, PlotRange-> All]
ListPlot3D[Abs[FT4], PlotRange-> All]

YTR=InverseFourier[YFT];

RotateLeft[YFT1]

7.2.2 Discussion

7.3 Phase-only mask

See: link to Digital Diffractive Optics