The second law of thermodynamics states: 

"Energy spontaneously tends to flow only from being concentrated in one place to becoming diffuse and spread out."

This basically means that you can't get something for nothing, there will always be a dissipation of energy as heat when producing work. This can be quantified in terms of a reversible cycle. A reversible cycle has the maximum efficiency of any system working between Thot and Tcold.


For a simplified Otto cycle the maximum efficiency is given by

where gamma is the ratio of heat capacities and the compression ratio is the max : min volume ratio of the engine's cylinder. 

(image taken, without permission from )

(reference 'Thermal Physics' R. Baierlein - Cambridge University press 1999)