The invention relates to a method for operating an internal combustion
engine operable in compression ignition mode, said engine comprising a
fuel supply means, a piston in each cylinder causing ignition during
compression ignition mode, at least one inlet and one exhaust valve, a
control unit that controls the valve timing and fuel quantity, and at
least one sensor for measuring an engine operation parameter. The
following steps are performed when switching from spark ignition to
compression ignition mode: controlling the exhaust and intake valves to
perform a negative valve overlap to retain exhaust residual gas,
determining a current combustion phasing timing, and correcting the
combustion phasing by increasing the retained exhaust residual gas
fraction by stepwise control of a combustion related parameter. The
invention further relates to an arrangement and a computer readable
device for controlling the combustion process.