# fdfd ::: meanas.fdfd ## Core operator layers ::: meanas.fdfd.functional ::: meanas.fdfd.operators ::: meanas.fdfd.solvers ::: meanas.fdfd.scpml ::: meanas.fdfd.farfield ## Bloch magnetic materials Bloch state vectors store the transverse Fourier coefficients of magnetic flux `B = mu * H`. They equal `H` when permeability is omitted. Pass the same `mu` to `bloch.hmn_2_hxyz(...)` and `bloch.hmn_2_exyz(...)` when converting solved vectors to fields. The eigensolver uses the projected `mu**-1` energy metric for finite positive real permeability, including anisotropic and spatially varying profiles. Its preconditioner remains finite at the Gamma point. ## Far-field normalization The near-to-far transform includes the cell area `dx * dy`, so normalized far-field amplitudes describe a Fourier integral and converge under spatial refinement. This changes amplitudes previously returned as unweighted FFT sums. The inverse applies the matching Fourier quadrature and returns spacings for the requested output shape. Both transforms center their origins at index `size // 2`; padding and cropping preserve that sample. The inverse does not modify input spectra. Transforms use the library's `exp(+i omega t)` time convention: outgoing plane waves vary as `exp(-i k dot r)`, so the angular projection uses a positive Fourier phase. The inverse uses a negative phase. Far-field vector pairs are ordered as polar and azimuthal components; near-field pairs are Cartesian. ## Solver and port calibration The default QMR wrapper raises `RuntimeError` on breakdown or failure to converge. PEC rows impose zero electric fields with unit diagonal entries; `solvers.generic` zeroes the corresponding source and initial-guess entries. H-only and EH operators impose analogous constraints for PMC locations. FDFD port calibration uses the complete incoming-amplitude matrix from all excitations, solving `S @ incoming_amplitudes = raw_outgoing_amplitudes`. Diagnostics include these matrices and the incoming/outgoing flux Gram matrices. Guided powers retain cross terms between nonorthogonal modes. Lossless modes at or above the propagation-grid band edge require a finer mesh for power normalization. Lorentz-normalized evanescent modes use the decaying spatial branch. Expansion on graded grids uses each electric component's own Yee intervals. ## SCPML conventions `stretch_with_scpml` now uses `-1` for the low-index face and `+1` for the high-index face, matching CPML and propagation conventions. It returns copied widths by default; pass `copy=False` to request mutation explicitly. Both SCPML builders accept `kappa_function(depth)` for real stretching and `max_imag_ratio` to limit the final dimensionless `abs(Im(s))/Re(s)`. Start a mode-solver convergence study with `max_imag_ratio=1.0`: overly strong imaginary stretching can produce above-light-line PML artifacts. The cap is not a general spectral guarantee, and weaker absorption can increase boundary reflections. Check domain size, PML thickness, strength, mode localization, and residuals. The general scattering profile remains uncapped by default. `uniform_grid_scpml` builds unit widths by applying `stretch_with_scpml` to both faces of each enabled axis. Both builders divide imaginary grading by physical layer thickness and sample electric widths at cell centers and magnetic widths at cell edges. This corrects the uniform builder's previous thickness-independent strength and reversed E/H sample offsets; retune existing uniform-builder profiles using domain/PML convergence checks.