Chapter 14 : Thermodynamics of Chemical Reactions

Example 14.1 Page No : 282

In [1]:
#Given
H_f_C2H4 = 12500.0;#Smath.radians(numpy.arcmath.tan(ard heat of formation of ethylene at 25 deg cel in Kcal/Kgmole
H_f_C2H4O = -11667.0;#Smath.radians(numpy.arcmath.tan(ard heat of formation of ethylene oxide at 25 deg cel in Kcal/Kgmole

#To Calculate the smath.radians(numpy.arcmath.tan(ard heats of reaction at 25 deg celsius
#The reaction is: C2H4 + (1/2)O2 - C2H4O
del_H_rxn = H_f_C2H4O-H_f_C2H4;#Since, Smath.radians(numpy.arcmath.tan(ard heat of formation of O2 is zero
print 'The standard heats of reaction at 25 deg celsius is %d Kcal/Kgmole'%(del_H_rxn);
#end
The standard heats of reaction at 25 deg celsius is -24167 Kcal/Kgmole

Example 14.2 Page No : 284

In [2]:
#Given
T1 = 25+273.0;#Initial temperature in K
T2 = 450+273.0;#Final temperature in K
#Specific heat of sulphur dioxide is given by the relation:
#Cp = 7.116+9.512*10**-3*T+(3.511*10**-6)*T**2

#To Calculate the sensible heat required
#Basis: 1 Kgmole of sulphur dioxide
Q = 7.116*(T2-T1)+(9.512*10**-3*(T2**2-T1**2)/2)+((3.51*10**-6)*(T2**3-T1**3)/3);
print 'Sensible heat required is %d Kcal/Kgmole'%(Q);
#end
Sensible heat required is 5499 Kcal/Kgmole

Example 14.3 Page No : 289

In [3]:
#Given
H_C2H4 = 12500;#Smath.radians(numpy.arcmath.tan(ard heat of formation  of ethylene at 25 de cel
H_C2H4O = -12190;#Smath.radians(numpy.arcmath.tan(ard heat of formation of ethylene oxide at 25 deg cel
H_CO2 = -94052;#Smath.radians(numpy.arcmath.tan(ard heat of formation of CO2 at 25 deg cel
H_H2O = -57798;#Smath.radians(numpy.arcmath.tan(ard heat of formation of H2O at 25 deg cel
T1 = 200;#temperature at which mixture entered in deg cel
Ti = 25;#intermediate temperature in deg cel
T2 = 260;#product temperature in deg cel
Cp_air_a = 7;#Mean specific heat for 25 to 200 deg cel in Kcal/Kgmole
Cp_C2H4_a = 18;#Mean specific heat for 25 to 200 deg cel in Kcal/Kgmole
#Mean specific heat for 25 to 260 deg cel in Kcal/Kgmole are given as:
Cp_C2H4_b = 19;
Cp_C2H4O_b = 21;
Cp_O2_b = 7.30;
Cp_N2_b = 7.00;
Cp_CO2_b = 10.00;
Cp_H2O_b = 8.25;
#Basis: 1 Kgmole of ethylene as feed
n_air = 9;#Kgmoles
n_C2H4 =1;#Kgmoles
n_C2H4_1 = 0.6#ethylene consumed while converting in C2H4O in Kgmoles (Rxn 1)
n_C2H4_2 = 0.3;#ethylene burnt completely to CO2 in Kgmoles (Rxn 2)

#To Calculate the heat must be removed if the product temperature should not exceed 260 deg cel
n_O2 = n_air*0.21;#Kgmoles of O2 fed
n_N2 = n_air-n_O2;#Kgmoles of N2 fed
#Rxn 1: (0.6)C2H4 + (0.3)O2 - (0.6)C2H4O;...(i) 60% of C2H4 is converted to C2H4O
n_O2_1 = n_C2H4_1/2;#Kgmoles of oxygen consumed
n_C2H4O_1 = n_C2H4_1;#C2H4O formed in Kgmoles
#Rxn 2: (0.3)C2H4 + (0.9)O2 - (0.6)CO2+ (0.6)H20;...(ii) 30%conversion
n_O2_2 = 3*n_C2H4_2;#Kgmoles of O2 reacted
n_CO2_2 = 2*n_C2H4_2;#Kgmoles of CO2 formed
n_H2O_2 = 2*n_C2H4_2;#Kgmoles of H2O formed
n_C2H4_r = n_C2H4 - n_C2H4_1 - n_C2H4_2;#unreacted ethylene in Kgmoles
n_O2_r = n_O2 - n_O2_1-n_O2_2;#unreacted O2 in Kgmoles
#The overall rxn is given by (i)&(ii),
#(0.9)C2H4 + (1.2)O2 - (0.6)C2H4O + (0.6)CO2 + (0.6)H2O...(iii)
del_H = (0.6*H_C2H4O)+(0.6*H_CO2)+(0.6*H_H2O)-(0.9*H_C2H4);#math.since,smath.radians(numpy.arcmath.tan(ard enthalpy of O2 is zero; Smath.radians(numpy.arcmath.tan(ard heat of rxn in Kcal/Kgmole
Q1 = (n_C2H4*Cp_C2H4_a + n_air*Cp_air_a)*(Ti-T1);#Sensible heat in feed in Kcal
Q2 = (n_C2H4_r*Cp_C2H4_b + n_C2H4O_1*Cp_C2H4O_b + n_CO2_2*Cp_CO2_b + n_H2O_2*Cp_H2O_b + n_O2_r*Cp_O2_b + n_N2*Cp_N2_b)*(T2-Ti);#Sensible heat in product in Kcal
Q = Q1+Q2+del_H;
print 'The heat to be removed is %f Kcal so that the product temperature is 260 deg celsius'%(-Q);
#end
The heat to be removed is 104988.605000 Kcal so that the product temperature is 260 deg celsius

Example 14.4 Page No : 293

In [4]:
%matplotlib inline
import math

import matplotlib.pyplot as plt
import numpy

#Given
#Basis: 1Kgmole of C0
#CO + (1/2)O2 - CO2
#Whem mixture entered,their compositions are given as:
n_CO = 1.0;#Kgmole
del_H = -67636.0;#Smath.radians(numpy.arcmath.tan(ard heat of reaction in Kcal/Kgmole at 25 deg cel
T1 = 95.0;#Temperature at which mixture entered in deg celsius
T2 = 25.0;#Intermediate temperature in deg celsius
#Mean specific heat values for the temperature between 25 and 95 deg celsius in Kcal/Kgmole are given as (from figure 14.4)(page no 303)
Cpm_CO = 6.95;
Cpm_O2 = 7.1;
Cpm_N2 = 6.95;

#To Calculate the theoretical flame temperature when both air and CO2 enter at 95 deg celsius
n_O2 = 1.0;#Kgmole, as 100% excess air is given
n_N2 = n_O2*(0.79/0.21);#Kgmole
#After the rxn:
n_CO2 = n_CO;#Kgmole
n_O2_r = n_O2-(n_CO/2);#remaining Kgmole of O2
#In equation 14.18 (page no 307) say: H_2-H_R = Ha, H_P-H_3 = Hb, Hc = del_H+Ha & Ht = Hc+Hb
Ha = (n_CO*Cpm_CO + n_O2*Cpm_O2 + n_N2*Cpm_N2)*(T2-T1);#in Kcal/Kgmole
Hc = del_H+Ha;#in Kcal/Kgmole
#For calculating Hb let us assume the temperature as
T = [530, 1000, 1650];#in deg celsius
Cpm_CO2 = [10.85, 12, 12.75];#Mean specific heat of CO2 at the coresspondig temperature (from figure 14.4)
Cpm_O2 = [7.55, 7.8, 8.3];#Mean specific heat of O2 at the coresspondig temperature (from figure 14.4)
Cpm_N2 = [7.15, 7.5, 7.85];#Mean specific heat of N2 at the coresspondig temperature (from figure 14.4)
Hb = []
Ht = []
for i in range(0,3):
    Hb.append((n_CO2*Cpm_CO2[i]+n_O2_r*Cpm_O2[i]+n_N2*Cpm_N2[i])*(T[i]-T2));#in Kcal/Kgmole
    Ht.append(Hc+Hb[i]);#in Kcal/Kgmole

plt.plot(T,Ht)
plt.title("")
plt.xlabel("Temperature, deg celsius")
plt.ylabel("Ht in Kcal/Kgmole")
plt.show()
Tf = numpy.interp(0,Ht,T)              
print 'The adiabatic temperature is read as %d degree celsius'%(Tf);
#end
The adiabatic temperature is read as 1549 degree celsius

Example 14.5 Page No : 294

In [5]:
#Given
T = 298.0;#Temperature in Kelvin
#standard enthalpy in Kcal/Kgmole of the following components at 298 K are given as
H_SO2 = -70960;
H_SO3 = -94450;
H_O2 = 0;
#standard entropy in Kcal/Kgmole K of the following components at 298 K are given as
S_SO2 = 2.48;
S_SO3 = -19.7
S_O2 = 0;
#Basis: 1 Kgmole of SO2
#SO2 +(1/2)O2 - SO3

#To Calculate the standard free energy for the reaction
n_SO2 = 1;#Kgmole of SO2 fed
n_O2 = (1/2)*2;#Kgmole of O2  fed as 100% excess O2 is given
n_SO3 = n_SO2;#Kgmole of SO3 formed
#From equation 14.38 (page no 312)
del_F = (H_SO3-(T*S_SO3))-(H_SO2-(T*S_SO2))-(H_O2-(T*S_O2));
print 'The standard free energy for the reaction at 25 degree celsius is %f Kcal/Kgmole'%(del_F);
#end
The standard free energy for the reaction at 25 degree celsius is -16880.360000 Kcal/Kgmole

Example 14.6 Page No : 299

In [1]:
%matplotlib inline
import math
import matplotlib.pyplot as plt
import numpy

#Given
#SO2 + (1/2)O2 - SO3
#Basis: 1 Kgmole of SO2
n_SO2 = 1.0;# SO2 fed in Kgmole
#From table 14.1 (page no 301)
#alpha values for the following components are given as
a_SO2 = 7.116;
a_O2 = 6.148;
a_SO3 = 6.077;
#beta values for the following components are given as
b_SO2 = 9.512*10**-3;
b_O2 = 3.102*10**-3;
b_SO3 = 25.537*10**-3;
#standard enthalpy of the following components at 25 deg cel in Kcal/Kgmole are given as
H_SO2 = -70960.0;
H_O2 = 0.0;
H_SO3 = -94450;
#standard free energy of the following components at 25 deg cel in Kcal/Kgmole K are given as
F_SO2 = -71680.0;
F_O2 = 0.0;
F_SO3 = -88590.08;
n_O2 = n_SO2;#O2 fed in Kgmole; math.since 50 mole percent mixture of SO2 & O2 is fed
n_SO3 = n_SO2;#SO3 formed in Kgmole
n_O2_e = n_O2-(n_O2/2);#Kgmoles of O2 in exit gas
n_O2_r = n_O2/2;#Kgmoles of O2 reacted
R = 1.98;#gas consmath.tant in Kcal/Kgmole K

#To show  the variation of the standard heats of reaction with temperature and the equilibrium consmath.tant with temperature graphically in the  given temperature range
#(i)Variation of the standard heats of reaction with temperature
del_H = (n_SO3*H_SO3)-(n_O2_r*H_O2)-(n_SO2*H_SO2);# in Kcal/Kgmole
del_F = (n_SO3*F_SO3)-(n_O2_r*F_O2)-(n_SO2*F_SO2);# in Kcal/Kgmole
#From equation 14.10 (page no 301)
del_a = (n_SO3*a_SO3)-(n_O2_r*a_O2)-(n_SO2*a_SO2);
del_b = (n_SO3*b_SO3)-(n_O2_r*b_O2)-(n_SO2*b_SO2);
#In equation 14.11 (page no 302), substituting del_H at
T = 298;#in deg cel
I = del_H - del_a*T - (del_b*(T**2)/2);# integrating consmath.tant
print 'iThe standard heat of reaction at any tempperature can be calculated by the relation:';
print '    del_Ht = %fT'%del_a,
print ' + %fT**2 '%(del_b/2),
print '%f'%I

#(ii)Variation of the equilibrium consmath.tant with temperature
#K1 = lnKa (say)
K1 = -del_F/(R*T);
#From equation 14.42 (page no 316); M1 = M/R (say)
M1 = K1-(del_a/R)*math.log(T)-(del_b/(2*R))*T+(I/(T*R));
#Let us assume the temperature in the range 800K to 1500K as
Ta = [700, 800, 825, 850, 900, 1000, 1100, 1300, 1500];
Ka = []
for i in range(0,9):
    Ka.append(math.e**((del_a/R)*math.log(Ta[i])+(del_b*Ta[i]/(2*R))-(I/(Ta[i]*R))+M1));


plt.plot(Ta,Ka);
plt.title("" )
plt.xlabel("Temperatur in K")
plt.ylabel("equilibrum constant K")
plt.show()
                                                                                                                                                                       
print 'ii)From the graph it can be seen that as temperature increases Ka decreases exponentially,(so the reaction is exothermic.';
#end
iThe standard heat of reaction at any tempperature can be calculated by the relation:
    del_Ht = -4.113000T  + 0.007237T**2  -22907.000548
