[Tex/LaTex] How to draw an optical lattice

metaposttechnical-drawingtikz-pgf

I want to make in TikZ or MetaPost an image of a two dimensional lattice with oscillations like these:

optical lattice
another optical lattice

(Source: http://www.uibk.ac.at/th-physik/qo/research/opticallattices.html)

or this one:

yet another optical lattice

(Source: http://news.sciencemag.org/sciencenow/2008/09/12-01.html)

I don't know even know how to begin.

Best Answer

Here's something to get you (or perhaps someone else) started

enter image description here

I realize that the balls aren't exactly where you want them, but you can tweak the positions yourself.

The idea was to use a surface plot of the function f(x,y)=cos(x)*cos(y) using the pgfplots package.

The only subtlety is to loop through the balls, which requires the loop to be wrapped in \pgfplotsextra{ ... }.

I borrowed Altermundus' ball shading from How can we draw a Christmas tree with decorations, using TikZ?

\documentclass{article}
\usepackage{pgfplots}

% borrowed from Altermundus' Christmas tree
% https://tex.stackexchange.com/questions/39149/how-can-we-draw-a-christmas-tree-with-decorations-using-tikz/39250#39250
\newsavebox{\ball}
\savebox{\ball}{ 
\begin{tikzpicture}[scale=.1]
 \shadedraw[ball color=red] (0,0) circle (60pt);
\end{tikzpicture}
} 

\begin{document}

\begin{tikzpicture}
 \begin{axis}[xmin=-5,xmax=5,ymin=-5,ymax=5,zmin=-5,zmax=5,colormap/cool]
  \addplot3[
    surf,
    shader=flat,
    samples=50,
    domain=-2*pi:2*pi,
    y domain=-2*pi:2*pi
  ]{cos(deg(x))*cos(deg(y))};
  \pgfplotsextra{
    \foreach \deco in {
        (axis cs:-1,-1,1),
        (axis cs:-2,-2,1),
        (axis cs:3,3,1),
        (axis cs:-3,-3,1),
        (axis cs:4,4,1)
    }{%
        \node at \deco {\usebox{\ball}};
    }
  }
 \end{axis}
\end{tikzpicture}
\end{document}