main
John Lauer Add three compact 3D cooling concepts and conditional thermal trade study 461aa3b
from pathlib import Path
import json,trimesh,numpy as np
R=Path(__file__).resolve().parents[1];O=R/'docs/cooling-3d';G=json.loads((R/'analysis/cooling-3d/geometry.json').read_text());audit=[]
for name,shapes in G.items():
 scene=trimesh.Scene();groups={}
 for i,b in enumerate(shapes):
  xyz=np.array(b['origin'])
  if b['type']=='box':
   m=trimesh.creation.box(extents=np.array(b['size'])/1000);pos=(xyz+np.array(b['size'])/2)/1000
  else:m=trimesh.creation.cylinder(radius=b['r']/1000,height=b['h']/1000,sections=16);pos=(xyz+[0,0,b['h']/2])/1000
  m.apply_translation(pos);color=tuple(bytes.fromhex(b['color'][1:]))+(255,);m.visual.vertex_colors=color
  n=b['name'];group='Cooling' if any(t in n for t in ['Fin_','Sink_','Fan_']) else 'Scaffold' if 'Scaffold' in n else 'MachinePins' if n.startswith('MP') else 'Q1_and_interface' if any(t in n for t in ['Q1','AlN','Spreader']) else 'Board_and_reservations'
  groups.setdefault(group,[]).append(m)
 for group,meshes in groups.items():scene.add_geometry(trimesh.util.concatenate(meshes),node_name=group,geom_name=group)
 scene.metadata={'status':'CONCEPT ONLY; no routed PCB; approximate vendor geometry','coordinates':'Z-up metres','boardTargetMm':[72,72],'pinCentersMm':[[4,4],[68,4],[4,68],[68,68]],'scaffoldPitchMm':32}
 path=O/(name+'.glb');path.write_bytes(scene.export(file_type='glb'));check=trimesh.load(path,force='scene');assert len(check.geometry)==5
 audit.append(dict(id=name,bytes=path.stat().st_size,boundsMm=(check.bounds*1000).tolist(),triangles=sum(len(m.faces) for m in check.geometry.values()),groups=list(groups)))
(O/'model-audit.json').write_text(json.dumps(audit,indent=2));print(json.dumps(audit,indent=2))