Simulation, numerics and systems
cooling-surrogate
Can a neural surrogate stand in for a verified physics solver, and will the release gate stop a copy that should not ship?
Answer
Inside its training box the surrogate gets the cooling time of a moulded part within 0.055 % on average (95 % interval 0.052 to 0.058 %), and one request takes 0.271 ms against 0.342 s for the solver: 1,266 times faster on one CPU thread. Its int8 copy passed both error thresholds and still failed a physics check in 749 of 1,000 test cases, so the gate blocked it and production stayed on float32.
How it was measured
- The solver: finite volumes across half the wall, Crank-Nicolson in time, latent heat of crystallisation as an enthalpy. Without latent heat the problem has an exact series solution, and the solver converges to it at order 2.02.
- The dataset: 6,500 solver runs, every array hashed with SHA-256, so each model version knows exactly which data it saw.
- The gate judges the upper end of each 95 % interval, not the point estimate: cooling-time error, profile error, and five physics checks (bounds, monotone cooling, coolest at the face, energy balance, ejection at the predicted time).
- A FastAPI service sends inputs outside the training box, or answers that fail a physics check, to the solver instead. A monitor reads the request log and re-runs a sample with the solver.
Proof
Every file is pinned to the commit the numbers come from, so the links cannot drift.
Reproduce it
pip install -r requirements-dev.txt
python -m cooling_surrogate.pipeline --config configs/full.json
python scripts/make_tables.py
pytest -qCPU only. CI runs the tests, checks the README tables against the result files, runs the pipeline on a tiny config, builds the image and sends it one request inside and one outside the training box.
Limits
- One-dimensional physics with constant material properties. The point is the machinery around the model; an exact answer lets every number be checked.
- The speed-up is against this repository's Python solver on one CPU thread, not against a production solver.