AIR_FUEL_RATIO
This function solves for the air or fuel molar flow rate when an air-fuel ratio is known on a mole, mass, or volume basis. In addition to the missing flow rate, it also reports the equivalent ratio expressed in all three bases so the result can be compared across operating conventions.
The three ratio definitions are:
AFR_{mole} = \frac{n_{air}}{n_{fuel}}, \qquad AFR_{mass} = \frac{n_{air} MW_{air}}{n_{fuel} MW_{fuel}}, \qquad AFR_{volume} = \frac{n_{air} V_{m,air}}{n_{fuel} V_{m,fuel}}
All supplied quantities must use a consistent basis. For example, the mass ratio should be supplied as mass per mass, and the molar volumes should correspond to the same reference conditions if a volume-based ratio is used.
Excel Usage
=AIR_FUEL_RATIO(Vm_air, Vm_fuel, MW_air, MW_fuel, ratio, n_air, n_fuel, basis)
Vm_air(float, required): Molar volume of air [m^3/mol].Vm_fuel(float, required): Molar volume of fuel [m^3/mol].MW_air(float, required): Molecular weight of air [g/mol].MW_fuel(float, required): Molecular weight of fuel [g/mol].ratio(float, optional, default: null): Air-fuel ratio, in the specified basis.n_air(float, optional, default: null): Molar flow rate of air [mol/s].n_fuel(float, optional, default: null): Molar flow rate of fuel [mol/s].basis(str, optional, default: “mass”): Basis of ratio (‘mass’, ‘mole’, or ‘volume’).
Returns (str): JSON string of n_air, n_fuel, mole_ratio, mass_ratio, volume_ratio.
Example 1: Air to fuel ratio by mole
Inputs:
| Vm_air | Vm_fuel | MW_air | MW_fuel | ratio | n_air | n_fuel | basis |
|---|---|---|---|---|---|---|---|
| 0.02493 | 0.02488 | 28.85 | 17.86 | 5 | 5 | mole |
Excel formula:
=AIR_FUEL_RATIO(0.02493, 0.02488, 28.85, 17.86, 5, , 5, "mole")
Expected output:
"{\"n_air\": 25, \"n_fuel\": 5, \"mole_ratio\": 5.0, \"mass_ratio\": 8.076707726763718, \"volume_ratio\": 5.010048231511254}"
Example 2: Air to fuel ratio by mass
Inputs:
| Vm_air | Vm_fuel | MW_air | MW_fuel | ratio | n_air | n_fuel | basis |
|---|---|---|---|---|---|---|---|
| 0.02493 | 0.02488 | 28.85 | 17.86 | 17.2 | 53.30051993067591 | 5 | mass |
Excel formula:
=AIR_FUEL_RATIO(0.02493, 0.02488, 28.85, 17.86, 17.2, 53.30051993067591, 5, "mass")
Expected output:
"{\"n_air\": 53.30051993067591, \"n_fuel\": 5, \"mole_ratio\": 10.660103986135182, \"mass_ratio\": 17.21970884658455, \"volume_ratio\": 10.681527024692526}"
Example 3: Solve fuel flow from air flow with volume ratio
Inputs:
| Vm_air | Vm_fuel | MW_air | MW_fuel | ratio | n_air | basis |
|---|---|---|---|---|---|---|
| 0.02493 | 0.02488 | 28.85 | 17.86 | 10 | 20 | volume |
Excel formula:
=AIR_FUEL_RATIO(0.02493, 0.02488, 28.85, 17.86, 10, 20, "volume")
Expected output:
"{\"n_air\": 20, \"n_fuel\": 2.0040192926045015, \"mole_ratio\": 9.979943842759727, \"mass_ratio\": 16.1210179094971, \"volume_ratio\": 10.0}"
Python Code
Show Code
import json
from chemicals.combustion import air_fuel_ratio_solver
def air_fuel_ratio(Vm_air, Vm_fuel, MW_air, MW_fuel, ratio=None, n_air=None, n_fuel=None, basis='mass'):
"""
Calculates molar flow rate of air or fuel from the other, using a specified air-fuel ratio.
See: https://chemicals.readthedocs.io/chemicals.combustion.html
This example function is provided as-is without any representation of accuracy.
Args:
Vm_air (float): Molar volume of air [m^3/mol].
Vm_fuel (float): Molar volume of fuel [m^3/mol].
MW_air (float): Molecular weight of air [g/mol].
MW_fuel (float): Molecular weight of fuel [g/mol].
ratio (float, optional): Air-fuel ratio, in the specified basis. Default is None.
n_air (float, optional): Molar flow rate of air [mol/s]. Default is None.
n_fuel (float, optional): Molar flow rate of fuel [mol/s]. Default is None.
basis (str, optional): Basis of ratio ('mass', 'mole', or 'volume'). Valid options: Mass, Mole, Volume. Default is 'mass'.
Returns:
str: JSON string of n_air, n_fuel, mole_ratio, mass_ratio, volume_ratio.
"""
try:
res = air_fuel_ratio_solver(ratio=ratio, Vm_air=Vm_air, Vm_fuel=Vm_fuel, MW_air=MW_air, MW_fuel=MW_fuel, n_air=n_air, n_fuel=n_fuel, basis=(basis if basis else 'mass'))
names = ["n_air", "n_fuel", "mole_ratio", "mass_ratio", "volume_ratio"]
return json.dumps(dict(zip(names, res)))
except Exception as e:
return f"Error: {str(e)}"