main
John Lauer Advance Board32 through current acceptance and retain unresolved thermal gate 1f15473
"""Plot the input-bound Board32 package study, with its unresolved assumptions."""
from pathlib import Path
import json,hashlib
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
from matplotlib.colors import LinearSegmentedColormap,Normalize
from matplotlib.cm import ScalarMappable
R=Path(__file__).resolve().parents[1];D=R/'checkpoints/board32-package-cooling/full-0p1';p=json.loads((D/'fields.json').read_text());q=p['packageCooling'][0]
plt.rcParams.update({'figure.facecolor':'#101923','axes.facecolor':'#101923','text.color':'#edf3f8','axes.labelcolor':'#edf3f8','xtick.color':'#b8cad9','ytick.color':'#b8cad9','font.size':14})
cmap=LinearSegmentedColormap.from_list('fields-magma',[[.001,0,.014],[.11,.06,.28],[.29,.06,.48],[.47,.11,.51],[.66,.18,.47],[.83,.28,.40],[.96,.44,.36],[.99,.65,.47],[.99,.99,.75]])
fig=plt.figure(figsize=(19.2,10.8),dpi=100);a=fig.add_axes([.04,.22,.29,.61]);b=fig.add_axes([.35,.22,.29,.61]);c=fig.add_axes([.76,.35,.20,.38])
for ax,prefix,title in [(a,'T','Still air · front copper'),(b,'Tm','Assumed forced air · front copper')]:
 ax.imshow(plt.imread(D/'tex'/f'{prefix}-F_Cu.png'));ax.set_title(title);ax.axis('off')
 for ref,xy,offset in [('Q1 pins',(294.6,560),(60,50)),('D1',(171.2,650),(70,-15))]:
  ax.annotate(ref,xy,xytext=offset,textcoords='offset points',color='white',fontsize=12,arrowprops={'arrowstyle':'->','color':'white','lw':1})
values=[40+q[k]['caseRiseC'] for k in ['still','moving']];c.bar([0,1],values,color=['#f5788c','#58d5c5']);c.axhline(55,color='#ffb77b',ls='--');c.set_ylim(40,85);c.set_xticks([0,1],['Still air','Assumed\nforced air']);c.set_ylabel('MOSFET case temperature (°C)');c.set_title('55 °C case ceiling',fontsize=16)
for i,v in enumerate(values):c.text(i,v+1,f'{v:.1f} °C',ha='center')
bar=fig.colorbar(ScalarMappable(norm=Normalize(0,p['scales']['tHi']),cmap=cmap),cax=fig.add_axes([.10,.15,.50,.022]),orientation='horizontal');bar.set_label('Calculated PCB temperature rise above 40 °C ambient')
fig.text(.05,.93,'Board32 · direct heatsink path still needs qualification',fontsize=27)
fig.text(.05,.035,'5.5 W MOSFET + diode, shunt and copper losses · 0.1 mm grid\nForced cooling assumes the catalog 400 LFM condition. Installed flow, interface contact and fault timing are unverified.\nFull-power still air fails. This parameter study does not pass the formal thermal gate.',fontsize=14)
fig.savefig(R/'aiflow/run/timeline/board32-package-thermal.png');plt.close(fig)
(R/'checkpoints/board32-package-cooling/plot-review.json').write_text(json.dumps({'fieldsSha256':hashlib.sha256((D/'fields.json').read_bytes()).hexdigest(),'caseTemperaturesC':values,'status':'unqualified-parameter-study','source':'tools/plot_board32_cooling.py'},indent=2)+'\n')