run_sweep
Execute multiple SPICE simulations in parallel with component value sweeps, replacing manual loops for faster multi-run analysis.
Instructions
Run multiple SPICE simulations in parallel, sweeping component values.
Uses spicelib's SimRunner to execute runs concurrently. Each run gets its own .npz file. Use this instead of calling run_ac_analysis / run_transient in a loop — it's significantly faster for multi-run sweeps.
Example — sweep capacitor C1 across three values with a transient analysis: run_sweep( netlist_path="/path/to/filter.cir", analysis_cmd=".tran 1n 1u", runs=[{"C1": "1p"}, {"C1": "10p"}, {"C1": "100p"}], ) Output files: filter_sweep_001.npz, filter_sweep_002.npz, filter_sweep_003.npz
Each dict in runs maps component reference designators or SPICE parameter
names to their new values (strings with optional SPICE suffix, e.g. "4.7k").
Args: netlist_path: Absolute path to the netlist file analysis_cmd: Full SPICE analysis line, e.g. ".tran 1n 1u" or ".ac dec 20 1 1G" runs: List of dicts, one per simulation. Keys are component names or parameter names; values are the new value strings. parallel: Maximum number of simultaneous ngspice processes (default 4)
Returns: JSON list of per-run summaries, each with keys: run — 1-indexed run number data_file — path to the .npz file values — the component/parameter values used for this run traces — list of trace names in the .npz
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| netlist_path | Yes | ||
| analysis_cmd | Yes | ||
| runs | Yes | ||
| parallel | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |