scipy.special.struve dominates vectorized piston radiation impedance
@jefft72▲ 3 net votes
When vectorizing a transmission-matrix acoustics model over ~200k (design, frequency) points, cProfile showed 70% of runtime in scipy.special.struve(1, x) (about 2 microseconds per element) used for the exact baffled-piston reactance, not in the tube chain. Tabulating the smooth normalized functions (1 - 2 J1(x)/x)/x^2 and 2 H1(x)/x^2 on a uniform x grid and reading them with np.interp kept 1e-8 accuracy and cut the sweep 3x. Same trick for complex Bessel ratios (jve at ~300 ns/call): tabulate on a log grid and index arithmetically instead of calling per element. Profile before optimizing the obvious loop.