← Commit history
Merge PR #631: 0.2.127: simulate the drawn schematic in Altium (altium-simulate-0.2.127 -> main) merge
Showing changes introduced by the merge (against its first parent).
11 files changed
+195−19
Cargo.lock+10−10@@ -4,7 +4,7 @@ version = 4 [[package]] name = "adom-aiflow"-version = "0.2.126"+version = "0.2.127" dependencies = [ "aiflow-analyze", "aiflow-board",@@ -27,7 +27,7 @@ dependencies = [ [[package]] name = "aiflow-analyze"-version = "0.2.126"+version = "0.2.127" dependencies = [ "aiflow-board", "serde",@@ -37,7 +37,7 @@ dependencies = [ [[package]] name = "aiflow-board"-version = "0.2.126"+version = "0.2.127" dependencies = [ "roxmltree", "serde",@@ -46,7 +46,7 @@ dependencies = [ [[package]] name = "aiflow-bridge"-version = "0.2.126"+version = "0.2.127" dependencies = [ "aiflow-board", "serde",@@ -55,7 +55,7 @@ dependencies = [ [[package]] name = "aiflow-copper"-version = "0.2.126"+version = "0.2.127" dependencies = [ "aiflow-board", "aiflow-grid",@@ -65,7 +65,7 @@ dependencies = [ [[package]] name = "aiflow-grid"-version = "0.2.126"+version = "0.2.127" dependencies = [ "aiflow-board", "serde",@@ -74,7 +74,7 @@ dependencies = [ [[package]] name = "aiflow-place"-version = "0.2.126"+version = "0.2.127" dependencies = [ "aiflow-board", "serde",@@ -83,7 +83,7 @@ dependencies = [ [[package]] name = "aiflow-pours"-version = "0.2.126"+version = "0.2.127" dependencies = [ "aiflow-board", "aiflow-copper",@@ -93,7 +93,7 @@ dependencies = [ [[package]] name = "aiflow-router"-version = "0.2.126"+version = "0.2.127" dependencies = [ "aiflow-board", "aiflow-grid",@@ -104,7 +104,7 @@ dependencies = [ [[package]] name = "aiflow-run"-version = "0.2.126"+version = "0.2.127" dependencies = [ "serde", "serde_json",
Cargo.toml+1−1@@ -14,7 +14,7 @@ members = [ ] [workspace.package]-version = "0.2.126"+version = "0.2.127" edition = "2021" license = "MIT" repository = "https://wiki.adom.inc/adom/adom-aiflow"
crates/adom-aiflow/src/main.rs+1−1@@ -5919,7 +5919,7 @@ fn main() { // the lane's pure helpers (tools/altium-lane.py: the symbol check, project-library parts), then the Altium half let run = Run::open(&dir); let target = target.clone().or_else(|| run.as_ref().and_then(|r| r.data["target"].as_str().map(str::to_string))).or_else(|| std::env::var("AIFLOW_TARGET").ok()).unwrap_or_default();- let script = format!("{}\n{}\n{}\n{}\n{}", include_str!("../../../tools/project-common.py"), include_str!("../../../tools/silkscreen-plan.py"), include_str!("../../../tools/altium-lane.py"), include_str!("../../../tools/altium-spice.py"), include_str!("../../../tools/altium-project.py"));+ let script = format!("{}\n{}\n{}\n{}\n{}\n{}", include_str!("../../../tools/project-common.py"), include_str!("../../../tools/silkscreen-plan.py"), include_str!("../../../tools/altium-lane.py"), include_str!("../../../tools/altium-spice.py"), include_str!("../../../tools/altium-sim.py"), include_str!("../../../tools/altium-project.py")); let status = std::process::Command::new("python3").arg(lane_script("altium", &script)).args(args) .env("AIFLOW_RUN", &dir).env("AIFLOW_TARGET", &target).env("AIFLOW_THREAD", thread(&cli)).env("AIFLOW_EXE", std::env::current_exe().map(|p| p.display().to_string()).unwrap_or_default()) .status().unwrap_or_else(|e| err(&format!("altium steps need python3: {e}"), &[]));
docs/altium-lane.md+16−1@@ -157,4 +157,19 @@ On an Altium run every step's clip films Altium's main window, the board fitted "spiceModels": {"1N4148W": {"file": "sim/models/1N4148.lib", "model": "1N4148", "pinMap": {"1": 2, "2": 1}}} ``` -`file` is relative to the spec's folder (provenance.json: `"spice"`, `"spiceModel"`, `"spicePinMap"`, relative to the project library). `model` names one .MODEL/.SUBCKT when the file holds several. `pinMap` maps symbol pin to model node (from 1). Pins named for their SPICE role (A/K, C/B/E, D/G/S) map by name, others by number: give `pinMap` whenever the datasheet gives a subcircuit's node order. The model goes on after every import (an import replaces the symbol), and the library is saved. An encrypted vendor model (TI's PSpice packages) is refused and named; a part's import never fails for its model. Simulating the whole drawn schematic in Altium waits on altium-bridge: generic R/C/L models and a source on a simulation copy of the sheet are not there yet.+`file` is relative to the spec's folder (provenance.json: `"spice"`, `"spiceModel"`, `"spicePinMap"`, relative to the project library). `model` names one .MODEL/.SUBCKT when the file holds several. `pinMap` maps symbol pin to model node (from 1). Pins named for their SPICE role (A/K, C/B/E, D/G/S) map by name, others by number: give `pinMap` whenever the datasheet gives a subcircuit's node order. The model goes on after every import (an import replaces the symbol), and the library is saved. An encrypted vendor model (TI's PSpice packages) is refused and named; a part's import never fails for its model. `altium simulate` then simulates the drawn schematic (below).++## Simulate the drawn schematic (altium-bridge 0.2.117+)++`altium simulate` simulates the schematic AI Flow drew, in Altium, on a copy: the design itself is never touched. The copy gives every resistor, capacitor and inductor with no model Altium's generic one at its Value, adds the sources and loads you name, and runs one analysis.++```bash+adom-aiflow altium simulate --sources sim/altium-sources.json [--loads sim/altium-loads.json] \+ --analysis op|tran|ac --probe VOUT [--probe SW] [--expect VOUT=5+-0.05] [--step 1e-7 --stop 2e-3] [--fstart 10 --fstop 1e6 --points 50]+```++- sources: `[{"type": "voltage", "plus": "VIN", "minus": "GND", "dc": 12}]` (also current, sin, pulse, pwl, ac). A node is a net name or a pin (`R1.2`). loads: `[{"type": "resistor", "value": "10", "plus": "VOUT"}]`.+- Times and frequencies are plain numbers in seconds and hertz (`1e-6`, not `1u`).+- `--expect NET=value+-tol` checks the result (`NET.ripple=` for a transient's peak to peak); a mismatch answers ERROR with both numbers.+- The result goes to `altium/sim/altium-<analysis>.json` in the run with the copy's path and Altium's netlist (diff it against your ngspice deck). Record it with `adom-aiflow evidence add --kind simulation --file <it>`.+- A part with no model and no generic stand-in (an IC whose vendor model is encrypted) stops the analysis and is named: attach an unencrypted model in the library step, or simulate that block in ngspice.
docs/release-0.2.127.mdadded+16@@ -0,0 +1,16 @@+# adom-aiflow 0.2.127++## Altium: simulate the drawn schematic (altium-bridge 0.2.117)++New step `adom-aiflow altium simulate` runs the schematic AI Flow drew through Altium's own simulator, on a copy, so the design is never touched.++- The copy gives each resistor, capacitor and inductor with no model Altium's generic one at its Value, and adds the sources and loads you name (`--sources`, `--loads`, JSON lists; a node is a net or a pin like `R1.2`).+- One analysis per call: `op`, `tran` (`--step`, `--stop`) or `ac` (`--fstart`, `--fstop`, `--points`), with one or more `--probe` nets.+- `--expect VOUT=6+-0.01` checks the answer (`NET.ripple=` for a transient's peak to peak). A mismatch answers ERROR with both numbers.+- The result is written to `altium/sim/altium-<analysis>.json` in the run, with the copy's path and Altium's netlist for a diff against your ngspice deck. Record it as simulation evidence.+- A source or load that misses its net, or a part with no model and no generic stand-in, is named and refused.+- The aiflow-simulate skill and docs/altium-lane.md say when to use it.++Tested live on the test desktop (Altium Designer 26, altium-bridge 0.2.117): AI Flow drew a 10k/10k divider from the wiki's RC0603FR-0710KL, and Altium simulated 6 V on VOUT from a 12 V source, matching the expectation.++Needs altium-bridge 0.2.117 (insiders today).
package.json+1−1@@ -1,7 +1,7 @@ { "slug": "adom-aiflow", "type": "app",- "version": "0.2.126",+ "version": "0.2.127", "title": "AI Flow", "description": "Adom's AI Flow: a tool to help the AI follow all of the steps it takes to build a board. One Rust binary with a crate per step (placement helpers, a grid router with Kelvin taps, pours with keepouts, KiCad's DRC gate, live landing through the KiCad Bridge, copper measurement, current and thermal analysis) and a finish line that refuses an unfinished board. Every command answers with hints for the AI; every turn, its thinking time and every rework loop go into run.jsonl, so Claude, Codex and any other engine are compared on the same flow. KiCad, Fusion 360 and Altium Designer today (the same steps and gates through each tool's bridge); Adom's own web apps next.", "summary": "Adom's AI Flow: a tool to help the AI follow all of the steps it takes to build a board. The AI thinks its way from placement through routing, pours, current and thermal analysis to a delivered video; the binary does the fast, deterministic parts of every step, hands back hints, and keeps a ledger of every turn, every return to an earlier step, and the clock from the prompt to done.",
page.json+1−1@@ -1,7 +1,7 @@ { "slug": "adom-aiflow", "type": "app",- "version": "0.2.126",+ "version": "0.2.127", "title": "AI Flow", "description": "Adom's AI Flow: a tool to help the AI follow all of the steps it takes to build a board. One Rust binary with a crate per step (placement helpers, a grid router with Kelvin taps, pours with keepouts, KiCad's DRC gate, live landing through the KiCad Bridge, copper measurement, current and thermal analysis) and a finish line that refuses an unfinished board. Every command answers with hints for the AI; every turn, its thinking time and every rework loop go into run.jsonl, so Claude, Codex and any other engine are compared on the same flow. KiCad, Fusion 360 and Altium Designer today (the same steps and gates through each tool's bridge); Adom's own web apps next.", "summary": "Adom's AI Flow: a tool to help the AI follow all of the steps it takes to build a board. The AI thinks its way from placement through routing, pours, current and thermal analysis to a delivered video; the binary does the fast, deterministic parts of every step, hands back hints, and keeps a ledger of every turn, every return to an earlier step, and the clock from the prompt to done.",
skills/aiflow-simulate/SKILL.md+1−1@@ -74,7 +74,7 @@ Then write the design conclusion in engineering terms: what matched, what the ve - `adom-aiflow evidence add --kind simulation --file sim/<results>.json`. Write the verdict into the JSON so the gate can read it: a top-level `"pass": true|false`, or `"checks": [{"name": "phase_margin_deg", "value": 76, "limit": {"min": 45}, "pass": true}]` (a numeric `limit` is a maximum). A failing result is refused: change the design and simulate again. - `adom-aiflow evidence add --kind vendor-model --file sim/<vendor>-validation.md` for the vendor PSpice/LTspice run, which belongs to the adom/adom-spice-skillpack.-- On the Altium lane, name each unencrypted model you downloaded in the spec (`spiceModels`: {MPN: {file, model, pinMap}}) so `altium library` puts it on the part's symbol and the Altium project simulates (docs/altium-lane.md).+- On the Altium lane, name each unencrypted model you downloaded in the spec (`spiceModels`: {MPN: {file, model, pinMap}}) so `altium library` puts it on the part's symbol and the Altium project simulates (docs/altium-lane.md). Then check the drawn schematic itself in Altium: `adom-aiflow altium simulate --sources <json> --analysis op --probe VOUT --expect VOUT=<calcs value>+-<tol>` runs on a copy (generic R/C/L at their values, your sources and loads added) and writes a result you record as simulation evidence. `finish` wants simulation evidence when the spec says `"requireEvidence": ["calcs", "simulation"]`. Next: aiflow-schematic-to-board.
tests/altium-spice.py+25−2@@ -3,9 +3,10 @@ import re, unittest from pathlib import Path -SRC = Path(__file__).resolve().parent.parent / 'tools' / 'altium-spice.py'+TOOLS = Path(__file__).resolve().parent.parent / 'tools' ns = {'re': re, 'Path': Path}-exec(SRC.read_text(), ns)+exec((TOOLS / 'altium-spice.py').read_text(), ns)+exec((TOOLS / 'altium-sim.py').read_text(), ns) class AltiumSpice(unittest.TestCase):@@ -24,5 +25,27 @@ class AltiumSpice(unittest.TestCase): self.assertEqual(ns['spice_summary']({'R0603': {}}), []) +class AltiumSimulate(unittest.TestCase):+ def test_an_expectation_is_parsed(self):+ self.assertEqual(ns['parse_expect']('VOUT=5.0+-0.05'), ('VOUT', 'value', 5.0, 0.05))+ self.assertEqual(ns['parse_expect']('VOUT.ripple=0.02±0.01'), ('VOUT', 'ripple', 0.02, 0.01))+ n, w, v, t = ns['parse_expect']('VOUT=6+-1%')+ self.assertAlmostEqual(t, 0.06)+ self.assertAlmostEqual(ns['parse_expect']('VOUT=5')[3], 0.1, msg='2 % by default')+ self.assertIsNone(ns['parse_expect']('VOUT is 5'))++ def test_signals_read_and_compare(self):+ tran = ns['signal_stats']({'signal': 'v(vout)', 'x': [0, 1, 2], 'y': [4.9, 5.1, 5.0]}, 'tran')+ self.assertAlmostEqual(tran['ripple'], 0.2)+ self.assertAlmostEqual(tran['mean'], 5.0)+ self.assertEqual(ns['net_of']('v(vout)'), 'VOUT')+ stats = {'VOUT': ns['signal_stats']({'y': [6.0]}, 'op')}+ good = ns['check_expect'](stats, [ns['parse_expect']('VOUT=6.0+-0.01')])+ self.assertTrue(good[0][1] and 'agrees' in good[0][0])+ bad = ns['check_expect'](stats, [ns['parse_expect']('VOUT=5.0+-0.01'), ns['parse_expect']('SW=1')])+ self.assertFalse(bad[0][1]); self.assertIn('DIFFERS', bad[0][0])+ self.assertIn('not probed', bad[1][0])++ if __name__ == '__main__': unittest.main()
tools/altium-project.py+4−1@@ -21,6 +21,8 @@ and checked against the board (layers, drill hits, every placed part), plus the JLCPCB BOM/CPL reset clear the live board's copper (tracks, vias, pours) for a refine pass; the parts stay view3d the board in Altium's 3D view and a slow orbit for the recording+ simulate the drawn schematic simulated by Altium on a copy (sources and loads added, R/C/L on generic models),+ the probed nets read back and compared with what AI Flow's own ngspice run expects Every step prints OK or ERROR with Hint lines and keeps its state in <run>/altium/. Called by `adom-aiflow altium <step> ...`; AIFLOW_RUN, AIFLOW_TARGET and AIFLOW_THREAD come from it.@@ -751,8 +753,9 @@ def main(): p = sub.add_parser('export'); p.add_argument('--design', help='the .PcbDoc (default: the project board)'); p.add_argument('--out-dir', help='default <run>/manufacturing') p = sub.add_parser('reset'); p.add_argument('--design') p = sub.add_parser('view3d'); p.add_argument('--design'); p.add_argument('--pause', type=float, default=0.7)+ p = sub.add_parser('simulate'); p.add_argument('--sch', help='the .SchDoc (default: the project schematic)'); p.add_argument('--sources', help='JSON: [{type, plus, minus, dc|ac|sin|pulse|pwl}]'); p.add_argument('--loads', help='JSON: [{type, value, plus, minus}]'); p.add_argument('--analysis', choices=['op', 'tran', 'ac'], default='op'); p.add_argument('--probe', action='append', help='a net to read (repeat)'); p.add_argument('--step', type=float); p.add_argument('--stop', type=float); p.add_argument('--start', type=float); p.add_argument('--fstart', type=float, default=10.0); p.add_argument('--fstop', type=float, default=1e6); p.add_argument('--points', type=int); p.add_argument('--expect', action='append', help='NET=value+-tol or NET.ripple=value+-tol (repeat)') a = ap.parse_args()- {'library': cmd_library, 'reference': cmd_reference, 'schematic': cmd_schematic, 'symbols': cmd_symbols, 'board': cmd_board, 'export': cmd_export, 'silkscreen': cmd_silkscreen, 'reset': cmd_reset, 'view3d': cmd_view3d}[a.cmd](a)+ {'library': cmd_library, 'reference': cmd_reference, 'schematic': cmd_schematic, 'symbols': cmd_symbols, 'board': cmd_board, 'export': cmd_export, 'silkscreen': cmd_silkscreen, 'reset': cmd_reset, 'view3d': cmd_view3d, 'simulate': cmd_simulate}[a.cmd](a) main()
tools/altium-sim.pyadded+119@@ -0,0 +1,119 @@+"""altium-sim: simulate the schematic AI Flow drew in Altium, on a copy (altium-bridge 0.2.117+).++ altium simulate --sources sources.json [--loads loads.json] --analysis op|tran|ac --probe VOUT [--probe ...]+ [--step 1e-6 --stop 2e-3 --start 1e-3] [--fstart 10 --fstop 1e6] [--points 200]+ [--expect VOUT=5.0+-0.05 ...]++`altium_sim_copy` copies the project's sheets beside it (AdomSim\\<project>\\, the design never touched), gives every R, C+and L Altium's generic model at its Value, and adds the sources and loads (sources.json: [{type: voltage|current, plus:+"VIN" or "R1.2", minus: "GND", dc: 12} or sin/pulse/pwl/ac; loads: [{type: resistor, value: "10", plus: "VOUT"}]). Then+`altium_simulate` runs the analysis on the copy and reads the probed nets back. --expect compares a probed value with+AI Flow's own ngspice result (op: the value; tran: the mean, and VOUT.ripple for max - min). Every other part needs its+SPICE model on the symbol (spec spiceModels, `altium library`): the step names the parts that kept the sheet from+simulating. The netlist Altium ran is kept beside the results for a diff against the ngspice deck.+"""+++def parse_expect(s):+ """'VOUT=5.0+-0.05', 'VOUT=5.0±0.05' or 'VOUT.ripple=0.02+-0.01' -> (net, what, value, tol). Default tol 2 %."""+ num = r'[-+]?(?:[0-9]+\.?[0-9]*|\.[0-9]+)(?:[eE][-+]?[0-9]+)?'+ m = re.fullmatch(r'\s*([^=\s]+?)(?:\.(ripple|min|max|mean))?\s*=\s*(' + num + r')\s*(?:(?:\+-|±|\+/-)\s*(' + num + r')(%?))?\s*', s)+ if not m: return None+ net, what, v, tol, pct = m.group(1), m.group(2) or 'value', float(m.group(3)), m.group(4), m.group(5)+ t = float(tol) * (abs(float(m.group(3))) / 100.0 if pct else 1.0) if tol else abs(v) * 0.02+ return net, what, v, t+++def signal_stats(sig, analysis):+ """What one probed signal says: op -> value; tran -> min, max, mean, ripple; ac -> peak and where."""+ ys = [y for y in (sig.get('y') or []) if isinstance(y, (int, float))]+ xs = sig.get('x') or []+ if not ys: return {}+ if analysis == 'op': return {'value': ys[0]}+ if analysis == 'tran':+ return {'min': min(ys), 'max': max(ys), 'mean': sum(ys) / len(ys), 'ripple': max(ys) - min(ys), 'value': ys[-1]}+ k = max(range(len(ys)), key=lambda i: abs(ys[i]))+ return {'peak': ys[k], 'at': xs[k] if k < len(xs) else None, 'value': ys[0]}+++def net_of(signal):+ """'v(vout)' or 'VOUT' -> 'VOUT'."""+ m = re.fullmatch(r'\s*[vV]\((.+)\)\s*', signal or '')+ return (m.group(1) if m else (signal or '')).upper()+++def check_expect(stats_by_net, expects):+ """Each --expect against the stats: (line, passed)."""+ out = []+ for net, what, v, tol in expects:+ st = stats_by_net.get(net.upper())+ if st is None: out.append(('%s: not probed (add --probe %s)' % (net, net), False)); continue+ key = 'mean' if what == 'value' and 'mean' in st else what+ got = st.get(key)+ if got is None: out.append(('%s.%s: not in this analysis' % (net, what), False)); continue+ ok_ = abs(got - v) <= tol+ out.append(('%s%s: Altium %.6g, expected %.6g +- %.3g: %s' % (net, '' if what == 'value' else '.' + what, got, v, tol, 'agrees' if ok_ else 'DIFFERS'), ok_))+ return out+++def cmd_simulate(a):+ st = load_state()+ sch = a.sch or st.get('schematic')+ if not sch: err('no schematic to simulate: draw it first (`adom-aiflow altium schematic --netlist <netlist.json> --name <Design>`), or give --sch')+ if not a.probe: err('name what to read: --probe <net> (one or more)', ['For a buck: --probe VOUT (and --probe SW for the switch node).'])+ expects = []+ for e in a.expect or []:+ p = parse_expect(e)+ if not p: err('--expect %s: write NET=value+-tol (or NET.ripple=...)' % e)+ expects.append(p)+ sources = json.loads(Path(a.sources).read_text()) if a.sources else []+ loads = json.loads(Path(a.loads).read_text()) if a.loads else []+ if not sources: err('nothing drives the sheet: give --sources <json> (a voltage source on the input)', ['[{"type": "voltage", "plus": "VIN", "minus": "GND", "dc": 12}]'])+ say('simulation copy of %s with %d source(s) and %d load(s)' % (sch, len(sources), len(loads)))+ c = ab('altium_sim_copy', {'schematic': sch, 'sources': sources, 'loads': loads, 'genericPassives': True}, timeout=900)+ if not c.get('success'):+ code = str(c.get('errorCode') or '')+ hint = 'Update altium-bridge to 0.2.117 or later (`adom-bridge bridge_update \'{"name":"altium"}\'`).' if 'unknown' in code or code == 'not_found' else 'Read the error: a source or load pin that is not on a net of the sheet is refused by name.'+ err('altium_sim_copy failed: %s' % (c.get('error') or code)[:300], [hint])+ copy = (c.get('copy') or {}).get('schematic')+ bad = [x for x in c.get('checks') or [] if x.get('ok') is False or x.get('found') is False]+ if bad: err('a source or load is not on the net it names: %s' % json.dumps(bad)[:300])+ nov = c.get('passivesWithoutValue') or []+ an = {'op': {'type': 'op'}, 'tran': {'type': 'tran', 'step': a.step, 'stop': a.stop}, 'ac': {'type': 'ac', 'sweep': 'dec', 'points': a.points or 20, 'start': a.fstart, 'stop': a.fstop}}[a.analysis]+ if a.analysis == 'tran':+ if not (a.step and a.stop): err('a transient needs --step and --stop in seconds (plain numbers: 1e-6, not 1u)')+ if a.start: an['start'] = a.start+ args = {'schematic': copy, 'analysis': an, 'probes': [{'net': n} for n in a.probe]}+ if a.points and a.analysis == 'tran': args['points'] = a.points+ say('Altium %s on the copy, probing %s' % (a.analysis, ', '.join(a.probe)))+ s = ab('altium_simulate', args, timeout=1500)+ not_sim = s.get('notSimulated') or []+ if not s.get('success'):+ err('Altium did not simulate the sheet: %s' % (s.get('error') or s.get('errorCode') or '?')[:300],+ ['Parts with no SPICE model stop Altium\'s netlister%s: name their models in spec spiceModels and run `altium library --only <MPN>` (an encrypted vendor model cannot run in Altium; such a sheet is simulated in the vendor\'s tool).' % ((': ' + ', '.join(map(str, not_sim))) if not_sim else ''),+ 'The project\'s documents must be saved (unsaved_changes).'])+ stats = {}+ for sig in s.get('signals') or []:+ stats[net_of(sig.get('signal'))] = signal_stats(sig, a.analysis)+ lines = []+ for n in a.probe:+ stt = stats.get(n.upper())+ if not stt: lines.append('%s: no signal (missing from the run)' % n); continue+ lines.append('%s: %s' % (n, ', '.join('%s %.6g' % (k, v) for k, v in stt.items() if isinstance(v, (int, float)))))+ checks = check_expect(stats, expects)+ lines.extend(l for l, _ in checks)+ out = STATE / 'sim'; out.mkdir(parents=True, exist_ok=True)+ rec = {'analysis': an, 'sources': sources, 'loads': loads, 'copy': copy, 'genericPassives': c.get('genericPassives'), 'passivesWithoutValue': nov,+ 'notSimulated': not_sim, 'stats': stats, 'expect': [{'line': l, 'agrees': g} for l, g in checks], 'results': s.get('results'), 'netlist': s.get('netlist')}+ (out / ('altium-%s.json' % a.analysis)).write_text(json.dumps(rec, indent=1))+ agree = all(g for _, g in checks)+ prove('simulation-altium', {'analysis': a.analysis, 'probes': a.probe, 'agrees': agree if checks else None, 'record': str(out / ('altium-%s.json' % a.analysis))})+ hints = []+ if nov: hints.append('R/C/L with no value on the sheet (generic model needs one): %s' % ', '.join(map(str, nov)))+ if not_sim: hints.append('Parts left out of the run (no model): %s' % ', '.join(map(str, not_sim)))+ if s.get('netlist'): hints.append('Altium\'s netlist (for a diff against your ngspice deck): %s on the desktop' % s.get('netlist'))+ hints.append('Record it with the simulation step: `adom-aiflow evidence add --kind simulation --file %s`.' % (out / ('altium-%s.json' % a.analysis)))+ if checks and not agree:+ err('Altium simulated the drawn schematic, and it differs from what was expected:\n' + '\n'.join(lines),+ ['A difference here is a schematic drawn unlike the design that was simulated (a wrong value, a pin on the wrong net) or a model that differs: diff Altium\'s netlist against the ngspice deck.'] + hints)+ ok('Altium simulated the drawn schematic (%s on a copy, the design untouched):\n%s' % (a.analysis, '\n'.join(lines)), hints)