pith. sign in

arxiv: 2512.08614 · v3 · submitted 2025-12-09 · ⚛️ physics.optics · physics.comp-ph

PyMieDiff: A differentiable Mie scattering library

Pith reviewed 2026-05-16 23:31 UTC · model grok-4.3

classification ⚛️ physics.optics physics.comp-ph
keywords Mie scatteringdifferentiable programmingPyTorchspherical particlesnanophotonicslight scatteringGPU accelerationautograd
0
0 comments X

The pith

PyMieDiff implements Mie scattering calculations inside PyTorch so gradients flow through scattering simulations for layered spherical particles.

A machine-rendered reading of the paper's core claim, the machinery that carries it, and where it could break.

The paper presents PyMieDiff as a fully differentiable, GPU-compatible library that brings Mie scattering theory into the PyTorch ecosystem for layered spherical particles. All inputs such as geometry, material dispersion, wavelengths, and observation angles are handled as tensors, allowing automatic differentiation through the entire computation. The library supplies custom autograd-compatible spherical Bessel and Hankel functions plus vectorized routines that return scattering efficiencies, angular patterns, and near-fields. This construction lets users embed classical electromagnetic scattering directly into gradient-based optimization or physics-informed neural networks without leaving the machine-learning framework.

Core claim

PyMieDiff is a fully differentiable, GPU-compatible implementation of Mie scattering for layered, spherical particles in PyTorch that provides native autograd-compatible spherical Bessel and Hankel functions, vectorized evaluation of Mie coefficients, and APIs for computing efficiencies, angular scattering, and near-fields, with all inputs represented as tensors to enable seamless integration with gradient-based optimization or physics-informed neural networks.

What carries the argument

Autograd-compatible spherical Bessel and Hankel functions that support vectorized, differentiable evaluation of Mie scattering coefficients for multi-layered spheres.

Load-bearing premise

The provided implementations of the spherical Bessel and Hankel functions and Mie coefficient formulas are numerically accurate and produce gradients that match the analytic derivatives of Mie theory.

What would settle it

Direct numerical comparison of scattering efficiencies and near-fields computed by PyMieDiff against finite-difference approximations and against independent non-differentiable Mie codes for a range of particle radii, layer thicknesses, and refractive indices.

Figures

Figures reproduced from arXiv: 2512.08614 by Oscar K. C. Jackson, Otto L. Muskens, Peter R. Wiecha, Simone De Liberato.

Figure 1
Figure 1. Figure 1: FIG. 1 [PITH_FULL_IMAGE:figures/full_fig_p002_1.png] view at source ↗
Figure 2
Figure 2. Figure 2: FIG. 2 [PITH_FULL_IMAGE:figures/full_fig_p003_2.png] view at source ↗
Figure 3
Figure 3. Figure 3: FIG. 3 [PITH_FULL_IMAGE:figures/full_fig_p004_3.png] view at source ↗
Figure 4
Figure 4. Figure 4: FIG. 4 [PITH_FULL_IMAGE:figures/full_fig_p005_4.png] view at source ↗
Figure 5
Figure 5. Figure 5: FIG. 5 [PITH_FULL_IMAGE:figures/full_fig_p006_5.png] view at source ↗
Figure 6
Figure 6. Figure 6: FIG. 6 [PITH_FULL_IMAGE:figures/full_fig_p008_6.png] view at source ↗
read the original 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 layered, spherical 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.

Editorial analysis

A structured set of objections, weighed in public.

Desk editor's note, referee report, simulated authors' rebuttal, and a circularity audit. Tearing a paper down is the easy half of reading it; the pith above is the substance, this is the friction.

Referee Report

2 major / 2 minor

Summary. The manuscript introduces PyMieDiff, a PyTorch library implementing fully differentiable Mie scattering for layered spherical particles. It provides native autograd-compatible spherical Bessel and Hankel functions, vectorized Mie coefficient evaluation, and tensor-based APIs for scattering efficiencies, angular distributions, and near-fields, with seamless integration to gradient-based optimization and the TorchGDM multi-particle framework.

Significance. If the numerical correctness and gradient accuracy are established, the library would enable end-to-end differentiable scattering simulations in nanophotonics, supporting inverse design, physics-informed neural networks, and hybrid ML-physics workflows. The open-source release and GPU compatibility are positive features for reproducibility in the field.

