%% $Id: pst-diffraction-docE.tex 134 2009-09-27 12:28:50Z herbert $
\documentclass[11pt,english,BCOR10mm,DIV12,bibliography=totoc,parskip=false,smallheadings,
    headexclude,footexclude,oneside]{pst-doc}
\usepackage{pst-grad,pst-diffraction}
\let\pstDiffractionFV\fileversion

\usepackage{libertinus}
\usepackage{biblatex}
\addbibresource{pst-diffraction-doc.bib}

\lstset{pos=t,wide=true,language=PSTricks,
    morekeywords={psdiffractionRectangle,psdiffractionCircle,psdiffractionCircular},basicstyle=\footnotesize\ttfamily}
\lstdefinestyle{syntax}{backgroundcolor=\color{blue!20},numbers=none,xleftmargin=0pt,xrightmargin=0pt,
    frame=single}
\lstdefinestyle{example}{backgroundcolor=\color{red!20},numbers=none,xleftmargin=0pt,xrightmargin=0pt,
    frame=single}
\newcommand*\psp{\texttt{pspicture}\xspace}
%
\begin{document}

\title{\texttt{pst-diffraction}}
\subtitle{Diffraction patterns for diffraction from circular, rectangular and triangular
apertures; v.\pstDiffractionFV}
\author{Manuel Luque \\ Herbert Vo\ss}
\docauthor{Herbert Voß}
\date{\today}
\maketitle

\tableofcontents

\clearpage

\begin{abstract}
\noindent

\vfill\noindent
Thanks to: Julien Cubizolles,
Doris Wagner, 
Timothy Van Zandt, Keno Wehr,
Michael Zedler.
\end{abstract}

\section{Optical setup}

\begin{center}
\begin{pspicture}(0,-3)(12,3)
\pnode(0,0){S}   \pnode(4,1){L'1}  \pnode(4,-1){L'2}  \pnode(6,1){E'1}   \pnode(6,-1){E'2}
\pnode(6,0.5){E1}\pnode(6,-0.5){E2}\pnode(8.5,1.5){L1}\pnode(8.5,0.5){L2}\pnode(11.5,1.25){P}
% lentille L'
\pscustom[fillstyle=gradient,linecolor=blue,gradend=white]{%
  \code{0.5 0.83333 scale}
  \psarc(4,0){4.176}{-16.699}{16.699}
  \psarc(12,0){4.176}{163.30}{196.699}}
% lentille L
\pscustom[fillstyle=gradient,linecolor=blue,gradend=white]{%
  \code{1 1.5 scale}
  \psarc(4.5,0){4.176}{-16.699}{16.699}
  \psarc(12.5,0){4.176}{163.30}{196.699}}
\pspolygon[linestyle=none,fillstyle=vlines,
    hatchcolor=yellow](S)(L'1)(E'1)(E1)(L1)(P)(L2)(E2)(E'2)(L'2)
