---
title: "Subwoofer project: from impedance curve to box"
heading: Measuring a driver's Thiele–Small parameters from its impedance curve, designing a sealed box for a chosen alignment and checking its −3 dB point, and finding how loud the system can play before the cone runs out of excursion
eyebrow: S16 · Lesson 52 · Subwoofer project
xp: 80
---

::: hook
Designing a subwoofer is a small, complete engineering loop. You start with a driver whose specifications you don't fully trust, measure its impedance against frequency, and extract its resonance and Q values the way loudspeaker labs do. Then you choose a box that gives the response you want, and finally you find out how much bass it can actually play, which at low frequencies is limited not by the amplifier but by how far the cone can move. This project builds each step in Python on top of lessons 39 and 41.
:::

::: predict
## A 0.022 m² cone can move 6 mm peak. At 30 Hz, how loud can it play at 1 m in half space, and how far must it move to reach 100 dB?

- [ ] 100 dB already; 6 mm is plenty
- [x] About 90 dB; it would need about 19 mm for 100 dB
- [ ] About 70 dB; 600 mm for 100 dB
- [ ] About 120 dB; 0.6 mm for 100 dB

::: reveal
A baffled cone's pressure grows as $\omega^2$ times its volume displacement: p = ρω²S_dx/2πr = 0.90 Pa peak, or 90.0 dB SPL. Ten more decibels need √10 = 3.16 times the excursion, 19 mm, beyond most drivers this size. That's why subwoofers use big cones or several of them.
:::
:::

::: nameit
## Step 1: parameters from impedance

The motional impedance peaks at $f_s$ with $|Z|_\max = R_e r_0$. At the two frequencies $f_1 < f_s < f_2$ where $|Z| = R_e\sqrt{r_0}$,

$$Q_{ms} = \frac{f_s\sqrt{r_0}}{f_2 - f_1}, \qquad Q_{es} = \frac{Q_{ms}}{r_0 - 1}, \qquad Q_{ts} = \frac{Q_{ms}Q_{es}}{Q_{ms} + Q_{es}}$$

The tests synthesize impedance curves from known mechanical parameters (with no coil inductance) and check the recovered values against the exact ones from lesson 39.

## Step 2: the sealed box

Lesson 41's relations: $f_c = f_s\sqrt{1 + V_{as}/V_b}$, $Q_{tc} = Q_{ts}\sqrt{1 + V_{as}/V_b}$, the second-order high-pass response, its −3 dB frequency, and the box volume for a target $Q_{tc}$.

## Step 3: excursion-limited output

A cone of area $S_d$ moving with peak excursion x at angular frequency ω has volume velocity $S_d\omega x$; in a baffle radiating into half space, its peak pressure at r is

$$p = \frac{\rho_0\omega^2S_dx}{2\pi r}$$

so at fixed excursion the output falls 12 dB per octave toward low frequencies.
:::

::: example
## What should step 1 recover for a driver with $R_e$ = 6 Ω, Bl = 7 T·m, $M_m$ = 20 g, $K_m$ = 2000 N/m and $R_m$ = 1.5 kg/s?

::: solution
1. **Exact and measured values.** The exact values, and what the impedance method gives on a 0.05 Hz grid:

| Parameter | Exact | Impedance method |
|---|---|---|
| $f_s$ | 50.33 Hz | 50.35 Hz |
| $Q_{ms}$ | 4.216 | 4.218 |
| $Q_{es}$ | 0.7744 | 0.7748 |
| $Q_{ts}$ | 0.654 | 0.6545 |

2. **Check.** All four are within 0.1%.

**Answer:** step 1 should recover about 50.35 Hz, 4.218, 0.7748 and 0.6545, within 0.1% of the exact 50.33 Hz, 4.216, 0.7744 and 0.654.
:::
:::

::: example
## What should steps 2 and 3 give for a driver with $f_s$ = 30 Hz, $Q_{ts}$ = 0.35 and $V_{as}$ = 80 L?

