Skip to main content

Module vector_calculus

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})$.