DEV Community

Cover image for Otto cycle vs Diesel cycle: coding both efficiency formulas side by side
Surendra Singh Kamboj
Surendra Singh Kamboj

Posted on AI-assisted

Otto cycle vs Diesel cycle: coding both efficiency formulas side by side

Petrol engines run the Otto cycle, diesel engines run the Diesel cycle — the efficiency formulas look nothing alike until you put them in code and compare real numbers.

Full disclosure: I build PractiSci, a free virtual physics and chemistry lab (https://www.practisci.in).

const gamma = 1.4;

// Otto: compression ratio 8 (typical petrol engine)
const rOtto = 8;
const etaOtto = 1 - Math.pow(rOtto, -(gamma - 1));

// Diesel: compression ratio 16, cutoff ratio 2 (typical diesel engine)
const rDiesel = 16, rc = 2;
const num = Math.pow(rc, gamma) - 1;
const den = Math.pow(rDiesel, gamma - 1) * (rc - 1);
const etaDiesel = 1 - (1 / gamma) * (num / den);

console.log('Otto:', (etaOtto * 100).toFixed(2), '%');
console.log('Diesel:', (etaDiesel * 100).toFixed(2), '%');
// Otto: 56.47 %
// Diesel: 61.38 %
Enter fullscreen mode Exit fullscreen mode

The diesel engine's much higher compression ratio (16 vs 8) outweighs the penalty its own formula carries for a nonzero cutoff ratio, which is why real diesel engines are more thermally efficient despite needing no spark plug.

Common mistake: plugging the SAME compression ratio into both formulas. Real engines never share one — diesel fuel needs a much higher ratio to self-ignite, which is exactly why its own cycle tolerates (and needs) a cutoff-ratio term that petrol's constant-volume Otto cycle does not.

Try PractiSci's Otto and Diesel cycle lab: https://www.practisci.in/labs/11-11-otto-diesel-cycle (part of the class 11 physics practicals: https://www.practisci.in/practicals/class-11-physics).

Top comments (0)