A method for controlling an air-fuel ratio (AFR) in an engine powered by a gaseous fuel having an unknown composition, the engine including a microprocessor adapted to perform the method, said method comprising:
- receiving an assumed gas species composition for the gaseous fuel;
- determining an assumed lower heating value (LHV) for the assumed gas species composition;
- determining a perceived lower heating value (LHV) for the gaseous fuel based on a perceived gas mass flow and a gas energy flow for the gaseous fuel;
- comparing the assumed LHV and the perceived LHV;
- updating the assumed gas species composition until the assumed LHV and the perceived LHV are aligned, the assumed gas species composition being an aligned gas species composition when the assumed LHV and the perceived LHV are aligned;
- determining a desired AFR using the aligned gas species composition and a desired λ;
- determining an airflow necessary to provide the desired AFR;
- and
- adjusting an air system controller of the engine to provide the airflow.