[pstricks] Example: Gaussian beam

Clemens Schäfermeier XC-lemens at web.de
Tue May 7 21:15:59 CEST 2013


Hi everyone,
I thought that maybe an example of a Gaussian beam profile is missing in 
the example section of http://tug.org/PSTricks/main.cgi/
If you like, use the appended one.
Best regards
Clemens
-------------- next part --------------
A non-text attachment was scrubbed...
Name: beam_new.png
Type: image/png
Size: 60058 bytes
Desc: not available
URL: <http://tug.org/pipermail/pstricks/attachments/20130507/1f04faed/attachment-0001.png>
-------------- next part --------------
%author: clemens sch\"afermeier
%clemens at fh-muenster.de
%7. may 2012
\documentclass[a4paper,dvips]{article}

\usepackage{pstricks,pstricks-add}

\begin{document}

\def\lwidth{.8pt}
\psset{unit=1cm,linewidth=\lwidth}

\begin{pspicture}*[showgrid=false](-6,-6)(7.5,4)
% some constants
\def\wO{.0008 \space} % beam waist in meters
\def\pi{\pstPI1 \space}
\def\tpi{\pstPI2 \space}
\def\lamb{.000000809\space} % wavelength in meters
\def\zr{\wO dup mul \pi mul \lamb div \space}
\def\zrr{\zr dup mul \space}
\def\thet{\wO 1000 mul \zr atan \space}
% function of beam radius
\def\wz{1 x dup mul \zrr div add sqrt \wO mul \space}

% %------------ wavefronts
\multido{\ra=1.+1.,\rb=.1+.1}{6}{%
\def\xr{\ra\space}%
\def\xrc{\rb\space}% just used for clipping
\def\Rzx{\xr \zrr \xr div add\space}%
% upper half
\psclip{
 \pscustom[linestyle=none]{
 \newpath\moveto(0,0)
 \moveto(-6.5,0)
 \psplot[plotstyle=curve]{-6.5}{6.5}{\wz 1000 mul}
 \lineto(6.5,-6.5)}
 \pscustom[linewidth=\lwidth,linecolor=red]{
 \psplot{\xr \xrc sub}{\xr}{\Rzx dup mul x \zrr \xr div add dup mul sub sqrt}}}
\endpsclip
\psclip{
 \pscustom[linestyle=none]{
 \newpath\moveto(0,0)
 \moveto(-6.5,0)
 \psplot[plotstyle=curve]{-6.5}{6.5}{\wz 1000 mul}
 \lineto(6.5,-6.5)}
 \pscustom[linewidth=\lwidth,linecolor=red]{
 \psplot{\xr neg}{\xr \xrc sub neg}{\Rzx dup mul x \zrr \xr div sub dup mul sub sqrt}}}
\endpsclip
% lower half
\psclip{
 \pscustom[linestyle=none]{
 \newpath\moveto(0,0)
 \moveto(6.5,0)
 \psplot[plotstyle=curve]{6.5}{-6.5}{\wz 1000 neg mul}
 \lineto(-6.5,6.5)}
 \pscustom[linewidth=\lwidth,linecolor=red]{
 \psplot{\xr \xrc sub}{\xr}{\Rzx dup mul x \zrr \xr div add dup mul sub sqrt neg}}}
\endpsclip
\psclip{
 \pscustom[linestyle=none]{
 \newpath\moveto(0,0)
 \moveto(6.5,0)
 \psplot[plotstyle=curve]{6.5}{-6.5}{\wz 1000 neg mul}
 \lineto(-6.5,6.5)}
 \pscustom[linewidth=\lwidth,linecolor=red]{
 \psplot{\xr neg}{\xr \xrc sub neg}{\Rzx dup mul x \zrr \xr div sub dup mul sub sqrt neg}}}
\endpsclip
}
% % gouy phase
% upper half
\def\xr{3\space}%
\def\xrc{.2\space}%
\def\Rzx{\xr \zrr \xr div add\space}%
\psclip{
 \pscustom[linestyle=none]{
 \newpath\moveto(0,0)
 \moveto(-6.5,0)
 \psplot[plotstyle=curve]{-6.5}{6.5}{\wz 1000 mul}
 \lineto(6.5,-6.5)}
 \pscustom[linewidth=.4pt,linecolor=red,linestyle=dashed]{
 \psplot{\xr \xrc sub}{\xr .2 add}{\Rzx dup mul x \zrr \xr div .2 sub add dup mul sub sqrt}}}
\endpsclip
% lower half
\psclip{
 \pscustom[linestyle=none]{
 \newpath\moveto(0,0)
 \moveto(6.5,0)
 \psplot[plotstyle=curve]{6.5}{-6.5}{\wz 1000 neg mul}
 \lineto(-6.5,6.5)}
 \pscustom[linewidth=.4pt,linecolor=red,linestyle=dashed]{
 \psplot{\xr \xrc sub}{\xr .2 add}{\Rzx dup mul x \zrr \xr div .2 sub add dup mul sub sqrt neg}}}
