© 2022 Horia Metiu

WorkBookT.21. Chemical equilibrium of coupled reactions

WorkBookT.21.1. The extent of reaction and the equilibrium constants for two coupled reactions

I will study the reactions
	(Subscript[C, gr])+(1/2)(Subscript[O, 2])(g) = CO(g)				(Subscript[K, 1]) = 1			(1)
and 
	CO(g) +(1/2)(Subscript[O, 2])(g) =(Subscript[CO, 2])(g)			(Subscript[K, 2]) = 2 			(2)
• The equilibrium constants (Subscript[K, 1]) and (Subscript[K, 2]) are fictitious.  I use them to illustrate how one calculates the composition when one knows the equilibrium constant. 
• (Subscript[K, 1]) and (Subscript[K, 2])  were chosen so that a reasonable amount of product is formed and not all the reactants are consumed. 
• I will calculate the equilibrium composition.

Cell 1:  Input data

Off[Remove::rmnsm]
Remove["Global`*"] ;
Needs["Utilities`CleanSlate`"];
CleanSlate[];

The reactions are;
	(Subscript[C, gr])+(1/2)(Subscript[O, 2])(g) = CO(g)				(1)
and 
	CO(g) +(1/2)(Subscript[O, 2])(g) =(Subscript[CO, 2])(g)			(2)
For numerical evaluations use
		 (Subscript[K, 1])=1 and (Subscript[K, 2])=0.1
and 
	(n^0)(C)=3  (n^0)((Subscript[O, 2]))=1  (n^0)(CO)=0  (n^0)((Subscript[CO, 2]))=0

Note that one mole of (Subscript[O, 2]) consumes two mole of carbon.  I start with one mole of oxygen and three mole of carbon.  These amounts were chosen so that the reactions do not stop because they consumed all the carbon.

Create lists with the data.  The list compounds contains the names of the chemicals involved in the reactions

compounds={"(Subscript[O, 2])","CO","(Subscript[CO, 2])"};

The list compounds1 one contains the names of the chemicals involved in reaction B.

compounds1={ "(Subscript[O, 2])(g)", "CO(g)","(Subscript[CO, 2])(g)"} ;

The list compounds2 one contains the names of the chemicals involved in reaction 2.

compounds2={"(Subscript[C, gr])", "CO(g)", "(Subscript[O, 2])(g)"};

The list ν contains two sublists.  The first has the stoichiometric coefficients of reaction 1; the second those of reaction 2.

ν={{-1/2,1,0},{-1/2,0,1}};

The list n0 contains the initial number of moles.

n0={1,0.0,0.0};

It is important that all the lists follow the pattern used in the compound lists

Cell 2: The number of moles, the molar fractions and the equilibrium constants.

I use the formulae given in Chapter 21, for the number of moles n and the molar fractions x

The reactions are 
	(Subscript[C, gr])+(1/2)(Subscript[O, 2])(g) = CO(g)	 			(1)
	CO(g) +(1/2)(Subscript[O, 2])(g) =(Subscript[CO, 2])(g)			(2)