ii)From the graph it can be seen that as temperature increases Ka decreases exponentially,(so the reaction is exothermic.

Example 14.7 Page No : 300

In [3]:
%matplotlib inline
import math
import matplotlib.pyplot as plt
import numpy

#Given
#SO2 + (1/2)O2 - SO3
#Basis: 1 Kgmole of SO2
n_SO2 = 1.0;# SO2 fed in Kgmole
n_O2 = n_SO2;#O2 fed in kgmole

#To Calculate the conversion of SO2 to SO3 at 1atm and at various temperature
#(1)Calculate the conversion of SO2 to SO3 
P = 1.0;#Pressure in atm
T = 850.0;#Temperature in K
m = 1-1-(1/2.0);
#From example 14.6
Ta = [700.0, 800.0, 825.0, 850.0, 900.0, 1000.0, 1100.0, 1300.0, 1500.0];
Ka = [395.40, 52.51, 34.60, 23.44, 11.59, 3.527, 1.48, 0.398, 0.0016];



plt.plot(Ta,Ka)
plt.title("Equilibrium consmath.tant vs Temperature")
plt.xlabel("Temperature in K")
plt.ylabel("Ka")
plt.show()
Ka1 = numpy.interp(850,Ta,Ka)


#Let Nc be the moles of SO3 at equilibrium
Nc = [0.1, 0.2, 0.3, 0.4, 0.5, 0.7, 0.8, 0.9, 0.930, 0.95, 0.98, 0.988, 0.989, 0.9895, 0.9897, 0.9899, 0.9900];
#From equation 14.49 (page no 320) and umath.sing the given data ,we got equation (b) (page no 323)
Ka = []
for i in range (0,17):
    Ka.append((((n_SO2+n_O2-0.5*Nc[i])/(n_O2-0.5*Nc[i]))**(1/2.0))*(Nc[i]/(n_SO2-Nc[i])));

    


plt.plot(Nc,Ka)
plt.title("Equilibrium consmath.tant vs Kgmoles of SO3")
plt.xlabel("Kg moles of SO3")
plt.ylabel("Ka")
Nc1 = numpy.interp(Ka1,Ka,Nc)


C = Nc1*100.0/n_SO2;
print '1)The conversion of SO2 to SO3 at 1atm and 850K is %f percent'%C;

#(2)Calculation of conversion at 1 atm and 850 K under the following conditions
#(i) Given:
n_N2 = 3.75;#Kgmoles of N2 fed
#Let Nc be the moles of SO3 at equilibrium
Nc = [0.85, 0.87, 0.90];
#From equation 14.49 (page no 320) and umath.sing the given data ,we got equation (c) (page no 324)
Ka2 = []
for i in range(0,3):
    Ka2.append((((+n_N2+n_SO2+n_O2-0.5*Nc[i])/(n_O2-0.5*Nc[i]))**(1/2.0))*(Nc[i]/(n_SO2-Nc[i])));



plt.plot(Nc,Ka2)
Nc2 = numpy.interp(Ka1,numpy.transpose(Ka2),Nc)

                
C2 = Nc2*100.0/n_SO2;
print ' 2)i)The conversion of SO2 to SO3 at 1 atm and 850 K when inert gas is also added is %f percent'%C2;



                

#(ii)SO3 is also sent along the original feed
n_SO3 = 1.0;#Kgmoles of SO3 fed
#Let Nc be the moles of SO3 at equilibrium
Nc = [0.80, 0.86, 0.92];
#From equation 14.49 (page no 320) and umath.sing the given data ,we got equation (d) (page no 326)
Ka3 = []
for i in range(0,3):
    Ka3.append((((+n_SO3+n_SO2+n_O2-0.5*Nc[i])/(n_O2-0.5*Nc[i]))**(1/2.0))*((n_SO3+Nc[i])/(n_SO2-Nc[i])));


plt.plot(Nc,Ka3)
Nc3 = numpy.interp(Ka1,Ka3,Nc)


C3 = Nc3*100.0/n_SO2;
print '   ii)The conversion of SO2 to SO3 at 1 atm and 850 K when SO3 is also added along the original feed is %f percent'%C3;

#(iii)Variation of SO2 to O2 ratio:
#(a)SO2:O2 = 1:1 ; This has been worked out in part 1
print '   iii)a)The conversion of SO2 to SO3 at 1atm and 850K when SO2:O2 = 1:1 is %f percent'%(C);
Xc = Nc1/(n_SO2+n_O2-0.5*Nc1);

#(b)SO2:O2 = 1.1:0.5,Now
n_SO2 = 1.1;#Kgmoles of SO2 fed
n_O2 = 0.5;#Kgmoles of O2 fed
#Let Nc be the moles of SO3 at equilibrium
Nc = [0.9, 0.91, 0.92];
#From equation 14.49 (page no 320) and umath.sing the given data ,we got equation (e) (page no 327)
Ka4 = []
for i in range(0,3):
        Ka4.append((((n_SO2+n_O2-0.5*Nc[i])/(n_O2-0.5*Nc[i]))**(1/2.0))*(Nc[i]/(n_SO2-Nc[i])));


plt.plot(Nc,Ka4)
Nc4 = numpy.interp(Ka1,Ka4,Nc)




C4 = Nc4*100.0/n_SO2;
print '   iii)b)The conversion of SO2 to SO3 at 1atm and 850K when SO2:O2 = 1.1:0.5 is %f percent'%C4;
Xc1 = Nc4/(n_SO2+n_O2-0.5*Nc4);

#(c)SO2:O2 = 1:0.5
n_SO2 = 1.0;#Kgmoles of SO2 fed
n_O2 = 0.5;#Kgmoles of O2 fed
#Let Nc be the moles of SO3 at equilibrium
Nc = [0.8, 0.85, 0.86, 0.87];
#From equation (a)
Ka5 = []
for i in range(0,4):
    Ka5.append((((n_SO2+n_O2-0.5*Nc[i])/(n_O2-0.5*Nc[i]))**(1/2.0))*(Nc[i]/(n_SO2-Nc[i])));



plt.plot(Nc,Ka5)
Nc5 = numpy.interp(Ka1,Ka5,Nc)

    
C5 = Nc5*100.0/n_SO2;
print '   iii)c)The conversion of SO2 to SO3 at 1atm and 850K when SO2:O2 = 1:0.5 is %f percent'%(C5);
Xc2 = Nc5/(n_SO2+n_O2-0.5*Nc5);

if(Xc2>Xc) and (Xc2>Xc1):
    print '        SO2:O2 = 1:0.5 gives the maximum concentration of SO3 at equilibrium.';
else:
    if(Xc1>Xc) and (Xc1>Xc2):
        print '        SO2:O2 = 1.1:0.5 gives the maximum concentration of SO3 at equilibrium';
    else:
        if(Xc>Xc1) and (Xc>Xc2):
            print '        SO2:O2 = 1:1 gives the maximum concentration of SO3 at equilibrium';



#(3)Conversion of SO2 to SO3 at 50 atm and 850 K when SO2:O2 = 1:1
n_SO2 = 1.0;#Kgmole of SO2 fed
n_O2 = 1.0;#Kgmoles of O2 fed
P = 50.0;#Pressure in atm
#From figure A.2.9
phi_SO2 = 0.99;
phi_SO3 = 0.972;
phi_O2 = 1.0;
#From equation 14.48 (page no320), Ka = Ky*(P**m)*K_phi
K_phi = phi_SO3/(phi_SO2*(phi_O2**2));
#Let Nc be the moles of SO3 at equilibrium
Nc = [0.99, 0.985, 0.97, 0.96];
Ka6 = []
for i in range(0,4):
    Ka6.append(K_phi*(P**m)*((((n_SO2+n_O2-0.5*Nc[i])/(n_O2-0.5*Nc[i]))**(1/2.0))*(Nc[i]/(n_SO2-Nc[i]))));


plt.plot(Nc,Ka6)
plt.legend(['1 part', '2.(i) part', '2.(ii) part', '2.(iii).(b) part', '2.(iii).(c) part', '3 part'])
plt.show()
Nc6 = numpy.interp(Ka1,Ka6,Nc)


C = Nc6*100.0/n_SO2;
print ' 3)The conversion of SO2 to SO3 at 50atm and 850K  when SO2:O2 = 1:1 is %f percent'%(C);
#legend("1 part","2.(i) part","2.(ii)part","2.(iii).(b)part","2.(iii).(c)part","3 part");



#end
1)The conversion of SO2 to SO3 at 1atm and 850K is 93.189481 percent
 2)i)The conversion of SO2 to SO3 at 1 atm and 850 K when inert gas is also added is 88.179412 percent
   ii)The conversion of SO2 to SO3 at 1 atm and 850 K when SO3 is also added along the original feed is 82.979198 percent
   iii)a)The conversion of SO2 to SO3 at 1atm and 850K when SO2:O2 = 1:1 is 93.189481 percent
   iii)b)The conversion of SO2 to SO3 at 1atm and 850K when SO2:O2 = 1.1:0.5 is 82.473630 percent
   iii)c)The conversion of SO2 to SO3 at 1atm and 850K when SO2:O2 = 1:0.5 is 85.774995 percent
        SO2:O2 = 1:0.5 gives the maximum concentration of SO3 at equilibrium.
 3)The conversion of SO2 to SO3 at 50atm and 850K  when SO2:O2 = 1:1 is 96.000000 percent

