# Chapter 10 : Material Balances for Processes Involving Reaction¶

### Example 10.1 Page no. 264¶

In :
F = 100             # feed to the reactor-[g mol]
CH4 = 0.4*F         # [g mol]
Cl2 = 0.5*F ;       # [g mol]
N2= 0.1*F ;         #[g mol]

nio_CH4 = CH4       #[g mol CH4]
vi_CH4 = -1         # coefficint of CH4

# Calculation and Result
ex_CH4 = -(nio_CH4)/vi_CH4        # Max. extent of reaction based on CH4

nio_Cl2 = Cl2 ;                   #[g mol Cl2]
vi_Cl2 = -1 ;                     # coefficint of Cl2
ex_Cl2 = -(nio_Cl2)/vi_Cl2 ;      # Max. extent of reaction based on Cl2

if (ex_Cl2 > ex_CH4 ):
print '  CH4 is limiting reactant  '
else:
print '  (b) Cl2 is limiting reactant  '

cn_CH4 = 67/100.0 ;               # percentage conversion of CH4
ex_r = (-cn_CH4)*CH4/vi_CH4 ;     # extent of reaction

print ' extent of reaction is %.1f g moles reacting '%ex_r

n_un = 11 ;                      # Number of unknowns in the given problem
n_ie = 11 ;                      # Number of independent equations
d_o_f = n_un-n_ie ;              # Number of degree of freedom
print ' Number of degree of freedom for the given system is  %i '%d_o_f

vi_CH3Cl = 1;
vi_HCl = 1;
vi_N2 = 0;
p_CH4 = CH4+(vi_CH4*ex_r);       # [g mol]
p_Cl2 = Cl2+(vi_Cl2*ex_r);       # [g mol]
p_CH3Cl = 0+(vi_CH3Cl*ex_r);     # [g mol]
p_HCl = 0+(vi_HCl*ex_r);         # [g mol]
p_N2 =  N2+(vi_N2*ex_r);         # [g mol]

print 'Composition of product stream in %% g mol of products'
print 'Product            Percentage g mol'
print 'CH4                %.1f%% g mol'%p_CH4
print 'Cl2                %.1f%% g mol'%p_Cl2
print 'CH3Cl              %.1f%% g mol'%p_CH3Cl
print 'HCl                %.1f%% g mol'%p_HCl
print 'N2                 %.1f%% g mol'%p_N2

  CH4 is limiting reactant
extent of reaction is 26.8 g moles reacting
Number of degree of freedom for the given system is  0
Composition of product stream in %% g mol of products
Product            Percentage g mol
CH4                13.2% g mol
Cl2                23.2% g mol
CH3Cl              26.8% g mol
HCl                26.8% g mol
N2                 10.0% g mol


### Example 10.2 Page no. 266¶

In :
# Variables
S = 5000. ;              # Sulphur [lb]
CH4 =  80. ;             # [%]
H2S =  20.;              # [%]

n_un = 11. ;
n_ie  = 11. ;

# Calculation and Result
d_o_f =  n_un-n_ie ;
print 'Number of degree of freedom for the given system is  %i '%d_o_f

m_S = 32.0              #molecular wt. of S -[lb]
mol_S = S/32.0;
nio_S = 0               #[g mol S]
ni_S = mol_S ;          #[g mol S]
vi_S = 3.               # coefficint of S -from given reaction
ex_r = (ni_S-nio_S)/vi_S ;     #  Extent of reaction based on S
print ' Extent of reaction is %.1f g moles reacting '%ex_r

vi_H2O = 2. ;             # coefficint of H2O
vi_H2S = -2. ;            # coefficint of H2S
vi_SO2 = -1. ;            #coefficint of SO2
vi_CH4 = 0 ;              #coefficint of CH4
P_H2O = 0+(vi_H2O*ex_r);  # [lb mol]
P_H2S = P_H2O/10 ;        #[lb mol]
P_SO2 = 3.*P_H2S ;        #[lb mol]

F = (P_H2S-vi_H2S*ex_r)/(H2S/100) ;          # total feed-[lb mol]
F_SO2 = P_SO2-(vi_SO2*ex_r);                 # feed rate of SO2- [lb mol]
F_CH4 = (CH4/100.)*F+vi_CH4*ex_r ;           #feed rate of CH4- [lb mol]
F_H2S = ((H2S/100.)*F) ;                     # feed rate of H2S-[lb mol]

