- Published on
Assembling and running an engine in a browser tab — a look at Combustion Lab
- Authors

- Name
- Youngju Kim
- @fjvbn20031
- Introduction — an engine that runs in a browser tab
- Four strokes, one closed loop
- A single-zone model is not CFD
- Running real-time physics in the browser
- Closing — why a tool like this is good
- References
Introduction — an engine that runs in a browser tab
Combustion Lab (combustionlab.net) has been making the rounds on Hacker News. It is a simulator that lets you assemble and run an internal combustion engine in a single browser tab, with no install and no login. The header describes itself plainly: "CRANK-ANGLE-RESOLVED ENGINE DYNAMICS · v2.0", meaning it computes engine behavior in steps of crankshaft angle.
Start with the build. Pick an architecture — Inline, V, Boxer, or Opposed — and set cylinder count, bore, stroke, and compression ratio. Choose spark ignition (Otto) or compression ignition (Diesel), then dial in the mixture ratio λ and spark advance. Induction can be naturally aspirated, turbocharged, or supercharged, with boost, spool RPM, and an intercooler option. The valvetrain exposes cam duration, intake close, exhaust open, and a redline.
Once the engine is built, you run it. Move RPM, throttle, and animation speed live while reading power (kW/HP) and torque (N·m/LB-FT). You read the results in five modes: DYNO (dyno curves), P–V (pressure-volume), P–θ (pressure-crank angle), ENERGY (energy flow), and CROSS-SECTION (an animated cutaway). Data exports to CSV, and there is a LEARN MODE that walks through the concepts.
The caveat the tool pins on itself is the honest part: "Trends are engineering-realistic; certify nothing with it." Trends are plausible; do not certify anything with it. That one line is the reference point this post keeps returning to.
Four strokes, one closed loop
The physics here is the textbook four-stroke cycle. Intake draws in air and fuel, compression squeezes it, combustion (expansion) does the work, and exhaust pushes it out. The tool marches through those four phases one step at a time, parametrized by crank angle θ.
The P–V mode shows the point of it all. Draw one cycle on a pressure-volume plane and you get a closed loop; the area that loop encloses is the indicated work for that cycle. Raise the compression ratio or advance the spark and you watch the loop swell and tilt.
The idealized Otto cycle in a textbook is close to a box with sharp corners. A real loop has those corners rounded off, because combustion takes a finite stretch of crank angle (the interval Wiebe describes) rather than an instant, and heat leaks to the walls (Woschni) the whole time. The value of a tool like this is that you can grab those roundings by their parameters.
That is also why the timing knobs are exposed. A few degrees of spark advance, a few degrees of valve timing, and the whole curve shifts. Push compression ratio, spark advance, and λ toward knock and auto-ignition looms; the tool estimates that margin with a Livengood–Wu integral. This is the moment an abstract cycle becomes something you can poke and watch respond.
A single-zone model is not CFD
Here it helps to be honest. Combustion Lab is a single-zone thermodynamic model. It treats the cylinder charge as one uniform blob, carries a single pressure and temperature at each crank angle, and solves an energy balance. This is the zero-dimensional (0D) model, the classic starting point of any engine-thermodynamics course.
The four models the page lists are empirical correlations plugged into that balance:
- Wiebe — an S-curve for how much of the charge has burned (mass fraction burned) versus crank angle.
- Woschni — the convective heat lost to the cylinder walls.
- Chen–Flynn — friction losses (FMEP), subtracted from indicated work to get brake torque.
- Livengood–Wu — the integral that estimates knock onset.
What this buys you is cycle-level energy accounting and believable trends as you vary bore, stroke, compression ratio, boost, and timing. These are decades-old correlations, so the direction of the answer is fairly trustworthy.
What it cannot capture is just as clear: in-cylinder flow (tumble and swirl), flame-front geometry, fuel spray, detailed emissions chemistry, and intake/exhaust acoustics. That is the territory of multi-zone models and full CFD, which cost orders of magnitude more compute and do not fit in a browser tab. Hence the "certify nothing" line. It is a tool for building intuition, not for signing off a design — and drawing that line itself is a virtue.
Running real-time physics in the browser
The site does not disclose what language or framework it is built with (no public GitHub is visible either), so rather than guess at the implementation, consider the general shape of running something like this live in a browser.
Resolving by crank angle means integrating an ODE forward in small angle steps. A four-stroke cycle spans 720°, so at, say, 0.5° per step you need 1,440 steps per cylinder per cycle — thousands of arithmetic operations behind every cycle you see on screen.
The usual move is to decouple the physics step from the render loop: render on requestAnimationFrame, while the "animation speed" control hints that the physics can be stepped faster or slower than wall-clock time. A fixed-step integration makes the run deterministic — the same inputs yield the same curve — which is exactly what a meaningful CSV export needs. The P–V and P–θ plots and the cutaway animation are cheap to draw on a 2D canvas.
Where WASM earns its keep is that hot integration loop. Compiling Rust, C++, or AssemblyScript to WebAssembly gives more predictable throughput than a JS JIT. That said, a single engine at interactive rates is often fine in plain JavaScript. I cannot confirm which they chose, and both are reasonable.
What matters is the experience the structure enables: no install, shareable by URL, works on a phone, and results react the instant you change a parameter. Raise the compression ratio and you see the P–V loop thicken and the knock margin shrink, right there.
Closing — why a tool like this is good
Two things stand out about Combustion Lab. It makes a graduate-level topic — engine thermodynamics — something you can touch in a tab, and it is honest about what it cannot do. The teaching power of an interactive simulator comes not from accuracy but from the immediate feedback loop between parameter and outcome. Intuition forms in the instant you change one number and watch the curve move.
At the same time, keep its nature in mind. These are trends, not truth, and a single-zone model hides everything spatial. It is not the tool for choosing an actual turbo or grinding a cam; it is the tool for feeling why those choices bend the curve the way they do. That immediacy is exactly why interactive in-browser simulators are underrated as teaching instruments.
References
- Combustion Lab — Interactive Engine Dynamics Simulator — the simulator discussed here.
- Combustion Engine Web-Based Simulator — Hacker News discussion
- ange-yaghi/engine-sim — for contrast: a separate, native (C++) desktop project focused on synthesizing sound from the simulation, not a browser tool.