main
John Lauer
Show reduced Q1 FR4 and heatsink conductive heat-flow animation with explicit limits
253cc27
"""Explicit reduced whole-assembly thermal model. Not native copper extraction."""
from pathlib import Path
import json,subprocess
R=Path(__file__).resolve().parents[1];src=R/'revisions/compact-r11/current-repair-r7/thermal-contact-sensitivity';out=R/'revisions/compact-r11/current-repair-r7/whole-thermal';out.mkdir(exist_ok=True)
solver='/home/adom/project/fields-3d-work-20261013/target/release/adom-fields'
def body(name,box,k,h=0,w=0):return dict(name=name,boxesMm=[box],conductivityWMk=k,convectionWM2k=[h]*6,watts=w,provenance='Explicit reduced assembly assumption, not exact native copper/package geometry')
for mode in ['off','on']:
s=json.loads((src/f'fan-{mode}-p1.json').read_text());s['pitchMm']=2;s['name']='Whole assembly reduced heat-flow study fan '+mode
bodies=s['bodies'];bodies.append(body('FR4_board',[0,0,0,72,72,1.6],.3,10 if mode=='off' else 25))
pairs=[('FR4_board','pad_'+str(i))for i in range(3)]
for i,x in enumerate([28,31,34]):
pad=body('pad_'+str(i),[x-.75,49.25,1.6,x+.75,50.75,1.635],400)
lead=body('Q1_lead_'+str(i),[x-.25,49.75,1.635,x+.25,50.25,7.2],200)
lead['boxesMm'].append([x-.25,38.66,6.9,x+.25,50.25,7.2]);bodies.extend([pad,lead]);pairs +=[(pad['name'],lead['name']),(lead['name'],'Q1_case_patch')]
for name,x,y,w in []:
bodies.append(body(name,[x-2,y-2,1.6,x+2,y+2,2.6],10,0,w));pairs.append(('FR4_board',name))
s['contacts'] += [dict(bodies=list(p),resistanceM2kW=0,provenance='Ideal reduced-model contact, unqualified')for p in pairs]
s['assumptions'] += ['72x72x1.6mm FR4 explicitly coupled to three assumed bent leads and local pads; exact copper pours, vias and package internals omitted.','Scalar FR4 k=.3 and lead k=200 W/mK are assumed; not anisotropic board qualification.','Q1-only heat-path study: D1, shunt and electrical Joule heating omitted. Not a total-board operating-temperature prediction.','The three lead paths are schematic thermal geometry, not a replacement mechanical CAD or routing model.','Fan mode changes prescribed convection only; no airflow CFD or time-dependent cooling.']
(out/f'fan-{mode}.json').write_text(json.dumps(s,indent=2)+'\n');subprocess.run([solver,'thermal3d','--spec',str(out/f'fan-{mode}.json'),'--out',str(out/f'fan-{mode}')],check=True)
results=json.loads((out/f'fan-{mode}/thermal3d.json').read_text())
# Retain strongest signed conductive flux samples across spatial bins; animation speed is illustrative.
cells=results['cells'];bins={}
for f in results['conductiveFaces']:
a=cells[f['from']];b=cells[f['to']];ca=[(a['boundsMm'][i]+a['boundsMm'][i+3])/2 for i in range(3)];cb=[(b['boundsMm'][i]+b['boundsMm'][i+3])/2 for i in range(3)];key=tuple(int(v/5) for v in ca)+(a['body'],f['axis'])
if key not in bins or abs(f['fluxWm2'])>abs(bins[key]['fluxWm2']):bins[key]=dict(a=ca,b=cb,fluxWm2=f['fluxWm2'],body=results['bodies'][a['body']]['name'])
vectors=sorted(bins.values(),key=lambda f:abs(f['fluxWm2']),reverse=True)[:500]
(out/f'flow-{mode}.json').write_text(json.dumps(dict(vectors=vectors,bodies=results['bodies'],inputSha256=results['inputSha256'],relativeEnergyError=results['relativeEnergyError'],note='Signed conductive heat flux W/m2; particle speed illustrative, steady state, no airflow or transient')))
subprocess.run(['python3','/home/adom/project/fields-3d-work-20261013/tools/thermal3d_glb.py',str(out/f'fan-{mode}/thermal3d.json'),str(out/f'fan-{mode}.glb'),'--color-min','40','--color-max','90'],check=True)
print(out)