A small modelling tool that model's the 2D axial contour of a liquid fuel rocket engine with a filleted thrust chamber. From three radii, chamber, throat, and exhaust, it assembles five analytic contour segments, mirrors them about the engine axis, and renders the result as a PNG.
The model began life as a MATLAB script. Since that environment is no longer available, the maintained renderer is a faithful Python / Matplotlib port; the original .m sources are kept under src/legacy/ for reference.
- ✅ Requirements
- ⚙️ Setup
▶️ Running- 🧩 Geometry Parameters
- 🧮 Mathematical Overview
- 📐 Thrust-Chamber Contour - Mathematical Definition
- 🗂️ Project Layout
⚠️ Notes and Limitations- 📜 License
- Python 3.9 or newer
- NumPy and Matplotlib
- MATLAB is optional — only needed to run the original
src/legacy/*.msources; the Python port has no MATLAB dependency
Create a virtual environment, then install the two runtime dependencies.
python -m venv .venv
.\.venv\Scripts\python.exe -m pip install -r requirements.txtpython3 -m venv .venv
./.venv/bin/python -m pip install -r requirements.txtpy -3 -m venv .venv
./.venv/Scripts/python.exe -m pip install -r requirements.txtThe renderer uses Matplotlib's headless Agg backend, so it writes a PNG directly — no display required. Run it from the project directory.
Show the available command-line options:
python src/engine_contour.py --helpRender with the default radii (RC = 4.0, RT = 1.5, RE = 3.0):
python src/engine_contour.pyRender a custom chamber, throat, and exhaust radius and choose the output file:
python src/engine_contour.py --rc 4 --rt 1 --re 2 --out images/engine-contour.pngWith no --out, the figure is saved to images/engine-contour.png (resolved relative to the script).
The repository also includes an interactive 3D wireframe viewer that revolves the same inner-surface profile about the engine axis. It opens a rotatable Matplotlib window (a GUI backend is required), ready to screenshot:
python src/engine_chamber_3d.py # defaults: RC=4.0, RT=1.5, RE=3.0
python src/engine_chamber_3d.py --rc 4 --rt 1 --re 2 # custom radii
python src/engine_chamber_3d.py --sides 16 --stations 40The three radii are the meaningful inputs; the axial section boundaries are fixed in the model.
| Option | Symbol | Meaning | Default |
|---|---|---|---|
--rc |
Combustion chamber radius | 4.0 |
|
--rt |
Throat radius | 1.5 |
|
--re |
Nozzle adaptor exhaust radius | 3.0 |
|
--out |
— | Output PNG path | images/engine-contour.png |
The fixed axial section boundaries (in chamber-radius units) partition the contour into its five segments:
| Boundary | Axial position | Marks the end of |
|---|---|---|
0 |
Injector face (origin) | |
1 |
Injector fillet | |
6 |
Combustion chamber | |
10 |
Neck | |
12 |
Throat | |
14 |
Nozzle adaptor (exit plane) |
The wall profile is built from five analytic pieces, joined end to end and mirrored about the axis (
The injector fillet is a quarter-circle arc of radius
The combustion chamber is a constant-radius wall:
The neck is a raised-cosine (half-period) transition from the chamber radius
The throat is a parabola
The parabola and line coefficients are not free — they are solved from continuity and smoothness constraints, derived next.
The throat parabola
Point
The six constraints are:
Solving this linear system in closed form (the role of the legacy exhaustSolver.m) gives, with
These coefficients guarantee a
rocket-engine-thrust-chamber/
├─ src/ Maintained Python renderers and legacy MATLAB sources
│ ├─ engine_contour.py 2D contour renderer (Matplotlib port); CLI entry point
│ ├─ engine_chamber_3d.py Interactive 3D wireframe viewer
│ └─ legacy/ Original MATLAB sources (kept for reference)
│ ├─ engineContour.m MATLAB contour model
│ ├─ circle.m Fillet construction circles
│ ├─ exhaustSolver.m Throat/nozzle coefficient solver
│ ├─ testFig.m Legacy MATLAB GUIDE harness (script)
│ └─ testFig.fig Legacy MATLAB GUIDE harness (figure)
│
├─ images/ Rendered output and published MATLAB HTML
│ ├─ engine-contour.png 2D axial contour (README headline)
│ ├─ inner-surface.png 3D wireframe render
│ └─ html/ Published MATLAB HTML
│
├─ requirements.txt Runtime dependencies (NumPy, Matplotlib)
├─ README.md This document
└─ LICENSE MIT license
- The original MATLAB
engineContour()accepts section boundariess1..s5as arguments but then immediately overrides them with hard-coded values. The Python port reproduces this behaviour faithfully: only the three radii are meaningful inputs, and the axial boundaries are fixed. - The model is a 2D axial profile for visualisation and geometry study — not a thermal, structural, or gas-dynamic analysis. The radii and boundaries are dimensionless model units, not a specific engine.
- The throat "parabola" and nozzle "line" describe the adaptor geometry only; they are not a method-of-characteristics or bell-nozzle optimisation.
Released under the MIT License. © 2019 Rohin Gosling.

