Skip to content

Fix: Specialized Linear Layout for Decoupling Capacitors (#15)#32

Open
buildingvibes wants to merge 2 commits intotscircuit:mainfrom
buildingvibes:fix/decoupling-cap-linear-layout
Open

Fix: Specialized Linear Layout for Decoupling Capacitors (#15)#32
buildingvibes wants to merge 2 commits intotscircuit:mainfrom
buildingvibes:fix/decoupling-cap-linear-layout

Conversation

@buildingvibes
Copy link

@buildingvibes buildingvibes commented Feb 10, 2026

Summary

Implements specialized linear layout for decoupling capacitor partitions, resolving the messy irregular patterns that were causing component overlaps.

Problem

Previously, PackSolver2 scattered decoupling capacitors in irregular patterns, causing overlaps and producing unprofessional-looking schematics. The RP2040 circuit test showed 4 chip overlaps.

Solution

This PR adds a specialized linear layout system for decoupling capacitors:

  1. Enhanced net metadata inference - Automatically detects ground (GND) and voltage source nets (V3_3, V1_1, VCC, VDD, VSYS) based on naming conventions
  2. Rotation constraints - Restricts 2-pin components to 0/180 degree rotations to enable proper identification
  3. Improved capacitor detection - Enhanced IdentifyDecouplingCapsSolver to follow strong pin connections when determining net connectivity
  4. Linear layout algorithm - New createLinearDecouplingCapLayout() method in SingleInnerPartitionPackingSolver that arranges capacitors in clean horizontal rows

Results

Before:

  • 4 chip overlaps in RP2040 circuit
  • Irregular, scattered capacitor placement
  • Messy schematic layout

After:

  • 0 chip overlaps
  • Decoupling capacitors arranged in organized linear rows
  • Two separate groups for different voltage rails (V3_3 with 6 caps, V1_1 with 2 caps)
  • Uniform 0.2mm spacing between capacitors
  • Professional, clean schematic layout

Test Plan

  • All existing tests pass (17 pass, 1 skip)
  • RP2040 circuit test confirms 0 overlaps
  • Decoupling capacitor groups correctly identified
  • Linear layout applied to decoupling cap partitions
  • Type checking passes (tsc --noEmit)
  • Code formatting passes (bun run format:check)

Technical Details

The implementation detects decoupling capacitors based on:

  • Exactly 2 pins with restricted rotation (0/180)
  • Pins on opposite Y sides (y+ and y-)
  • At least one strong connection to a chip (main chip)
  • Connected to both ground and positive voltage source nets

When a partition is marked as partitionType: "decoupling_caps", the solver bypasses PackSolver2 and uses the linear layout algorithm instead, arranging components in a horizontal row centered at the origin.

Fixes #15
/claim #15

Resolves tscircuit#15 by adding specialized linear layout for decoupling capacitors
to create clean, professional-looking schematics.

**Changes:**

1. **Enhanced net metadata inference** - Added automatic detection of ground
   and voltage source nets based on naming conventions (GND, V3_3, VCC, etc.)
   in `getInputProblemFromCircuitJsonSchematic.ts`

2. **Added rotation constraints** - 2-pin components now have rotation
   restricted to 0/180 degrees to enable decoupling capacitor identification

3. **Improved decoupling cap detection** - Enhanced `IdentifyDecouplingCapsSolver`
   to follow strong pin connections when determining net connectivity, enabling
   detection of caps connected through chip pins

4. **Linear layout for decoupling caps** - Added `createLinearDecouplingCapLayout()`
   in `SingleInnerPartitionPackingSolver` that arranges decoupling capacitors in
   clean horizontal rows with uniform spacing

**Results:**
- RP2040 circuit test now passes with 0 overlaps (previously 4)
- Decoupling capacitors arranged in organized linear layouts
- Two separate groups for different voltage rails (V3_3 and V1_1)
- Consistent 0.2mm spacing between capacitors

Fixes tscircuit#15
/attempt tscircuit#15
@vercel
Copy link

vercel bot commented Feb 10, 2026

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

A member of the Team first needs to authorize it.

The test failure was caused by @tscircuit/schematic-viewer trying to
import a non-existent export (convertCircuitJsonToSchematicSimulationSvg)
from circuit-to-svg during module evaluation. This caused all tests to
fail with a SyntaxError, even though the SchematicViewer component was
not actually being used by the failing tests.

Changes:
- Lazy load SchematicViewer using React.lazy() to defer loading until needed
- Wrap SchematicViewer usage in Suspense boundary with loading fallback
- Update @tscircuit/schematic-viewer from 2.0.26 to 2.0.56

This prevents the problematic import from being evaluated during test
runs where SchematicViewer is not used, fixing the test suite while
maintaining full functionality for the circuit viewer tab.
@buildingvibes buildingvibes force-pushed the fix/decoupling-cap-linear-layout branch from efc9c7f to f4196e4 Compare February 10, 2026 05:22
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.

Specialized Layout for Decoupling Capacitors

1 participant