Chris Collins

Tools · cars

Engine simulator

How a petrol engine works, animated and worked out: a four- or two-stroke cutaway with cams, valves, ports, spark and flame front on real slider-crank geometry; P–V and P–θ diagrams from a single-zone Wiebe combustion model against the ideal Otto cycle, with IMEP, efficiency, peak pressure, best-torque spark and a rough knock check; a draggable valve-timing wheel with lift, VE and torque curves; and firing orders, crank throws and primary/secondary balance for I3, I4, I6, V6, V8 and flat engines.

Added

Works with

How to use it

An engine is easiest to understand moving. This page draws one from the bore, stroke, rod length and compression ratio you give, runs it slowly enough to follow, and works out what the gas inside is doing — so the animation, the pressure diagrams, the cam timing and the balance of a multi-cylinder engine all come from the same numbers.

How to use it

  1. Pick an engine at the top, or type a bore, stroke, rod length, compression ratio and cylinder count. Every tab uses them. The line underneath gives the displacement, rod ratio and λ = crank radius ÷ rod length.

  2. Cutaway. Press Play to watch the four strokes, or Next stroke to step through them one at a time with an explanation of each. Drag the angle slider or tap the strip below the drawing to stop anywhere. The charge is blue, the flame front yellow, burning gas orange and exhaust grey; the cams turn at half crank speed and lift the valves by the cam profile on the Valve timing tab. Switch to Two-stroke to see the ports, the crankcase pump and the reed valve; the port timing sliders move the port edges. The cards give the piston’s position, speed, acceleration and rod angle at the engine speed you set, and the chart shows them over a whole turn.

  3. P–V & P–θ. Move the sliders — compression ratio, spark advance, burn duration, throttle as manifold pressure, air–fuel ratio, rpm and octane — and watch the pressure trace, the indicator loop and the figures change. Spark for best torque finds the advance that gives the most work (MBT). The buttons set up full throttle, a part-throttle cruise, an over-advanced spark that knocks, a retarded one and a lean mixture. log–log shows the P–V diagram on logarithmic axes, where the compression and expansion lines are straight.

  4. Valve timing. Drag the four dots on the wheel — inlet opening and closing, exhaust opening and closing — or type the cam-card figures (seat timing), or pick a preset. You get duration, overlap, lobe centres, the lobe separation angle, dynamic compression and the lift curves. Below, the volumetric efficiency, torque and power curves at full throttle, with the same cam with inlet closing 15° earlier and later so you can see the peak move.

  5. Multi-cylinder. Choose a layout. The animation shows the bores from the front and the crankshaft from the side, with each cylinder lit on its power stroke; the strip below shows the power strokes over two turns. The table says which of the primary and secondary forces and couples cancel, how big the rest are in newtons at your rpm and reciprocating mass, and the plots show the net shaking force and rocking couple over a turn.

The settings are kept in your browser; Share link copies a link that opens the page as you have it.

The model, and what it leaves out

Kinematics are exact for a centred slider-crank: piston travel from top dead centre x = r(1 − cos θ) + L − √(L² − r² sin² θ), with r = stroke ÷ 2 and L the rod length, and its first and second derivatives for velocity and acceleration. The acceleration’s series rω²(cos θ + λ cos 2θ + …) is where primary and secondary balance come from.

The cycle is a single-zone model (Heywood, Internal Combustion Engine Fundamentals, ch. 9):

  • The charge starts at bottom dead centre at the manifold pressure and 320 K, and the valves are taken as shut from BDC to BDC, so the cam timing does not change this tab. The residual gas is left out.

  • Compression and expansion are polytropic, the first law dp/dθ = ((γ − 1) dQ/dθ − γ p dV/dθ) / V integrated by Runge–Kutta in ¼° steps, with γ going from 1.35 (unburned) to 1.27 (burned) as the charge burns.

  • Heat is released by a Wiebe function, x = 1 − exp(−5((θ − θ₀)/Δθ)³), starting at the spark and lasting the burn duration (0 to 99 %). There is no separate ignition delay; the slow start of the Wiebe curve stands in for it. Away from λ ≈ 0.9 the burn is made slower, as real flames are.

  • The heat released is the fuel’s lower heating value (44 MJ/kg) times the fraction that burns — about 98 % lean of stoichiometric, limited by the oxygen when rich, with a smooth transition so power flattens out richer than λ ≈ 0.9 — less a fixed 20 % lost to the walls. A real engine loses heat mostly near TDC, so this model’s best-torque spark puts the 50 %-burned point (CA50) a few degrees earlier than the 8–10° after TDC real engines like, and its peak pressures run a little high.

  • The pumping loop is ideal: exhaust at 105 kPa, intake at the manifold pressure. Gross IMEP counts the compression and expansion strokes; net IMEP includes pumping. Indicated efficiency is the gross work over the fuel’s heating value.

  • The ideal Otto cycle drawn for comparison uses the same charge, the same heat and the same γ values, with all the heat added at TDC; a very short burn at TDC in the model reproduces it, which the tests check. The air-standard figure 1 − r^(1−1.4) is given too.

  • Knock is approximate and flagged as such. The unburned end gas is compressed isentropically, and its ignition delay from the Douaud & Eyzat correlation (τ = 17.68 (ON/100)^3.402 p^−1.7 e^(3800/T) ms, p in atm) is summed in the Livengood–Wu integral ∫ dt/τ until 90 % of the charge has burned; an integral of 1 means the end gas would self-ignite before the flame got there. The single-zone end gas runs hotter than a real one, so the delay is scaled by one factor, chosen so a 10.5:1 engine on 95-octane fuel at full throttle, 2000 rpm and best-torque spark sits right on the line. It shows the trends — compression, spark, boost, rpm and octane — but not a knock limit for your engine.

