main
John Lauer
Review cumulative land candidates and correct complete STEP assembly clearance checks
ca3da55
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
#!/usr/bin/env python3
"""Nominal support-layout CAD; not a qualified/print-ready cooling assembly."""
import hashlib
import json
import math
from pathlib import Path
from step_geometry import load_step
import cadquery as cq
from cadquery.occ_impl.exporters.assembly import exportGLTF
ROOT = Path(__file__).resolve().parents[1]
OUT = ROOT/'mechanical/carrier-study'
OUT.mkdir(exist_ok=True)
audit = json.loads((ROOT/'mechanical/cooling-680-body-audit.json').read_text())
screen = json.loads((ROOT/'mechanical/cooling-680-screen.json').read_text())
assert audit['boardSha256'] == hashlib.sha256((ROOT/'kicad/adom-custom-electronic-load.kicad_pcb').read_bytes()).hexdigest()
cx, cy = screen['sinkCenterXY']
half = 1.810*25.4/2
pitch = 1.5*25.4/2
bottom, height = 5.09, 31.75
roof_z, roof_t = bottom+height+1, 2
assembly = cq.Assembly(name='Cooling_carrier_LAYOUT_ONLY')
step_assembly = cq.Assembly(name='Cooling_carrier_LAYOUT_ONLY_mm')
pieces=[]
def box(bounds):
x,y,z,X,Y,Z=bounds
return cq.Workplane('XY').box(X-x,Y-y,Z-z,centered=(False,False,False)).translate((x,y,z)).val()
def add(name, shape, color, clearance=True):
# Board XY -> MP1 anchored Z-up visual coordinates. The board GLB top is 5.98 mm.
rendered=shape.mirror('XZ').translate((-100,100,5.98))
step_assembly.add(rendered,name=name,color=cq.Color(*color))
assembly.add(rendered.scale(.001),name=name,color=cq.Color(*color))
if clearance: pieces.append((name,shape))
# Load path: side towers -> bridge/ring -> three hanger bolts -> sink.
# Edge shoes are an envelope for split insulated clamps, not a snap-fit design.
for name,x,y,side in [('left',95,48.068,'left'),('right_front',162.5,52,'right'),('right_rear',162.5,86.168,'right')]:
add('tower_'+name,box([x,y-2,1.5,x+3,y+2,roof_z+roof_t]),(.15,.48,.52))
if side=='left': shoe=[95,y-3,-3.1,99.2,y+3,1.5]; slot=[97.9,y-3.1,-1.7,99.3,y+3.1,.1]
else: shoe=[160.8,y-3,-3.1,165.5,y+3,1.5]; slot=[160.7,y-3.1,-1.7,162.6,y+3.1,.1]
add('split_clamp_envelope_'+name,box(shoe).cut(box(slot)),(.22,.6,.62))
# A 52 mm plate separates the rotated fan holes from the sink hangers.
ring=box([cx-26,cy-26,roof_z,cx+26,cy+26,roof_z+roof_t])
ring=ring.cut(cq.Solid.makeCylinder(19,roof_t+2,cq.Vector(cx,cy,roof_z-1)))
sink_holes=[]
for dx,dy in [(-pitch,-pitch),(-pitch,pitch),(pitch,pitch)]:
x,y=cx+dx,cy+dy;sink_holes.append([x,y])
ring=ring.cut(cq.Solid.makeCylinder(1.7,roof_t+2,cq.Vector(x,y,roof_z-1)))
# Countersunk clearance only; hardware/preload is still unselected.
ring=ring.cut(cq.Solid.makeCone(1.7,3.2,1.5,cq.Vector(x,y,roof_z+roof_t-1.5)))
fan_holes=[]
for dx in [-16,16]:
for dy in [-16,16]:
x,y=cx+(dx-dy)/math.sqrt(2),cy+(dx+dy)/math.sqrt(2)
fan_holes.append([x,y])
ring=ring.cut(cq.Solid.makeCylinder(2.25,roof_t+2,cq.Vector(x,y,roof_z-1)))
add('fan_M4_and_three_sink_hanger_plate',ring,(.15,.48,.52))
add('left_bridge',box([95,46.068,roof_z,cx-half+.1,50.068,roof_z+roof_t]),(.15,.48,.52))
add('right_spine',box([cx+half-.1,46.068,roof_z,165.5,88.168,roof_z+roof_t]),(.15,.48,.52))
sink=box([cx-half,cy-half,bottom,cx+half,cy+half,bottom+height])
add('SINK_CLEARANCE_ENVELOPE_NOT_FIN_CAD',sink,(.35,.37,.40,.16),False)
fan=load_step(OUT/'fan-nominal.step')
fan=fan.rotate((0,0,0),(0,0,1),45).translate((cx,cy,roof_z+roof_t))
add('ADOM_nominal_fan_body_NO_WIRES',fan,(.24,.26,.28),True)
# Actual solid intersections against conservative fitted-body boxes.
conflicts=[]
for name,shape in pieces:
for row in audit['rows']:
volume=shape.intersect(box(row['boundsMm'])).Volume()
if volume>1e-6: conflicts.append(dict(part=name,reference=row['ref'],overlapMm3=volume))
probe_conflicts=[]
for p in screen['probeChecks']:
approach=cq.Solid.makeCylinder(2,75,cq.Vector(p['x'],p['y'],0))
for name,shape in pieces:
if shape.intersect(approach).Volume()>1e-6:probe_conflicts.append(dict(reference=p['ref'],part=name))
nut_checks=[]
for dx,dy in [(-pitch,-pitch),(pitch,-pitch),(-pitch,pitch),(pitch,pitch)]:
x,y=cx+dx,cy+dy
nut=cq.Solid.makeCylinder(3.2,1.8,cq.Vector(x,y,bottom-1.8))
hits=[r['ref'] for r in audit['rows'] if nut.intersect(box(r['boundsMm'])).Volume()>1e-6]
nut_checks.append(dict(x=x,y=y,assumedNutRadiusMm=3.2,assumedNutHeightMm=1.8,bodyConflicts=hits,used=[x,y] in sink_holes))
valid=all(s.isValid() for _,s in pieces)
step_assembly.save(str(OUT/'carrier-layout.step'))
# CQ normally rotates Z-up into glTF Y-up. Cancel it for the Adom Z-up viewer.
assembly.loc=cq.Location((0,0,0),(1,0,0),90)
exportGLTF(assembly,str(OUT/'carrier-layout.glb'),binary=True,tolerance=.00005,angularTolerance=.2)
report=dict(status='nominal-layout-study-not-fabrication',boardSha256=audit['boardSha256'],
sinkHangers=sink_holes,omittedSinkHole=[cx+pitch,cy-pitch],fanHolePitchMm=32,fanClearanceDrillMm=4.5,
fanRotationDegrees=45,fanHoleCenters=fan_holes,minSinkCountersinkToFanHoleEdgeMm=min(math.dist(a,b)-3.2-2.25 for a in sink_holes for b in fan_holes),ringBottomAboveBoardMm=roof_z,fanBodyTopAboveBoardMm=roof_z+roof_t+20,
bodyConflicts=conflicts,probeConflicts=probe_conflicts,nutEnvelopeChecks=nut_checks,validCarrierSolids=valid,
sources=['https://wakefieldthermal.com/content/data_sheets/677.pdf',
'https://www.sunon.com/PROSEARCH_FILES/%28D04114960G-01%29-1.pdf'],
limitations=['Sink is a translucent clearance envelope, not manufacturer fin geometry.',
'Fan is the MIT Adom nominal model: illustrative rotor, no wires, exact G99 connector, guard or motion states in this study.',
'Split edge clamps need tolerances, retention fasteners, insulation material and load/creep validation.',
'Hanger screw length, countersink seating, nuts and tool access remain unselected; cylindrical nut envelope is only a screen. Plate opening/web strength not qualified.',
'No case TIM/clamp or case sensor mounting is modeled.',
'Fan direction, plenum pressure losses and airflow remain unqualified.',
'No PCB drilling or electrical design changes. No release or thermal acceptance.'])
(OUT/'review.json').write_text(json.dumps(report,indent=2)+'\n')
print(json.dumps(report,indent=2))