Download Latest Version Consistency Release source code.zip (12.5 MB)
Home / 3.4.0
Name Modified Size InfoDownloads / Week
Parent folder
Consistency Release source code.tar.gz 2026-11-26 12.4 MB
Consistency Release source code.zip 2026-11-26 12.5 MB
README.md 2026-11-26 5.4 kB
Totals: 3 Items   24.9 MB 0

Thanks to @rcgiri-physics and @antonsoo for pointing out the time inconsistency exp(-iωt) or exp(+iωt) used for near and far field calculations. This release addresses that problem and fixes a number of minor inconsistencies and edge cases.

The time convention can now be configured by the user so that all calculated results are consistent with the selected time convention.

python mie.get_time_convention() # "+" (default) mie.set_time_convention("-") # exp(-iωt) mie.set_time_convention("-+") # exp(+iωt)

In total

  • behaviour change: one time convention for every complex result, chosen by the new set_time_convention, get_time_convention and the context manager time_convention. The default is exp(+jωt), which goes with m = n - ik and with Wiscombe's MIEV0; "-" gives exp(-iωt), the convention of Bohren & Huffman, Jackson and scattnlay. The two differ only by complex conjugation, and efficiencies, g and intensities are the same in both. Before, the package mixed them: S1_S2 and phase_matrix were exp(+jωt) while coefficients and every field function were exp(-iωt), which is what let the e_far error below go unnoticed. Under the default,

    • S1_S2, rayleigh.S1_S2 and phase_matrix are unchanged;
    • coefficients returns the conjugates of its previous values;
    • e_near, h_near, eh_near, their Cartesian forms and e_far return the conjugates of their previous fields, and a caller's abcd must come from coefficients under the same convention;
    • the miepython.vsh harmonics use h_n^(2) outside the sphere, and take m_index in the form that matches the active convention.

    Inside time_convention("-") the coefficients, fields and harmonics match 3.3.1, while S1_S2 returns Bohren & Huffman's amplitudes and phase_matrix puts S34 where their eq. 3.16 does. The raw kernels (an_bn, cn_dn, _S1_S2) ignore the setting and always return exp(-iωt); _S1_S2 no longer conjugates its sum a second time

  • e_far now broadcasts r, theta and phi as its docstring promised, returning shape (3, ...). An array r or phi with a scalar theta, or a 2-D theta, used to raise; all-scalar input now returns shape (3,) like e_near instead of (3, 1)

  • m = 0 is now an exact perfect conductor in efficiencies_mx, as it already was in coefficients, the field functions, rayleigh and for x < 0.1. It used to be replaced by 1 - 10000j for x >= 0.1
  • efficiencies_mx raises ValueError for an n_pole beyond wiscombe_terms(x), as S1_S2 does, instead of returning ~0
  • single_sphere and core.normalization_factor conjugate an index with a positive imaginary part themselves; the small-sphere branch used to give a negative qext for one
  • cn_dn defaults n_pole to 0 like an_bn, on both backends
  • norm='qsca' no longer returns NaN for a zero-size sphere
  • rayleigh.efficiencies_mx accepts a list of x and raises the same error as efficiencies_mx for mismatched lengths
  • clarify that coefficients returns orders 1 through n_pole
  • treat zero-dimensional NumPy arrays for m and x as scalar inputs throughout the public Mie API, including the JIT backend
  • return length-one arrays from the Rayleigh angular functions when mu is scalar, matching the full Mie API; correct the vsh.M_odd usage example
  • normalize the sign of an absorbing sphere's index before evaluating its interior near fields. Previously, a positive imaginary input produced the same scattering coefficients as its conjugate but different interior E and H fields, breaking boundary continuity. Both input signs now give the same fields in either time convention
  • make docs/13_resonance.ipynb construct silver indices as m = n - ik while plotting the positive absorption magnitude k, and clarify that m_im in docs/01_basics.ipynb is positive while Im(m) is negative
  • compare the scattnlay reference fields component by component, phase included, rather than only as magnitudes, which could not see a conjugated field
  • stop flipping the sign of S34 by hand in docs/07_algorithm.ipynb: Bohren's sample calculation now runs inside time_convention("-") and matches his table directly. docs/01_basics.ipynb explains both conventions, and docs/14_boundary_conditions.ipynb uses eps = n**2 for exp(+jωt)
  • fix the phase of e_far (#36, thanks @rcgiri-physics and @antonsoo). It conjugated the whole field, outgoing exp(ikr) included, so the radial phase ran backwards for the exp(-iωt) convention, and E_phi had the wrong sign relative to E_theta. Only S1 and S2 are conjugated now, and E_phi carries the -S1 sin(phi) of Bohren & Huffman eq. 4.74. e_far now agrees with e_near(..., include_incident=False) to O(1/kr) in every complex component; before, it was off by O(1). The old test compared magnitudes at theta = phi = 45 degrees, which could see neither error. Magnitudes, and so intensities, are unchanged
  • add PEP 723 inline metadata to docs/data/generate_scattnlay_reference_fields.py so uv run builds scattnlay 2.4 for it on demand. scattnlay stays out of the project extras, because nothing else needs it
Source: README.md, updated 2026-11-26