A Python-based thermodynamic simulation of a 6-cylinder internal combustion engine, modeling the full P-V cycle and visualizing power output as a 3D surface across environmental conditions.
EngineSim numerically models the pressure-volume (P-V) cycle of a 6-cylinder engine across a full 720° crankshaft rotation. Given environmental pressure and combustion temperature as inputs, it calculates net work output by integrating the pressure-volume curve, then computes shaft power output.
The simulation sweeps a grid of input conditions (ambient pressure 80–130 kPa, combustion temperature 2000–3500 K) and renders the results as an interactive 3D surface plot.
Two model versions are included:
- Polytropic compression and expansion (nc = 1.3)
- Peak pressure ratio scaling with combustion temperature
- Mass flow scaling relative to standard reference conditions
Adds three physical correction factors on top of the baseline:
- Temperature-dependent gamma — specific heat ratio adjusts with combustion temperature
- Heat loss factor — exponential Newtonian cooling model based on cylinder wall temperature (470 K)
- Combustion phasing efficiency — Gaussian efficiency curve peaking at optimal combustion temperature (2800 K), modeling the effect of ignition timing on work output
Both scripts generate a 3D surface plot:
- X-axis: Environmental pressure (Pa)
- Y-axis: Combustion temperature (K)
- Z-axis: Engine power output (W)
- Python
- NumPy — numerical integration and array operations
- Matplotlib — 3D surface visualization
pip install numpy matplotlib
python engine2.py| Parameter | Value |
|---|---|
| Cylinders | 6 |
| Engine speed | 15,000 RPM |
| Displacement per cylinder | 2.66 × 10⁻⁴ m³ |
| Compression ratio | 18 |
| Polytropic index | 1.3 |
| Peak pressure ratio | 6.5 |
Dexter (Yulin) Peng Computer Science, University of Minnesota Twin Cities GitHub