\endpsclip
% % spherical wavefront
%
\psclip{
 \pscustom[linestyle=none]{
 \newpath\moveto(0,0)
 \moveto(-6.5,0)
 \psplot[plotstyle=curve]{-6.5}{6.5}{\wz 1000 mul}
 \lineto(6.5,-6.5)}
 \pscustom[linewidth=.4pt,linestyle=dashed]{
 \psplot[polarplot=true]{0}{180}{1}
 \lineto(0,0)}}
\endpsclip
\psclip{
 \pscustom[linestyle=none]{
 \newpath\moveto(0,0)
 \moveto(6.5,0)
 \psplot[plotstyle=curve]{6.5}{-6.5}{\wz 1000 neg mul}
 \lineto(-6.5,6.5)}
 \pscustom[linewidth=.4pt,linestyle=dashed]{
 \psplot[polarplot=true]{180}{360}{1}
 \lineto(5,0)}}
\endpsclip
% %

% % beam width
\psplot[plotstyle=curve]{-7}{7}{\wz 1000 mul}
\psplot[plotstyle=curve]{-7}{7}{\wz 1000 neg mul}

\SpecialCoor

% % description

\pcline[linestyle=dashed]{-}(0,0)(7.5;!\thet)

\psarc{<-}{5.5}{!\thet}{!\thet 8 add}
\psarc{-}{5.5}{0}{!\thet}
\psarc{->}{5.5}{-8}{0}
\uput{5.6}[-4]{-90}(0,0){$\theta$}

\pcline[]{->}(0,0)(5;8)
\ncput*[nrot=:U]{$R(z)$}

% some stuff to make the arrows on which eta(z) is put really orthogonal to the wavefronts
\def\degg{10\space}
\rput(!\zrr \xr div neg 0){
\pcline[]{-}%
(!\Rzx 0 add \degg cos mul \Rzx 0 add \degg neg sin mul)%
(!\Rzx .2 add \degg cos mul \Rzx .2 add \degg neg sin mul)
\pcline[]{<-}%
(!\Rzx .2 add \degg cos mul \Rzx .2 add \degg neg sin mul)%
(!\Rzx .6 add \degg cos mul \Rzx .6 add \degg neg sin mul)
\pcline[]{->}%
(!\Rzx .8 neg add \degg cos mul \Rzx .8 neg add \degg neg sin mul)%
(!\Rzx 0 add \degg cos mul \Rzx 0 add \degg neg sin mul)
\naput[nrot=:U]{$\eta(z)$}
}

% the same for lambda
\def\degg{10\space}
\def\xra{4\space}
\def\xrb{5\space}
\def\Rzxa{\xra \zrr \xrb div add\space}%
\def\Rzxb{\xrb \zrr \xrb div add\space}%
\rput(!\zrr \xrb div neg 0){
\pcline[]{<->}%
(!\Rzxa \degg cos mul \Rzxa \degg neg sin mul)%
(!\Rzxb \degg cos mul \Rzxb \degg neg sin mul)
\naput[nrot=:U]{$\lambda$}
}

\pcline[]{->}(0,-2.2)(!0 \wO neg 1000 mul)
\pcline[]{-}(!0 \wO neg 1000 mul)(0,0)
\pcline[]{<-}(0,0)(0,.7)
\naput*[nrot=:U]{$w_0$}

\def\radx{4.15 neg\space}
\def\wzrx{\wO 1 \radx dup mul \zrr div add sqrt mul\space}

\pcline[]{->}(!\radx -2.4)(!\radx \wzrx neg 1000 mul)
\pcline[]{-}(!\radx \wzrx neg 1000 mul)(!\radx 0)
\pcline[]{<-}(!\radx 0)(!\radx 1.1)
\naput*[nrot=:U]{$w(z)$}

\def\radx{\zr\space}
\def\wzrx{\wO 1 \radx dup mul \zrr div add sqrt mul\space}
\def\radx{\zr neg\space}

\pcline[]{->}(!\radx -2.2)(!\radx \wzrx neg 1000 mul)
\pcline[]{-}(!\radx \wzrx neg 1000 mul)(!\radx 0)
\pcline[]{<-}(!\radx 0)(!\radx 1.1)
\naput[nrot=:U]{$\sqrt{2} \; w_0$}

\pcline[]{<->}(!\radx -2.)(0,-2.)
\naput[nrot=:U]{$z_R$}

\rput*[c](1.6,2.8){\rnode{a}{\psframebox*{Spherical wavefront}}}
\pnode(-.8,.5){b}
\ncarc[nodesepA=0pt]{->}{a}{b}

\rput*[c](-2.7,2.8){\rnode{a}{\psframebox*{Wavefront}}}
\pnode(-4.95,.7){b}
\ncarc[nodesepA=0pt]{->}{a}{b}

\pcline{->}(-6,0)(6,0)
\rput[ref=c](6.4,0){$z$}

\rput[lB]{0}(3,-4){
\psshadowbox[framearc=.8,framesep=.15,linestyle=none]{Gaussian beam model}}

\end{pspicture}

\end{document}


More information about the PSTricks mailing list