Fuel-flexible combustion control of modern compression-ignition and spark-ignition engines