Example 14.9 Page No : 305

In [8]:
import math 

#Given
#2A(g) - B(g)+C(g)
T = 400.0;#Temperature in Kelvin
P = 1.0;#Pressure in atm
R = 1.98;#gas consmath.tant in Kcal/Kgmole K
del_Fo = 3000.0;#standard free energy of the reaction in Kcal/Kgmole
n_A = 1.0;#Kgmoles of A
n_B = 0.1;#Kgmoles of B
n_C = 0.1;#Kgmoles of C

#To find out the equilibrium has been attained or not. If not then calculate the equilibrium composition and also find out whether the equilibrium composition  will change or not if pressure were increased to 3 atm.
#(1)To find out the equilibrium has been attained or not. If not then calculate the equilibrium composition
#P_B/P_C = 1 (Given)
n_T = n_A+n_B+n_C;#Total Kgmoles of the component
p_A = (n_A/n_T)*P;#Partial pressure of A
p_B = (n_B/n_T)*P;#Partial pressure of B
p_C = (n_C/n_T)*P;#Partial pressure of C
#Umath.sing the relation 14.36 (page no 312)
del_F = del_Fo + (R*T)*math.log((p_B*p_C)/(p_A**2));
if del_F == 0:
    print '1.Equilibrium has been attained.';
else:
    print '1.Equilibrium has not been attained.';
#Equilibrium composition
#At equilibrium del_F = 0
#From equations 14.35(page no 312) and 14.49(page no 320), we got the relations (a),(b)(page no 331) &(c)(page no 332) and
#ln(p_C**2/(P-(2*p_C**2)))= -del_Fo/(R*T); 
Kp = math.e**(-del_Fo/(R*T))#equilibrium consmath.tant in terms of pressure
p_C = (Kp**(1/2))/(1+2*(Kp**(1/2)));#Partial pressure of C at equilibrium in atm
p_B = p_C;#as p_B/p_C = 1
p_A = P-(2*p_C);#Partial pressure of A at equilibrium in atm
N_A = p_A*P*100.0;
N_B = p_B*P*100.0;
N_C = p_C*P*100.0;
print '   Equilibrium composition of A,(B and C are %f'%N_A,
print '(%f and '%N_B,
print '%f mole percent respectively.'%N_C
#2.Calculation of composition at 400 K and 3 atm and vapour pressure of C at 400 K is 0.3 atm
P = 3.0;#Pressure in atm
P_C = 0.3;#Vapour pressure of C in atm
#Since m=0,pressure will not have an effect on equilibrium compositions.
print ' 2.The compositions will be the same as above on increamath.sing the pressure.';
p_B1 = p_B*P;#Partial pressure of B in atm
p_C1 = p_B1;#Partial pressure of C in atm
p_A1 = p_A*P;#Partial pressure of A in atm
if P_C < p_C1:
    p_A2 = ((p_B1*P_C)/Kp)**(1/2.0);#decreased partial pressure of A in atm
print '   The partial pressure of A drops from %f'%p_A1,
print ' to %f to compensate for the amount of C condensed.'%p_A2;
#end
1.Equilibrium has not been attained.
   Equilibrium composition of A,(B and C are 33.333333 (33.333333 and  33.333333 mole percent respectively.
 2.The compositions will be the same as above on increamath.sing the pressure.
   The partial pressure of A drops from 1.000000  to 3.639888 to compensate for the amount of C condensed.

Example 14.10 Page No : 307

In [2]:
%matplotlib inline
import math
import matplotlib.pyplot as plt
import numpy

#Given
#SO2(A) + (1/2)O2 (B) - SO3(C)
#Basis: 1 Kgmole SO2
n_A = 1.0;#Kgmole of SO2 fed
n_B = n_A;#Kgmole of O2 fed
T1 = 273+400.0;#Temperature in K at which reacmath.tants enter
To = 298.0;#room temperature in K
del_H = -23490.0;#Smath.radians(numpy.arcmath.tan(ar heat of reaction at 25 deg cel from example 14.6 in Kcal/Kgmole

#At T1,
C_A_T1 = 11.0;
C_B_T1 = 7.4;#in Kcal/Kgmole
#Assume the various temperature be
T = [913.0, 1073.0, 1373.0, 1573.0];#in K
#Mean specific heats of the components A,B & C at various temperature are given below in Kcal/Kgmole K
C_A = [11.6, 11.8, 12.3, 12.5];
C_B = [7.7, 7.8, 8.0, 8.2];
C_C = [16.6, 17.2, 18.2, 18.6];

#To Calculate the final temperature for various conversions and the maximum conversion that can be attained in a math.single reactor operating adiabatically
#In equation 14.18 (page no 307), H2-Hr = K  & (Hp-H3)= L(say)
K = ((n_A*C_A_T1)+(n_B*C_B_T1))*(To-T1);#in Kcal/Kgmole
print 'Adiabatic reaction temp in K             pecentage conversion of SO2';
n_C = []
for i in range(0,4):
    n_C.append((-K-(C_A[i]*(T[i]-To))-(C_B[i]*(T[i]-To)))/((T[i]-To)*(C_C[i]-C_A[i]-0.5*C_B[i])+del_H));
    n_C[i] *= 100
    print '   %d'%T[i];
    print '                                              %f'%(n_C[i]*100);


plt.plot(T,n_C)

#Now equilibrium conversion at various temperature taken from figure 14.7 (page no 325) are given as
Ta = [850.0, 900.0, 1000.0, 1100.0, 1200.0, 1300.0, 1400.0,];
n_C1 = [93.5, 88.2, 69.0, 49.0, 37.0, 21.5, 6.25];

plt.plot(Ta,n_C1)
plt.title("Temperature vs Percentage Conversion")
plt.xlabel("Temperature in K")
plt.ylabel("% Conversion")
plt.show()

#From the graph,it can be seen that the curve cut each other approximately at the temp
T1 = 1140.0;#in Kelvin
C = numpy.interp(T1,Ta,n_C1)

print ' The maximum conversion that can be attained is %d percent'%C;
#end
Adiabatic reaction temp in K             pecentage conversion of SO2
   913
                                              2181.255555
   1073
                                              3712.910088
   1373
                                              6957.687376
   1573
                                              9308.739255
 The maximum conversion that can be attained is 44 percent

Example 14.11 Page No : 309

In [10]:
#Given
#Basis: 1 Kgmole of benzene
#C6H6 (A) + HNO3 (B) - C6H5NO2 (C) + H2O (D)
T = 298.0;#Temperature in K
R = 1.98;#gas consmath.tant in Kcal/Kgmole K
#standard enthalpy in Kcal/Kgmole at 25 deg celsius of the above components are given as
H_A = 11718.0;
H_B = -41404.0;
H_C = -68371.0;
H_D = 3800.0;
#standard entropy in Kcal/Kgmole K at 25 deg celsius of the above components are given as
S_A = 41.30;
S_B = 37.19;
S_C = 16.72;
S_D = 53.60;

#To Calculate the conversion of benzene at 25 degree celsius and 1 atm
del_F = (H_C+H_D-(T*(S_C+S_D)))-(H_A+H_B-(T*(S_A+S_B)));
Ka = math.e**(-del_F/(R*T));#Equilibrium consmath.tant
x = (Ka**(1/2.0)/(1+(Ka**(1/2.0))));
print 'The conversion is almost %f percent for this reaction.'%(x*100);
#end
The conversion is almost 100.000000 percent for this reaction.

Example 14.12 Page No : 311

In [19]:
import math 
from sympy import Symbol
import numpy

#Given
#C + 2H2 - CH4
#Basis: 1 Kgmole of C fed
T = 1000.0;#Temperature in K
P1 = 2.0;#Pressure in atm
del_F = 4580.0;#standard free energy in Kcal/Kgmole


#To Calculate the maximum CH4 concentration under the condition of 2 atm and the  quantity of methane obtained if pressure is 1 atm
Ka = math.e**(-del_F/(R*T));#Equilibrium consmath.tant
#In relation (d) (page no 339) p_H2 = p (say)
p = Symbol('p');
q = [Ka,1,-P1]#*(p**2)+p-P1;
r = numpy.roots(q);
p_H2 = r[1];#partial pressure of H2
p_CH4 = P1-p_H2;#partial pressure of CH4
X_H2 = p_H2*100/P1;#mole percent of H2
X_CH4 = p_CH4*100/P1;#mole percent of CH4
print 'Under the conditions of 2 atm and 1000 K, the maximum CH4 concentration is %f percent and further increase is not pssible'%(X_CH4);
#Now.pressure has become
P2 = 1;#in atm
q = Ka*(p**2)+p-P2;
r = [Ka,1,-P2]#numpy.roots(q);
p_H2 = r[1];#partial pressure of H2
p_CH4 = P2-p_H2;#partial pressure of CH4
X_H2 = p_H2*100/P2;#mole percent of H2
X_CH4 = p_CH4*100/P2;#mole percent of CH4
print ' Under the conditions of 1 atm and 1000 K,Methane = %f percent and Hydrogen = %f percent'%(X_CH4,X_H2);
#end
Under the conditions of 2 atm and 1000 K, the maximum CH4 concentration is 14.475434 percent and further increase is not pssible
 Under the conditions of 1 atm and 1000 K,Methane = 0.000000 percent and Hydrogen = 100.000000 percent

Example 14.13 Page No : 312

In [20]:
import math 

#Given
T1 = 273+110;#Temperature in K
T = 298.0;#Room temperature in K
P = 1.0;#Pressure in atm
R = 1.98;#gas consmath.tant in Kcal/Kgmole
#Ag2CO3(s) (A) = Ag2O(s) (B) + CO2(g) (C)
a = 1.0;#Stoichiometry coefficient of A
b = 1.0;#Stoichiometry coefficient of B
c = 1.0;#Stoichiometry coefficient of C
#standard entropy of the above components in Kcal/Kgmole K at 25 deg cel are given as
S_A = 40.17;
S_B = 29.09;
S_C = 51.08;
#standard enthalpy of the above components in Kcal/Kgmole at 25 deg cel are given as
H_A = -119900.0;
H_B = -6950.0;
H_C = -94036.0;
#Specific heat (assumed consmath.tant) of the above components in Kcal/Kgmole K are given as
C_A = 26.1;
C_B = 16.5;
C_C = 9.6;

#To Calculate the partial pressure of CO2 required for decomposition and thus determine whether Ag2CO3 will decomposes or not at the given pressure and temperature
del_H = H_C+H_B-H_A;#standard heat of reaction  at 25 deg cel in Kcal/Kgmole
del_C = b*C_B+c*C_C-a*C_A;
#From equation 14.15 (page no 340)
del_Ht = del_H +del_C*(T1-T);
del_F = del_H-(T*(S_B+S_C-S_A));#standard free energy in Kcal/Kgmole
Ka1 = math.e**(-del_F/(R*T));#Equilibrium consmath.tant at temperature T
#Since del_Ht is consmath.tant(as del_C = 0),Ka2 can be calculated by equation 14.43 (page no 316)
Ka2 = Ka1* math.e**((del_Ht/R)*(1/T1-1/T));
p_CO2 = Ka2;
print 'The partial pressure of CO2 required for decomposition is %4.3e atm'%(p_CO2);
if p_CO2 < P :
    print ' Silver carbonate will not decompose at 110 deg celsius as the pressure given is 1 atm';
else:
    print ' Silver carbonate will decompose at 110 deg celsius';
#end
The partial pressure of CO2 required for decomposition is 8.523e-20 atm
 Silver carbonate will not decompose at 110 deg celsius as the pressure given is 1 atm

Example 14.15 Page No : 314

In [23]:
from numpy import poly1d,roots
#Given
#C3H8 = C3H6 + H2... (i)
#C3H8 = C2H4 +CH4...(ii)
Kp1 = 7.88;#Equilibrium consmath.tant of equation (i)
Kp2 = 775.0;#Equilibrium consmath.tant of equation (ii)
T = 760+273;#Temperature in K

#To Calculate the equilibrium composition of the mixture
#Basis: 1 mole of C3H8 in feed
#From the equations (a) &(b) (page no 343); y/x = z (say)
z = (Kp2/Kp1)**(1/2);
#Substituting y = z*x in equation(a), we got the equation p:

#x = poly(0,'x')
p = poly1d([1+Kp1+Kp1*(z**2)+2*Kp1,0,-Kp1])
q = roots(p);

x = q[0];
y = z*x;
print 'Moles of H2, C3H6, C2H4 and CH4 formed at equilibrium are %f %f %f %f respectively.'%(x,x,y,y);
#end
Moles of H2, C3H6, C2H4 and CH4 formed at equilibrium are 0.492252 0.492252 0.492252 0.492252 respectively.