Work

Modernizing a Zero- and Quasi-Dimensional HCCI Engine Simulator: LLM-Assisted Migration from Legacy MATLAB to Python with Combustion Insights from Detailed Kinetics

Year: 2026
Type: preprint
Abstract: Legacy combustion simulation codes written in MATLAB or Fortran hold years of validated engineering work, but they are hard to share, tied to commercial licenses, and difficult to connect to modern Python tools. This paper describes engine_simulator, an open-source Python package for zero-dimensional (0D) single-zone and quasi-dimensional (QD) multi-zone simulation of Homogeneous Charge Compression Ignition (HCCI) engines, built by migrating legacy MATLAB code with the help of large language models (LLMs). It documents how the LLMs were used, where they worked well, and where human review was needed. The simulator couples Cantera chemical kinetics with a Woschni wall heat transfer correlation and an Adiabatic Core (AC) phenomenological model fitted to the multi-zone results. With wall heat transfer switched off, the multi-zone and single-zone models agree to every digit reported, as the formulation requires. With it switched on, thermal stratification at 10 zones lowers the peak burn rate by 26% compared with the single-zone model. Going from 10 to 40 zones lowers peak pressure by less than 1.5% but lowers the peak pressure rise rate by 36 to 40%. A 33-species skeletal mechanism and a 312-species gasoline surrogate agree on early phasing once matched, but differ by more than a factor of three in peak burn rate. These results describe the model as built, with an uncalibrated wall heat transfer correlation, and are not measurements of a real engine. The AC model predicts combustion phasing in under a millisecond, with R² from 0.80 to 0.97 on the simulations it was fitted to. The code, a Streamlit GUI, tutorial notebooks, and a 50-test suite are available at https://github.com/prasadshingne/engine_simulator (release v1.0.0, Cantera 3.1.0).
Language: English
Open Access status: green
OpenAlex ID: W7225998392
Cites:
Cited by:
Related to: 10