Diesel vs. gasoline engines: A detailed explanation
Both gasoline and diesel engines consist of one or more cylinders, each of which houses a piston that moves up and down. In a gasoline engine, as the piston moves down on its first stroke (or intake stroke), it draws in a mixture of gasoline and air. (The gas/air charge is pre-mixed by the fuel injection system or the carburetor in a relatively static mixture; the more air admitted to the engine, the more gasoline is mixed with it.) On the second stroke (compression) the piston moves up, compressing the mixture to around 1/9th of its original volume. As the piston approaches the top of its stroke, a spark from the spark plug ignites the mixture. The expansion of the resulting explosion pushes the piston downwards for the power stroke. Finally, the piston moves up, pushing out the spent contents in the exhaust stroke. When a driver steps on the accelerator, she is actually opening a valve that allows a larger amount of air (and a correspondingly larger amount of fuel) to enter the cylinders.
In a diesel engine, each piston draws in only air on the intake stroke. (Most modern diesels use a turbocharger, an exhaust-driven pump that pushes more air into the cylinder.) Unlike a gasoline engine, there is no restriction on the amount of air; the cylinder always draws in as much as it can. On the compression stroke, the air is compressed to about 1/25th of its original volume. Once the piston reaches the top of its stroke, diesel fuel -- which will only burn under intense pressure and heat -- is sprayed into the cylinder. Diesel fuel doesn't explode; it burns, and the expanding gasses push the cylinder down. Injection of fuel continues for most of the power stroke. As with a gas engine, the exhaust stroke pushes out the spent gases. With a diesel engine, the throttle pedal is connected to a governor, which varies the amount of fuel injected to control engine speed. Therefore, the mixture is always changing -- diesels run lean (a lower amount of fuel for a given volume of air) when power demand is low, and rich (a higher amount of fuel for a given volume of air) when power demand is high.