f_cn = -(vi_H2S*ex_r)/((H2S/100.)*F)         # Fractional conversion of limiting reagent

print '(1)Feed rate of H2S-  %.1f lb mol'%F_H2S
print '(2)Feed rate of SO2-  %.1f lb mol'%F_SO2
print '(3)Fractional conversion of limiting reagent-  %.2f '%f_cn

Number of degree of freedom for the given system is  0
Extent of reaction is 52.1 g moles reacting
(1)Feed rate of H2S-  114.6 lb mol
(2)Feed rate of SO2-  83.3 lb mol
(3)Fractional conversion of limiting reagent-  0.91


### Example 10.3 Page no. 270¶

In :
# Variables
F = 1                      #CH3OH -[gmol]
f_cn = 90.                 #[%]
vi_CH3OH = -1.             #coefficint of CH3OH

# Calculation and Result
ex_r1 = (-90./100)/vi_CH3OH       #  Extent of reaction based on CH3OH
print ' Extent of reaction 1 is %.2f g moles reacting '%ex_r1

yld = 75.                         #[%]
ex_r2 = ex_r1-(F*(yld/100.0));
print '  Extent of reaction 2 is %.2f g moles reacting '%ex_r2

f_O2 = 0.21                      # mol. fraction of O2
f_N2 = 0.79                      # mol. fraction of N2
n_O2 = 2*((1/2.0)*F)             # entering oxygen -[g mol]
air =  n_O2/f_O2                 # Amount of air entering
n_N2 = air-n_O2                  # entering nitrogen -[g mol]

n_un = 11.                       # Number of unknowns in the given problem
n_ie  = 11.                      # Number of independent equations
d_o_f =  n_un-n_ie               # Number of degree of freedom
print '  Number of degree of freedom for the given system is  %i '%d_o_f

v1_CH3OH = -1                    #coefficint of CH3OH
v1_O2 = -1./2                    #coefficint of O2
v1_CH2O = 1 ;                    #coefficint of CH2O
v1_H2O = 1 ;                     #coefficint of H2O
v1_CO = 0  ;                     #coefficient of CO

#Reaction 2
v2_O2 = -1./2                    #coefficint of O2
v2_CH2O = -1                     #coefficint of CH2O
v2_H2O = 1 ;                     #coefficint of H2O
v2_CO = 1 ;                      #coefficient of CO
P = F+air +(v1_CH3OH+v1_O2+v1_CH2O+v1_H2O)*ex_r1 +(v2_O2+v2_CH2O+v2_H2O+v2_CO)*ex_r2 ;# Product -[g mol]

no_CH3OH = F+(v1_CH3OH*ex_r1)+0 ;             # [g mol]
no_O2 = n_O2+(v1_O2*ex_r1)+v2_O2*ex_r2 ;      # [g mol]
no_CH2O = 0 + v1_CH2O*ex_r1 +v2_CH2O*ex_r2 ;  #[g mol]
no_CO =  0+v1_CO*ex_r1 +v2_CO*ex_r2 ;         #[g mol]
no_H2O = 0+v1_H2O*ex_r1+v2_H2O*ex_r2 ;        # [g mol]
no_N2 =  n_N2-0-0 ;                           # [g mol]

y_CH3OH = (no_CH3OH/P )*100 ;                 # mole %
y_O2 = (no_O2/P)*100 ;                        # mole %
y_CH2O = (no_CH2O/P)*100 ;                    # mole %
y_CO = (no_CO/P)*100 ;                        # mole %
y_H2O = (no_H2O/P)*100 ;                      # mole %
y_N2 = (no_N2/P )*100;                        # mole %

print 'Composition of product'
print 'Component        mole percent'
print ' CH3OH           %.1f %%'%y_CH3OH
print ' O2              %.1f %%'%y_O2
print ' CH2O            %.1f %%'%y_CH2O
print ' CO              %.1f %%'%y_CO
print ' H2O             %.1f %%'%y_H2O
print ' N2              %.1f %%'%y_N2

 Extent of reaction 1 is 0.90 g moles reacting
Extent of reaction 2 is 0.15 g moles reacting
Number of degree of freedom for the given system is  0
Composition of product
Component        mole percent
CH3OH           1.6 %
O2              7.6 %
CH2O            11.9 %
CO              2.4 %
H2O             16.7 %
N2              59.8 %


### Example 10.4 Page no. 273¶

In :
from numpy import matrix

# Variables
F = 4000. ;                  #[kg]
m_H2O = 18.02 ;              # molecular masss of water
m_C6H12O6 = 180.1 ;          # molecular mass of glucose
m_CO2 = 44. ;                #molecular mass of CO2
m_C2H3CO2H = 72.03 ;         # molecular mass of C2H3CO2H
m_C2H5OH = 46.05 ;           # molecular mass of ethanol

p_H2O = 88. ;                # [%]
p_C6H12O6 = 12.;             # [%]

# Calculation & Result
ni_H2O = (F*p_H2O/100.)/m_H2O ;                    # initial moles of water
ni_C6H12O6 = (F*(p_C6H12O6/100.))/m_C6H12O6 ;      # initial moles of glucose

n_un = 9.
n_ie  = 9.
d_o_f =  n_un-n_ie
print 'Number of degree of freedom for the given system is  %i '%d_o_f

ur_C6H12O6 =  90. ;                        #[kg]
pr_CO2 = 120. ;                            #[kg]
nf_C6H12O6 = ur_C6H12O6/m_C6H12O6 ;        # [kmoles]
nf_CO2 = pr_CO2/m_CO2 ;                    # [kmoles]

a = matrix([[-1,-1],[2,0]]);               # matrix formed by coefficients of unknowns
b = matrix([[(nf_C6H12O6-ni_C6H12O6)],[nf_CO2]]);      #matrix formed by constant
x = a**(-1)*b;                             #matrix formed by solution

print ' Extent of reaction 1 is %.3f kg moles reacting '%x
print ' Extent of reaction 2 is %.3f kg moles reacting '%x

nf_H2O = ni_H2O+0*x +2*x;
nf_C2H5OH = 0+2*x+0*x;
nf_C2H3CO2H = 0+0*x+2*x
total_wt = m_H2O*nf_H2O + m_C6H12O6*nf_C6H12O6 + m_CO2*nf_CO2 + \
m_C2H3CO2H*nf_C2H3CO2H + m_C2H5OH*nf_C2H5OH;
mp_C2H5OH = (m_C2H5OH*nf_C2H5OH*100)/total_wt
mp_C2H3CO2H = (m_C2H3CO2H*nf_C2H3CO2H*100)/total_wt

print '  Mass percent of ethanol in broth at end of fermentation process is  %.1f %%'%mp_C2H5OH
print ' Mass percent of propenoic acid  in broth at end of fermentation process is  %.1f %%'%mp_C2H3CO2H

Number of degree of freedom for the given system is  0
Extent of reaction 1 is 1.364 kg moles reacting
Extent of reaction 2 is 0.802 kg moles reacting
Mass percent of ethanol in broth at end of fermentation process is  3.1 %
Mass percent of propenoic acid  in broth at end of fermentation process is  2.9 %


### Example 10.5 Page no. 279¶

In :
from numpy import matrix

# Variables

print '(a)Solution of Example 10.1 using element balance'
F = 100                   # feed to the reactor-[g mol]

CH4 =  0.4*F ;             # [g mol]
Cl2 =  0.5*F ;             # [g mol]
N2 =  0.1*F                #[g mol]

n_un = 10                  # Number of unknowns in the given problem(excluding extent of reaction)
n_ie  = 10 ;               # Number of independent equations
d_o_f =  n_un-n_ie         # Number of degree of freedom
print '    Number of degree of freedom for the given system is  %i '%d_o_f

nio_CH4 = CH4 ;            #[g mol CH4]
vi_CH4 = -1;               # coefficint of CH4

# Calculation and  Result
ex_CH4 = -(nio_CH4)/vi_CH4 ;      # Max. extent of reaction based on CH4

nio_Cl2 =  Cl2             #[g mol Cl2]
vi_Cl2 = -1                # coefficint of Cl2
ex_Cl2 = -(nio_Cl2)/vi_Cl2       # Max. extent of reaction based on Cl2

if (ex_Cl2 > ex_CH4 ):
print '    CH4 is limiting reactant  '
else:
print '  (b) Cl2 is limiting reactant  '

cn_CH4 =  67.0/100          # percentage conversion of CH4(limiting reagent)
no_CH4 = CH4-(cn_CH4*CH4) ; #CH4 in product -[g mol]

no_N2 = N2                  #N2 in product -[g mol]

C = CH4 ;                   #moles of CH4  =  moles of C (by molecular formula)
H = 4*CH4 ;                 # moles of H  =  4*moles of CH4 (by molecular formula)
Cl = 2*Cl2 ;                # moles of Cl = 2* moles of Cl2 (by molecular formula)

a = matrix([[0,0,1],[0,1,3],[2,1,1]])            # matrix formed by coefficients of unknowns
b = matrix([[C-no_CH4*1],[H-4*no_CH4],[Cl]]) ;   #matrix formed by constant
x = a**(-1)*b ;                                  # matrix of solution

print 'Composition of product stream in %% g mol of products'
print 'Product            Percentage g mol'
print 'CH4                %.1f%% g mol'%no_CH4
print 'Cl2                %.1f%% g mol'%x
print 'CH3Cl              %.1f%% g mol'%x
print 'HCl                %.1f%% g mol'%x
print 'N2                 %.1f%% g mol'%no_N2

#(b)Solution of Example 10.3 using element balance
print '______________________________________________________________________________'
print '(b)Solution of Example 10.3 using element balance'

F = 1              #CH3OH -[gmol]
yld = 75           #[%]
cnv = 90 ;         #conversion of methanol-[%]

f_O2 = 0.21 ;      # mol. fraction of O2
f_N2 = 0.79 ;      # mol. fraction of N2
n_O2 = 2*((1/2.0)*F)           # entering oxygen -[g mol]
air =  n_O2/f_O2 ;             # Amount of air entering
n_N2 = air-n_O2                # entering nitrogen -[g mol]

n_un = 9           # Number of unknowns in the given problem(excluding extent of reactions)
n_ie  = 9 ;        # Number of independent equations
d_o_f =  n_un-n_ie      # Number of degree of freedom

print '  Number of degree of freedom for the given system is  %i '%d_o_f

no_N2 = n_N2        # inert ,terefore input  =  output
C = 1*F             #moles of C  =  moles of CH3OH (by molecular formula)
H = 4*F ;           #moles of H  =  4*moles of CH3OH (by molecular formula)
O =  1*F +2*n_O2;   # moles of O =  1*moles of CH3OH + O in air
no_CH2O = yld/100.0 #[g mol]
no_CH3OH = F-((cnv/100.0)*F)      # [g mol]

a = matrix([[0,0,1],[0,2,0],[2,1,1]])            # matrix formed by coefficients of unknowns
b = matrix([[(C-(no_CH3OH*1+no_CH2O*1))],[(H-(4*no_CH3OH+2*no_CH2O))],[(O-(no_CH3OH*1+no_CH2O*1))]]);
a = a.I
x = a * b ;                                      # matrix of solution

P = no_CH2O+no_CH3OH+no_N2+x+x+x;

# Composition of product
y_CH3OH = (no_CH3OH/P )*100;        # mole %
y_O2 = ((x)/P)*100;              # mole %
y_CH2O = (no_CH2O/P)*100 ;          # mole %
y_CO = (x/P)*100 ;               # mole %
y_H2O = (x/P)*100 ;              # mole %
y_N2 = (no_N2/P )*100;              # mole %

print 'Composition of product'
print 'Component        mole percent'
print ' CH3OH           %.1f %%'%y_CH3OH
print ' O2              %.1f %%'%y_O2
print ' CH2O            %.1f %%'%y_CH2O
print ' CO              %.1f %%'%y_CO
print ' H2O             %.1f %%'%y_H2O
print ' N2              %.1f %%'%y_N2

(a)Solution of Example 10.1 using element balance
Number of degree of freedom for the given system is  0
CH4 is limiting reactant
Composition of product stream in %% g mol of products
Product            Percentage g mol
CH4                13.2% g mol
Cl2                23.2% g mol
CH3Cl              26.8% g mol
HCl                26.8% g mol
N2                 10.0% g mol
______________________________________________________________________________
(b)Solution of Example 10.3 using element balance
Number of degree of freedom for the given system is  0
Composition of product
Component        mole percent
CH3OH           1.6 %
O2              7.6 %
CH2O            11.9 %
CO              2.4 %
H2O             16.7 %
N2              59.8 %


### Example 10.6 Page no. 281¶

In :
from numpy import matrix

# Variables
P=100. ;                   #Product from the reactor-[g mol]
C3H8 = 0.195*P ;           # [g mol]
C4H10 = 0.594*P ;          # [g mol]
C5H12 = 0.211*P;           # [g mol]

