resonance
Detect magnitude peaks in an AC sweep and calculate Q factor with -3 dB bandwidth for resonant circuits like RLC resonators or crystal oscillators.
Instructions
Detect magnitude peaks in an AC sweep and estimate Q factor + -3 dB bandwidth for each. Useful for RLC resonators, crystal oscillators, peaking amps, or any response with distinct resonant modes.
Q = f_peak / Δf(-3 dB from peak). Q is returned as null for peaks without two flanking -3 dB crossings inside the swept range — widen the sweep if you need Q for a boundary peak.
min_prominence_db=3 rejects the gentle hump of a filter's passband (which isn't a resonance). Tight resonances (Q > 30) need dense sampling near f_peak — log sweeps with <50 pts/decade will under-sample the peak and give inflated Q/bandwidth.
For overall filter characterization use bode_metrics(mode='filter'); for stability margins use stability_metrics.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| raw_file | Yes | Path to AC analysis .raw result file | |
| signal | Yes | Signal name (e.g. 'V(out)') | |
| min_prominence_db | No | Minimum peak prominence in dB. Smaller = more sensitive but also catches gentle humps. 3 dB rejects filter-passband shoulders. | |
| min_separation_decades | No | Merge peaks closer than this many decades (find_peaks can emit duplicates on shoulders). | |
| max_peaks | No | Maximum peaks returned (1..1000) | |
| step | No | Step index for .step sweeps | |
| format | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| peaks | Yes | ||
| num_peaks_detected | Yes | ||
| warnings | Yes | ||
| signal | Yes |