Breathing on the valve-timing tab is a simple model to show which way things move, not a dyno prediction:

  • Inlet closing sets which piston speed the engine fills best at: the charge’s momentum keeps it flowing in after BDC, and the best closing point is taken as about 3.5° ABDC per m/s of mean piston speed (a fit to stock cams, ~40° ABDC peaking near 11 m/s, and race cams, ~70° near 20 m/s). Closing later pushes charge back out (VE × the ratio of cylinder volumes at the two closing points), closing earlier cuts the filling short.

  • Overlap costs VE at low speed (exhaust flows back into the intake), fading out with rpm.

  • Runner tuning adds one Helmholtz resonance of runner and cylinder (Engelman’s model: f = c/2π √(A/(L·V_eff)), V_eff = Vd/2 · (r+1)/(r−1)), with the main peak where the crank turns at half f and a smaller one at a third.

  • Valve flow limits VE at high speed through Taylor’s inlet Mach index Z = (A_piston/A_valves) × S̄p / (C_i a); VE falls away past Z ≈ 0.6.

  • Torque is VE × air density × the cycle’s work per kilogram of air (with the P–V tab’s compression, AFR and burn, spark at best torque), less friction from a Chen–Flynn-style FMEP = 0.25 bar + 0.005 p_max + 0.08 S̄p + 0.0006 S̄p², constants typical of a modern petrol engine.

Balance uses the reciprocating mass only — piston, pin, rings and about a third of the rod — with the rotating parts taken as balanced by the crank’s counterweights. Cylinders in a V or opposed pair are offset along the crank by 0.3 of the cylinder spacing, which is why a boxer four shows its small secondary rocking couple. Every layout fires evenly: the crank-pin angles follow from the bank angles and the firing order (pin = bank angle − firing angle), and the tests check them against the real cranks, and the results against the textbook ones — the inline four’s secondary force of 4λ m r ω², the inline three’s primary couple of √3 m r ω² a, the cross-plane V8’s rotating primary couple of √10 m r ω² a, and the full balance of the inline and flat sixes. A non-zero primary couple of constant size rotates with the crank, so counterweights can cancel it (the cross-plane V8 and the 60° V6); one that rocks needs a balance shaft. The two-stroke’s crankcase pressure is a rough adiabatic pump with a primary compression ratio of 1.4.

Sources: J. B. Heywood, Internal Combustion Engine Fundamentals (McGraw-Hill; Wiebe function §9.2, heat-release analysis, volumetric efficiency and the inlet Mach index §6.2, friction ch. 13); G. Douaud and P. Eyzat, "Four-octane-number method for predicting the anti-knock behavior of fuels and engines", SAE 780080 (1978); J. C. Livengood and P. C. Wu, "Correlation of autoignition phenomena in internal combustion engines and rapid compression machines" (1955); H. W. Engelman, "Design of a tuned intake manifold", ASME 73-WA/DGP-2 (1973); C. F. Taylor, The Internal Combustion Engine in Theory and Practice (MIT Press), vol. 1; and any machine-dynamics text for the balance of multi-cylinder engines.

Related: engine calculator for compression ratio and gearing, turbocharger matching, small engines and linkages for slider-cranks and cams in general.

Privacy

Everything runs in the browser. Nothing is sent anywhere; a share link carries only the settings.

Runs entirely in your browser; nothing you type leaves this page.