A Streamlit web‑app that couples thermodynamic performance calculations with a PyVista 3‑D slider‑crank animation.
Change any parameter—bore, stroke, RPM, boost, ambient conditions—and both the numeric gauges and the engine model update in real time.
- Key Features
- Quick Start
- Folder Structure
- Physics Model
- Code Walk‑Through
- Calibration & Tuning
- Typical Use Cases
- Road‑map
- References
- License
| Domain | Highlights |
|---|---|
| Thermodynamics | • Skewed‑Gaussian volumetric‑efficiency curve • BSFC map linked to VE peak • Watson–Heywood FMEP for mechanical η • Computes HP, Torque, BMEP, IMEP, BSFC, brake‑thermal η, etc. |
| Environment & Load | • ISA altitude & ambient‑temperature sliders • Fuel selector (Gasoline / Diesel / E85) swaps LHV & AFR • Boost and throttle scalers |
| 3‑D Visualiser | • Metric scaling (mm → m) for true proportions • Dynamic connecting‑rod geometry • Free‑orbit WebGL canvas with eye‑dome lighting |
| UI | • Streamlit metric panel (HP, Torque, BMEP, efficiencies) • Collapsible “Detailed Specs” section • Hooks for live BMEP‑vs‑RPM plot |
| Extensibility | • CSV lookup for real VE/BSFC maps • Clean helper module for ISA density • Clearly marked TODOs for valve/cam kinematics and turbo maps |
git clone https://github.com/your-handle/engine-sim.git
cd engine-sim
python -m venv .venv && source .venv/bin/activate # Windows: .venv\Scripts\Activate
pip install -r requirements.txt
streamlit run app.pyBrowse to http://localhost:8501 and start dragging sliders.
├── app.py # Streamlit UI glue
├── engine_simulator.py # All thermodynamic maths
├── engine_visualizer_3d.py # PyVista scene builder
├── engine_visualizer.py # 2D scene builder
├── helpers
│ └── isa.py # Mini ISA density helper
├── maps
│ └── ve_bsfc.csv # Optional VE/BSFC lookup table
├── assets
│ └── brushed_metal.png # shader
└── README.md
with
(four‑stroke ⇒ rev s⁻¹ = RPM / 60, then ÷ 2).
Watson–Heywood friction mean effective pressure:
(defaults A = 30 kPa, B = 1.5, C = 2 × 10⁻⁴)
| File | Purpose | Key entry‑points |
|---|---|---|
engine_simulator.py |
Numerical core | EngineSimulator._calculate_performance() – pure, stateless maths; unit‑test friendly |
engine_visualizer_3d.py |
3‑D model | EngineVisualizer3D.build_scene() – rebuilds meshes; geometry metric‑scaled |
app.py |
UI orchestration | Sidebar widgets → update engine → render metrics + 3‑D |
| Goal | Parameter(s) | Typical range |
|---|---|---|
| Lower idle BSFC | BSFC_nom |
260–320 g/kWh (SI) |
| Softer high‑rpm fall‑off | σ_high |
0.18 → 0.25 × Rpk |
| More aggressive cam | σ_low ↓ |
0.25 → 0.15 × Rpk |
| Heavier diesel friction | FMEP_A/B/C ↑ |
50 kPa / 2.5 / 4e‑4 |
- Lecture demos – illustrate how VE, AFR, or boost shape the torque curve in real time.
- Concept feasibility – sanity‑check bore‑stroke combos before detailed GT‑POWER sims.
- Test‑cell dashboards – feed live MAF + RPM into the model to estimate BMEP on the fly.
- Marketing widget – embed the 3‑D model on a product page for interactive specs.
| Milestone | Status |
|---|---|
| CSV VE/BSFC map support | ☐ |
| Full valve & cam animation | ☐ |
| Wiebe heat‑release → cylinder pressure | ☐ |
| Turbo map with compressor‑η islands | ☐ |
| Export power/torque curve (CSV/PDF) | ☐ |
- Heywood, J. B. Internal Combustion Engine Fundamentals, 2e, McGraw‑Hill, 2018
- Watson, N. & Janota, M. Turbocharging the Internal Combustion Engine, Macmillan, 1982
- SAE J1349 – Engine power test code
- ISO 2534 – Fuel consumption & BSFC definitions
Distributed under the MIT License. See LICENSE for details.
- Author: Daglar Duman
- Project Link: https://github.com/daglar510/Engine_sim