::: solution
1. **Box volume.** For $Q_{tc}$ = 0.707:
   $$\begin{aligned} V_b &= \frac{V_{as}}{(Q_{tc}/Q_{ts})^2 - 1} \\ &= 25.97\ \text{L} \end{aligned}$$
2. **A 26 L box.** It gives
   $$\begin{aligned} f_c &= 60.57\ \text{Hz} \\ Q_{tc} &= 0.7067 \\ f_3 &= 60.61\ \text{Hz} \end{aligned}$$
3. **Output at 30 Hz.** With a 0.022 m² cone and 6 mm of excursion it reaches 90.0 dB at 1 m.
4. **Excursion for 100 dB.**
   $$\begin{aligned} x &= 6\ \text{mm} \times 10^{(100 - 90.04)/20} \\ &= 18.9\ \text{mm} \end{aligned}$$

**Answer:** a 25.97 L box for $Q_{tc}$ = 0.707; a 26 L box gives $f_c$ = 60.57 Hz, $Q_{tc}$ = 0.7067 and $f_3$ = 60.61 Hz, and it reaches 90.0 dB at 30 Hz, with 100 dB needing 18.9 mm of excursion.
:::
:::

::: check
kind: python

## Step 1. Write `ts_from_impedance`: Thiele–Small parameters from an impedance sweep.

```python starter
import numpy as np

def ts_from_impedance(f, Z, Re):
    # f: frequencies (Hz); Z: impedance magnitudes (ohms) around the resonance; Re: DC resistance.
    # Thiele-Small method: fs at the peak; r0 = Zmax/Re; f1 < fs < f2 where |Z| = Re*sqrt(r0)
    # (interpolate linearly between samples); Qms = fs*sqrt(r0)/(f2 - f1); Qes = Qms/(r0 - 1);
    # Qts = Qms*Qes/(Qms + Qes). Return (fs, Qms, Qes, Qts).
    return 0.0, 0.0, 0.0, 0.0

f = np.linspace(20, 120, 2001)
w = 2*np.pi*f
Z = np.abs(6 + 49/(1.5 + 1j*(w*0.02 - 2000/w)))
print(ts_from_impedance(f, Z, 6.0))
```

```python solution
import numpy as np

def ts_from_impedance(f, Z, Re):
    f, Z = np.asarray(f, float), np.asarray(Z, float)
    k = int(np.argmax(Z))
    fs, r0 = f[k], Z[k]/Re
    level = Re*np.sqrt(r0)
    i = k
    while Z[i] > level:
        i -= 1
    f1 = f[i] + (level - Z[i])*(f[i + 1] - f[i])/(Z[i + 1] - Z[i])
    j = k
    while Z[j] > level:
        j += 1
    f2 = f[j - 1] + (level - Z[j - 1])*(f[j] - f[j - 1])/(Z[j] - Z[j - 1])
    Qms = fs*np.sqrt(r0)/(f2 - f1)
    Qes = Qms/(r0 - 1)
    return fs, Qms, Qes, Qms*Qes/(Qms + Qes)

f = np.linspace(20, 120, 2001)
w = 2*np.pi*f
Z = np.abs(6 + 49/(1.5 + 1j*(w*0.02 - 2000/w)))
print(ts_from_impedance(f, Z, 6.0))
```

```python tests
for Re, Bl, M, K, R in ((6.0, 7.0, 0.02, 2000.0, 1.5), (3.5, 9.0, 0.05, 1800.0, 2.4)):
    f = np.linspace(10, 150, 4001)
    w = 2*np.pi*f
    Z = np.abs(Re + Bl**2/(R + 1j*(w*M - K/w)))
    fs0 = np.sqrt(K/M)/(2*np.pi)
    Qms0 = np.sqrt(K*M)/R
    Qes0 = 2*np.pi*fs0*M*Re/Bl**2
    fs, Qms, Qes, Qts = ts_from_impedance(f, Z, Re)
    assert abs(fs/fs0 - 1) < 2e-3, f"fs should be {fs0:.2f} Hz; got {fs:.2f}."
    assert abs(Qms/Qms0 - 1) < 0.01 and abs(Qes/Qes0 - 1) < 0.01, f"Expected Qms = {Qms0:.3f}, Qes = {Qes0:.3f}; got {Qms:.3f}, {Qes:.3f}."
    assert abs(Qts - Qms*Qes/(Qms + Qes)) < 1e-12, "Qts combines Qms and Qes like parallel resistors."
```

::: right
Right. The impedance method recovers the driver's resonance and Q values to within a fraction of a percent of their exact values.
:::
:::

::: check
kind: python

## Step 2. Write `sealed_box`, `response_db` and `box_for_q`: the closed-box alignment.

```python starter
import numpy as np

def sealed_box(fs, Qts, Vas, Vb):
    # Return (fc, Qtc, f3) for a driver in a sealed box of volume Vb (same units as Vas).
    return 0.0, 0.0, 0.0

def response_db(f, fc, Qtc):
    # Second-order high-pass magnitude in dB: x = f/fc, H = x^2/sqrt((1 - x^2)^2 + (x/Qtc)^2).
    return 0.0

def box_for_q(Qts, Vas, Qtc):
    # Box volume that gives the target Qtc.
    return 0.0

print(sealed_box(30, 0.35, 80, 26), box_for_q(0.35, 80, 0.707))
```

```python solution
import numpy as np

def sealed_box(fs, Qts, Vas, Vb):
    a = np.sqrt(1 + Vas/Vb)
    fc, Q = fs*a, Qts*a
    u = 1/Q**2 - 2
    return fc, Q, fc*np.sqrt((u + np.sqrt(u*u + 4))/2)

def response_db(f, fc, Qtc):
    x = np.asarray(f, float)/fc
    return 20*np.log10(x**2/np.sqrt((1 - x**2)**2 + (x/Qtc)**2))

def box_for_q(Qts, Vas, Qtc):
    return Vas/((Qtc/Qts)**2 - 1)

print(sealed_box(30, 0.35, 80, 26), box_for_q(0.35, 80, 0.707))
```

```python tests
fc, Q, f3 = sealed_box(30, 0.35, 80, 26)
assert abs(fc - 30*np.sqrt(1 + 80/26)) < 1e-9 and abs(Q - 0.35*np.sqrt(1 + 80/26)) < 1e-9, f"fc and Qtc should be {30*np.sqrt(1 + 80/26):.3f} Hz and {0.35*np.sqrt(1 + 80/26):.4f}; got {fc:.3f}, {Q:.4f}."
for q in (0.5, 0.707, 1.0, 1.3):
    fc, Q, f3 = sealed_box(40, q/2, 60, 20)
    assert abs(response_db(f3, fc, Q) + 10*np.log10(2)) < 1e-9, f"At f3 the response must be exactly -3.01 dB; for Qtc = {Q:.3f} you get {float(response_db(f3, fc, Q)):.4f} dB."
Vb = box_for_q(0.35, 80, 0.707)
assert abs(sealed_box(30, 0.35, 80, Vb)[1] - 0.707) < 1e-9, "box_for_q must give exactly the target Qtc."
assert abs(response_db(1e5, 50, 0.707)) < 1e-6, "Far above fc the response is flat at 0 dB."
```

::: right
Right. Your box hits its target Q exactly, and its response is exactly −3.01 dB at the computed $f_3$ for every alignment.
:::
:::

::: check
kind: python

## Step 3. Write `spl_for_excursion` and `excursion_for_spl`: how loud before the cone bottoms out.

```python starter
import numpy as np

RHO = 1.204

def spl_for_excursion(f, Sd, x, r=1.0):
    # A cone of area Sd moving with peak excursion x at frequency f radiates into half space
    # from a baffle. Its peak pressure at distance r is RHO*(2 pi f)^2*Sd*x/(2 pi r).
    # Return the SPL (RMS, re 20 uPa).
    return 0.0

def excursion_for_spl(f, Sd, spl, r=1.0):
    # The peak excursion needed to reach a given SPL. Return it in meters.
    return 0.0

print(spl_for_excursion(30, 0.022, 0.006), excursion_for_spl(30, 0.022, 100))
```