major comments (2)
  1. [Implementation description (abstract and methods)] The central claim that the custom spherical Bessel/Hankel implementations and recursive Mie coefficient formulas produce both forward values and gradients matching analytic Mie theory lacks any supporting numerical evidence. No finite-difference comparisons, reference-code cross-checks, or stability tests for complex arguments and large orders are described, which directly undermines the advertised differentiability for optimization tasks.
  2. [Spherical Bessel/Hankel and Mie coefficient sections] The handling of branch cuts, recurrence relations, and numerical stability for the autograd-compatible special functions is not specified. Any discrepancy here would propagate to all downstream quantities (efficiencies, angular scattering, near-fields) and break end-to-end differentiability, yet no validation protocol is provided.
minor comments (2)
  1. [Abstract] The GitHub link should include explicit installation instructions, example notebooks demonstrating gradient computation, and a clear statement of the supported particle layering and size-parameter range.
  2. [API description] Notation for the layered-sphere coefficients (e.g., how the recursive formulas are vectorized over tensors) should be clarified with a short pseudocode or equation block to aid readers implementing similar functionality.

Simulated Author's Rebuttal

2 responses · 0 unresolved

We thank the referee for their constructive comments and for recognizing the potential of PyMieDiff for end-to-end differentiable nanophotonics workflows. We agree that the current manuscript lacks explicit numerical validation of both forward values and gradients, as well as details on numerical stability. We will revise the manuscript to address these points directly.

read point-by-point responses
  1. Referee: The central claim that the custom spherical Bessel/Hankel implementations and recursive Mie coefficient formulas produce both forward values and gradients matching analytic Mie theory lacks any supporting numerical evidence. No finite-difference comparisons, reference-code cross-checks, or stability tests for complex arguments and large orders are described, which directly undermines the advertised differentiability for optimization tasks.

    Authors: We agree that the manuscript does not currently include numerical evidence supporting the accuracy of forward computations and gradients. In the revised version we will add a dedicated validation section containing: (i) direct comparisons of scattering efficiencies and angular patterns against analytic Mie theory and established non-differentiable codes (e.g., PyMieScatt) for both real and complex refractive indices; (ii) finite-difference gradient checks across a range of particle sizes, layer thicknesses, and wavelengths; and (iii) stability tests for high orders and complex arguments. These additions will substantiate the differentiability claims. revision: yes

  2. Referee: The handling of branch cuts, recurrence relations, and numerical stability for the autograd-compatible special functions is not specified. Any discrepancy here would propagate to all downstream quantities (efficiencies, angular scattering, near-fields) and break end-to-end differentiability, yet no validation protocol is provided.

    Authors: We acknowledge that the manuscript does not describe the numerical treatment of branch cuts, the specific recurrence relations implemented for spherical Bessel and Hankel functions, or the validation protocol used to ensure stability. In the revision we will expand the methods section to document these choices explicitly, including how branch cuts are handled for complex arguments and the safeguards applied during recurrence. We will also include a validation protocol subsection that reports agreement metrics with reference implementations over the relevant parameter space. revision: yes

Circularity Check

0 steps flagged

No circularity: software library announcement with no derivation chain

full rationale

The paper introduces PyMieDiff as a PyTorch implementation of standard Mie scattering for layered spheres, providing autograd-compatible spherical Bessel/Hankel functions and related APIs. No new physical derivations, parameter fits, or predictions are claimed; the central assertion is simply the existence and feature set of the released code. No self-citations, ansatzes, or uniqueness theorems are invoked to justify any result. The implementation details rest on established Mie theory without reducing any output to its own inputs by construction.

Axiom & Free-Parameter Ledger

0 free parameters · 0 axioms · 0 invented entities

No new physical axioms, free parameters, or invented entities are introduced; the work is a computational re-implementation of standard Mie theory in differentiable form.

pith-pipeline@v0.9.0 · 5487 in / 1099 out tokens · 41368 ms · 2026-05-16T23:31:33.083021+00:00 · methodology

discussion (0)

Sign in with ORCID, Apple, or X to comment. Anyone can read and Pith papers without signing in.

Lean theorems connected to this paper

Citations machine-checked in the Pith Canon. Every link opens the source theorem in the public Lean library.

What do these tags mean?
matches
The paper's claim is directly supported by a theorem in the formal canon.
supports
The theorem supports part of the paper's argument, but the paper may add assumptions or extra steps.
extends
The paper goes beyond the formal theorem; the theorem is a base layer rather than the whole result.
uses
The paper appears to rely on the theorem as machinery.
contradicts
The paper's claim conflicts with a theorem or certificate in the canon.
unclear
Pith found a possible connection, but the passage is too broad, indirect, or ambiguous to say the theorem truly supports the claim.

Reference graph

Works this paper leans on

38 extracted references · 38 canonical work pages · 2 internal anchors

  1. [1]

    Mie ,\ 10.1002/andp.19083300302 journal journal Annalen der Physik \ volume 330 ,\ pages 377 ( year 1908 ) NoStop

    author author G. Mie ,\ 10.1002/andp.19083300302 journal journal Annalen der Physik \ volume 330 ,\ pages 377 ( year 1908 ) NoStop

  2. [2]

    author author C. F. \ Bohren \ and\ author D. R. \ Huffman ,\ @noop title Absorption and Scattering of Light by Small Particles \ ( publisher Wiley ,\ year 1998 ) NoStop

  3. [3]

    Kuhn , author T

    author author L. Kuhn , author T. Rep \"a n , \ and\ author C. Rockstuhl ,\ 10.1038/s41598-022-21802-3 journal journal Scientific Reports \ volume 12 ,\ pages 19019 ( year 2022 ) NoStop

  4. [4]

    Peurifoy , author Y

    author author J. Peurifoy , author Y. Shen , author L. Jing , author Y. Yang , author F. Cano-Renteria , author B. G. \ DeLacy , author J. D. \ Joannopoulos , author M. Tegmark , \ and\ author M. Solja c i \'c ,\ 10.1126/sciadv.aar4206 journal journal Science Advances \ volume 4 ,\ pages eaar4206 ( year 2018 ) NoStop

  5. [5]

    Simultaneous inverse design of materials and parameters of core-shell nanoparticle via deep-learning: Demonstration of dipole resonance engineering

    author author S. So , author J. Mun , \ and\ author J. Rho ,\ 10.1021/acsami.9b05857 journal journal ACS Applied Materials & Interfaces \ volume 11 ,\ pages 24264 ( year 2019 ) ,\ http://arxiv.org/abs/1904.02848 arXiv:1904.02848 NoStop

  6. [6]

    Estrada-Real , author A

    author author A. Estrada-Real , author A. Khaireh-Walieh , author B. Urbaszek , \ and\ author P. R. \ Wiecha ,\ 10.1016/j.photonics.2022.101066 journal journal Photonics and Nanostructures - Fundamentals and Applications \ volume 52 ,\ pages 101066 ( year 2022 ) ,\ http://arxiv.org/abs/2207.03431 arXiv:2207.03431 [physics] NoStop

  7. [7]

    Soun , author A

    author author D. Soun , author A. Az \'e ma , author L. Roach , author G. L. \ Drisko , \ and\ author P. R. \ Wiecha ,\ 10.1364/OE.561657 journal journal Optics Express \ volume 33 ,\ pages 25945 ( year 2025 ) ,\ http://arxiv.org/abs/2502.13338 arXiv:2502.13338 [physics] NoStop

  8. [8]

    Li \ and\ author N

    author author Y. Li \ and\ author N. Bowler ,\ 10.1364/AO.52.004997 journal journal Applied Optics \ volume 52 ,\ pages 4997 ( year 2013 ) NoStop

  9. [9]

    Prahl ,\ 10.5281/zenodo.7949263 title Miepython: A Python library for Mie scattering calculations , \ ( year 2025 ) NoStop

    author author S. Prahl ,\ 10.5281/zenodo.7949263 title Miepython: A Python library for Mie scattering calculations , \ ( year 2025 ) NoStop

  10. [10]

    author author M. P. \ de Sivry-Houle , author N. Godbout , \ and\ author C. Boudoux ,\ 10.1364/OPTCON.473102 journal journal Optics Continuum \ volume 2 ,\ pages 520 ( year 2023 ) NoStop

  11. [11]

    Ladutenko , author U

    author author K. Ladutenko , author U. Pal , author A. Rivera , \ and\ author O. Pe \ n a-Rodr \'i guez ,\ 10.1016/j.cpc.2017.01.017 journal journal Computer Physics Communications \ volume 214 ,\ pages 225 ( year 2017 ) NoStop

  12. [12]

    author author P. R. \ Wiecha ,\ @noop title Pymiecs - a simple python Mie toolbox GitLab , \ howpublished https://gitlab.com/wiechapeter/pymiecs ( year 2024 ) NoStop

  13. [13]

    author author R. E. \ Wengert ,\ 10.1145/355586.364791 journal journal Commun. ACM \ volume 7 ,\ pages 463 ( year 1964 ) NoStop

  14. [14]

    author author T. W. \ Hughes , author I. A. D. \ Williamson , author M. Minkov , \ and\ author S. Fan ,\ 10.1021/acsphotonics.9b01238 journal journal ACS Photonics \ volume 6 ,\ pages 3010 ( year 2019 ) NoStop

  15. [15]

    Minkov , author I

    author author M. Minkov , author I. A. D. \ Williamson , author L. C. \ Andreani , author D. Gerace , author B. Lou , author A. Y. \ Song , author T. W. \ Hughes , \ and\ author S. Fan ,\ 10.1021/acsphotonics.0c00327 journal journal ACS Photonics \ volume 7 ,\ pages 1729 ( year 2020 ) NoStop

  16. [16]

    Inverse design and flexible parameterization of meta-optics using algorithmic differentiation

    author author S. Colburn \ and\ author A. Majumdar ,\ 10.1038/s42005-021-00568-6 journal journal Communications Physics \ volume 4 ,\ pages 1 ( year 2021 ) NoStop

  17. [17]

    2022 , keywords =

    author author C. Wang , author N. Chen , \ and\ author W. Heidrich ,\ 10.1109/TCI.2022.3212837 journal journal IEEE Transactions on Computational Imaging \ volume 8 ,\ pages 905 ( year 2022 ) NoStop

  18. [18]

    Luce , author R

    author author A. Luce , author R. Alaee , author F. Knorr , \ and\ author F. Marquardt ,\ 10.1088/2632-2153/ad5411 journal journal Machine Learning: Science and Technology \ volume 5 ,\ pages 025076 ( year 2024 ) NoStop

  19. [19]

    Kim , author A

    author author Y. Kim , author A. W. \ Jung , author S. Kim , author K. Octavian , author D. Heo , author C. Park , author J. Shin , author S. Nam , author C. Park , author J. Park , author S. Han , author J. Lee , author S. Kim , author M. S. \ Jang , \ and\ author C. Y. \ Park ,\ 10.48550/arXiv.2406.12904 title Meent: Differentiable Electromagnetic Simul...

  20. [20]

    Ponomareva , author A

    author author S. Ponomareva , author A. Patoux , author C. Majorel , author A. Az \'e ma , author A. Cuche , author C. Girard , author A. Arbouet , \ and\ author P. Wiecha ,\ 10.21468/SciPostPhysCodeb.60 journal journal SciPost Physics Codebases \ ,\ pages 060 ( year 2025 ) NoStop

  21. [21]

    Training Deep Neural Networks for the Inverse Design of Nanophotonic Structures

    author author D. Liu , author Y. Tan , author E. Khoram , \ and\ author Z. Yu ,\ 10.1021/acsphotonics.7b01377 journal journal ACS Photonics \ volume 5 ,\ pages 1365 ( year 2018 ) NoStop

  22. [22]

    Khaireh-Walieh , author D

    author author A. Khaireh-Walieh , author D. Langevin , author P. Bennet , author O. Teytaud , author A. Moreau , \ and\ author P. R. \ Wiecha ,\ 10.1515/nanoph-2023-0527 journal journal Nanophotonics \ volume 12 ,\ pages 4387 ( year 2023 ) ,\ http://arxiv.org/abs/2307.08618 arXiv:2307.08618 [physics] NoStop

  23. [23]

    author author N. J. \ Dinsdale , author P. R. \ Wiecha , author M. Delaney , author J. Reynolds , author M. Ebert , author I. Zeimpekis , author D. J. \ Thomson , author G. T. \ Reed , author P. Lalanne , author K. Vynck , \ and\ author O. L. \ Muskens ,\ 10.1021/acsphotonics.0c01481 journal journal ACS Photonics \ volume 8 ,\ pages 283 ( year 2021 ) ,\ h...

  24. [24]

    \ Cai ,\ 10.1016/j.cpc.2010.11.019 journal journal Computer Physics Communications \ volume 182 ,\ pages 663 ( year 2011 ) NoStop

    author author L.-W. \ Cai ,\ 10.1016/j.cpc.2010.11.019 journal journal Computer Physics Communications \ volume 182 ,\ pages 663 ( year 2011 ) NoStop

  25. [25]

    author author M. N. \ Polyanskiy ,\ 10.1038/s41597-023-02898-2 journal journal Scientific Data \ volume 11 ,\ pages 94 ( year 2024 ) NoStop

  26. [26]

    Jiang \ and\ author J

    author author J. Jiang \ and\ author J. A. \ Fan ,\ 10.1515/nanoph-2020-0407 journal journal Nanophotonics \ volume 10 ,\ pages 361 ( year 2020 ) NoStop

  27. [27]

    Gillman \ and\ author H

    author author E. Gillman \ and\ author H. R. \ Fiebig ,\ 10.1063/1.168296 journal journal Computer in Physics \ volume 2 ,\ pages 62 ( year 1988 ) NoStop

  28. [28]

    author author P. B. \ Johnson \ and\ author R. W. \ Christy ,\ 10.1103/PhysRevB.6.4370 journal journal Physical Review B \ volume 6 ,\ pages 4370 ( year 1972 ) NoStop

  29. [29]

    author author D. F. \ Edwards ,\ in\ @noop booktitle Handbook of Optical Constants of Solids ,\ editor edited by\ editor E. D. \ Palik \ ( publisher Academic Press ,\ address Burlington ,\ year 1997 )\ pp.\ pages 547--569 NoStop

  30. [30]

    Beutel , author I

    author author D. Beutel , author I. Fernandez-Corbaton , \ and\ author C. Rockstuhl ,\ 10.1016/j.cpc.2023.109076 journal journal Computer Physics Communications \ volume 297 ,\ pages 109076 ( year 2024 ) NoStop

  31. [31]

    author author D. P. \ Kingma \ and\ author J. Ba ,\ @noop journal journal arXiv:1412.6980 [cs] \ ( year 2014 ) ,\ http://arxiv.org/abs/1412.6980 arXiv:1412.6980 [cs] NoStop

  32. [32]

    Nocedal ,\ 10.1090/S0025-5718-1980-0572855-7 journal journal Mathematics of Computation \ volume 35 ,\ pages 773 ( year 1980 ) NoStop

    author author J. Nocedal ,\ 10.1090/S0025-5718-1980-0572855-7 journal journal Mathematics of Computation \ volume 35 ,\ pages 773 ( year 1980 ) NoStop

  33. [33]

    Majic \ and\ author E

    author author M. Majic \ and\ author E. C. L. \ Ru ,\ 10.1364/AO.379694 journal journal Applied Optics \ volume 59 ,\ pages 1293 ( year 2020 ) NoStop

  34. [34]

    author author J. Zhang ,\ 10.48550/arXiv.2409.10877 title A modified recursive transfer matrix algorithm for radiation and scattering computation of multilayer spheres , \ ( year 2024 ),\ http://arxiv.org/abs/2409.10877 arXiv:2409.10877 [physics] NoStop

  35. [35]

    Spherical fourier neural operators: Learning stable dynamics on the sphere,

    author author B. Bonev , author T. Kurth , author C. Hundt , author J. Pathak , author M. Baust , author K. Kashinath , \ and\ author A. Anandkumar ,\ 10.48550/arXiv.2306.03838 title Spherical Fourier Neural Operators : Learning Stable Dynamics on the Sphere , \ ( year 2023 ),\ http://arxiv.org/abs/2306.03838 arXiv:2306.03838 [cs] NoStop

  36. [36]

    Asadova , author J

    author author N. Asadova , author J. D. \ Fischbach , author R. Vall \'e e , author Y. Augenstein , author D. Vovchuk , author A. Kharchevskii , author P. Ginzburg , \ and\ author C. Rockstuhl ,\ 10.48550/arXiv.2512.08615 title Gradient-based optimization of scatterer arrangements based on the T-Matrix method , \ ( year 2025 a ),\ http://arxiv.org/abs/251...

  37. [37]

    author author W. J. \ Lentz ,\ 10.1063/1.168382 journal journal Computer in Physics \ volume 4 ,\ pages 403 ( year 1990 ) NoStop

  38. [38]

    Asadova , author K

    author author N. Asadova , author K. Achouri , author K. Arjas , author B. Augui \'e , author R. Aydin , author A. Baron , author D. Beutel , author B. Bodermann , author K. Boussaoud , author S. Burger , author M. Choi , author K. M. \ Czajkowski , author A. B. \ Evlyukhin , author A. Fazel-Najafabadi , author I. Fernandez-Corbaton , author P. Garg , aut...