Skip to content

Latest commit

 

History

33 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ignis

A real-time internal combustion engine simulator. A hand-written 2D constraint solver drives the crank, rods, and pistons, a lumped gas model burns the charge, and the exhaust note is synthesized sample by sample from that same simulation. There are no audio recordings anywhere in the project, what you hear is the cylinder pressure doing its thing.

demo.mp4

Idle, revs through the gears, turbo spool and blow-off, and the anti-lag crackle on lift. The video frames and the audio track come from the same simulation pass. (direct file)

the dashboard, driving an inline 4 in first gear

Building

Needs a C++20 compiler, CMake, and SDL2 development headers. Dear ImGui is a submodule.

git clone --recurse-submodules https://github.com/xevrion/ignis.git
cd ignis
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build -j
./build/ignis

Tested on Fedora 43 with GCC 15 and SDL2 2.32. ctest --test-dir build runs the physics test suite (solver accuracy, firing phase, combustion, ignition timing, and a stability stress across all engine configs).

Controls

Key Action
W or Up throttle
S or Down lift off
E / Q shift up / down
Space clutch
Left Shift hold for the two-step launch limiter
[ and ] ignition timing
+ / - zoom

The panel selects the engine (single, inline 3/4/6, V6, V8 cross-plane and flat-plane, V12, boxer 4 and 6, single and twin rotor), the induction (none, turbo, or supercharger), and the lift-off behaviour (a clean blow-off valve or a compressor surge). There are live tuning sliders for compression, burn duration, charge, redline, boost, spool lag, and the gearbox, so you can reshape the running engine and hear it change. One-click presets set up a few famous combinations (2JZ, LS V8, boxer, 13B rotary, flat-plane V8, and a rally anti-lag car) as starting points.

Some things to try: lift off sharply with boost up and hear the blow-off or the 2JZ-style surge flutter, that is trapped pressure venting, not a sample. Turn on anti-lag and trail the throttle for the spaced, machine-gun bangs out the pipe. Downshift (Q) while off the throttle and the gearbox auto-blips to rev-match, so the revs flare up to meet the lower gear and then crackle back down, the same throttle stab a heel-toe downshift makes. Hold Left Shift against the two-step and bounce it off the limiter.

What is simplified

This is a physics simulation tuned for sound and feel, not a CFD solver, and it cuts corners a real engine analysis could not:

  • Gas behavior is lumped per cylinder: one pressure, polytropic compression and expansion, and a Wiebe-style finite burn. There is no port flow model, no intake or exhaust wave tuning, and no real temperature tracking.
  • The intake and exhaust strokes just relax the cylinder toward manifold and atmospheric pressure. Valves are timing indicators, not flow restrictions.
  • Friction is a three-term torque curve on the crank, tuned per layout so every engine idles. Real rubbing losses are far messier.
  • The rotary's combustion cadence and torque are modeled (three faces, one power event per output revolution), but the rotor itself is kinematic. The piston engines' crank, rods, and pistons really are solved as constrained rigid bodies; the rotor is drawn from the shaft angle and its epitrochoid geometry.
  • The exhaust audio path is a small resonator bank plus the pressure pulse train, not an acoustic pipe model.
  • The car behind the gearbox is a point mass on wheels.

What is implemented

  • Sequential impulse constraint solver with split-impulse position correction, written for this project. Pin joints and a prismatic joint, that is all an engine needs.
  • Configurable engines: single, inline 3/4/6, V6, V8 (cross-plane and flat-plane), V12, boxer 4 and 6, and single and twin rotor Wankels. The firing spacing falls out of each crank's pin geometry, so a cross-plane V8 fires as unevenly as the real thing, and its two banks feed separate exhaust collectors that ring against each other for the burble.
  • Cylinder pressure from chamber volume, spark timing with a real torque optimum (too advanced fights the piston, too retarded wastes the stroke, both are audible).
  • Audio that is the simulation: the physics runs at the audio sample rate and every step emits one summed exhaust-port-flow sample into a lock-free ring. The SDL callback drains that ring and runs it through a small output chain (DC removal, a pressure-derivative edge, and delay-line pipe resonances). Idle is lumpy, high rpm blurs into a tone, more cylinders sound smoother, all of it falls out of the firing schedule.
  • A cam that shapes the note: intake and exhaust valve lift come from cam profiles, and the exhaust pulse is gated by the lift curve, so the port only makes sound while it is actually open.
  • A rev limiter that cuts spark past redline, a two-step you can hold at a lower limit for the launch bounce, and overrun/anti-lag afterfire. The unburned charge from every cut cycle lights in the pipe, and a fast decay makes each one a sharp crack, so a string of them is the machine-gun rattle at the limiter and the crackle on a trailing throttle.
  • A five-speed gearbox with a slipping clutch and anti-stall take-up, so revs drop on upshifts and the engine brakes on the overrun.
  • A turbo with spool inertia, a wastegate, a blow-off valve, and a compressor surge mode, or a lag-free supercharger. Boost strengthens combustion, the whistle rides the compressor speed, the wastegate chatters at the boost limit, and on a hard lift you get either a clean blow-off or the surge flutter, all from the venting dynamics rather than a sample.
  • The dashboard: engine cross-section, tach and throttle gauges with spring-damped needles, a live oscilloscope of the output waveform, firing status, and gear, speed, and boost readouts.

Not implemented: a proper 1D acoustic exhaust model (the exhaust is a small resonator and pipe bank, not a wave solver), tyres that can spin or grip, and anything past two rotors or twelve cylinders.

Credit

The concept, a constraint-solved engine that you hear, is from Ange Yaghi's engine-sim, which is the reason this project exists. The dashboard look and the default color theme follow his. The architecture and all the code here are my own, written from scratch, not ported.

About

Real-time internal combustion engine simulator with physics-driven audio synthesis

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages