skill
SPICE Simulation Skills
Public Made by Adomby adom
Pick, run and license the right SPICE simulator from an AI thread: ngspice in the container by default, LTspice and PSpice for TI on a Windows host for vendor models.
← Commit history
Publish 0.2.2
8 files changed
+187−60
README.md+78−45@@ -1,97 +1,130 @@ # SPICE Simulation Skills -Circuit simulation for AI agents in the Adom ecosystem. This skill pack tells an agent which SPICE engine to use, where to run it, how to drive it headless, and what each tool's licence allows. It comes from a hands-on comparison of ngspice, LTspice and PSpice for TI on a real board: a TPS54202 12 V to 5 V, 1 A buck converter.+Circuit simulation for AI agents in the Adom ecosystem. Install this pack and your agent knows which SPICE engine to use, where to run it, how to drive it without a person clicking, and what each tool's licence allows. It also installs **Adom SPICE**, a dashboard that runs a circuit in ngspice, LTspice or PSpice for TI (one, two or all three) and shows the results on one set of axes.++Everything here comes from a hands-on comparison on a real board: a TPS54202 12 V to 5 V, 1 A buck converter molecule. <video controls preload="metadata" width="1080" poster="docs/spice-comparison-poster.png" src="docs/spice-comparison.mp4"></video> -A 4 minute tour: the real board in 3D, the same test in ngspice, LTspice and PSpice for TI, all four runs on one set of axes, the Adom SPICE dashboard, and an AI thread in Adom Hydrogen running the whole comparison from one prompt. [Download the video](docs/spice-comparison.mp4).+A 4 minute tour: the board in 3D, the same test in ngspice, LTspice and PSpice for TI, all four runs on one set of axes, the Adom SPICE dashboard, and an AI thread in Adom Hydrogen running the whole comparison from one prompt. [Download the video](docs/spice-comparison.mp4). -## The short version+## Ask your AI -- **Default to ngspice in the Ubuntu container.** It is free (BSD), small, runs headless and in parallel, and works the same in WSL2, in Lima on a Mac, and in the cloud. It is the only mainstream option that may back a hosted simulation dashboard.-- **Use PSpice for TI only for PSpice-encrypted vendor models** (TI and many power-device vendors ship these). Nothing else can run them. It runs on a Windows host through Adom Bridge, for internal checks.-- **Use LTspice for ADI / LT parts** on a Windows host through Adom Bridge.-- **Never decrypt a vendor model.** Validate a fast hand-built model against the vendor model once instead.+You do not need to learn any commands. This is the prompt typed into a Claude thread in Adom Hydrogen in the video: -+```text+Install adom/adom-spice-skillpack from the Adom wiki. Then use the adom-spice dashboard to simulate+the TPS54202 12 V to 5 V buck example in ngspice, LTspice and PSpice for TI (LTspice and PSpice for TI+are installed on <your Windows PC>, so set the bridge target to <your Windows PC>). Show the dashboard+in a webview here and tell me whether the three engines agree.+``` -## What we learned+ -- **Accuracy**: on a well-posed netlist the engines gave consistent steady-state results. The differences we saw came from translating a netlist between dialects, not from the solvers.-- **Speed**: behavioral models run in seconds. A transistor-level vendor model of a switching regulator takes minutes to tens of minutes for a few milliseconds of switching, so iterate with a behavioral model and validate once with the vendor model.-- **Automation**: ngspice is the easiest to drive from an agent. LTspice has a working batch mode once a first-run dialog is answered. PSpice for TI has no batch runner in this edition, so an agent has to drive its GUI.-- **Install friction**: ngspice installs in minutes with no account. LTspice installs per-user without admin rights. PSpice for TI needs a TI account, an export-control request, an access key and an admin install a person must approve.-- **Model validation**: a hand-built model matched TI's vendor model closely on startup and ripple but under-predicted load-step overshoot. Fitted models are good for startup and ripple; check their loop dynamics against the vendor model.+The agent installed the pack, ran ngspice in its container, drove LTspice and PSpice for TI on the Windows PC through Adom Bridge, opened the dashboard in a Hydrogen webview, and answered with the comparison: -We do not publish timing or head-to-head numbers for LTspice or PSpice because their licences restrict publishing benchmarks. The ngspice numbers below are our own.+ -+### Most of the time, one engine is enough -## ngspice in the container (measured)+Running all three engines is how you check a model. Day to day, one engine usually does the job, and ngspice is the default because it runs right in your container: -| | ngspice 42 (apt) | ngspice 47 (source build) |-|---|---|---|-| Disk | 36 MB | 21 MB |-| 5 ms of a 500 kHz buck with a load step | 1.4 s | 1.8 s |-| 400-run Monte Carlo of a Sallen-Key filter, 16 cores | 0.6 s | |+- *"Simulate my buck converter in ngspice with the Adom SPICE dashboard and show me the start-up and load-step response."*+- *"This regulator's model is encrypted for PSpice. Run it in PSpice for TI on my Windows PC and show me the output ripple."*+- *"Run my circuit in LTspice as well, and tell me if it agrees with ngspice."* -## Tool facts+A single-engine run gets the same charts and measurements; add a second engine whenever you want a cross-check. -| | ngspice | LTspice | PSpice for TI |-|---|---|---|---|-| Where it runs | Ubuntu container | Windows or macOS host | Windows host |-| Disk | 21 to 36 MB | about 270 MB | about 7 GB |-| Install | apt, or a 4 minute source build | per-user MSI, no admin | TI access key + admin install |-| Headless batch | yes | yes | no, GUI only |-| Runs PSpice-encrypted models | no | no | yes |-| May back a hosted dashboard | yes | no | no |+ ## The Adom SPICE dashboard -The pack installs `adom-spice`, a dashboard that runs one study in all three engines and puts the results on one set of axes. ngspice runs in your container; LTspice and PSpice for TI run on your Windows machine through Adom Bridge. Every engine is measured by the same code, and the dashboard tells you whether they agree. When they do not, it names the measurement and the engine that is out of line, which is usually a netlist-translation or model problem worth finding before you build the board.+`adom-spice` runs one study in any of the three engines. ngspice runs in your container. LTspice and PSpice for TI run on your Windows PC through Adom Bridge (PSpice for TI has no batch mode, so the dashboard opens it, presses Run, and reads the results back). Every engine is measured by the same code, so when two engines disagree, the dashboard names the measurement and the engine that is out of line. That is usually a netlist-translation or model problem worth finding before you build the board.  -It also keeps a ledger of each run: the simulation time (LTspice and PSpice times stay hidden by default, per their licences) and the AI tokens the run cost.+It also keeps a ledger of every run: the simulation time (LTspice and PSpice times stay hidden by default, per their licences) and the AI tokens the run cost.  -Ask your AI: *"Simulate the TPS54202 buck in ngspice, LTspice and PSpice for TI with the Adom SPICE dashboard, and tell me whether they agree."* Or drive it yourself:+On the example board all three engines agree on all eight measurements: output voltage, output ripple, inductor ripple, start-up peak current, time to 95 %, overshoot, undershoot and settling. TI's own encrypted model, added as a reference, starts up the same way, sits about 30 mV higher, and swings a little more on each load step.++Driving it yourself: ```bash adom-spice --ai-thread "buck check" start adom-spice --ai-thread "buck check" study ~/.adom/adom-spice/examples/tps54202-buck/study.json-adom-spice --ai-thread "buck check" run ngspice ltspice pspice-adom-spice --ai-thread "buck check" show+adom-spice --ai-thread "buck check" run ngspice # or: run ngspice ltspice pspice+adom-spice --ai-thread "buck check" settings bridgeTarget=<your Windows PC> # for LTspice and PSpice for TI+adom-spice --ai-thread "buck check" show # opens the dashboard in a Hydrogen webview ``` -On the example board all three engines agree on all eight measurements (output voltage, ripple, inductor ripple, start-up peak current, time to 95 %, overshoot, undershoot, settling).+A study is one JSON file: a netlist per engine, the signal names, the chart windows and the measurements. The **adom-spice** skill in this pack documents the format.++## Which engine to use++- **Default to ngspice in the Ubuntu container.** It is free (BSD), small, runs headless and in parallel, and works the same in WSL2, in Lima on a Mac, and in the cloud. It is the only mainstream option that may back a hosted simulation dashboard.+- **Use PSpice for TI for PSpice-encrypted vendor models** (TI and many power-device vendors ship these). Nothing else can run them. It runs on a Windows PC through Adom Bridge, for internal checks.+- **Use LTspice for Analog Devices / Linear Technology parts** on a Windows PC through Adom Bridge.+- **Never decrypt a vendor model.** Validate a fast hand-built model against the vendor model once instead.++| | ngspice | LTspice | PSpice for TI |+|---|---|---|---|+| Where it runs | Ubuntu container | Windows or macOS host | Windows host |+| Disk | 21 to 36 MB | about 270 MB | about 7 GB |+| Install | apt, or a 4 minute source build | per-user MSI, no admin | TI access key + admin install |+| Headless batch | yes | yes | no, GUI only |+| Runs PSpice-encrypted models | no | no | yes |+| May back a hosted dashboard | yes | no | no |++## What we learned++- **Accuracy**: on the same well-posed netlist the engines agreed closely. The differences we saw came from translating a netlist between dialects, not from the solvers.+- **Speed**: behavioral models run in seconds. A transistor-level vendor model of a switching regulator takes minutes to tens of minutes for a few milliseconds of switching, so iterate with a behavioral model and validate once with the vendor model.+- **Automation**: ngspice is the easiest to drive from an agent. LTspice has a working batch mode once its first-run dialogs are answered. PSpice for TI has no batch runner in this edition, so an agent has to drive its window.+- **Install friction**: ngspice installs in minutes with no account. LTspice installs per-user without admin rights. PSpice for TI needs a TI account, an export-control request, an access key and an admin install a person must approve.+- **Model validation**: our hand-built model matched TI's vendor model on start-up and ripple but under-predicted load-step deviation by about 15 %. Fitted models are good for start-up and ripple; check their loop dynamics against the vendor model.+- **AI cost**: a fresh agent running one board simulation used about 40,000 tokens with ngspice or LTspice and about 49,000 with PSpice for TI (it has to drive a window). Most of that is the agent's fixed start-up context, not the simulation.++We do not publish timing or head-to-head numbers for LTspice or PSpice because their licences restrict publishing benchmarks. The ngspice numbers below are our own.++++## ngspice in the container (measured)++| Run | Time |+|---|---|+| The TPS54202 board, 9 ms of 500 kHz switching with two load steps | 13 to 16 s |+| 2000-run Monte Carlo of a Sallen-Key filter, 16 cores in parallel | about 5 s |+| A simple 5 ms buck test bench (ngspice 42 / 47) | 1.4 s / 1.8 s |++ ## Skills in this pack | Skill | Use it for | |---|---| | **adom-spice-skillpack** | Start here: the decision rule, the findings, the skill map. |-| **spice-choose** | Which engine for which job; container vs Windows host; WSL2 vs Lima; install weight. |+| **adom-spice** | The dashboard: study format, one or more engines, running LTspice and PSpice through the bridge, agreement check, run ledger. |+| **spice-choose** | Which engine for which job; container vs Windows PC; WSL2 vs Lima; install weight. | | **spice-ngspice** | ngspice in the container: batch runs, measures, parallel Monte Carlo, building ngspice 47, parse traps. |-| **spice-ltspice** | LTspice on a Windows host through Adom Bridge: silent install, the first-run dialog, batch runs. |-| **spice-pspice-ti** | PSpice for TI: access, admin install, driving the GUI, output traps, CSDF output. |+| **spice-ltspice** | LTspice on a Windows PC through Adom Bridge: silent install, the first-run dialogs, batch runs. |+| **spice-pspice-ti** | PSpice for TI: access, admin install, driving the window, output traps, CSDF output. | | **spice-vendor-models** | Encrypted models: what runs where, validating a behavioral model, what never to do. | | **spice-portable-netlists** | One netlist for ngspice, LTspice and PSpice; the dialect differences. | | **spice-licensing** | Where each tool may run, hosted dashboards, commercial use, publishing results. |-| **adom-spice** | The dashboard: study format, running engines through the bridge, agreement check, run ledger. | ## Examples -- `examples/buck_portable.cir`: the 12 V to 5 V buck test bench for ngspice and LTspice, with `.meas` results.-- `examples/buck_portable_pspice.cir`: the same circuit in PSpice syntax.+- `app/examples/tps54202-buck/`: the dashboard study for the board in the video, with one netlist per engine.+- `examples/buck_portable.cir` and `examples/buck_portable_pspice.cir`: a simple buck test bench in the ngspice/LTspice and PSpice dialects. - `examples/sallen_key_ac.cir`: the Sallen-Key filter used for the Monte Carlo run. - `examples/csdf.py`: a reader for PSpice `.PROBE/CSDF` text output. ## Install ```bash-adom-wiki pkg install adom-spice-skillpack+adom-wiki pkg install adom/adom-spice-skillpack ``` -This installs the main skill, all eight sub-skills and the `adom-spice` dashboard command.+This installs the main skill, eight sub-skills and the `adom-spice` dashboard command. LTspice and PSpice for TI themselves are installed on your Windows PC; the **spice-ltspice** and **spice-pspice-ti** skills walk your agent through that.
app/adom_spice/analysis.py+1−1@@ -44,7 +44,7 @@ def agreement(results, spec, tol): for m in spec: n = m['name']; vals = {e: results[e].get(n) for e in engines if results[e].get(n) is not None} if len(vals) < 2:- rows.append({'metric': n, 'unit': m.get('unit', ''), 'values': vals, 'spread': None, 'ok': None}); continue+ rows.append({'metric': n, 'unit': m.get('unit', ''), 'label': m.get('label', n), 'values': vals, 'spread': None, 'ok': None}); continue arr = np.array(list(vals.values())); med = float(np.median(arr)); spread = float(arr.max() - arr.min()) lim = m['abs_tol'] if 'abs_tol' in m else tol['rel'] * abs(med) # a study's own limit wins over the global % rows.append({'metric': n, 'unit': m.get('unit', ''), 'label': m.get('label', n), 'values': vals,
app/adom_spice/server.py+5−1@@ -160,7 +160,11 @@ def recompute(): row['reference'] = {r['label']: r['metrics'].get(row['metric']) for r in refs} STATE['agreement'] = rows checked = [r for r in rows if r['ok'] is not None]- if len(engs) < 2: STATE['verdict'] = {'kind': 'pending', 'text': 'Run at least two engines to check agreement.'}+ names = {'ngspice': 'ngspice', 'ltspice': 'LTspice', 'pspice': 'PSpice for TI'}+ if not engs: STATE['verdict'] = {'kind': 'pending', 'text': 'Pick an engine and press Run (ngspice runs right here in the container).'}+ elif len(engs) == 1:+ e = next(iter(engs)); n = len(st['measurements'])+ STATE['verdict'] = {'kind': 'single', 'text': f'{names[e]} run complete: {n} measurements below. Run a second engine any time to cross-check it.'} elif all(r['ok'] for r in checked): STATE['verdict'] = {'kind': 'agree', 'text': f'{len(engs)} engines agree on all {len(checked)} measurements.'} else:
app/web/app.js+4−3@@ -82,13 +82,14 @@ function renderCharts() { function renderAgree() { const t = $('#agree'); if (!S.agreement.length) { t.innerHTML = '<tr><td>No measurements yet.</td></tr>'; return; }+ const single = S.verdict && S.verdict.kind === 'single'; const engs = Object.keys(ENG).filter(e => runFor(e) && runFor(e).status === 'done'); const refs = S.runs.filter(r => r.engine === 'reference').map(r => r.label);- t.innerHTML = `<tr><th>Measurement</th>${engs.map(e => `<th><span class="sw" style="background:${S.colors[e]}"></span> ${ENG[e].name}</th>`).join('')}<th>Spread</th><th>Limit</th><th>Engines</th>${refs.map(r => `<th>${r}</th>`).join('')}</tr>` ++ t.innerHTML = `<tr><th>Measurement</th>${engs.map(e => `<th><span class="sw" style="background:${S.colors[e]}"></span> ${ENG[e].name}</th>`).join('')}${single ? '' : '<th>Spread</th><th>Limit</th><th>Engines</th>'}${refs.map(r => `<th>${r}</th>`).join('')}</tr>` + S.agreement.map(row => `<tr class="${row.ok === false ? 'flag' : ''}"><td>${row.label || row.metric} <span class="sub">${row.unit}</span></td> ${engs.map(e => `<td class="num ${row.outlier === e ? 'outlier' : ''}">${fmt(row.values[e])}</td>`).join('')}- <td class="num">${fmt(row.spread)}</td><td class="num">${fmt(row.limit)}</td>- <td class="${row.ok ? 'ok' : row.ok === false ? 'bad' : ''}">${row.ok ? 'agree' : row.ok === false ? 'differ' : '-'}</td>+ ${single ? '' : `<td class="num">${fmt(row.spread)}</td><td class="num">${fmt(row.limit)}</td>+ <td class="${row.ok ? 'ok' : row.ok === false ? 'bad' : ''}">${row.ok ? 'agree' : row.ok === false ? 'differ' : '-'}</td>`} ${refs.map(r => `<td class="num">${fmt((row.reference || {})[r])}</td>`).join('')}</tr>`).join(''); }
app/web/style.css+1@@ -19,6 +19,7 @@ main { padding: 16px; display: flex; flex-direction: column; gap: 16px; max-widt .verdict { padding: 14px 18px; border-radius: 10px; font-size: 18px; font-weight: 600; border: 1px solid var(--line); } .verdict.agree { background: #0f2a22; border-color: #1f6f5b; color: #7ff0d6; } .verdict.disagree { background: #2b1414; border-color: #7f2a2a; color: #fca5a5; }+.verdict.single { background: #10202a; border-color: #1f4f6f; color: #9fd3f0; } .verdict.pending { background: var(--panel); color: var(--dim); } .engines { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; } .eng { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
package.json+7−7@@ -2,7 +2,7 @@ "slug": "adom-spice-skillpack", "title": "SPICE Simulation Skills", "type": "skill",- "version": "0.2.1",+ "version": "0.2.2", "description": "Pick, run and compare SPICE simulators from an AI thread: ngspice in the Ubuntu container, LTspice and PSpice for TI on a Windows host through Adom Bridge, plus the adom-spice dashboard that overlays all three and flags where they disagree.", "tags": [ "skill",@@ -30,16 +30,16 @@ "discovery_pitch": "Reach for this whenever a circuit needs simulating or a SPICE tool or vendor model has to be chosen, installed or licensed.", "sample_prompts": [ {- "label": "Simulate a buck",- "prompt": "Simulate my 12 V to 5 V buck converter and check the load-step response"+ "label": "Simulate in ngspice",+ "prompt": "Simulate my buck converter in ngspice with the Adom SPICE dashboard and show me the start-up and load-step response" }, {- "label": "Vendor model",- "prompt": "TI only gives a PSpice model for this regulator, how do we simulate it?"+ "label": "Encrypted vendor model",+ "prompt": "This regulator's model is encrypted for PSpice. Run it in PSpice for TI on my Windows PC and show me the output ripple" }, {- "label": "Pick a tool",- "prompt": "Should we use ngspice, LTspice or PSpice for our simulation dashboard?"+ "label": "Compare three engines",+ "prompt": "Simulate the TPS54202 buck example in ngspice, LTspice and PSpice for TI with the Adom SPICE dashboard and tell me whether the three engines agree" } ], "files": [
page.json+87−3@@ -2,7 +2,91 @@ "title": "SPICE Simulation Skills", "brief": "Pick, run and license the right SPICE simulator from an AI thread: ngspice in the container by default, LTspice and PSpice for TI on a Windows host for vendor models.", "type": "skill",- "tags": ["skill", "skillpack", "spice", "simulation", "ngspice", "ltspice", "pspice", "electronics"],+ "tags": [+ "skill",+ "skillpack",+ "spice",+ "simulation",+ "ngspice",+ "ltspice",+ "pspice",+ "electronics"+ ], "visibility": "public",- "hero": { "type": "image", "path": "docs/hero.png" }-}+ "hero": {+ "type": "image",+ "path": "docs/hero.png"+ },+ "slug": "adom-spice-skillpack",+ "version": "0.2.2",+ "description": "Pick, run and compare SPICE simulators from an AI thread: ngspice in the Ubuntu container, LTspice and PSpice for TI on a Windows host through Adom Bridge, plus the adom-spice dashboard that overlays all three and flags where they disagree.",+ "dependencies": {},+ "discovery_triggers": [+ "simulate this circuit",+ "run a spice simulation",+ "which spice simulator should I use",+ "ngspice or ltspice",+ "run the TI pspice model",+ "can we host ltspice in a dashboard",+ "spice licensing",+ "compare ngspice ltspice and pspice",+ "do my simulators agree",+ "spice dashboard"+ ],+ "discovery_pitch": "Reach for this whenever a circuit needs simulating or a SPICE tool or vendor model has to be chosen, installed or licensed.",+ "sample_prompts": [+ {+ "label": "Simulate in ngspice",+ "prompt": "Simulate my buck converter in ngspice with the Adom SPICE dashboard and show me the start-up and load-step response"+ },+ {+ "label": "Encrypted vendor model",+ "prompt": "This regulator's model is encrypted for PSpice. Run it in PSpice for TI on my Windows PC and show me the output ripple"+ },+ {+ "label": "Compare three engines",+ "prompt": "Simulate the TPS54202 buck example in ngspice, LTspice and PSpice for TI with the Adom SPICE dashboard and tell me whether the three engines agree"+ }+ ],+ "files": [+ "SKILL.md",+ "README.md",+ "package.json",+ "install.sh",+ "uninstall.sh",+ "skills/spice-choose/SKILL.md",+ "skills/spice-ngspice/SKILL.md",+ "skills/spice-ltspice/SKILL.md",+ "skills/spice-pspice-ti/SKILL.md",+ "skills/spice-vendor-models/SKILL.md",+ "skills/spice-portable-netlists/SKILL.md",+ "skills/spice-licensing/SKILL.md",+ "examples/buck_portable.cir",+ "examples/buck_portable_pspice.cir",+ "examples/sallen_key_ac.cir",+ "examples/csdf.py",+ "skills/adom-spice/SKILL.md",+ "app/adom_spice/analysis.py",+ "app/adom_spice/engines.py",+ "app/adom_spice/server.py",+ "app/bin/adom-spice",+ "app/examples/tps54202-buck/board_ltspice.cir",+ "app/examples/tps54202-buck/board_ngspice.cir",+ "app/examples/tps54202-buck/board_pspice.cir",+ "app/examples/tps54202-buck/study.json",+ "app/install.sh",+ "app/uninstall.sh",+ "app/web/app.js",+ "app/web/index.html",+ "app/web/style.css"+ ],+ "scripts": {+ "install": "./install.sh",+ "uninstall": "./uninstall.sh"+ },+ "org": "adom",+ "author": {+ "name": "John Lauer",+ "email": "[email protected]"+ }+}
skills/adom-spice/SKILL.md+4@@ -24,6 +24,10 @@ adom-spice --ai-thread "<name>" state # verdict + agr - Record what the AI side cost: `adom-spice --ai-thread "<name>" tokens pspice 49099 --tool-calls 16`. - Add a vendor-model run as a reference that is shown but does not vote: `adom-spice --ai-thread "<name>" ingest ti.csd --kind csdf --label "TI model" --signals '{"vout":"V(Rpv)","il":"I(L1)"}'`. +## One engine or several++Run what the user asked for. "Simulate this" means ngspice only (it is in the container, fast and free); do not start LTspice or PSpice for TI unless the user asks for them, the circuit needs a PSpice-encrypted vendor model, or the user wants a cross-check. A single-engine run shows the same charts and measurements with a "run complete" banner; the agreement verdict appears as soon as a second engine has run. PSpice for TI takes over the Windows PC's screen for minutes, so say so before starting it.+ ## The study file `study.json` holds one netlist per engine dialect, the signal names per engine, the chart views (time windows) and the measurements (windows, kind, unit, tolerance). Every engine is measured by the same code, so a disagreement always means the engines or the netlist translations differ, never the measuring. Kinds: `mean`, `pp`, `max`, `min`, `overshoot`, `undershoot` (need `ref` window), `t_reach` (needs `frac`, `ref`), `settle` (needs `band`, `ref`). `abs_tol` per measurement; otherwise the global percent in Settings.