# Yee grid (2D FDTD) The **Yee grid** is a staggered arrangement of electric and magnetic field samples used by [[fdtd-cuda-fdtd|FDTD]]. Instead of placing every component at the same position, it offsets them by half a cell. In FDTD CUDA's two-dimensional TMz simulation, the sample positions are: $$ \begin{aligned} E_z(i,j)&:\quad (i\Delta x,\;j\Delta y)\\ H_x(i,j)&:\quad (i\Delta x,\;(j+\tfrac12)\Delta y)\\ H_y(i,j)&:\quad ((i+\tfrac12)\Delta x,\;j\Delta y) \end{aligned} $$ This places each magnetic sample halfway between the electric samples used to update it. For example, the difference between $E_z(i+1,j)$ and $E_z(i,j)$ approximates the $x$ derivative at $H_y(i,j)$. The electric update then uses differences between the surrounding magnetic samples. \documentclass{standalone} \usepackage{tikz} \begin{document} \begin{tikzpicture}[x=2.8cm,y=2.8cm,>=stealth,font=\small] \draw[step=1,gray!35] (0,0) grid (2,2); % Ez samples sit at integer grid positions and point out of the plane. \foreach \i in {0,1,2} { \foreach \j in {0,1,2} { \draw[blue!75!black,fill=white] (\i,\j) circle (3pt); \fill[blue!75!black] (\i,\j) circle (1pt); } } % Hx is staggered along y and directed along x. \foreach \i in {0,1,2} { \foreach \j in {0,1} { \draw[->,red!75!black,thick] (\i-0.10,\j+0.5) -- (\i+0.10,\j+0.5); } } % Hy is staggered along x and directed along y. \foreach \i in {0,1} { \foreach \j in {0,1,2} { \draw[->,green!40!black,thick] (\i+0.5,\j-0.10) -- (\i+0.5,\j+0.10); } } \node[below left,blue!75!black] at (0,0) {$E_z(i,j)$}; \node[below right,blue!75!black] at (1,0) {$E_z(i+1,j)$}; \node[above left,blue!75!black] at (0,1) {$E_z(i,j+1)$}; \node[above,red!75!black] at (0.12,0.5) {$H_x(i,j)$}; \node[right,green!40!black] at (0.5,0.16) {$H_y(i,j)$}; \draw[<->] (0,-0.42) -- node[fill=white] {$\Delta x$} (1,-0.42); \draw[<->] (-0.60,0) -- node[fill=white] {$\Delta y$} (-0.60,1); \draw[->] (2.30,0) -- (2.65,0) node[right] {$x$}; \draw[->] (2.30,0) -- (2.30,0.35) node[above] {$y$}; \node[anchor=west,align=left] at (0,-0.80) {$\odot\ E_z$: out of the plane\quad $\rightarrow\ H_x$\quad $\uparrow\ H_y$}; \end{tikzpicture} \end{document} The implementation stores each component in a separate array, using `j * pitch + i` to locate an element. The half-cell offsets are represented by the update equations; they do not require fractional array indices. Equal indices in different component arrays therefore refer to different physical positions.