Skip to content

feat(converter): keep the LTspice drawing in the emitted .plecs (#94) - #96

Open
tinix84 wants to merge 1 commit into
feat/band4-answer-holds-upfrom
feat/issue-094-ltspice-drawing-fidelity
Open

feat(converter): keep the LTspice drawing in the emitted .plecs (#94)#96
tinix84 wants to merge 1 commit into
feat/band4-answer-holds-upfrom
feat/issue-094-ltspice-drawing-fidelity

Conversation

@tinix84

@tinix84 tinix84 commented Aug 29, 2026

Copy link
Copy Markdown
Owner

Closes #94. Follow-up recorded as #95 (auto-layout for sources without geometry).

Why

The .plecs emitted from an .asc simulated correctly but the schematic was misleading: bodies displaced from their wires, wires through bodies, every multi-pin net a star. Three causes, all fixed here:

  1. Position was the LTspice symbol origin; PLECS Position is the body centre.
  2. Direction was 180° off. Mining PLECS 4.7 demos/*.plecs + components.plecs (hundreds of connections): Direction names the side terminal 1 faces, Flipped on swaps the ends. R0 (pin 1 on top) is up, not down; M* becomes the opposite direction, never Flipped on.
  3. WIRE geometry was discarded; the emitter wrote point-less Connections branching off pins[0].

What changed

  • Net gains optional segments / pin_points (Circuit Model coordinates = PLECS convention). Empty for every other parser; those paths emit byte-for-byte what they did (regression-locked on simple_buck_prb.plecs).
  • LTspice parser: 16 → 10 grid scale, centre between pins, direction from pin 1, flipped=False.
  • PLECS emitter: segment graph → Connection/Branch tree; dangling stubs pruned; only corners + attach points as Points; Branch at junctions and pass-through pins; unreachable pins fall back to the old point-less branch.

Evidence

  • Default gate: ruff clean; full suite 269 passed with PLECS up.
  • Live: -m converter_acceptance -k rc_step on LTspice 26.0.1 vs PLECS 4.7.7 — PASS, max |Δ|/step = 1.06e-7. Bundle tests/evidence/rc_step/step/2026-08-29T210930Z-ltspice-import/ (compare the Points/Position lines with the 12:29Z bundle for before/after).

Not touched

emitters/ltspice.py::_orientation is wrong under the same semantics (up → R270) — that is the .asc emitter defect on #20.

🤖 Generated with Claude Code

…direction, wire Points

The .plecs emitted from an .asc was electrically right but misleading to look
at: PLECS Position is the body centre while LTspice SYMBOL x y is the symbol
origin; the Direction table was 180 degrees off (PLECS names the side terminal
1 faces, verified over hundreds of connections in the 4.7 demos, and Flipped
swaps the ends); and the WIRE segments were dropped, so every net became a
star from the alphabetically first pin.

The Circuit Model Net now carries its wire segments and pin attach points
(optional, empty for formats without layout). The LTspice parser scales
16 -> 10 onto the PLECS grid, centres each body between its pins, derives the
direction from pin 1, and never emits Flipped. The PLECS emitter turns the
segment graph into the Connection/Branch tree: stubs pruned, only corners and
attach points as Points, a Branch at every junction or pass-through pin;
nets without geometry emit byte-for-byte what they did before.

Live: rc_step re-run on LTspice 26.0.1 vs PLECS 4.7.7, PASS at 1.06e-7,
Evidence Bundle 2026-08-29T210930Z.

Closes #94
Refs: #91, #95

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant