Engines are supposed to burn fuel in the smallest space possible inside a cylinder. In this way you can extract maximum work out of them or in engineering terms it’s one of the ways in which their volumetric efficiency increases. The compression ratio is the measure of the maximum volume to the minimum volume that a reciprocating piston can make inside a cylinder (See figure).
The Compression ratio is a very important design parameter of an engine and is decided based on the quality of fuel that’s available and the engine type (i.e. petrol or diesel). Diesel engines have higher compression ratios (14:1 or above) because they are suppose to compress air to a point and raise the temperature so that diesel self-ignites as soon as it is injected in the cylinder.
However, there is limit to which the fuel can be compressed in case of petrol engines (which have ratios around 10:1 or so) because the fuel heats up as it compresses. And if the petrol reaches sufficiently high temperature, it pre-ignites and this is known as knocking.
Most modern engines are equipped with knock sensors these days that are capable of detecting knock that’s being caused due to fuel. And as a preventive measure, engine management system can advance the ignition timing to reduce the effects of knocking. However still, the octane number of the fuel affect the engine design to great extent.
The Octane Rating in ordinary language is the measure of knock resistance of a petrol engine and the quality of fuel that it is suppose to run on. To prevent knock, engines with higher compression ratios require a fuel with higher octane ratings. A fuel with higher octane rating requires higher activation energies and can therefore withstand higher compression ratios without self igniting.
A similar rating is given to diesel and it’s known as Cetane number. Unlike petrol, diesel is supposed to have lubrication properties and Cetane number is a factor in determining the quality of diesel. While diesel does not pre ignite like petrol, knocking can occur in case of diesel engines too if the Cetane number is too low.
There’s no fuel in the cylinder during the compression stroke of a diesel engine, therefore, pre-ignition cannot occur. The knocking is a result of a delayed shock wave caused due to late ignition of the fuel after injection. A higher Cetane number ensures proper combustion after diesel injection and results in smooth burning of fuel and refined engines.