We know (from years of Chemistry classes) how to balance an equation:

$N_2 + 3H_2 \Longleftrightarrow 2NH_3$

We will write this type of reaction in the following form, replacing each chemical species with a generic $A_i$ identifier:

$\nu_1A_1 + \nu_2A_2 \Longleftrightarrow \nu_3A_3$

where we are using $\nu_i$ to denote the stoichiometric coefficients where we would consider $\nu_1 = -1$, $\nu_2 = -3$, and $\nu_3 = +2$ so that, in general, "reactants" would have $\nu_i<0$ and "products" would have $\nu_i>0$.

We put the reactants and products in quotes since, depending on the initial distribution of chemical species, the reaction can really go in either direction. Here, we will consider "products" to mean chemical species on the right-hand-side.

Since there is one degree of freedom when determining the $\nu_i$ values (that is, you can arbitrarily multiply all of them by any value you like as long as they maintain the same ratios), it is useful to consider changes in the number of moles of each species as ratios, so:

$\frac{dn_1}{dn_2}=\frac{\nu_1}{\nu_2}$

or that the ratio of the change in moles of any two species is
equal to the ratio of their stoichiometric coefficients. Writing
one of these expressions for *each* component and then
rearranging gives

$\frac{dn_1}{\nu_1}=\frac{dn_2}{\nu_2}=\frac{dn_3}{\nu_3}=\frac{dn_i}{\nu_i}$

We use this expression to define the **extent of reaction
or reaction coordinate** as:

$\frac{dn_i}{\nu_i}=d\xi$

Rearranging this and integrating gives a general reactive material balance for any component, $i$,

$n_i = n_{i_o} + \nu_1\xi$

where we need to note that $n_{i_o}$ is the number of moles of species $i$ present prior to the reaction occurring.

If we want to calculate a mole fraction, we need to determine the total numberof moles, so we sum these up

$n_{tot} = \sum_i n_i = \sum_i n_{i_o} + \sum_i \nu_1\xi$

The number of moles is not necessarily a constant. If $\sum_i \nu_i \ne 0$ then $n_{tot}$ changes as the reaction proceeds. Also, we need to note that, when calculating the mole fraction in a multi-phase mixture, we need to use a different material balance in each of the phases.

Using this we get a vapor and liquid phase mole fraction as

$y_i = \frac{n_i^v}{n_{tot}^v} = \frac{n_i^v}{\sum_i n_{i_o}^v + \sum_i (\nu_1\xi)^v}$

$x_i = \frac{n_i^L}{n_{tot}^L} = \frac{n_i^L}{\sum_i n_{i_o}^L + \sum_i (\nu_1\xi)^L}$

Write balance chemical reaction expressions with associate reaction stoichiometry

Calculate the number of moles and mole fraction as a function of the reaction coordinate for the reaction:

$H_2 + \frac{1}{2}O_2 \Longleftrightarrow H_2O$

when we start with 5 moles of $H_2$ and 2 moles of $O_2$. Also, determine the bounds of each variable (that is, what are the maximum and minimum values of $y_i, \xi$, etc.).