```python solution
import numpy as np

RHO = 1.204

def spl_for_excursion(f, Sd, x, r=1.0):
    p = RHO*(2*np.pi*f)**2*Sd*x/(2*np.pi*r)
    return 20*np.log10(p/np.sqrt(2)/20e-6)

def excursion_for_spl(f, Sd, spl, r=1.0):
    p = 20e-6*10**(spl/20)*np.sqrt(2)
    return p*2*np.pi*r/(RHO*(2*np.pi*f)**2*Sd)

print(spl_for_excursion(30, 0.022, 0.006), excursion_for_spl(30, 0.022, 100))
```

```python tests
L = spl_for_excursion(30, 0.022, 0.006)
assert abs(L - 90.04) < 0.01, f"A 0.022 m^2 cone moving 6 mm peak at 30 Hz gives 90.04 dB at 1 m; got {L:.3f}."
assert abs(spl_for_excursion(60, 0.022, 0.006) - L - 20*np.log10(4)) < 1e-9, "Doubling the frequency at the same excursion should add 12 dB."
assert abs(spl_for_excursion(30, 0.022, 0.006, 2.0) - L + 20*np.log10(2)) < 1e-9, "Doubling the distance should cost 6 dB."
for f, Sd, s in ((25, 0.05, 105), (40, 0.012, 95)):
    x = excursion_for_spl(f, Sd, s)
    assert abs(spl_for_excursion(f, Sd, x) - s) < 1e-9, "excursion_for_spl must invert spl_for_excursion."
assert abs(excursion_for_spl(30, 0.022, 100) - 0.006*10**((100 - L)/20)) < 1e-12, "Each 20 dB needs ten times the excursion."
```

::: right
Right. Your output model shows the 12 dB per octave fall at fixed excursion and the tenfold excursion each extra 20 dB costs.
:::
:::

::: explain
## Why does a subwoofer's maximum output fall so steeply at low frequencies?

::: model
Below a few hundred hertz a cone is a small source, and its radiated pressure is proportional to the rate of change of its volume velocity, that is, to its volume acceleration. For a sinusoidal motion of fixed amplitude, acceleration grows as the square of frequency, so halving the frequency at the same excursion cuts the pressure by four, 12 dB. Holding the output constant down to low frequencies therefore demands four times the excursion per octave, and every driver has a mechanical limit. The ways out are more cone area, longer excursion, or more drivers, which is why serious subwoofers are big.
:::
:::

::: practice

::: check
given: f = 20 | 40 | 80; S = 0.012 | 0.05; x = 3 | 12
answer: 20*log(1.204*(2*pi*f)^2*S*x*1e-3/(2*pi)/sqrt(2)/20e-6)
unit: dB
tolerance: 0.5%

## SPL at 1 m: {f} Hz, cone {S} m², {x} mm peak excursion?

::: misses
- [any] $p = \rho\omega^2S_dx/2\pi r$, then the RMS level.
:::
:::

::: check
given: r = 3 | 6 | 12; s = 40 | 50 | 80; d = 10 | 20
answer: s*sqrt(r)/d/(r - 1)
tolerance: 0.5%

## An impedance curve peaks at {r} times $R_e$ at {s} Hz, and the points where $|Z| = R_e\sqrt{r_0}$ are {d} Hz apart. What's $Q_{es}$?

::: misses
- [any] $Q_{ms} = f_s\sqrt{r_0}/(f_2 - f_1)$, then $Q_{es} = Q_{ms}/(r_0 - 1)$.
:::
:::

::: check
given: f = 20 | 60; q = 0.3 | 0.5; V = 30 | 150; b = 10 | 100
answer: q*sqrt(1 + V/b)
tolerance: 0.5%

## $Q_{tc}$: $Q_{ts}$ = {q}, $V_{as}$ = {V} L, $V_b$ = {b} L?

::: misses
- [any] $Q_{ts}\sqrt{1 + V_{as}/V_b}$.
:::
:::
:::