\uput[90](4,1){$L'$}\uput[90](8.5,2){$L$}
\psdot(S)\uput[180](S){S}
\psline(S)(12,0)\psline[linewidth=2\pslinewidth](6,2)(6,0.5)\psline[linewidth=2\pslinewidth](6,-2)(6,-0.5)
\psline[linestyle=dashed](6,0.5)(6,-0.5)\psline(11.5,-3)(11.5,3)\psline(S)(L'1)(E'1)\psline(S)(L'2)(E'2)
\uput[0](P){P}
\psline(E1)(L1)(P)\psline(E2)(L2)(P)\psline[linestyle=dashed](8.5,0)(P)
%\rput(8.5,0){\psarc{->}(0,0){1.5}{0}{!1.25 3 atan}\uput[0](1.5;15){$\theta$}}
\uput[-90](10,0){$f$}\uput[0](6,2){E}\uput[135](6,0){T}\uput[45](11.5,0){O}
\end{pspicture}
\end{center}

Monochromatic light rays diverging from the focal point S of a positive lens L' emerge parallel to
the axis and strike the aperture stop E with the aperture T.
The light bends behind the aperture, this bending is called diffraction:
Every point in the opening acts as if it was a point source (Huygens's principle) and the
light waves of all those points overlap and produce an interference pattern (diffraction
pattern) on a screen. When the screen is very far away, the observed patterns are called
Fraunhofer diffraction patterns. In this case one can assume that the rays from the aperture
striking the same point P on the screen are parallel.\\
In practice one wants to realize a short distance between the aperture stop and the screen.
Hence one sets up a converging lens L after the opening and installs the screen
into the focal plane (containing the points P and O) of this lens. Parallel rays incident on
the lens are then focused at a point P in the focal plane.

With the following PSTricks-commands we can draw the diffraction patterns for different
geometric forms
of apertures. It is understood that only monochromatic light is used. The aperture stops can
have rectangular, circular or triangular openings.

The options available are the dimensions of the aperture under consideration and of the particular optical
setting, e.g. the radius in case of an circular opening. Moreover one can choose the wavelength
of the light (the associated color will be given automatically by the package).

There are three commands, for rectangular, circular and triangular openings respectively:

\begin{BDef}
\Lcs{psdiffractionRectangle}\OptArgs\\
\Lcs{psdiffractionCircular}\OptArgs\\
\Lcs{psdiffractionTriangle}\OptArgs
\end{BDef}


\section{The color}
The desired color is defined by specifying the associated wavelength $\lambda$ (in nanometers).
Red for instance one gets by the option \Lkeyword{lambda}=632 because 
red light has the wavelength $\lambda_{\textrm{rot}}=632\,\textrm{nm}$.

The conversion of the wavelength into the associated \texttt{RGB}-value is done by PostScript. 
The code is similar to the code of a FORTRAN program which can be found here: \\
\url{http://www.midnightkite.com/color.html}

\section{Diffraction from a rectangular aperture}

\begin{center}
\begin{pspicture}(-2,-1)(2,1.5)
\psframe(-0.5,-1)(0.5,1)
\pcline{<->}(-0.5,1.1)(0.5,1.1)
\Aput{$a$}
\pcline{<->}(0.6,1)(0.6,-1)
\Aput{$h=k\times a$}
\end{pspicture}
\end{center}

The width of the rectangle with the area $h=k\times a$ is defined by the letter \Lkeyword{a},
the height by \Lkeyword{k}.
The focal length is specified by \Lkeyword{f}, the desired resolution in pixels [pixel].
With the option \Lkeyword{contrast} one can improve the visibility of the minor secondary
maxima more.
We get a black and white picture if we use the option \Lkeyword{colorMode}=0,
the option \Lkeyword{colorMode}=1 provides the associated negative pattern. The options
\Lkeyword{colorMode}=2 and \Lkeyword{colorMode}=3 render color pictures in the
\Index{CMYK} and \Index{RGB} color model respectively.

By default the settings are as follows: 


\begin{tabular}{@{}lll@{}}
\Lkeyword{a}=0.2e-3 in m;    & \Lkeyword{k}=1;       &  \Lkeyword{f}=5 in m;\\
\Lkeyword{lambda}=650 in nm; & \Lkeyword{pixel}=0.5; &   \Lkeyword{contrast}=38, greates value;\\
\Lkeyword{colorMode}=3;   &   \Lkeyword{IIID}=\false.
\end{tabular}

\bigskip
\noindent
\begin{pspicture}(-3.5,-3.5)(3.5,3.5)
\psdiffractionRectangle[f=2.5]
\end{pspicture}
\hfill
\begin{pspicture}(-1.5,-2.5)(3.5,3.5)
\psdiffractionRectangle[IIID,Alpha=30,f=2.5]
\end{pspicture}

\begin{lstlisting}[style=example]
\begin{pspicture}(-3.5,-3.5)(3.5,3.5)
\psdiffractionRectangle[f=2.5]
\end{pspicture}
\hfill
\begin{pspicture}(-1.5,-2.5)(3.5,3.5)
\psdiffractionRectangle[IIID,Alpha=30,f=2.5]
\end{pspicture}
\end{lstlisting}



\noindent\begin{pspicture}(-2,-4)(2,4)
\psdiffractionRectangle[a=0.5e-3,k=0.5,f=4,pixel=0.5,colorMode=0]
\end{pspicture}
\hfill
\begin{pspicture}(0,-3)(4,4)
\psdiffractionRectangle[IIID,a=0.5e-3,k=0.5,f=4,pixel=0.5,colorMode=0]
\end{pspicture}


\begin{lstlisting}[style=example]
\begin{pspicture}(-2,-4)(2,4)
\psdiffractionRectangle[a=0.5e-3,k=0.5,f=4,pixel=0.5,colorMode=0]
\end{pspicture}
\hfill
\begin{pspicture}(0,-3)(4,4)
\psdiffractionRectangle[IIID,a=0.5e-3,k=0.5,f=4,pixel=0.5,colorMode=0]
\end{pspicture}
\end{lstlisting}



\noindent
\begin{pspicture}(-2.5,-2.5)(3.5,3)
\psdiffractionRectangle[a=0.5e-3,k=2,f=10,lambda=515,colorMode=1]
\end{pspicture}
\hfill
\begin{pspicture}(-1.5,-2)(3.5,3)
\psdiffractionRectangle[IIID,Alpha=20,a=0.5e-3,k=2,f=10,lambda=515,colorMode=1]
\end{pspicture}


\begin{lstlisting}[style=example]
\begin{pspicture}(-2.5,-2.5)(3.5,3)
\psdiffractionRectangle[a=0.5e-3,k=2,f=10,lambda=515,colorMode=1]
\end{pspicture}
\hfill
\begin{pspicture}(-1.5,-2)(3.5,3)
\psdiffractionRectangle[IIID,Alpha=20,a=0.5e-3,k=2,f=10,lambda=515,colorMode=1]
\end{pspicture}
\end{lstlisting}


\noindent
\begin{pspicture}(-3.5,-1)(3.5,1)
\psdiffractionRectangle[a=0.5e-3,k=20,f=10,pixel=0.5,lambda=450]
\end{pspicture}
\hfill
\begin{pspicture}(-3.5,-1)(3.5,4)
\psdiffractionRectangle[IIID,Alpha=10,a=0.5e-3,k=20,f=10,pixel=0.5,lambda=450]
\end{pspicture}

\begin{lstlisting}[style=example]
\begin{pspicture}(-3.5,-1)(3.5,1)
\psdiffractionRectangle[a=0.5e-3,k=20,f=10,pixel=0.5,lambda=450]
\end{pspicture}
\hfill
\begin{pspicture}(-3.5,-1)(3.5,4)
\psdiffractionRectangle[IIID,Alpha=10,a=0.5e-3,k=20,f=10,pixel=0.5,lambda=450]
\end{pspicture}
\end{lstlisting}

\section[Diffraction from two rectangular apertures]{Diffraction from two rectangular apertures%
\protect\footnote{This simulation was provided by Julien Cubizolles.}}
It is also possible to render the diffraction pattern of two congruent rectangles
(placed parallel such that their base is located on the $x$-axis)
by using the option \Lkeyword{twoSlit}.
By default this option is deactivated.
The distance of the two rectangles is specified by the option $s$.
The default for $s$ is $12e^{-3}\,\mathrm{m}$.


\begin{center}
\noindent
\begin{pspicture}(-4,-1)(4,1)
\psdiffractionRectangle[a=0.5e-3,k=10,f=10,pixel=0.5,lambda=650,twoSlit,s=2e-3]
\end{pspicture}
\end{center}

\begin{lstlisting}[style=example]
\begin{pspicture}(-4,-1)(4,1)
\psdiffractionRectangle[a=0.5e-3,k=10,f=10,pixel=0.5,lambda=650,twoSlit,s=2e-3]
\end{pspicture}
\end{lstlisting}

\begin{center}
\begin{pspicture}(-2,-1)(4,4)
\psdiffractionRectangle[IIID,Alpha=20,a=0.5e-3,k=10,f=10,pixel=0.5,lambda=650,twoSlit,s=2e-3]
\end{pspicture}
\end{center}

\begin{lstlisting}[pos=t,style=example,wide=false]
\begin{pspicture}(-2,-1)(4,4)
\psdiffractionRectangle[IIID,Alpha=20,a=0.5e-3,k=10,f=10,pixel=0.5,lambda=650,twoSlit,s=2e-3]
\end{pspicture}
\end{lstlisting}





%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Diffraction from a circular aperture}
The radius of the circular opening can be chosen via the letter \Lkeyword{r}, e.g.
\Lkeyword{r}=1e-3. The default is $r=1$ mm. In the first quadrant
PSTricks displays the graph of the intensity distribution (the maximum in the center will be
cropped if its height exceeds the margin of the environment \Lenv{pspicture*}).

\hspace*{-1cm}%
\begin{LTXexample}[pos=t,style=example,wide=false]
\begin{pspicture}(-3.5,-3.5)(3.5,3.5)
\psdiffractionCircular[r=0.5e-3,f=10,pixel=0.5,lambda=520]
\end{pspicture}
%
\begin{pspicture}(-3.5,-1.5)(3.5,3.5)
\psdiffractionCircular[IIID,r=0.5e-3,f=10,pixel=0.5,lambda=520]
\end{pspicture}
\end{LTXexample}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Diffraction from two circular apertures}
Only the case of equal radii is provided, this common radius can be defined like in the
previous section via \Lkeyword{r}=\dots.
Furthermore one has to give the half distance of the circles measured from their centers by 
\Lkeyword{d}=\dots, e.g. \Lkeyword{d}=3e-3. Also the option
\Lkeyword{twoHole} has to be used.\\
The rendering process could take some time in this case\dots


\begin{pspicture}(-3,-3.5)(3.5,3.5)
\psdiffractionCircular[r=0.5e-3,f=10,d=3e-3,lambda=515,twoHole]
\end{pspicture}
%
\begin{pspicture}(-3.5,-1.5)(3.5,3.5)
\psdiffractionCircular[IIID,r=0.5e-3,f=10,d=3e-3,lambda=515,twoHole]
\end{pspicture}


\begin{lstlisting}[style=example]
\begin{pspicture}(-3,-3.5)(3.5,3.5)
\psdiffractionCircular[r=0.5e-3,f=10,d=3e-3,lambda=515,twoHole]
\end{pspicture}
%
\begin{pspicture}(-3.5,-1.5)(3.5,3.5)
\psdiffractionCircular[IIID,r=0.5e-3,f=10,d=3e-3,lambda=515,twoHole]
\end{pspicture}
\end{lstlisting}


\hspace*{-1cm}%
\begin{pspicture}(-3,-3)(3.5,4)
\psdiffractionCircular[r=0.5e-3,f=10,d=2e-3,lambda=700,twoHole,colorMode=0]
\end{pspicture}
%
\begin{pspicture}(-3.5,-2)(3.5,3.5)
\psdiffractionCircular[IIID,r=0.5e-3,f=10,d=2e-3,lambda=700,twoHole,colorMode=0]
\end{pspicture}

\begin{lstlisting}[style=example]
\begin{pspicture}(-3.5,-3)(3.5,4)
\psdiffractionCircular[r=0.5e-3,f=10,d=2e-3,lambda=700,twoHole,colorMode=0]
\end{pspicture}
%
\begin{pspicture}(-3.5,-2)(3.5,3.5)
\psdiffractionCircular[IIID,r=0.5e-3,f=10,d=2e-3,lambda=700,twoHole,colorMode=0]
\end{pspicture}
\end{lstlisting}

Not in every case bands occur in the central circle. The number $N$ of those inner
bands is given by $N=2.44\frac{d}{r}$. Thus this effect is not observable until $N\geq2$
or $d=\frac{2r}{1.22}$ (see 
\url{http://www.unice.fr/DeptPhys/optique/diff/trouscirc/diffrac.html}).

\hspace*{-1cm}%
\begin{pspicture}(-3,-3.5)(3,3.5)
\psdiffractionCircular[r=0.5e-3,f=10,d=4.1e-4,lambda=632,twoHole]
\end{pspicture}
%
\begin{pspicture}(-3.5,-1.5)(3.5,3)
\psdiffractionCircular[IIID,r=0.5e-3,f=10,d=4.1e-4,lambda=632,twoHole]
\end{pspicture}


\begin{lstlisting}[style=example]
\begin{pspicture}(-3,-3.5)(3,3.5)
\psdiffractionCircular[r=0.5e-3,f=10,d=4.1e-4,lambda=632,twoHole]
\end{pspicture}
%
\begin{pspicture}(-3.5,-1.5)(3.5,3)
\psdiffractionCircular[IIID,r=0.5e-3,f=10,d=4.1e-4,lambda=632,twoHole]
\end{pspicture}
\end{lstlisting}



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Diffraction from a triangular aperture}

Only the case of an equilateral triangle is provided, whose height \Lkeyword{h} has to be
defined as an option. As is generally known, $h$ can be computed from the length $s$ of 
its side by $h=\frac{\sqrt{3}}{2}s$. A black and white picture can be obtained by using the
option \Lkeyword{colorMode}=0.



\begin{center}
\begin{pspicture}(-1,-1)(1,1)
\pspolygon*(0,0)(1;150)(1;210)
\pcline{|-|}(-0.732,-1)(0,-1)
\Aput{$h$}
\end{pspicture}
\end{center}

\makebox[\linewidth]{%
\begin{pspicture}(-3,-3)(3,2.5)
\psdiffractionTriangle[f=10,h=1e-3,lambda=515,contrast=38]
\end{pspicture}
\quad
\begin{pspicture}(-3,-3)(3,2.5)
\psdiffractionTriangle[f=10,h=1e-3,colorMode=1,contrast=38,lambda=515]
\end{pspicture}
\quad
\begin{pspicture}(-3,-3)(3,2.5)
\psdiffractionTriangle[f=10,h=1e-3,colorMode=0,contrast=38,lambda=515]
\end{pspicture}}


\begin{lstlisting}[style=example]
\begin{pspicture}(-3,-3)(3,2.5)
\psdiffractionTriangle[f=10,h=1e-3,lambda=515,contrast=38]
\end{pspicture}
\quad
\begin{pspicture}(-3,-3)(3,2.5)
\psdiffractionTriangle[f=10,h=1e-3,colorMode=1,contrast=38,lambda=515]
\end{pspicture}
\quad
\begin{pspicture}(-3,-3)(3,2.5)
\psdiffractionTriangle[f=10,h=1e-3,colorMode=0,contrast=38,lambda=515]
\end{pspicture}
\end{lstlisting}


\makebox[\linewidth]{%
\begin{pspicture}(-3,-2)(3,3.5)
\psdiffractionTriangle[IIID,f=10,h=1e-3,lambda=515,contrast=38]
\end{pspicture}
\quad
\begin{pspicture}(-3,-2)(3,3.5)
\psdiffractionTriangle[IIID,f=10,h=1e-3,colorMode=1,contrast=38,lambda=515]
\end{pspicture}
\quad
\begin{pspicture}(-3,-2)(3,3.5)
\psdiffractionTriangle[IIID,f=10,h=1e-3,colorMode=0,contrast=38,lambda=515]
\end{pspicture}}

\begin{lstlisting}[style=example]
\begin{pspicture}(-3,-2)(3,3.5)
\psdiffractionTriangle[IIID,f=10,h=1e-3,lambda=515,contrast=38]
\end{pspicture}
\quad
\begin{pspicture}(-3,-2)(3,3.5)
\psdiffractionTriangle[IIID,f=10,h=1e-3,colorMode=1,contrast=38,lambda=515]
\end{pspicture}
\quad
\begin{pspicture}(-3,-2)(3,3.5)
\psdiffractionTriangle[IIID,f=10,h=1e-3,colorMode=0,contrast=38,lambda=515]
\end{pspicture}
\end{lstlisting}



\clearpage
\section{List of all optional arguments for \texttt{pst-diff}}
\Loption{pst-diff} is the short form for the keywords in the package \LPack{pst-diffraction}.

\xkvview{family=pst-diff,columns={key,type,default}}



\raggedright
\nocite{*}
\printbibliography
%\bibliography{pst-diffraction-doc}

\printindex

\end{document}
