how petrol and diesel engine works