I am trying to calculate mass fractions of a Hydrogen Oxygen gas mixture as a function of equivalence ratio before ignition. My work is the following:
Equivalence Ratio: $$\phi=\frac{FA}{FA_s}=\frac{\frac{m_f}{m_{air}}}{\frac{m_{fs}}{m_{air,s}}}=\frac{\frac{n_f}{n_{air}}}{\frac{n_{fs}}{n_{air,s}}}$$
Where $FA$ is the fuel to air ratio and a subscript $s$ stands for the stoichiometric reaction.
The balanced combustion reaction equation (assuming a perfectly stoichiometric mixture) is:
$$2H_2+1O_2\rightarrow2H_2O$$
Thus, $n_{fs} = 2$ and $n_{air,s}=1$. Now, when I write the mass fractions as a function of equivalence ratio, my work is:
$$y_{O_2}=\frac{m_{air}}{m_f+m_{air}}=\frac{1}{FA+1}=\frac{1}{\phi\frac{n_{fs}}{n_{air,s}}+1}=\frac{n_{air,s}}{\phi n_{fs}+n_{air,s}}=\frac{1}{2\phi+1}$$
By a similar calculation:
$$y_{H_2}=\frac{n_{fs}\phi}{n_{fs}\phi+n_{air,s}}=\frac{2\phi}{2\phi+1}$$
A quick check that should be true reveals that $y_{H_2}+y_{O_2}=1$
The reason I am asking about this calculation is that I did this calculation for a previous project and the results the class said was correct was the reverse (i.e. the expression with $\phi$ in the numerator was for $y_{O_2}$ not $y_{H_2}$. Is there something I did wrong/did I calculate them the wrong way round? The code I am basing my previous work off of (written in MATLAB) is:
yO = 32/(4*phi+32);
yH = 4*phi/(4*phi+32);
The 32 crops up because the molar mass of $O_2$ was in the expression for some reason and I have not been able to figure out exactly how the above code expressions were derived. I just know they gave results that were marked correct for the class I did this for.
EDIT: I have figured out the source of my confusion. The statement
$$\phi=\frac{FA}{FA_s}=\frac{\frac{m_f}{m_{air}}}{\frac{m_{fs}}{m_{air,s}}}=\frac{\frac{n_f}{n_{air}}}{\frac{n_{fs}}{n_{air,s}}}$$
is true by itself, but this does not mean that $FA_s=\frac{n_{fs}}{n_{air,s}}$! I made this assumption in my head after I canceled out the molar masses used to transform the masses into moles.
The correct expressions are: $$y_{O_2} = \frac{n_{o,s}M_O}{\phi n_{f,s}{M_f}+n_{o,s}M_O}$$
and
$$y_{H_2} = \frac{\phi n_{f,s}M_f}{\phi n_{f,s}{M_f}+n_{O,s}M_O}$$