Diagnostics and validation
Field energy and divergence
The energy diagnostic is the electromagnetic field contribution
\[w_{\rm EM}=\tfrac12\left(\epsilon_\infty |E|^2+\mu|H|^2\right).\]
In a nondispersive physical region it satisfies the continuous balance
\[\partial_t w_{\rm EM}+\nabla\cdot(E\times H) =-\sigma|E|^2-E\cdot J_{\rm src}.\]
With dispersion, an additional $-E\cdot\sum_kJ_k$ transfers energy between fields and material oscillators. The reported energy_total is the field energy above; it does not include oscillator or PML auxiliary energy.
The analysis callbacks also report broken, elementwise norms
\[\|\nabla\cdot E_h\|_{L^2(\mathcal T_h)}^2 =\sum_K\int_K|\nabla\cdot E_h|^2dx,\qquad \|\nabla\cdot E_h\|_{\infty,h}=\max_{K,a}|(\nabla\cdot E_h)(x_{K,a})|,\]
and likewise for $H$. The infinity norm is sampled at solution nodes. These norms exclude distributional jumps at element faces; they are not global Gauss-law residuals for $D$ and $B$ across material interfaces. DGMulti uses its mass and differentiation operators; curved meshes use their local metrics and quadrature. DGSEM uses nodal derivatives and metric-weighted tensor quadrature.
The error-norm extensions for DGMulti and DGSEM report errors for the six physical fields and mask the extra components. Validate material parameters and auxiliary dynamics with their dedicated tests rather than interpreting those zeros as an error estimate.
Analytical time-domain references
The PEC cavity provides both the nondispersive, possibly lossy TM mode and a lossless single-Drude-pole mode. Together with the Fresnel and dipole examples, these test propagation, material interfaces, time-domain dispersion and source strength against analytical solutions.
MaxwellTrixi.initial_condition_cavity — Function
initial_condition_cavity(x, t, equations::MaxwellEquations3D{Homogeneous})Lowest TM mode of a perfectly conducting cube cavity filled with a homogeneous, possibly lossy medium,
\[E_z = e^{-\gamma t} \left( \cos \omega t - \frac{\gamma}{\omega} \sin \omega t \right) \sin(\pi x) \sin(\pi y), \qquad \omega_0 = \sqrt{2} \pi c, \quad \gamma = \frac{\sigma}{2 \epsilon}, \quad \omega = \sqrt{\omega_0^2 - \gamma^2},\]
with $H$ from Faraday's law and $H(0) = 0$. Requires $\gamma < \omega_0$; for $\sigma = 0$ it is the undamped mode of B 10.5. Valid on any box whose faces lie on integer coordinates, such as $[-1, 1]^3$ or $[0, 1]^3$, with boundary_condition_perfect_electric_conductor on all faces and, for $\sigma > 0$, source_terms_conductivity.
- Jan S. Hesthaven, Tim Warburton (2008) Nodal Discontinuous Galerkin Methods, Section 10.5 DOI: 10.1007/978-0-387-72067-8
initial_condition_cavity(x, t, equations::MaxwellEquations3D{Homogeneous, <:Dispersive})Lowest TM mode of a perfectly conducting cube cavity filled with a lossless Drude medium with one pole, $\gamma = 0$, starting with $H = J = 0$:
\[E_z = \cos(\omega t) \sin(\pi x) \sin(\pi y), \qquad \omega^2 = \frac{\omega_0^2 + \omega_p^2}{\epsilon_\infty}, \quad \omega_0 = \sqrt{2} \pi / \sqrt{\mu},\]
with $H$ from Faraday's law and $J_z = \omega_p^2 \sin(\omega t) / \omega \, \sin(\pi x) \sin(\pi y)$. Requires $\sigma = 0$.
Relevant tests are in test/test_dgmulti_3d.jl and test/test_dgsem_3d.jl: cavity convergence and energy, Fresnel interface energy and convergence, dipole probes, TF/SF leakage, and PML reflection. Curved import, interpolation and VTK are covered by test/test_meshes.jl and the simulation tests. Unit and type tests exercise flux consistency, axis/normal agreement, and Float32/Float64 behavior.
Surface Fourier transforms
Frequency-domain diagnostics are separate from the time-domain visualizations. The surface callbacks currently operate on fixed DGMulti meshes. They accumulate fields after accepted time steps rather than retaining the complete solution history. The integration uses the actual step lengths, including variable ones.
MaxwellTrixi.SurfaceTransformCallback — Type
SurfaceTransformCallbackDiscrete Fourier transform $\hat u(f) = \sum_n u(t_n) e^{-2 \pi i f t_n} (t_n - t_{n-1})$ of the scattered field $u - u_i$ and of the incident field $u_i$ at the face nodes of an oriented surface of interior faces, accumulated after every time step. Built by CrossSectionCallback and DetectorPlaneCallback; evaluated by cross_sections and transmittance_reflectance. The fields have to have left the surface at the end of the simulation.
MaxwellTrixi.CrossSectionCallback — Function
CrossSectionCallback(semi, tfsf::TotalFieldScatteredField, frequencies)SurfaceTransformCallback on the surface of the total-field region of tfsf, for cross_sections. The scattered field on the surface is the mean of the scattered-field trace and the total-field trace minus the incident field.
MaxwellTrixi.DetectorPlaneCallback — Function
DetectorPlaneCallback(semi, incident_field, frequencies; point, normal)SurfaceTransformCallback on all interior faces in the plane through point with unit normal, oriented along normal, for transmittance_reflectance. The plane has to lie in the total-field region and consist of element faces.
MaxwellTrixi.cross_sections — Function
cross_sections(callback)Scattering, extinction and absorption cross sections at the frequencies of a CrossSectionCallback, from the transformed fields on the closed surface:
\[\sigma_\mathrm{sca} = \frac{1}{Y |\hat E_i|^2} \oint \operatorname{Re}(\hat E_s \times \hat H_s^*) \cdot n \, dA, \quad \sigma_\mathrm{ext} = -\frac{1}{Y |\hat E_i|^2} \oint \operatorname{Re}(\hat E_s \times \hat H_i^* + \hat E_i \times \hat H_s^*) \cdot n \, dA,\]
with the incident intensity averaged over the surface and $\sigma_\mathrm{abs} = \sigma_\mathrm{ext} - \sigma_\mathrm{sca}$. Returns a named tuple (; frequencies, scattering, extinction, absorption).
MaxwellTrixi.transmittance_reflectance — Function
transmittance_reflectance(callback)Power transmittance and reflectance at the frequencies of a DetectorPlaneCallback: the flux of the total field and the negative flux of the scattered field through the plane, both divided by the flux of the incident field,
\[T = \frac{\int \operatorname{Re}(\hat E \times \hat H^*) \cdot n \, dA}{\int \operatorname{Re}(\hat E_i \times \hat H_i^*) \cdot n \, dA}, \quad R = -\frac{\int \operatorname{Re}(\hat E_s \times \hat H_s^*) \cdot n \, dA}{\int \operatorname{Re}(\hat E_i \times \hat H_i^*) \cdot n \, dA}.\]
$T$ is meaningful behind a scatterer, $R$ in front of it. Returns a named tuple (; frequencies, transmittance, reflectance).
The field transform uses $e^{-2\pi i f t}$. The resulting complex spectra can be conjugated to match the $e^{-i\omega t}$ phasor convention used by the material references; the real power ratios are unchanged. Run long enough for the pulse and relevant transients to leave the integration surfaces. Normalize only at frequencies with appreciable incident signal. Detector planes must consist of interior element faces in the total-field region.
Mie and slab references
The Mie routine sums spherical multipoles to obtain scattering and extinction; absorption follows by subtraction. Efficiencies become cross sections after multiplication by the sphere's geometric area. The Airy formula sums repeated reflections in a planar slab at normal incidence. Both are references for the configured homogeneous media and geometry, rather than substitutes for general inhomogeneous scattering simulations.
MaxwellTrixi.mie_efficiencies — Function
mie_efficiencies(m, x)Scattering, extinction and absorption efficiencies $Q = \sigma / (\pi a^2)$ of a homogeneous sphere of radius $a$ with relative refractive index m and size parameter x $= k a$ in the background medium, from the Mie series in the form of Bohren and Huffman (BHMIE). An absorbing sphere has $\operatorname{Im} m > 0$. For the electric and magnetic multipole coefficients $a_n$ and $b_n$,
\[Q_{\mathrm{sca}} = \frac{2}{x^2}\sum_{n\geq1}(2n+1)(|a_n|^2+|b_n|^2),\qquad Q_{\mathrm{ext}} = \frac{2}{x^2}\sum_{n\geq1}(2n+1)\operatorname{Re}(a_n+b_n),\]
and $Q_{\mathrm{abs}}=Q_{\mathrm{ext}}-Q_{\mathrm{sca}}$. The implementation uses downward recurrence for the logarithmic derivative and truncates the series at $\operatorname{round}(x+4x^{1/3}+2)$. Returns a named tuple (; scattering, extinction, absorption).
MaxwellTrixi.slab_transmittance_reflectance — Function
slab_transmittance_reflectance(n, thickness, frequency)Power transmittance and reflectance of a slab with relative refractive index n and the given thickness in vacuum at normal incidence (Airy formula),
\[t = \frac{t_{12} t_{21} e^{i \delta}}{1 - r_{21}^2 e^{2 i \delta}}, \quad r = r_{12} + \frac{t_{12} t_{21} r_{21} e^{2 i \delta}}{1 - r_{21}^2 e^{2 i \delta}}, \quad \delta = 2 \pi f n d,\]
with the interface coefficients $r_{12} = (1 - n) / (1 + n) = -r_{21}$, $t_{12} = 2 / (1 + n)$ and $t_{21} = 2 n / (1 + n)$. An absorbing slab has $\operatorname{Im} n > 0$. Returns (; transmittance, reflectance).