main
John Lauer
Preserve board29, component assets and scaffold-fit correction candidate with reviewed footage
c54169e
"""Prepare isolated derivatives of the reviewed studies; leave historical outputs intact."""
from pathlib import Path
import json,shutil,hashlib,sys
import sexp
R=Path(__file__).resolve().parents[1];O=R/'mechanical/formed-stack-study';T=R/'tools/formed_stack';T.mkdir(exist_ok=True)
board=R/'checkpoints/formed-stack-review/formed-stack-candidate.kicad_pcb'
# Probe coordinates are unchanged from the archived physical layout; rebind explicitly.
screen=json.loads((R/'mechanical/cooling-680-screen.json').read_text());b=sexp.parse(board.read_text());fps={next(p[2]for p in sexp.find(f,'property')if p[1]=='Reference'):f for f in sexp.find(b,'footprint')}
for probe in screen['probeChecks']:
at=sexp.first(fps[probe['ref']],'at');assert abs(float(at[1])-probe['x'])<1e-8 and abs(float(at[2])-probe['y'])<1e-8
screen['boardSha256']=hashlib.sha256(board.read_bytes()).hexdigest();screen['scope']='Rebound unchanged probe coordinates, raised stack candidate; old fit conclusions not reused';screen['sinkBottomMm']=7.25
(O/'cooling-screen.json').write_text(json.dumps(screen,indent=2)+'\n')
replacements={
'mechanical/cooling-680-body-audit.json':'mechanical/formed-stack-study/body-audit.json',
'mechanical/cooling-680-screen.json':'mechanical/formed-stack-study/cooling-screen.json',
'kicad/adom-custom-electronic-load.kicad_pcb':'checkpoints/formed-stack-review/formed-stack-candidate.kicad_pcb',
'mechanical/carrier-study':'mechanical/formed-stack-study/carrier',
'mechanical/installed-fan-study':'mechanical/formed-stack-study/fan',
'mechanical/sensor-study':'mechanical/formed-stack-study/sensor',
'mechanical/aln-stack-study':'mechanical/formed-stack-study/interface',
'Path(__file__).resolve().parents[1]':'Path(__file__).resolve().parents[2]'
}
for old,new in [('cooling_carrier_study.py','carrier.py'),('installed_fan_study.py','fan.py'),('sensor_mount_study.py','sensor.py'),('aln_stack_study.py','interface.py')]:
s=(R/'tools'/old).read_text()
for a,c in replacements.items():s=s.replace(a,c)
if new=='carrier.py':s=s.replace('bottom, height = 5.09, 31.75','bottom, height = 7.25, 31.75')
if new=='fan.py':s=s.replace('fan_z=39.84','fan_z=42.0')
if new=='sensor.py':s=s.replace('62.8,2.8','62.8,4.92').replace('51.5-i*1.2,2.8','51.5-i*1.2,4.92');s=s.replace("'No change to formal board, BOM, firmware, calibration or acceptance.'", "'Direct Harwin sensor crimp is NOT accepted:0.85mm insulation below0.90mm specified minimum; termination redesign open.','No change to formal board, BOM, firmware, calibration or acceptance.'")
if new=='interface.py':s=s.replace('tab_top=4.455','tab_top=6.575').replace('sink_bottom=5.13','sink_bottom=7.25').replace('kicad/3d/TO-220-3_Horizontal_TabUp.step','mechanical/q1-formed-study/ixtp15n50l2-formed-study.step');s=s.replace("'Sink rises 0.04 mm to include two assumed 20 micrometre grease films; existing carrier/assembly model not updated.'", "'Rebuilt carrier and fan are raised2.16mm from the previous5.09mm-base stack; interface includes two assumed20micrometre grease films.'")
(T/new).write_text(s)
for folder in ['carrier','fan','sensor','interface']:(O/folder).mkdir(exist_ok=True)
shutil.copy2(R/'mechanical/carrier-study/fan-nominal.step',O/'carrier/fan-nominal.step')
shutil.copytree(R/'mechanical/installed-fan-study/source',O/'fan/source',dirs_exist_ok=True)
print('Isolated raised-stack scripts prepared; sensor termination remains rejected')