EMpy 3.0.0 is a major numerical, electrodynamic, and architectural overhaul across every module of the library, resolving dozens of long-standing physical and numerical bugs, stabilizing ill-conditioned multilayer/grating/waveguide cascades, removing legacy broken dependencies, and expanding both the verification test suite and literature-benchmarked examples.
Breaking / Convention Alignment Notice
- Unified Harmonic & Passive Loss Convention (
exp(+iωt - ik·r)):- All solvers and utilities now consistently follow
exp(+iωt - ik·r)with passive complex refractive indexn = n_r - iκ(κ ≥ 0,Im(n) ≤ 0), passive forward/evanescent wavevector branch selection (Re(k_z) - Im(k_z) ≥ 0), and passive complex-coordinate PML stretching (Im(factor) < 0instretchmesh). EMpy.utils.rix2lossesnow computes positive absorptionα = -4π Im(n) / λmatchingloss_cm2rix,loss_m2rix, andloss_dBcm2rix(previously had an inverted sign).EMpy.constants.eta0now uses the exact CODATA relationmu0 * cinstead of the120πapproximation.
- All solvers and utilities now consistently follow
- Python & Scientific Stack Modernization:
- Requires Python
>= 3.10,numpy >= 2.1,scipy >= 1.13, andmatplotlib >= 3.8.4(numpy.trapzupdated tonumpy.trapezoid; Python 3 slicing, sorting, and integer indexing restored throughout).
- Requires Python
- Reorganized
examples/Directory Layout:- Legacy numbered
examples/ex_*.pyscripts have been replaced by 22 topic-organized scripts across 7 domain subdirectories (transfer_matrix/,liquid_crystals/,rcwa/,modesolvers/,waveguide_circuits/,devices/,scattering/) plusexamples/data/andexamples/README.md.
- Legacy numbered
Added
- Out-of-the-Box Liquid-Crystal BVP Solver (
EMpy.utils.LiquidCrystalCell):- Solves the coupled 1D Oseen–Frank elastic free-energy and Laplace electrostatic boundary-value problem directly via
scipy.integrate.solve_bvp, eliminating the unmaintainedscikits.bvp1lgrequirement (while retaining compatibility if explicitly installed).
- Solves the coupled 1D Oseen–Frank elastic free-energy and Laplace electrostatic boundary-value problem directly via
- Dual Passive & Lorentz-Reciprocal Mode-Matching (
EMpy.modesolvers.geometries.SimpleJoint):- Added
method="passive"(default conjugated-Poynting mode matching guaranteeing‖S‖₂ ≤ 1under modal basis truncation) andmethod="reciprocal"(bilateral unconjugated Lorentz-reaction polar-midpoint formulation enforcing exactS = Sᵀand port-swap symmetry at every truncation order). - Added direct cross-solver mode-overlap support between
FDMode(VFDModeSolver) andFMMMode2d(FMM2d).
- Added
- 22 Literature-Benchmarked Examples (
examples/):- Full coverage of every
EMpymodule with bibliographic citations in each docstring, including Kretschmann SPR (κ → 0⁺), Gooch–Tarry TN switching, de Vries chiral Bragg reflectors, Moharam ETM gratings, conical Wood–Rayleigh anomalies, Koshelev dimer quasi-BICs, Chew–Weedon PML leaky waveguides, Soldano MMI self-imaging, Barbarossa coupled-ring filters, thermo-optic silicon MZIs, and Kottler vector aperture diffraction.
- Full coverage of every
- Comprehensive Physics & Degenerate-Limit Test Suite (
tests/):- Expanded to 85 tests validating lossless energy conservation/unitarity, passive lossy bounds, Lorentz reciprocity,
Δn → 0anisotropic-to-isotropic limits,κ → 0⁺lossy-to-lossless limits, scale invariance, and CI smoke-testing across Python 3.10–3.14 andlowest-directdependencies.
- Expanded to 85 tests validating lossless energy conservation/unitarity, passive lossy bounds, Lorentz reciprocity,
Fixed
- Transfer Matrix (
EMpy.transfer_matrix):- Rewrote
AnisotropicTransferMatrixaround the exact 4 × 4 Berreman eigenproblem with SVD nullspace polarization vectors, biaxial optic-axis / binormal orthogonalization, weak-birefringence (Δn → 0) continuity, and full cross-mode-interference Poynting fluxS_z(including negative local Goos–Hänchen TIR flux from lossy superstrates without artificial clamping). - Fixed
snellandIsotropicTransferMatrixevanescent branch selection under total internal reflection (TIR), lossy incident media, and negative-permittivity (Re(n) = 0, Im(n) < 0) plasmonic layers, plus scalar wavelength support.
- Rewrote
- Rigorous Coupled-Wave Analysis (
EMpy.RCWA):- Stabilized
AnisotropicRCWAwith Moharam's Enhanced Transmittance Matrix (ETM) recursion to eliminate exponential overflow on thick or high-order gratings. - Implemented Li's inverse-rule Fourier factorization for discontinuous anisotropic permittivity tensors, proper ordinary + extraordinary eigenwave superposition in uniaxial end layers, and phase-preserving unit polarization vectors (
dE_hat) on lossy uniaxial superstrates. - Fixed
IsotropicRCWAnormal-incidence conical azimuth (α = 0, δ ≠ 0), complex transverse wavevectors(kx, ky)in lossy/negative-εsuperstrates, ill-conditioned Wood-anomalykxshifts, andSymmetricDoubleGratingridge spacing. - Fixed
dispersion_relation_ordinaryanddispersion_relation_extraordinaryto preserve exact Helmholtz roots (kz² = delta) on the passive branch cut.
- Stabilized
- Waveguide Mode Solvers & Circuits (
EMpy.modesolvers):- Made
FMM1dandFMM2dgeometrically scale-invariant across SI meters (wl ~ 1.55e-6) and microns (wl ~ 1.55) by scaling wavenumber search steps/bounds byk₀, normalizingMvec / k₀, removing globalnumpy.random.seed()calls, fixing removablek_x d → 0singularities, and eliminatingO(exp(4 |Im(k)| d))catastrophic cancellation in evanescentscalarprodintegrals. - Fixed
FMMMode2danalytical Poyntingoverlapconjugation/signs, right-wall boundary condition checks (xright), and staggered-gridget_fields_for_FDTDtransposes, as well asscripts/FDTD.py(overlap_f) impedance scaling and conjugation. - Stabilized
GenericDeviceandSWGvia direct boundedexp(-iβL)S-matrices and Redheffer star-product cascading so sub-cutoff (Im(n_eff) < 0) and long lossy waveguides never overflow. - Fixed
SVFDModeSolverpolarization-dependent boundary symmetry signs (Exvs.Ey),VFDModeSolvershift-invert"LM"target selection and passive cutoff branch,FDModestaggered-grid interpolation, andstretchmeshcomplex PML coordinate differentials.
- Made
- Photonic Devices, Materials, Scattering & Utilities (
EMpy.devices,EMpy.materials,EMpy.scattering,EMpy.utils):- Fixed
NRR.solve()readingH.data[1, 0]forDROP,T_TCRR/T_CTCRRnon-mutating"optimum"coupling synthesis and phase factors, andEtalondispersive group-indexFSRwl, passive lossy Airy transmission, and low-reflectivityF < 1finesse handling. - Fixed
RefractiveIndex/EpsilonTensortabulatedn0_knowninterpolation preserving inputwlsarray shapes (scalar,1D,2D). - Fixed
LiquidCrystalCellzero-voltage planar pretilt alignment, linear twist profile, chiralq₀ · dscaling, real staticcapacitance(), and anchoring thickness validation. - Fixed
group_delay_and_dispersionphase unwrapping and wavelength differentiation, andfind_peaksflat-top plateau / monotonic inflection handling. - Fixed
currentsScatteringKottlerandstackinput shape normalization,R == 0self-point guards, and passive complexepsrrefractive-index branch selection.
- Fixed
What's Changed
Full Changelog: 2.2.4...3.0.0