Module vector_calculus
Expand description
3D Staggered & Collocated Electromagnetic Vector Calculus Operators (etalon-sim).
Provides second-order and fourth-order finite-difference Yee staggered-grid
curl, divergence, double-curl, Gauss-law residuals, discrete charge conservation,
Stokes-theorem face circulation/flux verification, and analytical Fourier-mode
spectral differential operators. All hot-path routines execute with zero heap
allocations over caller-supplied slices and are wasm32-compatible.
Functionsยง
- gauss_
electric_ residual - Compute the electric Gauss-law residual $r_D = \nabla \cdot \mathbf{D} - \rho_v$.
- gauss_
magnetic_ residual - Compute the magnetic Gauss-law residual $r_B = \nabla \cdot \mathbf{B}$.
- spectral_
plane_ wave_ curl - Exact spectral Fourier-mode curl oracle for a real plane wave $\mathbf{A}(\mathbf{r}) = \mathbf{A}_0 \cos(\mathbf{k}\cdot\mathbf{r} + \phi_0)$.
- spectral_
plane_ wave_ divergence - Exact spectral Fourier-mode divergence oracle for a real plane wave $\mathbf{A}(\mathbf{r}) = \mathbf{A}_0 \cos(\mathbf{k}\cdot\mathbf{r} + \phi_0)$.
- verify_
discrete_ charge_ conservation - Verify discrete charge conservation on the Yee lattice: $\frac{(\nabla \cdot \mathbf{D})^{n+1} - (\nabla \cdot \mathbf{D})^n}{\Delta t} + \nabla \cdot \mathbf{J}^{n+1/2} = 0$.
- verify_
div_ curl_ zero_ 2nd - Verify the exact staggered discrete vector identity $\nabla \cdot (\nabla \times \mathbf{A}) = 0$.
- verify_
stokes_ circulation_ cell - Verify integral Stokes theorem $\oint_{\partial S} \mathbf{E} \cdot d\mathbf{l} = \iint_S (\nabla \times \mathbf{E}) \cdot d\mathbf{A}$
on a single Yee cell
(ix, iy, iz). - yee_
curl_ e_ 2nd - Second-order staggered Yee forward curl $\nabla \times \mathbf{E}$ mapping edge-staggered electric fields $(E_x, E_y, E_z)$ to face-staggered magnetic flux rates.
- yee_
curl_ e_ 4th - Fourth-order staggered forward curl $\nabla^{(4)} \times \mathbf{E}$ (Fang-type 4th-order stencil with weights $c_1 = 9/8$ and $c_2 = -1/24$).
- yee_
curl_ h_ 2nd - Second-order staggered Yee backward curl $\nabla \times \mathbf{H}$ mapping face-staggered magnetic fields $(H_x, H_y, H_z)$ to edge-staggered electric displacement rates.
- yee_
curl_ h_ 4th - Fourth-order staggered backward curl $\nabla^{(4)} \times \mathbf{H}$.
- yee_
div_ b_ 2nd - Second-order staggered cell-center divergence $\nabla \cdot \mathbf{B}$ for face-staggered fields.
- yee_
div_ d_ 2nd - Second-order staggered vertex divergence $\nabla \cdot \mathbf{D}$ for edge-staggered fields.
- yee_
double_ curl_ e_ 2nd - Evaluate the staggered double-curl operator $\nabla \times (\mu^{-1} \nabla \times \mathbf{E})$.