n_un = 3 ;                 # Number of unknowns in the given problem(excluding extent of reaction)
n_ie  = 3 ;                # Number of independent equations

# Calculation and Result
d_o_f =  n_un-n_ie ;       # Number of degree of freedom
print 'Number of degree of freedom for the given system is  %i '%d_o_f

C = C3H8*3+C4H10*4+C5H12*5        # moles of C on product side
H = C3H8*8+C4H10*10+C5H12*12 ;    # moles of H on product side

a = matrix([[8,0],[18,2]])        # matrix formed by coefficients of unknowns
b = matrix([[C],[H]]) ;           #matrix formed by constant
a = a.I
x = a*b ;                         # matrix of solution

R = x/x ;                   # Ratio of H2 consumed to C8H18 reacted  = G/F
print ' Molar ratio of H2 consumed to C8H18 reacted is %.3f  '%R

Number of degree of freedom for the given system is  0
Molar ratio of H2 consumed to C8H18 reacted is 0.992


### Example 10.7 Page no. 286¶

In :
# Variables
C3H8 = 20                #C3H8 burned in a test-[kg]
m_C3H8 = 44.09           # mol. wt . of 1 kmol C3H8
cf_O2 = 5                # coefficient of O2 in given reaction
air = 400                # Air given -[kg]
m_air = 29.0             # molecular wt. of  1kmol air-[kg]
O2p = 21                 # percentage of O2 in air-[%]
p_CO2 =  44              # CO2 produced -[kg]
p_CO = 12                # CO produced -[kg]

# Calculation
O2 = (air*O2p/100.0)/(m_air)      # amount of entering O2-[k mol]
rqO2 = (C3H8*cf_O2)/(m_C3H8)      # Required O2 for given reaction
ex_air = ((O2-rqO2)*100.0)/rqO2 ;  # Excess air percent-[%]

# Result
print 'Excess air percent is %.0f %%.'%ex_air

Excess air percent is 28 %.


### Example 10.8 Page no. 287¶

In :
# Variables
F = 16.               # feed of CH4 -[kg]
CH4p = 100.           #[%]
m_CH4 = 16. ;         # mass of kmol of CH4-[kg]
mol_CH4 = (F*CH4p/100)/m_CH4         #k moles of CH4 in feed-[kmol]
air = 300. ;                         # Air given -[kg]
m_air = 29.                          # molecular wt. of  1kmol air-[kg]
mol_air = air/m_air ;                # kmoles of air-[kmol]
O2p = 21.                            # percentage of O2 in air-[%]
O2 = (mol_air*O2p/100)               # amount of entering O2-[k mol]
N2 = mol_air-O2 ;                    # amount of entering N2-[k mol]

n_un = 8.                   # Number of unknowns in the given problem(excluding extent of reactions)
n_ie  = 8.                  # Number of independent equations
d_o_f =  n_un-n_ie          # Number of degree of freedom
print 'Number of degree of freedom for the given system is  %i '%d_o_f

# Product composition analysis using element balance of C,H,O and N
p_N2 = N2                   # inert
C_in = 1*mol_CH4 ;          # kmoles of carbon in input-[kmol]
H_in = 4*mol_CH4            # kmoles of hydrogen in input-[kmol]
O_in = 2*O2 ;               # kmoles of oxygen in input-[kmol]
p_CO2 = C_in/1 ;            #kmoles of  CO2 in product obtained  by carbon balance-[kmol]
p_H2O = H_in/2 ;            #kmoles of  H2O in product obtained  by hydrogen balance-[kmol]
p_O2 = (O_in-(2*p_CO2+p_H2O))/2         #kmoles of  O2 in product obtained  by oxygen balance-[kmol]
p_CH4 = 0                   # Complete reaction occurs
P = p_CH4 + p_N2+  p_CO2 + p_H2O + p_O2;

y_N2 = p_N2*100/P ;         #[mol %]
y_CO2 = p_CO2*100/P ;       #[mol %]
y_H2O = p_H2O*100/P ;       #[mol %]
y_O2 = p_O2*100/P ;         #[mol %]
y_CH4 = p_CH4*100/P ;       #[mol %]

# Results
print 'Composition of product'
print 'Component        mole percent'
print ' CH4             %.1f %%'%y_CH4
print ' O2              %.1f %%'%y_O2
print ' CO2             %.1f %%'%y_CO2
print ' H2O             %.1f %%'%y_H2O
print ' N2              %.1f %%'%y_N2

Number of degree of freedom for the given system is  0
Composition of product
Component        mole percent
CH4             0.0 %
O2              1.5 %
CO2             8.8 %
H2O             17.6 %
N2              72.0 %


### Example 10.9 Page no. 290¶

In :
# Variables
F = 100.                 # feed of coal -[lb]
C = 83.05                #[%]
H = 4.45                 #[%]
O = 3.36 ;               # [%]
N = 1.08                 # [%]
S = 0.70                 #[%]
ash = 7.36               #[%]
H2O = 3.9 ;              #[%]
w_C = 12. ;              # mol. wt. of C
w_H =  1.008;            #mol. wt. of H
w_O = 16. ;              # mol. wt. of O
w_N = 14. ;              # mol. wt. of N
w_S = 32.  ;             #mol. wt. of S

CO2 =  15.4              #[%]
CO = 0.0                 #[%]
O2 = 4.0 ;               # [%]
N2 = 80.6                #[%]
ash_R = 86               #[%]
odr = 14                 #[%]

H2O_air =  .0048         # [lb H2O/lb dry air]
m_air = 29.              # mol. wt. of air
mf_O2 = 0.21             # mole fraction of  O2 in air
mf_N2 = 0.79             #mole fraction of  N2 in air
m_H2O =  18.             # mol. wt. of H2O

#Calculations
H_cl = (H2O*2)/m_H2O ;   # lb mol of H in coal moisture
O_cl = H_cl/2. ;         # lb mol of O in coal moisture

H_air = (H2O_air*m_air )/m_H2O      # lb mol of H per lb mol air
O_air = H_air/2.                    # lb mol of O per lb mol  air

# Ash balance to get refuse(R)
R = ash/(ash_R/100.)              # Refuse-[lb]

pub_cl = 14.                      # percentage of unburned coal in refuse-[%]
ub_cl =  (14/100.)*R              # amount of unburned coal in refuse
C_p = (C/(100-ash))*ub_cl         #  C in unburned coal-[lb]
H_p = (H/(100-ash))*ub_cl ;       #  H in unburned coal-[lb]
O_p =  (O/(100-ash))*ub_cl ;      #  O in unburned coal-[lb]
N_p =  (N/(100-ash))*ub_cl ;      #  N in unburned coal-[lb]
S_p =  (S/(100-ash))*ub_cl ;      #  S in unburned coal-[lb]
mol_C =  C_p/w_C;                 # lb mol of C
mol_H = H_p/w_H ;                 # lb mol of H
mol_N = N_p/w_N ;                 # lb mol of N
mol_O = O_p/w_O ;                 # lb mol of O
mol_S = S_p/w_S ;                 # lb mol of S

n_un = 4.                         # Number of unknowns in the given problem(excluding extent of reactions)
n_ie  = 4.                        # Number of independent equations
d_o_f =  n_un-n_ie                # Number of degree of freedom
print 'Number of degree of freedom for the given system is  %i '%d_o_f

#Using element balance of C+S, N& H
P = (C/w_C + S/w_S - (mol_C+mol_S ))/.154        # mol of stack gas-[lb mol]
A = (2*P*.806 +2*mol_N-N/w_N)/(2*mf_N2)          # mol of air -[lb mol]
W = (H/w_H +H_cl+H_air*A-mol_H)/2                # moles of exit water-[lb mol]
print ' Moles of stack gas(P)   -      %.1f  lb mol'%P
print ' Moles of air (A)        -      %.1f lb mol '%A
print ' Moles of exit water(W)  -      %.1f lb mol '%W

C_req =  (C/w_C)/1
H_req = (H/w_H)/4
N_req = 0                   # inert
O_req = (O/w_O)/2
S_req = (S/w_S)/1
total_O2_req =  C_req+H_req+N_req+O_req +S_req
O2_in = A*mf_O2             # O2 entering in air
ex_air = 100*((O2_in-total_O2_req)/total_O2_req)

# Results
print ' Excess air is %.1f %%.'%ex_air

Number of degree of freedom for the given system is  0
Moles of stack gas(P)   -      44.5  lb mol
Moles of air (A)        -      45.4 lb mol
Moles of exit water(W)  -      2.6 lb mol
Excess air is 16.8 %.

In [ ]: