PyMieDiff: A differentiable Mie scattering library
Oscar K. C. Jackson, Simone De Liberato, Otto L. Muskens, Peter R. Wiecha
TL;DR
PyMieDiff delivers a fully differentiable, GPU‑accelerated Mie solver for core–shell spheres implemented in PyTorch, enabling backpropagation through scattering observables with respect to geometry, dispersion, and experimental setup. The framework features vectorized batched evaluation, two AD pathways, and a material interface, and it integrates with TorchGDM for end‑to‑end multi‑particle simulations. Demonstrations include gradient‑based inverse design, a Mie‑informed tandem network, and end‑to‑end metasurface optimization, all leveraging analytic Mie theory with exact derivatives. This differentiable solver bridges analytic nanophotonics and modern ML pipelines, enabling rapid gradient‑based design, sensitivity analysis, and physics‑informed learning in nano‑optics.
Abstract
Light scattering by spherical-shaped particles of sizes comparable to the wavelength is foundational in many areas of science, from chemistry to atmospheric science, photonics and nanotechnology. With the new capabilities offered by machine learning, there is a great interest in end-to-end differentiable frameworks for scattering calculations. Here we introduce PyMieDiff, a fully differentiable, GPU-compatible implementation of Mie scattering for core-shell particles in PyTorch. The library provides native, autograd-compatible spherical Bessel and Hankel functions, vectorized evaluation of Mie coefficients, and APIs for computing efficiencies, angular scattering, and near-fields. All inputs - geometry, material dispersion, wavelengths, and observation angles and positions - are represented as tensors, enabling seamless integration with gradient-based optimisation or physics-informed neural networks. The toolkit can also be combined with "TorchGDM" for end-to-end differentiable multi-particle scattering simulations. PyMieDiff is available under an open source licence at https://github.com/UoS-Integrated-Nanophotonics-group/MieDiff.
