Skip to content

feat: specialized linear layout for decoupling capacitor partitions#40

Open
huangyebiaoke wants to merge 1 commit intotscircuit:mainfrom
huangyebiaoke:feat/decoupling-caps-linear-layout
Open

feat: specialized linear layout for decoupling capacitor partitions#40
huangyebiaoke wants to merge 1 commit intotscircuit:mainfrom
huangyebiaoke:feat/decoupling-caps-linear-layout

Conversation

@huangyebiaoke
Copy link
Copy Markdown

Summary

/claim #15

Replaces the generic PackSolver2 with a dedicated horizontal row layout for partitions of type decoupling_caps, matching the "acceptable solution" image posted by @seveibar.

Before / After

Before (PackSolver2): caps cluster in a chaotic pile

After (this PR): caps are arranged in a clean horizontal row, centered at origin, with configurable gap:

[C7] [C8] [C9] [C10] [C11]
       ← centered at x=0 →

Implementation

Only one file changed in lib/SingleInnerPartitionPackingSolver.ts:

override _step() {
  // Specialized path for decoupling cap partitions
  if (this.partitionInputProblem.partitionType === "decoupling_caps" && ...) {
    this.layout = this._layoutDecouplingCapsLinear()
    this.solved = true
    return
  }
  // ... existing PackSolver2 path unchanged
}

_layoutDecouplingCapsLinear():

  • Sorts caps deterministically by chipId (lexicographic) → stable CI results
  • Centers the entire row at x=0, y=0
  • Respects decouplingCapsGap property (fallback: chipGap → 0.2)
  • Sets ccwRotationDegrees=0 for all caps (vertical, y+ pin on top per schematic convention)

Tests

All 6 new tests pass:

  • ✅ All caps placed at y=0 (horizontal row)
  • ✅ Deterministic sort by chipId
  • ✅ Row centered at x=0
  • ✅ Gap between adjacent caps = decouplingCapsGap
  • ✅ Single cap placed at origin
  • ✅ RP2040 full pipeline still completes successfully

Pre-existing IdentifyDecouplingCapsSolver06 failure is unrelated (circuit-to-svg export mismatch on main).

…scircuit#15)

Replaces the generic PackSolver2 with a dedicated horizontal row layout
for partitions of type 'decoupling_caps'.

## Problem

Decoupling capacitors placed by PackSolver2 produce a chaotic cluster
(see before screenshot in tscircuit#15). The maintainer's 'acceptable solution'
shows caps arranged in a clean horizontal row.

## Solution

In SingleInnerPartitionPackingSolver._step(), when the partition type
is 'decoupling_caps', skip PackSolver2 and call _layoutDecouplingCapsLinear()
instead.

_layoutDecouplingCapsLinear():
- Sorts caps deterministically by chipId (lexicographic) → stable CI results
- Centers the row at the origin (x=0, y=0)
- Uses decouplingCapsGap (fallback: chipGap → 0.2) between caps
- Sets ccwRotationDegrees=0 for all caps (vertical orientation, y+ pin on top)

## Tests

New test file: tests/DecouplingCapsLinearLayout.test.ts
- All caps placed at y=0 in a horizontal row
- Deterministic sorting by chipId
- Row is centered at x=0
- Gap between adjacent caps matches decouplingCapsGap
- Single cap placed at origin
- RP2040 pipeline completes successfully

All new tests pass. Pre-existing IdentifyDecouplingCapsSolver06 failure
is unrelated (circuit-to-svg export mismatch, present on main).

Fixes tscircuit#15
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 6, 2026

Someone is attempting to deploy a commit to the tscircuit Team on Vercel.

A member of the Team first needs to authorize it.

@huangyebiaoke
Copy link
Copy Markdown
Author

The CI failure in IdentifyDecouplingCapsSolver06.test.ts is a pre-existing issue unrelated to this PR:

SyntaxError: Export named 'convertCircuitJsonToSchematicSimulationSvg' not found in module 'circuit-to-svg/dist/index.js'

This error exists on main branch as well (run #22041362111). All 6 new tests in this PR pass ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant