Skip to content

PyStratify 0.7.1

Choose a tag to compare

@multilayerapp multilayerapp released this 04 Oct 01:31
· 91 commits to main since this release

The normalized formulation through real zeros of ψ_l

normalized_decay_rates (the formulation of the accompanying paper) built ψ_l ξ_l and the normalized j̄_l as products of consecutive ratios. At a real zero of ψ_{l-1}, which occurs for lossless shells and at the emitter, each of these products is a 0·∞ form whose small and large factors were rounded independently. Within a relative distance δ of such a zero, about log10(1/δ) digits were lost. A round parameter choice can hit a zero exactly: an emitter at r = 200 nm in water at 532 nm has k r = π, and its radiative rate came out 42 % too small. decay_rates, emission_rates and the plane-wave routines were not affected.

Fix (normalized.auxiliary)

  • ξ'/ξ is computed by its own upward recurrence, and P_l = ψ_l ξ_l = i/(B_l − A_l) is formed one order at a time from the Wronskian. No product runs through a zero, the cancellation of l/z − A_{l−1} for l ≫ |z| is gone, and for real z the small real part ψ_l² is a ratio of positive quantities (relative error 1e-15 instead of up to 4e-9).
  • The ratios of j̄ reuse the sums A_l + l/z that are rounded in the recurrence for A, and ψ_0 = s_1 ψ_1 is used near a zero of sin z. At a zero, j̄_l and P_l therefore carry the same rounding, and P/j̄ stays exact.
  • For strongly amplifying media (Im z ≤ −1), where the forward recurrence of ξ'/ξ is unstable and ψ has no zero within distance 1, P is still obtained from a cancellation-free product recurrence.

Accuracy against extended-precision transfer matrices

0.7.0 0.7.1
emitters and interfaces at or near real zeros up to O(1) ≤ 6e-14
20 benchmark cases (total / radiative), up to 22 620 multipoles 8.0e-13 / 6.2e-13 1.5e-14 / 1.2e-14
emitters 0.05–0.1 nm from gold 7.7e-11 1.5e-14

758 random multilayers agree with 0.7.0 to a median of 4e-15. In the five cases where the two versions differed by more than 1e-11, the extended-precision reference sides with 0.7.1.

Tests: 22 new tests cover real zeros, the small real part of ψξ, gain media and rates at zeros; 17 of them fail on 0.7.0. The full suite gives 320 passed.