Skip to content

[FEATURE] add pytta.loudspeaker with Thiele-Small parameters - #82

Open
aguirreSL wants to merge 1 commit into
PyTTaMaster:developmentfrom
aguirreSL:dev-thiele_small
Open

aguirreSL wants to merge 1 commit into
PyTTaMaster:developmentfrom
aguirreSL:dev-thiele_small

Conversation

@aguirreSL

@aguirreSL aguirreSL commented Oct 31, 2026 •

Copy link
Copy Markdown

Adds pytta.loudspeaker with the Thiele-Small parameters of a loudspeaker from its electrical impedance, as ita_thiele_small in the ITA-Toolbox. The ITA code was read for its semantics only and nothing was copied.

  1. impedance_model(params, freq): the impedance of the lumped model, Z = Re + j ω Le + Re (Qms/Qes) / (1 + j Qms (f/fs - fs/f)).
  2. thiele_small(impedance, Re=None, area=None, added_mass=None, impedance_with_mass=None, added_volume=None, impedance_in_box=None, fit=False, c=343.2, rho=1.204): the impedance is a SignalObj or a (freq, Z) pair.
    • From one curve it returns Re, fs, Qms, Qes and Qts. The resonance is found from the sign change of the reactance, so that the rise caused by Le at high frequency is skipped. The bandwidth is read where |Z| = sqrt(Rmax Re).
    • With a second curve, measured with an added mass or in a closed box of known volume, it also returns Rms, Mms, Cms, Bl and, with the cone area, Vas.
    • With fit=True, the closed form is refined by a least squares fit of Re, fs, Qms, Qes and Le to the whole curve (scipy.optimize.least_squares).

The equations follow Beranek and Mellow, Acoustics: Sound Fields and Transducers (2012), section 6.10, eq. 6.58 and 6.59 for the Q values, 6.66 for the added mass and 6.69 to 6.72 for the closed box, and the technical note "Measuring Thiele/Small parameters" of SB Acoustics.

The tests in tests/test_loudspeaker.py print the measured differences:

  1. Re, fs, Qms, Qes and Qts are recovered from a curve of impedance_model within 6.5e-7, relative.
  2. With an added mass, Mms, Cms, Rms, Bl and Vas are recovered within 2.9e-6. The two curves are written directly as the mechanical circuit, which also checks the electrical form of the model.
  3. With a closed box, the same parameters are recovered within 1.4e-6.
  4. With Le = 1.2 mH the closed form is biased by 1.1e-2 in Qms and Qes, and the fit recovers all five parameters exactly.
  5. Parity with the ITA-Toolbox on golden data from tests/golden/make_thiele_small_ita.m (MATLAB R2026b): impedance_model matches ita_linear_loudspeaker within 8e-16, and the estimates match ita_thiele_small within 0.53 %. That remaining difference comes from ITA reading the peak and the bandwidth at whole bins, while this module interpolates. Against the true values the estimates of this module are within 4e-5.
  6. Invalid input is rejected: no resonance in the band, a second curve without its mass, and a mass that raises the resonance.

Checked with Python 3.12, numpy 1.26 and scipy 1.17. The 7 failures of development (3 in test_h5io.py, 4 in test_pyttasave.py) are the same with and without this change.

Co-Authored-By: Claude Fable 5.1 noreply@anthropic.com

New module pytta.loudspeaker estimates the small signal parameters of an
electrodynamic loudspeaker from its electrical impedance, given as a
SignalObj or as (freq, Z) arrays.

thiele_small reads fs, Re, Qms, Qes and Qts from the impedance peak and
the two frequencies where |Z| = sqrt(Rmax Re) (Small 1972; Beranek and
Mellow 2012, section 6.10). A second curve with an added mass or in a
closed box of known volume gives Mms, Cms, Rms, Bl and Vas. With
fit=True every curve is refined by a least squares fit of the lumped
model, which also returns Le and removes the bias that Le causes in the
closed form.

impedance_model returns Z = Re + j w Le + Zmot of the same model.

Six tests: recovery of the parameters from synthetic curves for the
impedance, added mass, added volume and fit methods, parity with
ita_linear_loudspeaker and ita_thiele_small of the ITA-Toolbox (golden
data and generator script in tests/golden), and rejection of invalid
input.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant