Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions lib/utils/getTunedTotalCapacity1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,27 @@ import { CapacityMeshNode } from "lib/types/capacity-mesh-types"
* @returns The calculated capacity
*/
export const getTunedTotalCapacity1 = (
nodeOrWidth: CapacityMeshNode | { width: number; availableZ?: number[] },
nodeOrWidth:
| CapacityMeshNode
| { width: number; height?: number; availableZ?: number[] },
maxCapacityFactor = 1,
opts: { viaDiameter?: number; obstacleMargin?: number } = {},
) => {
const VIA_DIAMETER = opts.viaDiameter ?? 0.3
const TRACE_WIDTH = 0.15
const width = "width" in nodeOrWidth ? nodeOrWidth.width : nodeOrWidth
const obstacleMargin = opts.obstacleMargin ?? 0.2
const height =
"height" in nodeOrWidth && typeof nodeOrWidth.height === "number"
? nodeOrWidth.height
: width

const width = "width" in nodeOrWidth ? nodeOrWidth.width : nodeOrWidth
const viaLengthAcross = width / (VIA_DIAMETER / 2 + obstacleMargin)
// Use the geometric mean so thin rectangular nodes are assigned less capacity
// than similarly wide square nodes while preserving previous behavior when only
// width is provided.
const effectiveNodeSpan = Math.sqrt(width * height)
const viaLengthAcross =
effectiveNodeSpan / (VIA_DIAMETER / 2 + obstacleMargin)

const tunedTotalCapacity = (viaLengthAcross / 2) ** 1.1 * maxCapacityFactor

Expand Down
2 changes: 1 addition & 1 deletion tests/__snapshots__/e2e3-jumpers.snap.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions tests/__snapshots__/e2e3-multisection.snap.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions tests/__snapshots__/e2e3.snap.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion tests/bugs/__snapshots__/bugreport03-fe4a17.snap.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion tests/bugs/__snapshots__/bugreport04-aa1d41.snap.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion tests/bugs/__snapshots__/bugreport05-f03221.snap.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion tests/bugs/__snapshots__/bugreport16-d95f38.snap.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion tests/bugs/__snapshots__/bugreport18-1b2d06.snap.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion tests/bugs/__snapshots__/bugreport19.snap.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion tests/bugs/__snapshots__/bugreport2-e2e.snap.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion tests/bugs/__snapshots__/bugreport44-0ec411.snap.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion tests/bugs/__snapshots__/missing-portpoints-001.snap.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion tests/repro/__snapshots__/pipeline1-bug1.snap.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading