main
John Lauer
Land and record reviewed diode vias; reject colliding heatsink mounting pattern
f197072
"""Screen commercial 40 mm sink placement against nominal contact, bodies and probes."""
import json,math
from pathlib import Path
P=Path(__file__).resolve().parents[1];a=json.loads((P/'mechanical/cooling-body-audit.json').read_text());old=json.loads((P/'mechanical/cooling-mount-screen.json').read_text());bodies=[r for r in a['rows']if r.get('boundsMm') and r['boundsMm'][5]>=0];probes=old['probeChecks'];solutions=[]
def distance(pt,b):return math.hypot(max(b[0]-pt[0],0,pt[0]-b[2]),max(b[1]-pt[1],0,pt[1]-b[3]))
for i in range(47):
x=98+i*.5
for k in range(51):
y=37+k*.5;box=[x,y,x+40,y+40]
if not(x<=121.345 and x+40>=133.575 and y<=61.525 and y+40>=77.3):continue
if y+40>102:continue
conflicts=[r['ref']for r in probes if distance((r['x'],r['y']),box)<2]
if conflicts:continue
holes=[(x+3.5,y+3.5),(x+36.5,y+3.5),(x+3.5,y+36.5),(x+36.5,y+36.5)]
collisions=[];minimum=1e9
for pt in holes:
for r in bodies:
b=r['boundsMm'];d=distance(pt,[b[0],b[1],b[3],b[4]])-3
minimum=min(minimum,d)
if d<.25:collisions.append({'hole':pt,'ref':r['ref'],'clearanceMm':round(d,3)})
solutions.append({'sinkXY':box,'holeCenters':holes,'minimumBodyClearanceMm':round(minimum,3),'bodyConflicts':collisions})
solutions.sort(key=lambda r:(len(r['bodyConflicts']),-r['minimumBodyClearanceMm']))
r={'boardSha256':a['boardSha256'],'mpn':'ATS-CPX040040020-115-C1-R0','method':'0.5 mm XY grid, 1 mm nominal case-face margin, 2 mm probe radius, 3 mm hardware radius plus 0.25 mm body clearance','survivingProbeClearCandidates':len(solutions),'bestCandidates':solutions[:10],'limitations':['No PCB holes added','Copper and drill clearance not yet checked','Generic Q1 contact face, not exact manufacturer CAD','Actual hardware and TIM unselected','Mating plugs, airflow and physical qualification pending']};(P/'mechanical/cooling-40mm-search.json').write_text(json.dumps(r,indent=2)+'\n');print(json.dumps({**r,'bestCandidates':solutions[:3]},indent=2))