| title | Mathematical Concepts | ||
|---|---|---|---|
| numbering |
|
Here we briefly outline the mathematical concepts required to run STEM simulations.
(math_numbers)=
You are probably very familiar with the real numbers, which are values which measure a continuous quantity.
These numbers can be integers such as
By contrast, a vector is a value which cannot be represented by a single number.
Examples include three-dimensional (3D) position coordinates
(math_complex_numbers)=
To model scattering in electron microscopy, we work with a special number system referred to as complex numbers.
A complex number is a length-2 vector, where the two values are called the real and imaginary values.
The real part of each number is the kind of real number as described as above.
The imaginary part is also a real number, but multiplied by the imaginary unit
:label: eq:imag
i^2 = -1.
Examples of complex numbers include
:name: fig_complex
:placeholder: ./figures/complex_numbers.png
**Complex numbers.** Every complex value consists of a real and an imaginary component, which can be used to compute the magnitude and phase of each value.
In addition to the real and imaginary parts, we can define two other useful quantities.
The magnitude of a complex number
:label: eq:mag
|z| = \sqrt{a^2 + b^2}.
This quantity is also sometimes referred to as the magnitude or the absolute value.
The second quantity we define is the complex argument, defined as the angle
:label: eq:arg
\phi = \arctan2(b, a).
In programming, functions which measure this value are often named
:label: eq:euler
\exp(i z) = \cos(z) + i \sin(z).
This expression links complex numbers to the trigonometric functions. This relationship foreshadows a key upcoming concept, namely that the trigonometric oscillations describe waves, where the physical concept of the complex angle will be mapped onto relative phase shifts of electron waves. We will therefore usually refer to the complex argument as the phase of a given complex value.
As we will see, even though computers internally store complex numbers using real and imaginary components as
We also sometimes take the conjugate of complex numbers, which means that we reverse the sign of the imaginary part.
This operation is defined for a complex number
:label: eq:complex_conjugate
z^* = a - i b
or for
:label: eq:complex_conjugate_2
z^* = |z|\exp{(-i \phi)}.
(math_fourier_transform)=
The Fourier transform is an integral transformation that decomposes a function into its constituent spatial frequencies. This means that we write a function as a series of orthogonal sine waves with different frequencies / periodicities. A set of functions are orthogonal if we can multiply any pair of them and integrate over their domain to get a result of zero. The key property conveyed by this orthogonality is that the set of sine waves output by the Fourier Transform form a complete basis, and thus can represent any arbitrary function.
We can map a function
:label: eq:ft_forward
F(\omega) = \int_{-\infty}^{\infty}
f(x) \exp\left(
-i \omega x
\right) dx,
and we can recover the original function with the inverse transform
:label: eq:ft_inverse
f(x) = \frac{1}{2 \pi} \int_{-\infty}^{\infty}
F(\omega) \exp\left(
-i \omega x
\right) d\omega.
(math_discrete_fourier_transform)=
The Fourier transform is very useful for many mathematical analyses.
However, we cannot use it in this form for this article, because unlike continuous variables such as position
:label: eq:dft_forward
\begin{aligned}
F(k)
&= \mathscr{F}_{r \rightarrow k}\{ f(r) \}
\\
&= \sum_{n=0}^{N-1}
f_n \exp\left(
-2 i \pi k n / N
\right),
\end{aligned}
where
:label: eq:dft_inverse
\begin{aligned}
f(r)
&= \mathscr{F}_{k \rightarrow r}\{ F(k) \}
\\
&= \frac{1}{N} \sum_{k=0}^{N-1}
F_k \exp\left(
2 i \pi k n / N
\right),
\end{aligned}
where
shows an interactive version of the 1D discrete Fourier transform.
Try switching between the different preset functions.
You can also change the amplitude of
:name: fig:fft_1d
:placeholder: ./static/fft_1d.png
**Interactive discrete 1D Fourier transform.**
(math_fast_fourier_transform)=
When simulating transmission electron microscopy images, diffraction patterns, and other wavefunctions, we are typically working with two-dimensional (2D) arrays. Thus we need to expand our previous definition to work in two dimensions. However, because this transformation is orthogonal over different Cartesian coordinates, we can compute a 2D discrete Fourier transform by simply sequentially multiplying the two transformations, giving
:label: eq:dft_2d_xy
\begin{aligned}
F(k_x, k_y)
&= \mathscr{F}_{x \rightarrow k_x}\{
\mathscr{F}_{y \rightarrow k_y}\{
f(x,y)
\}
\}
\\
&= \sum_{m=0}^{M-1} \sum_{n=0}^{N-1}
f_{nm}
\exp\left(
-2 i \pi k_x m / M
\right)
\exp\left(
-2 i \pi k_y n / N
\right),
\end{aligned}
where
:label: eq:dft_2d
\begin{aligned}
F(\bm{k})
&= \mathscr{F}_{r \rightarrow k}\{
f(\bm{r})
\}
\\
f(\bm{r})
&= \mathscr{F}_{k \rightarrow r}\{
F(\bm{k})
\},
\end{aligned}
where
:name: fig:fft_2d
:placeholder: ./static/fft_2d.png
**Interactive discrete 2D Fourier transform.** Left panel shows diffraction space, right shows real space upsampled by 4x.
Both images have been FFT-shifted, with origins shown as a red `+` symbol.
Amplitude is shown as the pixel values, while phase is shown as a periodic colorwheel.
On the left panel of , you can click to swap individual pixels between 0 and 1 in Fourier space, while observing the response on the real space function.
On the right panel, you can click and drag to shift the function by a distance
f(\bm{r} - \Delta \bm{r}) =
\mathscr{F}_{k \rightarrow r}\{
\mathscr{F}_{r \rightarrow k}\{
f(\bm{r})
\}
\exp( -2i \pi \bm{k} \, \cdot \Delta \bm{r} )
\},
where
A deep understanding of the 2D Fourier transform is essential to both simulate and understand TEM experiments. Therefore in we provide a table of Fourier transform pairs which are important for TEM. Note that for simplicity we have omitted some details such as some of the numerical prefactors in front of each function.
(math_fourier_pairs)=
:::{list-table} 2D Fourier transform pairs important in TEM simulation and analysis. Note that these transform pairs assume that both
-
- Diffraction space
- Real space
-
- Name
- Function
- Function
- Name
-
- Delta Dirac
$\delta(\bm{k})$ - 1
- plane wave along optic axis
-
- Shifted Dirac function
$\delta(\bm{k} - \bm{k}_0)$ $\exp(-2i \pi , \bm{r} \cdot \bm{k}_0)$ - plane wave tilted to
$\bm{k}_0$
-
- diffraction spot pair
$\delta(\bm{k} - \bm{k}_0) + \delta(\bm{k} + \bm{k}_0)$ $\cos(-2 \pi , \bm{r} \cdot \bm{k}_0)$ - cosine wave
-
- plane wave mult.
$F(\bm{k}) \exp(-2i \pi \bm{k} \cdot \Delta \bm{r})$ $f(\bm{r} - \Delta \bm{r})$ - Shifted function
-
- circular aperture
$u(|\bm{k}| - k_{\rm{max}})$ $\frac{J_1(2 \pi k_{\rm{max}} |\bm{r}| )}{\pi k_{\rm{max}} |r|}$ - Airy disk function
-
- defocus operator
$\exp(-i\pi \lambda |\bm{k}|^2 C_1)$ $\exp \left( i \frac{\pi |\bm{r}|^2}{\lambda C_1} \right)$ - Fresnel quadratic phase factor
-
- Gaussian envelope
$\exp \left( -\frac{|\bm{k}|^2}{2 \sigma^2} \right)$ $\exp \left( -2 \pi^2 \sigma^2 |\bm{r}|^2 \right)$ - Gaussian envelope
-
- exponential decay
$\exp(-\lambda |\bm{k}|)$ $\frac{\lambda^3}{(\lambda^2 + |\bm{r}|^2)^{3/2}}$ - 3D Lorentzian function
-
- Lorentzian function
$\frac{\gamma^2}{\gamma^2 + |\bm{k}|^2}$ $K_0(2 \pi \gamma |\bm{r}|)$ - Modified Bessel func.,
$2^{\rm{nd}}$ kind :::
Additional transform pairs can be found in the Wikipedia table of important Fourier transforms.