main
John Lauer Record temperature shutdown replay and screen an offset passive cooling alternative c7a3cd8
"""Conservative offset envelope study; no installed thermal or mounting qualification."""
from pathlib import Path
import json,hashlib,math,sys
sys.path.insert(0,str(Path(__file__).resolve().parent));import sexp
R=Path(__file__).resolve().parents[1];board=R/'aiflow/run/board-32.kicad_pcb'
a=json.loads((R/'checkpoints/board32-temperature-bound/passive-body-audit.json').read_text());assert a['boardSha256']==hashlib.sha256(board.read_bytes()).hexdigest();assert a['coverage']=={'models':91,'unsupported':0}
# Dimensions of the separately screened 3-inch 125319 extrusion; full solid envelope.
w,d,h=76.0984,76.2,50.8;z=7.25
# Conservative entire Q1 body/lead XY envelope, stricter than just tab contact.
q=next(r['boundsMm'] for r in a['rows'] if r['ref']=='Q1');tree=sexp.parse(board.read_text());probes=[]
for f in sexp.find(tree,'footprint'):
 p={v[1]:v[2] for v in sexp.find(f,'property')}
 if p['Reference'].startswith('TP'):
  x,y=map(float,sexp.first(f,'at')[1:3]);probes.append((p['Reference'],x,y))
# Saved board outline nominal extrema verified from Edge.Cuts primitives in the audit.
edge=[]
for k in ('gr_line','gr_arc'):
 for g in sexp.find(tree,k):
  if sexp.first(g,'layer')[1]!='Edge.Cuts':continue
  for e in ('start','mid','end'):
   p=sexp.first(g,e)
   if p:edge.append(tuple(map(float,p[1:3])))
bounds=[min(x for x,y in edge),min(y for x,y in edge),max(x for x,y in edge),max(y for x,y in edge)]
rows=[]
for ix in range(180,245):
 for iy in range(20,81):
  x,y=ix*.5,iy*.5;b=[x,y,z,x+w,y+d,z+h]
  if not(x+1<=q[0] and y+1<=q[1] and x+w-1>=q[3] and y+d-1>=q[4]):continue
  collisions=[r['ref'] for r in a['rows'] if r['ref']!='Q1' and all(max(r['boundsMm'][i]-.5,b[i])<min(r['boundsMm'][i+3]+.5,b[i+3]) for i in range(3))]
  pc=[ref for ref,px,py in probes if math.hypot(max(x-px,0,px-x-w),max(y-py,0,py-y-d))<2]
  if collisions or pc:continue
  over=[max(bounds[0]-x,0),max(bounds[1]-y,0),max(x+w-bounds[2],0),max(y+d-bounds[3],0)]
  rows.append({'envelopeMm':b,'edgeOverhangMm':over,'maximumOverhangMm':max(over),'bodyConflictsWith0p5mmMargin':collisions,'probeConflictsAt2mmRadius':pc})
rows.sort(key=lambda r:(r['maximumOverhangMm'],sum(r['edgeOverhangMm'])))
r={'status':'offset-envelope-screen-only-not-adopted','boardSha256':a['boardSha256'],'stockExtrusion':'125319','cutLengthMm':d,'outlineBoundsMm':bounds,'sourceAudit':'checkpoints/board32-temperature-bound/passive-body-audit.json','candidateCount':len(rows),'best':rows[:10],'limits':['Entire sink represented as a solid rectangular envelope; no fins or machined device holes designed.','Only fitted PCB component bounds and vertical bare-test-pad approach checked; excludes mating plugs, wire bends, mounting tools, fan, carrier and workcell boundaries.','Contact area, offset-source spreading, insulation, clamp and structural support unqualified.','Natural-convection catalog value is not a guaranteed installed low-rise resistance; no thermal gate pass.','Original PCB and all selected assembly assets remain unchanged.']}
o=R/'checkpoints/board32-temperature-bound/passive-offset-screen.json';o.write_text(json.dumps(r,indent=2)+'\n');print(json.dumps({'candidateCount':len(rows),'best':rows[:1],'outlineBoundsMm':bounds},indent=2))