One of the numerical methods used to simulate electric and magnetic fields is known as the finite difference time domain (FDTD) method. In the application to Maxwell’s laws, this method starts by exploding the differential form of Faraday’s law and the Ampere-Maxwell law, the two curl equations in Maxwell’s equations, into 6 coupled partial differential equations. Then the equations are discretized and the derivatives approximated with finite difference approximations. If you’re interested in learning more, I highly recommend Dr. Rumpf’s course on the subject.

The purpose of this post is to share some tikz code for drawing a ‘Yee Cell.’ The Yee Cell describes the way that the vector field components must be arranged in a discretized grid to arrive at a stable implementation (the method uses central finite differences so the E & H fields must be staggered so that the finite difference exists in the middle). The result of the Tikz code is shown below.

Let me know if you have any recommendations for improvements or if you’ve found this useful. One thing that could be done for the sake of completeness (and the expense of clarity) is to draw the vectors of adjacent cells where they correspond on this cell.

Here is the code:

% * ---------------------------------------------------------------------------- % * "THE BEER-WARE LICENSE" (Revision 42): % * <bob@bobadams5.com> wrote this file. As long as you retain this notice you % * can do whatever you want with this stuff. If we meet some day, and you think % * this stuff is worth it, you can buy me a beer in return. Bob Adams % * ---------------------------------------------------------------------------- \documentclass[12pt]{article} \usepackage{tikz} \usepackage{tikz-3dplot} \begin{document} \begin{section}{Yee Cell} \begin{figure}[!h] \centering \tdplotsetmaincoords{60}{120} \begin{tikzpicture}[scale=3,tdplot_main_coords] % Coordinate axes \draw[thick,->] (0,0,0) -- (2,0,0) node[anchor=north east]{$x$}; \draw[thick,->] (0,0,0) -- (0,2,0) node[anchor=north west]{$y$}; \draw[thick,->] (0,0,0) -- (0,0,2) node[anchor=south]{$z$}; % Draw the cell outline \draw[dashed] (1.5,0,0) -- (1.5,1.5,0); \draw[dashed] (1.5,1.5,0) -- (1.5,1.5,1.5); \draw[dashed] (1.5,1.5,1.5) -- (0,1.5,1.5); \draw[dashed] (0,1.5,1.5) -- (0,1.5,0); \draw[dashed] (0,1.5,0) -- (1.5,1.5,0); \draw[dashed] (1.5,1.5,1.5) -- (1.5,0,1.5); \draw[dashed] (1.5,0,1.5) -- (1.5,0,0); \draw[dashed] (1.5,0,1.5) -- (0,0,1.5); \draw[dashed] (0,0,1.5) -- (0,1.5,1.5); % Draw arrows for E field \draw[ultra thick, color=blue,->] (0,0,0.4) -- (0,0,0.7) node[anchor=south east]{$E_z$}; \draw[ultra thick, color=blue,->] (0,0.4,0) -- (0,0.7,0) node[anchor=north east]{$E_y$}; \draw[ultra thick, color=blue,->] (0.4,0,0) -- (0.7,0,0) node[anchor=north west]{$E_x$}; % Draw arrows for H field \draw[ultra thick, color=red,->] (0.75,0.75,0) -- (0.75,0.75,0.3) node[anchor=north east]{$H_z$}; \draw[ultra thick, color=red,->] (0.75,0,0.75) -- (0.75,0.3,0.75) node[anchor=north east]{$H_y$}; \draw[ultra thick, color=red,->] (0,0.75,0.75) -- (0.3,0.75,0.75) node[anchor=north west]{$H_x$}; \end{tikzpicture} \end{figure} \end{section} \end{document}