The number of moles are given by (see Chapter 21, §9):
n((Subscript[O, 2]); (Subscript[ξ, 1]), (Subscript[ξ, 2])) = (n^0)((Subscript[O, 2])) - (1/2)((Subscript[ξ, 1]) +  (Subscript[ξ, 2]))
n(CO; (Subscript[ξ, 1]), (Subscript[ξ, 2])) = (n^0)(CO) +  ((Subscript[ξ, 1]) -  (Subscript[ξ, 2]))
n((Subscript[CO, 2]); (Subscript[ξ, 1]), (Subscript[ξ, 2])) = (n^0)((Subscript[CO, 2])) +   (Subscript[ξ, 2])
n(C; (Subscript[ξ, 1]), (Subscript[ξ, 2])) = (n^0)(C) - (Subscript[ξ, 1]) 
Note that it appears that the number of moles of carbon does not affect the extent of reaction (n(C) is not present in these equations.  This is not quite true.  The reaction will stop if the system runs out of carbon.  This means that 
	n(C; (Subscript[ξ, 1]), (Subscript[ξ, 2])) > 0 
which means 
	 (n^0)(C) - (Subscript[ξ, 1]) > 0 
or 
	(Subscript[ξ, 1]) <(n^0)(C)
I picked the initial amounts so that we are not running out of carbon.  If I did not do that I would have to use the inequality as a condition when I calculate (Subscript[ξ, 1]) and (Subscript[ξ, 2])

The number of moles are

n=n0+{-(ξ1+ξ2)/2,ξ1-ξ2,ξ2}

The initial number of moles of graphite is not included because graphite does not mix with the cases (does not dissolve in the gas). The molar fractions are

x=n/Plus@@n//FullSimplify

Display the results

TableForm[Transpose[{compounds, n,x}], TableHeadings->{None,{"Compound","n(i;(Subscript[ξ, 1]),(Subscript[ξ, 2]))","x(i;(Subscript[ξ, 1]),(Subscript[ξ, 2]))"}}]

Cell 3: The equilibrium constants as a function of (Subscript[ξ, 1]) and (Subscript[ξ, 2])

The equilibrium constants depend on the extent of reactions and the initial number of moles

The stoichiometric coefficients of reaction 1 are

ν[[1]]

The molar fractions are

x

The rate constant of the  reaction
	(Subscript[C, gr])+(1/2)(Subscript[O, 2])(g) = CO(g)	
is
	(Subscript[K, 1]) = ((x(CO))/((x(O2))^(1/2)))

K1=Times@@( x^ν[[1]])

The rate constant of reaction 2 is

K2=Times@@( x^ν[[2]])

Cell 4:  Calculate (Subscript[ξ, 1]) and (Subscript[ξ, 2])

You know that the equilibrium constants are 
	(Subscript[K, 1]) = 1 and (Subscript[K, 2]) = 2.  				(3)
Expressing (Subscript[K, 1]) and (Subscript[K, 2]) in terms of (Subscript[ξ, 1]) and (Subscript[ξ, 2]) gives two equations.  I solve them to get (Subscript[ξ, 1]) and (Subscript[ξ, 2]).

equations={1==K1,2==K2}

sol=Solve[equations,{ξ1,ξ2}]//Flatten

Both reactions go to the right ( the extents of reactions are positive).   I expect that.  Because (Subscript[K, 1])= 1 and (Subscript[K, 2]) = 2, which means that a substantial amount of product is formed in both reactions. 
NOTE: we are lucky.  For a more complicated reaction system one gets more than one solution and one has to do quite a bit of analysis to decide which solution is physically meaningfull.

Calculate the equilibrium molar fractions

xe=x/.sol

Calculate the number of moles at equilibrium

{compounds,ne=n/.sol}

The initial number of moles were

{compounds,n0}

The reactions consume oxygen, produce CO and produce (Subscript[CO, 2]) 
	(Subscript[C, gr])+(1/2)(Subscript[O, 2])(g) = CO(g)			(Subscript[K, 1]) = 1		(1)
	CO(g) +(1/2)(Subscript[O, 2])(g) =(Subscript[CO, 2])(g)		(Subscript[K, 2]) =2		(2)

Calculate the number of moles of graphite at equilibrium.  We had initially 3 moles of graphite.

nC=3-ξ1/.sol

Display the results:

TableForm[Transpose[{compounds,n0,ne,xe}],TableHeadings->{None,{"compound","(n^0)","(Subscript[n, e])","(Subscript[x, e])"}}]

The molar fraction of graphite is one and the number of moles at equilibrium is 2.033.

WorkBookT.21.2.  Calculate the equilibrium concentration in a system undergoing three coupled reactions

Cell 1: Specify the notation and the problem

The reactions are
	C2H5OH = C2H4+H2O					(1)
	C2H5OH = CH3CHO + H2					(2)
	C2H4 + CH3CHO = C4H6 + H2O			(3)
	 
• The reactions are run at a temperature and a pressure for which the equilibrium constants are 
	(Subscript[K, 1]) = 0.8									(4)
	(Subscript[K, 2]) = 0.9									(5)
	(Subscript[K, 3]) = 1.2									(6)
• These are fictitious equilibrium constant.  I use this data to show how one calculates the equilibrium composition.

I specify the notation.  
• I have three reaction.  To specify them I use the letter α = 1, 2, 3. For example, α = 2 indicates a quantity that pertains to the second reaction.
• There are six compounds and for each reaction I need to define six stoichiometric coefficients.  They are denoted ν(i, α), where i labels the compound and α the reaction. 
• The equilibrium constant of the reaction α is
	(Subscript[K, α]) =(∏_( i=1)^( 6))((x(i))^(ν(i,α)))					(7)
• The molar fractions are 
	x(i) = n(i)/(∑_( i=1)^( 6))n(i)						(8)
• The number of moles are 
	n(i)=(n^0)(i) + (∑_( α=1)^( 3))ν(i,α) (Subscript[ξ, α])				(9)
Here (Subscript[ξ, α]) is the extent of reaction for reaction α.  
• Eq. 9 takes into account that a compound may be involved in several reactions.

• By inserting the molar fractions in the three equations for (Subscript[K, α ]) (given by Eqs. 7) I express (Subscript[K, 1]),(Subscript[K, 2]), and (Subscript[K, 3]) in terms of the three extent of reactions (Subscript[ξ, 1]), (Subscript[ξ, 2]), and  (Subscript[ξ, 3]).
• I will solve these equations for the extent of reaction and use the results to calculate the number of moles and the molar fractions at equilibrium (from Eqs. 5 and 6)

Cell 2: Input data

Input the stoichiometric coefficients, the initial number of moles and the values of the equilibrium constants.

Make a list of all the compounds involved in the coupled reactions.

Off[Remove::rmnsm]
Remove["Global`*"] ;
Needs["Utilities`CleanSlate`"];
CleanSlate[];

compounds={"(Subscript[C, 2])(Subscript[H, 5])OH","(Subscript[C, 2])(Subscript[H, 4])","(Subscript[H, 2])O","(Subscript[CH, 3])CHO","(Subscript[H, 2])","(Subscript[C, 4])(Subscript[H, 6])"}

Make a list of the stoichiometric coefficients for the three reaction.  Give a zero coefficient to a compound that does not participate in a given reaction reaction.  For example, the first list, {-1,1,1,0,0,0}, corresponds to the first reaction. It tells me that stoichiometric coefficient of (Subscript[C, 2])(Subscript[H, 5])OH is -1 (ethanol is consumed), that  (Subscript[C, 2])(Subscript[H, 4]) is produced and  (Subscript[H, 2])O is produed. No other compound participates in the reaction 1.

nu={{-1,1,1,0,0,0},{-1,0,0,1,1,0},{0,-1,1,-1,0,1}}

TableForm[{compounds, nu[[1]],nu[[2]],nu[[3]]},
TableHeadings->{{"", "ν(i,1)","ν(i,2)","ν(i,3)"},None}]

Define a function that given the stoichiometric coefficients and the list of compound, prints out the reaction. The purpose is to test whether the lists with the stoichiometric coefficients are correct.  If you are not interested in improving your Mathematica programing skill you need not understand how this function works. You don’t have to use it in what follows

rea[nu_List,compounds_List]:=
Module[{left={},right={}},
For[i=1,i<=Length[nu],i++,
      If[nu[[i]]==0,Null,
         If[nu[[i]]<0,
         AppendTo[ left,-nu[[i]]*compounds[[i]] ] ,
         AppendTo[ right,nu[[i]]*compounds[[i]] ] 
           ];
        ];
   ];
   Print[Apply[Plus,left]," = ",Apply[Plus,right]]
      ]

Check that the stoichiometric coefficients are correct:

rea[nu[[1]],compounds]

rea[nu[[2]],compounds]

rea[nu[[3]],compounds]

The lists with the stoichiometric coefficients are correct.

The equilibrium constants:

K={ 0.8,0.9,1.2}

The initial number of moles:

nInit={0,1,1,0,0,0}

Cell 3: Calculate the number of moles and the molar fractions

Define a function whose arguments are the initial number of moles and the stoichiometric coefficients and whose output are the extents of reactions.  This implements 
	n(i)=(n^0)(i) + (∑_( α=1)^( 3))ν(i,α) (Subscript[ξ, α])			(10)

nbMoles[nInit_List,nu_List]:=
Module[{w=Range[6],n,ξ={ξ1,ξ2,ξ3}},
For[i=1,i<=Length[nInit],i++,
    w[[i]]=nInit[[i]]+Sum[nu[[j,i]]*ξ[[j]],{j,1,Length[nu]}];
   ];
w      ]

Use the function nbMoles to calculate a list of number of moles

compounds
n=nbMoles[nInit,nu]

compounds

These seem OK. The reactions are 
	C2H5OH = C2H4+H2O					(1)
	C2H5OH = CH3CHO + H2					(2)
	C2H4 + CH3CHO = C4H6 + H2O			(3)
The list of compounds is 
{C2H5OH ,C2H4,	H2O,CH3CHO, H2,C4H6 }

Calculate the molar fractions from  
	x(i) = n(i)/(∑_( i=1)^( 6))n(i)

x=n/(Plus@@n)

Display the results obtained so far:

toTable =Transpose[{compounds,nInit,n ,x}]

TableForm[toTable]

TableForm[toTable, TableHeadings-> {None,{"compounds","(Subscript[n, 0])" ,"(Subscript[n, i])","(Subscript[x, i])"} } ]

Cell 4: The equilibrium constants

Use  
	(Subscript[K, α]) =(∏_( i=1)^( 6))((x(i))^(ν(i,α)))
The molar fractions are already expressed in terms of the extent of reactions

Clear[Keq]
Keq[nu_List,x_List,α_Integer]:=Module[{},
Times@@(x^nu[[α]])]

Make a list with the expressions for the equilibrium constants:

KeqList=Table[Keq[nu,x,α] ,{α,1,3}]

Display the expressions for the equilibrium constants:

TableForm[KeqList,TableHeadings->{{"(Subscript[K, 1])", "(Subscript[K, 2])","(Subscript[K, 3])"}, None}]

Cell 5:  Find the extent of reactions

Generate the equations to be solved

eqs=MapThread[{#1==#2}&,{K,KeqList}]//Flatten

Solve the equations:

Off[Solve::ratnz]
sol=Solve[eqs,{ξ1,ξ2,ξ3},Reals]

There are many solutions and only one solves our problem. We find which one by calculating the molar fractions. The ones corresponding to the correct solution are between  zero and one.

xNum=x/.sol

The first solution gives absurd results (e.g. a molar fraction equal to 20.3258).  The second solution is fine.

solOurs=sol[[2]]

Calculate the molar fractions corresponding to this solution:

mf=x/.solOurs

Check that the molar fractions add up to 1

Plus@@mf

Calculate the number of moles at equilibrium

nMoles=n/.solOurs

Display the results. The reactions are 
	C2H5OH = C2H4+H2O					(1)
	C2H5OH = CH3CHO + H2					(2)
	C2H4 + CH3CHO = C4H6 + H2O			(3)

TableForm [Transpose[{compounds, mf,nMoles}], TableHeadings->{None,{"comp","nb moles","molar fraction"}}]

Cell 6:  What happens if we only consider the first reaction?

cond1={ξ2->0,ξ3->0}

To eliminate reaction 2 and 3 I set (Subscript[ξ, 2]) and (Subscript[ξ, 3]) equal to zero.

The equilibrium conditions for the three reactions were

eqs

Get the condition for the reaction one alone

eq1Alone=eqs[[1]]/.cond1

Let us solve it for (Subscript[ξ, 1]):

sol1Alone=Solve[eq1Alone,ξ1]

Calculate the molar fractions to decide which output is physically relevant:

x/.cond1/.sol1Alone

The second solution gives correct molar fractions:

sol1AloneOurs=sol1Alone[[2]]

The solution when all three reactions are considered is:

solOurs

The molar fractions for the case when reaction 1 runs alone are:

x1Alone=x/.cond1/.sol1AloneOurs

Some molar fractions will be zero because of the non-existence of the reactions 2 and 3.  The molar fractions when the three reactions are taken into account are

mf

The number of moles when reaction 1 is alone are very different then when the other reactions are present.  
If you want to get correct results you must include all possible reactions that will affect the compounds involved.

The number of moles when the reaction 1 is run alone:

n1Alone=n/.cond1/.sol1AloneOurs

The number of moles when all three reactions are considered are:

nMoles

Display these results:

toTable=Transpose[{compounds,n1Alone,nMoles}]

TableForm[toTable, TableHeadings->{None,{"compound","nb Moles Alone","nb Moles All"}}]

The reactions are 
	C2H5OH = C2H4+H2O					(1)
	C2H5OH = CH3CHO + H2				(2)
	C2H4 + CH3CHO = C4H6 + H2O                         (3)

When we run reaction 1 alone, we start with ethylene and water and nothing else.  If reaction 1 is performed alone (we can only do that in a calculation; in the laboratory the reaction will do whatever it pleases and 2 and 3 will take place) the reaction 1 makes 0.33 moles of ethanol from one mole of ethylene.  However, if the other to reactions are taken into account we obtain only 0.094 moles of ethanol, from the same initial composition.  Much of the methanol formed in reaction 1 is wasted in reaction 2. Note that LeChatelier principle works. Regard reaction 2 as a disturbance of reaction 1, in which we remove ethanol. According to Le Chatelier principle, the reaction 1 will shift to diminish the effect of our action, that is, to make more ethanol. You can see that from the fact that much more ethylene is consumed when the reactions take place together. The reaction 3 uses up some of the aldehyde produced by Eq. 2 and this (Le Chatelier again) causes reaction 2 to consume more ethanol to produce more aldehyde. 
	In your practice, you should never ignore any reaction that can take place in the system, if they are coupled to the one you study. Note that reaction 3 is not coupled directly to reaction 1; it is however coupled to 2 which is coupled to 1.  Therefore, if we are interested in any one of these three reactions we cannot ignore the other two.
	Exercise: study the equilibrium in the case when you consider 1 and 2 and ignore 3.