{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Chapter 14: Chemical reaction equilibrium" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 14.10: Adiabatic_reaction_temperature.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "// Y.V.C.Rao ,1997.Chemical Engineering Thermodynamics.Universities Press,Hyderabad,India.\n", "\n", "//Chapter-14,Example 10,Page 500\n", "//Title: Adiabatic reaction temperature\n", "//================================================================================================================\n", "clear \n", "clc\n", "\n", "//INPUT\n", "T0=298.15;//temperature at the entrance (feed) in K\n", "P=0.1;//pressure (operating) in MPa\n", "//The reaction is given by: H2(g)+(1/2)O2(g)--->H20(g)\n", "n=[1;-1;-0.5];//stoichiometric coefficients of H2O(g),H2(g)and O2(g) respectively (no unit)\n", "n_r=[1;0.5];//stochiometric coefficients on the reactant side alone for computing the right hand side of Eq.(A)\n", "m=[0;1;0.5];//inlet mole number of H2O(g),H2(g) and O2(g) respectively \n", "//The isobaric molar capacity is given by Cp=a+bT+cT^2+dT^3+eT^-2 in J/molK and T is in K from Appendix A.3\n", "//coefficient in the expression for computing the isobaric molar heat capacity from Appendix A.3 (for H2O(g),H2(g),O2(g) respectively)\n", "a=[28.850;27.012;30.255];\n", "//coefficient in the expression for computing the isobaric molar heat capacity from Appendix A.3 (for H2O(g),H2(g),O2(g) respectively)\n", "b=[12.055*10^-3;3.509*10^-3;4.207*10^-3];\n", "//coefficient in the expression for computing the isobaric molar heat capacity from Appendix A.3 (for H2O(g),H2(g),O2(g) respectively)\n", "c=[0;0;0];\n", "//coefficient in the expression for computing the isobaric molar heat capacity from Appendix A.3 (for H2O(g),H2(g),O2(g) respectively)\n", "d=[0;0;0];\n", "//coefficient in the expression for computing the isobaric molar heat capacity from Appendix A.3 (for H2O(g),H2(g),O2(g) respectively)\n", "e=[1.006*10^5;0.690*10^5;-1.887*10^5];\n", "del_H=-241.997;//enthalpy of reaction at 298.15K in kJ\n", "del_G=-228.600;//Gibbs free energy of reaction at 298.15K in kJ\n", "R=8.314;//universal gas constant in J/molK\n", "\n", "//CALCULATION\n", "//Framing the isobaric molar heat capacity expression\n", "del_a=(n(1,:)*a(1,:))+(n(2,:)*a(2,:))+(n(3,:)*a(3,:));\n", "del_b=(n(1,:)*b(1,:))+(n(2,:)*b(2,:))+(n(3,:)*b(3,:));\n", "del_c=(n(1,:)*c(1,:))+(n(2,:)*c(2,:))+(n(3,:)*c(3,:));\n", "del_d=(n(1,:)*d(1,:))+(n(2,:)*d(2,:))+(n(3,:)*d(3,:));\n", "del_e=(n(1,:)*e(1,:))+(n(2,:)*e(2,:))+(n(3,:)*e(3,:));\n", "mtot=m(1,:)+m(2,:)+m(3,:);//calculation of the total mole number of feed entering (no unit)\n", "del_n=n(1,:)+n(2,:)+n(3,:);//calculation of the total mole number (no unit)\n", "//Using Eq.14.21 to compute the value of del_H0 in kJ\n", "del_H0=((del_H*10^3)-((del_a*T0)+((del_b/2)*T0^2)+((del_c/3)*T0^3)+((del_d/4)*T0^4)-(del_e/T0)))*10^-3;\n", "//Using Eq.14.23 to compute the integration constant\n", "I=(1/(R*T0))*(((del_H0*10^3)-(del_a*T0*log(T0))-((del_b/2)*T0^2)-((del_c/6)*T0^3)-((del_d/12)*T0^4)-((del_e/2)*(1/T0))-(del_G*10^3)));\n", "//The conversion is computed by using Eq.(A) and by Eq.(B) and the two are plotted with respect to temperature. The point of intersection gives the adiabatic reaction temeperature and from that the conversion and the composition are determined.Let E_A denote the conversion obtained by using Eq.A and E_B denote the conversion obtained by using Eq.B (no unit)\n", "//For both the equations, conversion is determined for a temperature range of 2000 to 3800K, by incrementing temperature by 100K every time.\n", "T=2000:100:3800;//framing the temperature range in K\n", "l=length(T);//iteration parameter (no unit)\n", "i=1;//iteration parameter\n", "tol=1e-4;//tolerance limit for convergence of the system when using fsolve\n", "while iCO(g)+3H2(g)\n", "//CO(g)+H2O(g)----->CO2(g)+H2(g)\n", "//CH4(g)+2H2O(g)---->CO2(g)+4H2(g)\n", "//CO2(g)---->CO(g)+(1/2)O2(g)\n", "//CH4(g)+2O2(g)---->CO2(g)+2H2O(g)\n", "//CH4(g)+O2(g)---->CO(g)+H2O(g)+H2(g)\n", "\n", "//Let CH4=A1,H2O=A2,CO=A3,H2=A4,CO2=A5,O2=A6\n", "\n", "stoichio_matrix=[-1 -1 1 3 0 0;0 -1 -1 1 1 0;-1 -2 0 4 1 0;0 0 1 0 -1 0.5;-1 2 0 0 1 -2;-1 1 1 1 0 -1]//Framing the stoichiometric coefficient matrix\n", "\n", "\n", "\n", "//CALCULATION\n", "\n", "r=rank(stoichio_matrix);//Determining the rank of the given matrix(number of independent row/columns),which is indicative of the number of primary reactions\n", "\n", "//Performing elementary row operations to obtain diagonal elements as 0 or 1 and all elements below the diagonal as zero\n", "stoichio_matrix(1,:)=-stoichio_matrix(1,:);\n", "stoichio_matrix(3,:)=stoichio_matrix(3,:)+stoichio_matrix(1,:);\n", "stoichio_matrix(5,:)=stoichio_matrix(5,:)+stoichio_matrix(1,:);\n", "stoichio_matrix(6,:)=stoichio_matrix(6,:)+stoichio_matrix(1,:);\n", "stoichio_matrix(2,:)=-stoichio_matrix(2,:);\n", "stoichio_matrix(3,:)=stoichio_matrix(3,:)+stoichio_matrix(2,:);\n", "stoichio_matrix(5,:)=stoichio_matrix(5,:)-(3*stoichio_matrix(2,:));\n", "stoichio_matrix(6,:)=stoichio_matrix(6,:)-(2*stoichio_matrix(2,:));\n", "x=stoichio_matrix(:,3);\n", "y=stoichio_matrix(:,4);\n", "stoichio_matrix(:,3)=y;\n", "stoichio_matrix(:,4)=x;\n", "stoichio_matrix(5,:)=stoichio_matrix(5,:)+(4*stoichio_matrix(4,:));\n", "stoichio_matrix(6,:)=stoichio_matrix(6,:)+(2*stoichio_matrix(4,:));\n", "\n", "\n", "\n", "//OUTPUT\n", "mprintf('\n The stoichiometric coefficient matrix after performing the elementary row operations=\n');\n", "disp(stoichio_matrix);\n", "mprintf('\n The number of primary reactions=%d\n',r);\n", "mprintf('\n The non zero rows are (1,2,4)\n');\n", "mprintf('\n The primary reactions are: CH4(g)+H2O(g)--->CO(g)+3H2(g), CO(g)+H2O(g)--->CO2(g)+H2(g), CO2(g)--->CO(g)+(1/2)O2(g)\n');\n", "\n", "//===============================================END OF PROGRAM===================================================\n", "\n", "\n", "" ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 14.13: Equilibrium_composition_in_a_simultaneous_reaction.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "// Y.V.C.Rao ,1997.Chemical Engineering Thermodynamics.Universities Press,Hyderabad,India.\n", "\n", "//Chapter-14,Example 13,Page 510\n", "//Title: Equilibrium composition in a simultaneous reaction \n", "//================================================================================================================\n", "clear \n", "clc\n", "\n", "//INPUT\n", "//The simultaneous reactions are given as:\n", "//A+B--->C+D =>1\n", "//A+C--->D+E =>2\n", "Ka1=0.1429;//equilibrium constant of reaction 1 (no unit)\n", "Ka2=2;//equilibrium constant of reaction 2 (no unit)\n", "P=1;//pressure in bar\n", "m=[1;1;0;0;0];//mole number in the feed (for A,B,C,D and E respectively) (equimolar mixture of A and B are present in the feed)\n", "n1=[-1;-1;1;1;0];//stoichiometric coefficients for reaction 1 (A,B,C D,E respectively) (no unit)\n", "n2=[-1;0;-1;1;1];//stoichiometric coefficients for reaction 2 (A,B,C D E respectively) (no unit)\n", "\n", "//CALCULATION\n", "del_n1=n1(1,:)+n1(2,:)+n1(3,:)+n1(4,:);//calculation of the total mole number for reaction 1 (no unit)\n", "del_n2=n2(1,:)+n2(2,:)+n2(3,:)+n2(4,:);//calculation of the total mole number for reaction 2 (no unit)\n", "//calculation of the equilibrium constant in terms of the mole fractions using Eq.(14.30) (no unit) (for reaction 1) (K_phi=1.0,assuming ideal gas behaviour)\n", "Ky1=Ka1/(P^del_n1);\n", "//calculation of the equilibrium constant in terms of the mole fractions using Eq.(14.30) (no unit) (for reaction 2) (K_phi=1.0,assuming ideal gas behaviour)\n", "Ky2=Ka2/(P^del_n2);\n", "mtot=m(1,:)+m(2,:)+m(3,:)+m(4,:)+m(5,:);//calculation of the total mole number of feed entering (no unit)\n", "//To determine the degree of conversion, a trial and error process is used to solve the equations given by Ky1=(y_C*y_D)/(y_A*y_B), and Ky2=(y_D*y_E)/(y_A*y_C) where y_A,y_B,y_C,y_D,y_E are the mole fractions of A,B,C,D and E respectively. Let the equilibrium conversion be denoted as epsilon1 for reaction 1 and epsilon2 for reaction 2 respectively.\n", "epsilon1_guess=0.3;//taking a guess value for the degree of conversion (reaction1) for the trial and error process (no unit)\n", "tol=1e-6;//defining the tolerance limit for obtaining the convergence of the system using fsolve\n", "E_guess=0.1;//taking a guess value for the degree of conversion (reaction2) to be used for solving the set of equations by the inbuilt function fsolve\n", "function[fn1]=solver_func1(En)\n", " //The system of equations to be solved for reaction 1\n", " fn1=Ky1-((((m(3,:)+(n1(3,:)*epsilon1_guess)+(n2(3,:)*En))/(mtot))^n1(3,:))*(((m(4,:)+(n1(4,:)*epsilon1_guess)+(n2(4,:)*En))/(mtot))^n1(4,:))*(((m(1,:)+(n1(1,:)*epsilon1_guess)+(n2(1,:)*En))/(mtot))^n1(1,:))*(((m(2,:)+(n1(2,:)*epsilon1_guess)+(n2(2,:)*En))/(mtot))^n1(2,:)));\n", "endfunction\n", "[epsilon2]=fsolve(E_guess,solver_func1,tol);//using inbuilt function fsolve for solving the system of equations\n", "E_guess=0.2;//taking a guess value for the degree of conversion (reaction1) to be used for solving the set of equations by the inbuilt function fsolve\n", "function[fn2]=solver_func2(Em)\n", " //For reaction 2, the degree of conversion(reaction2), determined above is used along with the guess value and the system of equations below are solved\n", "fn2=Ky2-((((m(4,:)+(n1(4,:)*Em)+(n2(4,:)*epsilon2))/(mtot))^n2(4,:))*(((m(5,:)+(n1(5,:)*Em)+(n2(5,:)*epsilon2))/(mtot))^n2(5,:))*(((m(1,:)+(n1(1,:)*Em)+(n2(1,:)*epsilon2))/(mtot))^n2(1,:))*(((m(3,:)+(n1(3,:)*Em)+(n2(3,:)*epsilon2))/(mtot))^n2(3,:))); \n", "endfunction\n", "[epsilon1]=fsolve(E_guess,solver_func2,tol);//using inbuilt function fsolve for solving the system of equations\n", "//calculation of the equilibrium composition at 1 bar pressure of A,B,C,D and E respectively (no unit)\n", "y_A=((m(1,:)+(n1(1,:)*epsilon1)+(n2(1,:)*epsilon2)))/(mtot);\n", "y_B=(m(2,:)+(n1(2,:)*epsilon1)+(n2(2,:)*epsilon2))/(mtot);\n", "y_C=((m(3,:)+(n1(3,:)*epsilon1)+(n2(3,:)*epsilon2)))/(mtot);\n", "y_D=(m(4,:)+(n1(4,:)*epsilon1)+(n2(4,:)*epsilon2))/(mtot);\n", "y_E=((m(5,:)+(n1(5,:)*epsilon1)+(n2(5,:)*epsilon2)))/(mtot);\n", "\n", "//OUTPUT\n", "mprintf('\nThe degree of conversion :epsilon1=%0.1f\t epsilon2=%0.1f \n',epsilon1,epsilon2);\n", "mprintf('\nThe equilibrium composition at 1 bar pressure for an equimolar mixture of A and B fed to the reactor:\n y_A=%0.2f \t y_B=%0.2f \t y_C=%0.2f \t y_D=%0.2f \t y_E=%0.1f\n',y_A,y_B,y_C,y_D,y_E);\n", "\n", "\n", "//===============================================END OF PROGRAM===================================================" ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 14.14: Equilibrium_concentration.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "// Y.V.C.Rao ,1997.Chemical Engineering Thermodynamics.Universities Press,Hyderabad,India.\n", "\n", "//Chapter-14,Example 14,Page 515\n", "//Title: Equilibrium concentration\n", "//================================================================================================================\n", "clear \n", "clc\n", "\n", "//INPUT\n", "//The reaction is given by :\n", "//CH3COOH(l)+C2H5OH(l)--->CH3COOC2H5(l)+H2O(l)\n", "T=100;//temperature in degree celsius\n", "Kc=2.92;//equilibrium constant (in terms of concentration) at T (no unit)\n", "v=1;//volume of the aqueous solution in m^3\n", "m=[0;10;10;5];//feed composition of CH3COOC2H5(l),H20(l),C2H5OH(l),CH3COOH(l) respectively in kmol\n", "n=[1;1;-1;-1];//stoichiometric coefficient for the reaction (no unit)(CH3COOC2H5(l),H20(l),C2H5OH(l),CH3COOH(l) respectively)\n", "\n", "//CALCULATION\n", "//For convenience, CH3COOH(l) is denoted as A, C2H5OH(l) is denoted as B, CH3COOC2H5(l) is denoted as C and H2O(l) as D\n", "//Calculation of the extent of the reaction, expressed in concentration units.The inbuilt function fsolve is used for solving the set of equations\n", "tol=1e-6;//tolerance limit framed for the convergence of the system of equations by using fsolve\n", "Eguess=1;//taking a guess value for the extent of reaction (no unit)\n", "function[fn]=solver_func(Ei)\n", " //Function defined for solving the system\n", " fn=Kc-(((m(1,:)+n(1,:)*Ei)^n(1,:))*((m(2,:)+n(2,:)*Ei)^n(2,:))*((m(3,:)+n(3,:)*Ei)^n(3,:))*((m(4,:)+n(4,:)*Ei)^n(4,:)));\n", "endfunction\n", "[E]=fsolve(Eguess,solver_func,tol);//using inbuilt function fsolve for solving the system of equations\n", "C_A=(m(4,:)+n(4,:)*E);//equilibrium concentration of CH3COOH(l) (no unit)\n", "C_B=(m(3,:)+n(3,:)*E);//equilibrium concentration of C2H5OH(l) (no unit)\n", "C_C=(m(1,:)+n(1,:)*E);//equilibrium concentration of CH3COOC2H5(l) (no unit)\n", "C_D=(m(2,:)+n(2,:)*E);//equilibrium concentration of H2O(l) (no unit)\n", "\n", "//OUTPUT\n", "mprintf('\n The extent of reaction, expressed in concentration units=%0.4f\n',E);\n", "mprintf('\n The equilibrium concentration:C_A=%0.4f kmol/m^3 \t C_B=%0.4f kmol/m^3 \t C_C=%0.4f kmol/m^3 \t C_D=%0.4f kmol/m^3 \n',C_A,C_B,C_C,C_D);\n", "\n", "//===============================================END OF PROGRAM===================================================\n", "" ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 14.15: Decomposition_pressure.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "// Y.V.C.Rao ,1997.Chemical Engineering Thermodynamics.Universities Press,Hyderabad,India.\n", "\n", "//Chapter-14,Example 15,Page 517\n", "//Title: Decomposition pressure\n", "//================================================================================================================\n", "clear \n", "clc\n", "\n", "//INPUT\n", "//The reaction is given by: CaCO3(s)--->CaO(s)+CO2(g)\n", "T=1200;//temperature in K\n", "T0=298.15;//reference temperature in K\n", "//The isobaric molar capacity is given by Cp=a+bT+cT^2+dT^3+eT^-2 in J/molK and T is in K \n", "//coefficient in the expression for computing the isobaric molar heat capacity (for CaO(s),CO2(g),CaCO3(s) respectively)\n", "a=[41.84;45.369;82.34];\n", "//coefficient in the expression for computing the isobaric molar heat capacity (for CaO(s),CO2(g),CaCO3(s) respectively)\n", "b=[20.25*10^-3;8.688*10^-3;49.75*10^-3];\n", "//coefficient in the expression for computing the isobaric molar heat capacity (for CaO(s),CO2(g),CaCO3(s) respectively)\n", "c=[0;0;0];\n", "//coefficient in the expression for computing the isobaric molar heat capacity (for CaO(s),CO2(g),CaCO3(s) respectively)\n", "d=[0;0;0];\n", "//coefficient in the expression for computing the isobaric molar heat capacity (for CaO(s),CO2(g),CaCO3(s) respectively)\n", "e=[-4.51*10^5;-9.619*10^5;-12.87*10^5];\n", "del_Gf=[-604.574;-394.815;-1129.515]//Standard Gibbs free energies of formation of (CaO(s),CO2(g),CaCO3(s)) in kJ\n", "del_Hf=[-635.975;-393.978;-1207.683]//Standard enthalpies of formation of (CaO(s),CO2(g),CaCO3(s))in kJ\n", "n=[1;1;-1];//stoichiometric coefficients of CaO(s),CO2(g) and CaCO3(s) respectively (no unit)\n", "R=8.314;//universal gas constant in J/molK\n", "\n", "//CALCULATION\n", "del_G=(n(1,:)*del_Gf(1,:))+(n(2,:)*del_Gf(2,:))+(n(3,:)*del_Gf(3,:));//calculation of the Gibbs free energy of reaction in kJ\n", "del_H=(n(1,:)*del_Hf(1,:))+(n(2,:)*del_Hf(2,:))+(n(3,:)*del_Hf(3,:));//calculation of the enthalpy of the reaction in kJ\n", "//Framing the isobaric molar heat capacity expression\n", "del_a=(n(1,:)*a(1,:))+(n(2,:)*a(2,:))+(n(3,:)*a(3,:));\n", "del_b=(n(1,:)*b(1,:))+(n(2,:)*b(2,:))+(n(3,:)*b(3,:));\n", "del_c=(n(1,:)*c(1,:))+(n(2,:)*c(2,:))+(n(3,:)*c(3,:));\n", "del_d=(n(1,:)*d(1,:))+(n(2,:)*d(2,:))+(n(3,:)*d(3,:));\n", "del_e=(n(1,:)*e(1,:))+(n(2,:)*e(2,:))+(n(3,:)*e(3,:));\n", "//Using Eq.14.21 to compute the value of del_H0 in kJ\n", "del_H0=((del_H*10^3)-((del_a*T0)+((del_b/2)*T0^2)+((del_c/3)*T0^3)+((del_d/4)*T0^4)-(del_e/T0)))*10^-3;\n", "//Using Eq.14.23 to compute the value of IR (no unit)\n", "IR=(1/(T0))*((del_H0*10^3)-(del_a*T0*log(T0))-((del_b/2)*T0^2)-((del_c/6)*T0^3)-((del_d/12)*T0^4)-((del_e/2)*(1/T0))-(del_G*10^3));\n", "//Using Eq.14.23 to compute the Gibbs free energy of the reaction at T in kJ\n", "del_G_T=((del_H0*10^3)-(del_a*T*log(T))-((del_b/2)*T^2)-((del_c/6)*T^3)-((del_d/12)*T^4)-((del_e/2)*(1/T))-(IR*T))*10^-3;\n", "Ka=exp((-del_G_T*10^3)/(R*T));//calculation of the equilibrium constant (no unit)\n", "//Now, Ka=(a_CaO*a_CO2)/a_CaCO3. We get a_CaO=1 and a_CaCO3=1, if we choose the pure component solids CaO(s) and CaCO3(s) at 1200K(at T)and 1 bar pressure as the standard states. Then, Ka=a_CO2=(f/f0)_CO2=((phi*y*P)/f0)_CO2. Assume the gas phase (pure CO2) is ideal. Then, phi=1 and y=1. The usual standard state for the gas gives f0=1 bar.Therefore, Ka=P\n", "y=1;\n", "phi=1;\n", "f0=1;\n", "P=(Ka*f0)/(phi*y);//calculation of the decomposition pressure in bar\n", "\n", "//OUTPUT\n", "mprintf('\n The decomposition pressure,P=%f bar \n',P);\n", "\n", "//===============================================END OF PROGRAM===================================================\n", "\n", "//DISCLAIMER: THE TEXTBOOK, GIVES A VALUE OF 2.42 bar FOR THE VALUE OF THE DECOMPOSITION PRESSURE. HOWEVER, THE ACTUAL VALUE IS ONLY 2.38 bar AND NOT 2.42 bar AS PRINTED IN THE TEXTBOOK. " ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 14.1: Standard_Gibbs_free_energy_change_and_equilibrium_constant.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "// Y.V.C.Rao ,1997.Chemical Engineering Thermodynamics.Universities Press,Hyderabad,India.\n", "\n", "//Chapter-14,Example 1,Page 489\n", "//Title: Standard Gibbs free energy change and equilibrium constant\n", "//================================================================================================================\n", "clear \n", "clc\n", "\n", "//INPUT\n", "//The water gas shift reaction is given by : CO2(g)+H2(g)--->CO(g)+H2O(g)\n", "T=298.15;//temperature in K\n", "del_Gf=[-137.327;-228.600;-394.815;0];//the standard Gibbs free energy of formation of CO(g),H2O(g),CO2(g) and H2(g) in kJ\n", "n=[1;1;-1;-1];//stoichiometric coefficients of CO(g),H2O(g),CO2(g) and H2(g) respectively (no unit)\n", "R=8.314;//universal gas constant in J/molK\n", "\n", "//CALCULATION\n", "//calculation of the standard Gibbs free energy of reaction at 298.15K using Eq.(14.1) in kJ\n", "del_G=(n(1,:)*del_Gf(1,:))+(n(2,:)*del_Gf(2,:))+(n(3,:)*del_Gf(3,:))+(n(4,:)*del_Gf(4,:));\n", "Ka=exp((-(del_G*10^3))/(R*T));//calculation of the equilibrium constant using Eq.(14.9) (no unit)\n", "\n", "//OUTPUT\n", "mprintf('The standard Gibbs free energy of the water gas shift reaction at 298.15K=%0.3f kJ \n',del_G);\n", "mprintf('The equilibrium constant of the water gas shift reaction at 298.15K=%0.3e \n',Ka);\n", "\n", "//===============================================END OF PROGRAM===================================================\n", "" ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 14.2: Standard_Gibbs_free_energy_of_formation.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "// Y.V.C.Rao ,1997.Chemical Engineering Thermodynamics.Universities Press,Hyderabad,India.\n", "\n", "//Chapter-14,Example 2,Page 490\n", "//Title: Standard Gibbs free energy of formation\n", "//================================================================================================================\n", "clear \n", "clc\n", "\n", "//INPUT\n", "T=298.15;//temperature in K\n", "P_s=0.16716;//saturation pressure of CH3OH in bar at T\n", "//The reactions can be written down as:\n", "//C(s)+2H2(g)+(1/2)O2(g)---->CH3OH(l)--->del_G1\n", "//CH3OH(l)--->CH3OH(g)--->del_G2\n", "//Overall: C(s)+2H2(g)+(1/2)O2(g)--->CH3OH(g)--->del_G=del_G2+del_G1\n", "del_G1=-166.215;//standard Gibbs free energy of formation of CH3OH(l) in kJ\n", "R=8.314;//universal gas constant in J/molK\n", "\n", "//CALCULATION\n", "//Now, the value of del_G2 has to be computed, from which del_G can be determined. The standard state for CH3OH(l) is 1 bar and 298.15K\n", "//del_G2 is given by, del_G2=RTln(f_v/f_l), where f_v and f_l are the fugacities of the vapour and liquid phases respectively\n", "//At 1 bar pressure, the vapour is an ideal gas and hence its fugacity is equal to pressure\n", "f_v=1;//fugacity of the vapour in bar\n", "f_l=P_s;//fugacity of the liquid is the saturation pressure at T, in bar\n", "del_G2=R*T*log(f_v/f_l)*10^-3;//calculation of the value of del_G2 in kJ\n", "del_G=del_G2+del_G1;//calculation of the standard Gibbs free energy of formation of CH3OH(g) in kJ\n", "\n", "//OUTPUT\n", "mprintf('The standard Gibbs free energy of formation of CH3OH(g)=%0.3f kJ \n',del_G);\n", "\n", "\n", "//===============================================END OF PROGRAM===================================================\n", "\n", "\n", "" ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 14.3: Equilibrium_constant.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "// Y.V.C.Rao ,1997.Chemical Engineering Thermodynamics.Universities Press,Hyderabad,India.\n", "\n", "//Chapter-14,Example 3,Page 491\n", "//Title: Equilibrium constant\n", "//================================================================================================================\n", "clear \n", "clc\n", "\n", "//INPUT\n", "//The water gas shift reaction is given by: CO2(g)+H2(g)--->CO(g)+H2O(g)\n", "T1=298.15;//initial temperature in K\n", "Ka1=8.685*10^-6;//equilibrium constant for the water-gas shift reaction at T1 (no unit)\n", "T2=1000;//temperature at which the equilibrium constant has to be determined in K\n", "R=8.314;//universal gas constant in J/molK\n", "del_Hf=[-110.532;-241.997;-393.978;0];//the standard enthalpy of formation of CO(g),H2O(g),CO2(g) and H2(g) in kJ\n", "n=[1;1;-1;-1];//stoichiometric coefficients of CO(g),H2O(g),CO2(g) and H2(g) respectively (no unit)\n", "\n", "//CALCULATION\n", "//It is assumed that del_H is constant in the temperature range T1 and T2\n", "del_H=(n(1,:)*del_Hf(1,:))+(n(2,:)*del_Hf(2,:))+(n(3,:)*del_Hf(3,:))+(n(4,:)*del_Hf(4,:));//calculation of the standard enthalpy of the reaction in kJ\n", "Ka2=Ka1*exp(((del_H*10^3)/R)*((1/T1)-(1/T2)));//calculation of the equilibrium constant at T2 (no unit)\n", "\n", "//OUTPUT\n", "mprintf('The equilibrium constant for the water gas shift reaction at 1000K=%f \n',Ka2);\n", "\n", "\n", "//===============================================END OF PROGRAM===================================================\n", "\n", "\n", "\n", "" ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 14.4: Equilibrium_constant_with_enthalpy_of_reaction_varying_with_temperature.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "// Y.V.C.Rao ,1997.Chemical Engineering Thermodynamics.Universities Press,Hyderabad,India.\n", "\n", "//Chapter-14,Example 4,Page 492\n", "//Title: Equilibrium constant with enthalpy of reaction varying with temperature\n", "//================================================================================================================\n", "clear \n", "clc\n", "\n", "//INPUT\n", "//The water gas shift reaction is given by: CO2(g)+H2(g)--->CO(g)+H2O(g)\n", "P=0.1;//pressure in MPa\n", "T1=298.15;//initial temperature in K\n", "Ka1=8.685*10^-6;//equilibrium constant for the water-gas shift reaction at T1 (no unit) (from Example 14.1)\n", "T2=1000;//temperature at which the equilibrium constant is to be found, in K\n", "del_H=41.449;//standard enthalpy of the reaction at T1 in kJ (from Example 14.3)\n", "//The isobaric molar capacity is given by Cp=a+bT+cT^2+dT^3+eT^-2 in J/molK and T is in K from Appendix A.3\n", "//coefficient in the expression for computing the isobaric molar heat capacity from Appendix A.3 (for CO(g),H2O(g),CO2(g),H2(g) respectively)\n", "a=[28.068;28.850;45.369;27.012];\n", "//coefficient in the expression for computing the isobaric molar heat capacity from Appendix A.3 (for CO(g),H2O(g),CO2(g),H2(g) respectively)\n", "b=[4.631*10^-3;12.055*10^-3;8.688*10^-3;3.509*10^-3];\n", "//coefficient in the expression for computing the isobaric molar heat capacity from Appendix A.3 (for CO(g),H2O(g),CO2(g),H2(g) respectively)\n", "c=[0;0;0;0];\n", "//coefficient in the expression for computing the isobaric molar heat capacity from Appendix A.3 (for CO(g),H2O(g),CO2(g),H2(g) respectively)\n", "d=[0;0;0;0];\n", "//coefficient in the expression for computing the isobaric molar heat capacity from Appendix A.3 (for CO(g),H2O(g),CO2(g),H2(g) respectively)\n", "e=[-0.258*10^5;1.006*10^5;-9.619*10^5;0.690*10^5];\n", "n=[1;1;-1;-1];//stoichiometric coefficients of CO(g),H2O(g),CO2(g) and H2(g) respectively (no unit)\n", "R=8.314;//universal gas constant in J/molK\n", "Ka2_prev=1.0855;//equilibrium constant calculated in Example (14.3) without considering the variation of del_H between T1 and T2 (no unit)\n", "\n", "\n", "//CALCULATION\n", "//Framing the isobaric molar heat capacity expression\n", "del_a=(n(1,:)*a(1,:))+(n(2,:)*a(2,:))+(n(3,:)*a(3,:))+(n(4,:)*a(4,:));\n", "del_b=(n(1,:)*b(1,:))+(n(2,:)*b(2,:))+(n(3,:)*b(3,:))+(n(4,:)*b(4,:));\n", "del_c=(n(1,:)*c(1,:))+(n(2,:)*c(2,:))+(n(3,:)*c(3,:))+(n(4,:)*c(4,:));\n", "del_d=(n(1,:)*d(1,:))+(n(2,:)*d(2,:))+(n(3,:)*d(3,:))+(n(4,:)*d(4,:));\n", "del_e=(n(1,:)*e(1,:))+(n(2,:)*e(2,:))+(n(3,:)*e(3,:))+(n(4,:)*e(4,:));\n", "//Using Eq.14.21 to compute the value of del_H0 in kJ\n", "del_H0=(del_H*10^3)-((del_a*T1)+((del_b/2)*T1^2)+((del_c/3)*T1^3)+((del_d/4)*T1^4)-(del_e/T1));\n", "//Calculation of the integration constant using Eq.(14.22) (no unit)\n", "I=(log(Ka1))-((1/R)*((-del_H0/T1)+(del_a*log(T1))+((del_b/2)*T1)+((del_c/6)*T1^2)+((del_d/12)*T1^3)+((del_e/(2*T1^2)))));\n", "//calculation of the equilibrium constant at T2 using Eq.(14.22) (no unit)\n", "Ka2=exp(((1/R)*((-del_H0/T2)+(del_a*log(T2))+((del_b/2)*T2)+((del_c/6)*T2^2)+((del_d/12)*T2^3)+((del_e/(2*T2^2)))))+I);\n", "\n", "//OUTPUT\n", "mprintf('The equilibrium constant for the water gas shift reaction at 1000K by taking into account the variation of del_H with temperature=%f \n',Ka2);\n", "mprintf('The equilibrium constant for the water gas shift reaction at 1000K without considering the variation of del_H with temperature as given by Example(14.3)=%0.4f \n',Ka2_prev);\n", "\n", "\n", "//===============================================END OF PROGRAM===================================================\n", "\n", "" ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 14.5: Conversion_and_composition_of_the_equilibrium_mixture.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "// Y.V.C.Rao ,1997.Chemical Engineering Thermodynamics.Universities Press,Hyderabad,India.\n", "\n", "//Chapter-14,Example 5,Page 494\n", "//Title: Conversion and composition of the equilibrium mixture\n", "//================================================================================================================\n", "clear \n", "clc\n", "\n", "//INPUT\n", "//Industrial methanol is produced by the following reaction:\n", "//CO(g)+2H2(g)--->CH3OH(g)\n", "T0=298.15;//standard temperature in K\n", "T=500;//temperature in K\n", "P=5;//pressure in bar\n", "del_Hv=37.988;//enthalpy of vapourization of CH3OH at 298.15K in kJ/mol\n", "R=8.314;//universal gas constant in J/molK\n", "del_Gf=[-161.781;-137.327;0]//Standard Gibbs free energies of formation of CH3OH(g) from Example(14.2),CO(g) and H2(g) respectively in kJ\n", "del_Hf=[-238.648;-110.532;0]//Standard enthalpies of formation of CH3OH(l), CO(g) and H2(g) respectively in kJ\n", "//The isobaric molar capacity is given by Cp=a+bT+cT^2+dT^3+eT^-2 in J/molK and T is in K from Appendix A.3\n", "//coefficient in the expression for computing the isobaric molar heat capacity from Appendix A.3 (for CH3OH(g),CO(g),H2(g) respectively)\n", "a=[18.382;28.068;27.012];\n", "//coefficient in the expression for computing the isobaric molar heat capacity from Appendix A.3 (for CH3OH(g),CO(g),H2(g) respectively)\n", "b=[101.564*10^-3;4.631*10^-3;3.509*10^-3];\n", "//coefficient in the expression for computing the isobaric molar heat capacity from Appendix A.3 (for CH3OH(g),CO(g),H2(g) respectively)\n", "c=[-28.683*10^-6;0;0];\n", "//coefficient in the expression for computing the isobaric molar heat capacity from Appendix A.3 (for CH3OH(g),CO(g),H2(g) respectively)\n", "d=[0;0;0];\n", "//coefficient in the expression for computing the isobaric molar heat capacity from Appendix A.3 (for CH3OH(g),CO(g),H2(g) respectively)\n", "e=[0;-0.258*10^5;0.690*10^5];\n", "n=[1;-1;-2];//stoichiometric coefficients of CH3OH(g),CO(g) and H2(g) respectively (no unit)\n", "m=[0;1;2];//mole number in feed (for CH3OH(g),CO(g),H2(g) respectively)\n", "\n", "//CALCULATION\n", "del_Hf_CH3OH_g=del_Hf(1,:)+del_Hv;//calculation of the standard enthalpy of formation of CH3OH(g) in kJ\n", "del_G=(n(1,:)*del_Gf(1,:))+(n(2,:)*del_Gf(2,:))+(n(3,:)*del_Gf(3,:));//calculation of the Gibbs free energy of reaction in kJ\n", "del_H=del_Hf_CH3OH_g+(n(2,:)*del_Hf(2,:))+(n(3,:)*del_Hf(3,:));//calculation of the enthalpy of the reaction in kJ\n", "//Framing the isobaric molar heat capacity expression\n", "del_a=(n(1,:)*a(1,:))+(n(2,:)*a(2,:))+(n(3,:)*a(3,:));\n", "del_b=(n(1,:)*b(1,:))+(n(2,:)*b(2,:))+(n(3,:)*b(3,:));\n", "del_c=(n(1,:)*c(1,:))+(n(2,:)*c(2,:))+(n(3,:)*c(3,:));\n", "del_d=(n(1,:)*d(1,:))+(n(2,:)*d(2,:))+(n(3,:)*d(3,:));\n", "del_e=(n(1,:)*e(1,:))+(n(2,:)*e(2,:))+(n(3,:)*e(3,:));\n", "//Using Eq.14.21 to compute the value of del_H0 in kJ\n", "del_H0=((del_H*10^3)-((del_a*T0)+((del_b/2)*T0^2)+((del_c/3)*T0^3)+((del_d/4)*T0^4)-(del_e/T0)))*10^-3;\n", "//Using Eq.14.23 to compute the integration constant (no unit)\n", "I=(1/(R*T0))*((del_H0*10^3)-(del_a*T0*log(T0))-((del_b/2)*T0^2)-((del_c/6)*T0^3)-((del_d/12)*T0^4)-((del_e/2)*(1/T0))-(del_G*10^3));\n", "//Using Eq.14.23 to compute the Gibbs free energy of the reaction at T in kJ\n", "del_G_T=((del_H0*10^3)-(del_a*T*log(T))-((del_b/2)*T^2)-((del_c/6)*T^3)-((del_d/12)*T^4)-((del_e/2)*(1/T))-(I*R*T))*10^-3;\n", "Ka=exp((-del_G_T*10^3)/(R*T));//calculation of the equilibrium constant (no unit)\n", "del_n=n(1,:)+n(2,:)+n(3,:);//calculation of the total mole number (no unit)\n", "Ky=Ka/((P)^del_n);//calculation of the equilibrium constant in terms of the mole fractions using Eq.(14.30) (no unit) (K_phi=1.0,assuming ideal gas behaviour)\n", "mtot=m(1,:)+m(2,:)+m(3,:);//calculation of the total mole number of feed entering (no unit)\n", "//To determine the degree of conversion, the inbuilt function fsolve is used to solve the equation given by Ky=(y_CH3OH)/(y_CO*y_H2^2), where y_CH3OH,y_CO,y_H2 are the mole fractions of CH3OH,CO,H2 respectively. Let the equilibrium conversion be denoted as E\n", "E_guess=0.1;//taking a guess value for the degree of conversion,to be used in the inbuilt function fsolve (no unit)\n", "tol=1e-6;//tolerance limit for convergence of the system when using fsolve\n", "function[fn]=solver_func(Ei)\n", " //Function defined for solving the system \n", " fn=Ky-((((m(1,:)+(n(1,:)*Ei))/(mtot+(del_n*Ei)))^n(1,:))*(((m(2,:)+(n(2,:)*Ei))/(mtot+(del_n*Ei)))^n(2,:))*(((m(3,:)+(n(3,:)*Ei))/(mtot+(del_n*Ei)))^n(3,:)));\n", "endfunction\n", "[E]=fsolve(E_guess,solver_func,tol)//using inbuilt function fsolve for solving the system of equations\n", "//Calculation of the composition of the equilibrium mixture (for CH3OH(g),CO(g),H2(g) respectively)(no unit)\n", "y_CH3OH=(m(1,:)+(n(1,:)*E))/(mtot+(del_n*E));\n", "y_CO=(m(2,:)+(n(2,:)*E))/(mtot+(del_n*E));\n", "y_H2=(m(3,:)+(n(3,:)*E))/(mtot+(del_n*E));\n", "\n", "//OUTPUT\n", "mprintf('The degree of conversion at 500K and 5bar pressure=%0.4f\n',E);\n", "mprintf('The composition of the equilibrium mixture at 500K and 5bar pressure: y_CH3OH=%0.4f\t y_CO=%0.4f\t y_H2=%0.4f\n',y_CH3OH,y_CO,y_H2);\n", "\n", "//===============================================END OF PROGRAM===================================================" ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 14.6: Conversion_and_composition_of_the_equilibrium_mixture_at_5_and_100_bar_Pressures.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "// Y.V.C.Rao ,1997.Chemical Engineering Thermodynamics.Universities Press,Hyderabad,India.\n", "\n", "//Chapter-14,Example 6,Page 496\n", "//Title: Conversion and composition of the equilibrium mixture at 5 and 100 bar Pressures\n", "//================================================================================================================\n", "clear \n", "clc\n", "\n", "//INPUT\n", "//Industrial methanol is produced by the following reaction:\n", "//CO(g)+2H2(g)--->CH3OH(g)\n", "T0=298.15;//standard temperature in K\n", "T=500;//temperature in K\n", "P1=5;//pressure in bar\n", "P2=100;//pressure in bar\n", "del_Hv=37.988;//enthalpy of vapourization of CH3OH at 298.15K in kJ/mol\n", "R=8.314;//universal gas constant in J/molK\n", "del_Gf=[-161.781;-137.327;0]//Standard Gibbs free energies of formation of CH3OH(g) from Example(14.2),CO(g) and H2(g) respectively in kJ\n", "del_Hf=[-238.648;-110.532;0]//Standard enthalpies of formation of CH3OH(l), CO(g) and H2(g) respectively in kJ\n", "//The isobaric molar capacity is given by Cp=a+bT+cT^2+dT^3+eT^-2 in J/molK and T is in K from Appendix A.3\n", "//coefficient in the expression for computing the isobaric molar heat capacity from Appendix A.3 (for CH3OH(g),CO(g),H2(g) respectively)\n", "a=[18.382;28.068;27.012];\n", "//coefficient in the expression for computing the isobaric molar heat capacity from Appendix A.3 (for CH3OH(g),CO(g),H2(g) respectively)\n", "b=[101.564*10^-3;4.631*10^-3;3.509*10^-3];\n", "//coefficient in the expression for computing the isobaric molar heat capacity from Appendix A.3 (for CH3OH(g),CO(g),H2(g) respectively)\n", "c=[-28.683*10^-6;0;0];\n", "//coefficient in the expression for computing the isobaric molar heat capacity from Appendix A.3 (for CH3OH(g),CO(g),H2(g) respectively)\n", "d=[0;0;0];\n", "//coefficient in the expression for computing the isobaric molar heat capacity from Appendix A.3 (for CH3OH(g),CO(g),H2(g) respectively)\n", "e=[0;-0.258*10^5;0.690*10^5];\n", "n=[1;-1;-2];//stoichiometric coefficients of CH3OH(g),CO(g) and H2(g) respectively (no unit)\n", "m=[0;1;2];//mole number in feed (for CH3OH(g),CO(g),H2(g) respectively)\n", "\n", "//CALCULATION\n", "//From Example 14.5, the conversion and the equilibrium composition has been determined and this is given below:\n", "E1=0.0506;\n", "y_CH3OH_1=0.0175;\n", "y_CO_1=0.3275;\n", "y_H2_1=0.6550;\n", "//Calculation of conversion and equilibrium composition for the pressure of 100 bars(P2)\n", "del_Hf_CH3OH_g=del_Hf(1,:)+del_Hv;//calculation of the standard enthalpy of formation of CH3OH(g) in kJ\n", "del_G=(n(1,:)*del_Gf(1,:))+(n(2,:)*del_Gf(2,:))+(n(3,:)*del_Gf(3,:));//calculation of the Gibbs free energy of reaction in kJ\n", "del_H=del_Hf_CH3OH_g+(n(2,:)*del_Hf(2,:))+(n(3,:)*del_Hf(3,:));//calculation of the enthalpy of the reaction in kJ\n", "//Framing the isobaric molar heat capacity expression\n", "del_a=(n(1,:)*a(1,:))+(n(2,:)*a(2,:))+(n(3,:)*a(3,:));\n", "del_b=(n(1,:)*b(1,:))+(n(2,:)*b(2,:))+(n(3,:)*b(3,:));\n", "del_c=(n(1,:)*c(1,:))+(n(2,:)*c(2,:))+(n(3,:)*c(3,:));\n", "del_d=(n(1,:)*d(1,:))+(n(2,:)*d(2,:))+(n(3,:)*d(3,:));\n", "del_e=(n(1,:)*e(1,:))+(n(2,:)*e(2,:))+(n(3,:)*e(3,:));\n", "//Using Eq.14.21 to compute the value of del_H0 in kJ\n", "del_H0=((del_H*10^3)-((del_a*T0)+((del_b/2)*T0^2)+((del_c/3)*T0^3)+((del_d/4)*T0^4)-(del_e/T0)))*10^-3;\n", "//Using Eq.14.23 to compute the integration constant (no unit)\n", "I=(1/(R*T0))*((del_H0*10^3)-(del_a*T0*log(T0))-((del_b/2)*T0^2)-((del_c/6)*T0^3)-((del_d/12)*T0^4)-((del_e/2)*(1/T0))-(del_G*10^3));\n", "//Using Eq.14.23 to compute the Gibbs free energy of the reaction at T in kJ\n", "del_G_T=((del_H0*10^3)-(del_a*T*log(T))-((del_b/2)*T^2)-((del_c/6)*T^3)-((del_d/12)*T^4)-((del_e/2)*(1/T))-(I*R*T))*10^-3;\n", "Ka=exp((-del_G_T*10^3)/(R*T));//calculation of the equilibrium constant (no unit) \n", "del_n=n(1,:)+n(2,:)+n(3,:);//calculation of the total mole number (no unit)\n", "Ky=Ka/((P2)^del_n);//calculation of the equilibrium constant in terms of the mole fractions using Eq.(14.30) (no unit) (K_phi=1.0,assuming ideal gas behaviour)\n", "mtot=m(1,:)+m(2,:)+m(3,:);//calculation of the total mole number of feed entering (no unit)\n", "//To determine the degree of conversion, the inbuilt function fsolve is used to solve the equation given by Ky=(y_CH3OH)/(y_CO*y_H2^2), where y_CH3OH,y_CO,y_H2 are the mole fractions of CH3OH,CO,H2 respectively. Let the equilibrium conversion be denoted as E\n", "E_guess=0.1;//taking a guess value for the degree of conversion,to be used in the inbuilt function fsolve (no unit)\n", "tol=1e-6;//tolerance limit for convergence of the system when using fsolve\n", "function[fn]=solver_func(Ei)\n", " //Function defined for solving the system \n", " fn=Ky-((((m(1,:)+(n(1,:)*Ei))/(mtot+(del_n*Ei)))^n(1,:))*(((m(2,:)+(n(2,:)*Ei))/(mtot+(del_n*Ei)))^n(2,:))*(((m(3,:)+(n(3,:)*Ei))/(mtot+(del_n*Ei)))^n(3,:)));\n", "endfunction\n", "[E2]=fsolve(E_guess,solver_func,tol)//using inbuilt function fsolve for solving the system of equations\n", "//Calculation of the composition of the equilibrium mixture (for CH3OH(g),CO(g),H2(g) respectively)(no unit)\n", "y_CH3OH_2=(m(1,:)+(n(1,:)*E2))/(mtot+(del_n*E2));\n", "y_CO_2=(m(2,:)+(n(2,:)*E2))/(mtot+(del_n*E2));\n", "y_H2_2=(m(3,:)+(n(3,:)*E2))/(mtot+(del_n*E2));\n", "\n", "//OUTPUT\n", "mprintf('The degree of conversion at 500K and 5bar pressure=%0.4f\n',E1);\n", "mprintf('The composition of the equilibrium mixture at 500K and 5bar pressure: y_CH3OH=%0.4f\t y_CO=%0.4f\t y_H2=%0.4f\n',y_CH3OH_1,y_CO_1,y_H2_1);\n", "mprintf('The degree of conversion at 500K and 100bar pressure=%0.3f\n',E2);\n", "mprintf('The composition of the equilibrium mixture at 500K and 100bar pressure: y_CH3OH=%0.4f\t y_CO=%0.4f\t y_H2=%f\n',y_CH3OH_2,y_CO_2,y_H2_2);\n", "//===============================================END OF PROGRAM===================================================" ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 14.7: Conversion_and_composition_of_the_equilibrium_mixture_with_inerts.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "// Y.V.C.Rao ,1997.Chemical Engineering Thermodynamics.Universities Press,Hyderabad,India.\n", "\n", "//Chapter-14,Example 7,Page 497\n", "//Title: Conversion and composition of the equilibrium mixture with inerts\n", "//================================================================================================================\n", "clear \n", "clc\n", "\n", "//INPUT\n", "//Industrial methanol is produced by the following reaction:\n", "//CO(g)+2H2(g)--->CH3OH(g)\n", "T0=298.15;//standard temperature in K\n", "T=500;//temperature in K\n", "P=5;//pressure in bar\n", "del_Hv=37.988;//enthalpy of vapourization of CH3OH at 298.15K in kJ/mol\n", "R=8.314;//universal gas constant in J/molK\n", "del_Gf=[-161.781;-137.327;0]//Standard Gibbs free energies of formation of CH3OH(g) from Example(14.2),CO(g) and H2(g) respectively in kJ\n", "del_Hf=[-238.648;-110.532;0]//Standard enthalpies of formation of CH3OH(l), CO(g) and H2(g) respectively in kJ\n", "//The isobaric molar capacity is given by Cp=a+bT+cT^2+dT^3+eT^-2 in J/molK and T is in K from Appendix A.3\n", "//coefficient in the expression for computing the isobaric molar heat capacity from Appendix A.3 (for CH3OH(g),CO(g),H2(g) respectively)\n", "a=[18.382;28.068;27.012];\n", "//coefficient in the expression for computing the isobaric molar heat capacity from Appendix A.3 (for CH3OH(g),CO(g),H2(g) respectively)\n", "b=[101.564*10^-3;4.631*10^-3;3.509*10^-3];\n", "//coefficient in the expression for computing the isobaric molar heat capacity from Appendix A.3 (for CH3OH(g),CO(g),H2(g) respectively)\n", "c=[-28.683*10^-6;0;0];\n", "//coefficient in the expression for computing the isobaric molar heat capacity from Appendix A.3 (for CH3OH(g),CO(g),H2(g) respectively)\n", "d=[0;0;0];\n", "//coefficient in the expression for computing the isobaric molar heat capacity from Appendix A.3 (for CH3OH(g),CO(g),H2(g) respectively)\n", "e=[0;-0.258*10^5;0.690*10^5];\n", "n=[1;-1;-2];//stoichiometric coefficients of CH3OH(g),CO(g),H2(g) respectively (no unit)\n", "//The inert is denoted as A\n", "m=[0;1;2;5];//mole number in feed (for CH3OH(g),CO(g),H2(g),A(g) respectively)\n", "\n", "//CALCULATION\n", "del_Hf_CH3OH_g=del_Hf(1,:)+del_Hv;//calculation of the standard enthalpy of formation of CH3OH(g) in kJ\n", "del_G=(n(1,:)*del_Gf(1,:))+(n(2,:)*del_Gf(2,:))+(n(3,:)*del_Gf(3,:));//calculation of the Gibbs free energy of reaction in kJ\n", "del_H=del_Hf_CH3OH_g+(n(2,:)*del_Hf(2,:))+(n(3,:)*del_Hf(3,:));//calculation of the enthalpy of the reaction in kJ\n", "//Framing the isobaric molar heat capacity expression\n", "del_a=(n(1,:)*a(1,:))+(n(2,:)*a(2,:))+(n(3,:)*a(3,:));\n", "del_b=(n(1,:)*b(1,:))+(n(2,:)*b(2,:))+(n(3,:)*b(3,:));\n", "del_c=(n(1,:)*c(1,:))+(n(2,:)*c(2,:))+(n(3,:)*c(3,:));\n", "del_d=(n(1,:)*d(1,:))+(n(2,:)*d(2,:))+(n(3,:)*d(3,:));\n", "del_e=(n(1,:)*e(1,:))+(n(2,:)*e(2,:))+(n(3,:)*e(3,:));\n", "//Using Eq.14.21 to compute the value of del_H0 in kJ\n", "del_H0=((del_H*10^3)-((del_a*T0)+((del_b/2)*T0^2)+((del_c/3)*T0^3)+((del_d/4)*T0^4)-(del_e/T0)))*10^-3;\n", "//Using Eq.14.23 to compute the integration constant (no unit)\n", "I=(1/(R*T0))*((del_H0*10^3)-(del_a*T0*log(T0))-((del_b/2)*T0^2)-((del_c/6)*T0^3)-((del_d/12)*T0^4)-((del_e/2)*(1/T0))-(del_G*10^3));\n", "//Using Eq.14.23 to compute the Gibbs free energy of the reaction at T in kJ\n", "del_G_T=((del_H0*10^3)-(del_a*T*log(T))-((del_b/2)*T^2)-((del_c/6)*T^3)-((del_d/12)*T^4)-((del_e/2)*(1/T))-(I*R*T))*10^-3;\n", "Ka=exp((-del_G_T*10^3)/(R*T));//calculation of the equilibrium constant (no unit)\n", "del_n=n(1,:)+n(2,:)+n(3,:);//calculation of the total mole number (no unit)\n", "Ky=Ka/((P)^del_n);//calculation of the equilibrium constant in terms of the mole fractions using Eq.(14.30) (no unit) (K_phi=1.0,assuming ideal gas behaviour)\n", "mtot=m(1,:)+m(2,:)+m(3,:)+m(4,:);//calculation of the total mole number of feed entering (no unit)\n", "//To determine the degree of conversion, the inbuilt function fsolve is used to solve the equation given by Ky=(y_CH3OH)/(y_CO*y_H2^2), where y_CH3OH,y_CO,y_H2 are the mole fractions of CH3OH,CO,H2 respectively. Let the equilibrium conversion be denoted as E\n", "E_guess=0.1;//taking a guess value for the degree of conversion,to be used in the inbuilt function fsolve (no unit)\n", "tol=1e-6;//tolerance limit for convergence of the system when using fsolve\n", "function[fn]=solver_func(Ei)\n", " //Function defined for solving the system \n", " fn=Ky-((((m(1,:)+(n(1,:)*Ei))/(mtot+(del_n*Ei)))^n(1,:))*(((m(2,:)+(n(2,:)*Ei))/(mtot+(del_n*Ei)))^n(2,:))*(((m(3,:)+(n(3,:)*Ei))/(mtot+(del_n*Ei)))^n(3,:)));\n", "endfunction\n", "[E]=fsolve(E_guess,solver_func,tol)//using inbuilt function fsolve for solving the system of equations\n", "//Calculation of the composition of the equilibrium mixture (for CH3OH(g),CO(g),H2(g),A(g) respectively)(no unit)\n", "y_CH3OH=(m(1,:)+(n(1,:)*E))/(mtot+(del_n*E));\n", "y_CO=(m(2,:)+(n(2,:)*E))/(mtot+(del_n*E));\n", "y_H2=(m(3,:)+(n(3,:)*E))/(mtot+(del_n*E));\n", "y_A=m(4,:)/(mtot+(del_n*E));\n", "//OUTPUT\n", "mprintf('The degree of conversion at 500K and 5bar pressure=%0.5f\n',E);\n", "mprintf('The composition of the equilibrium mixture at 500K and 5bar pressure: y_CH3OH=%0.5f\t y_CO=%0.5f\t y_H2=%0.5f\t y_A=%0.4f \n',y_CH3OH,y_CO,y_H2,y_A);\n", "//===============================================END OF PROGRAM===================================================" ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 14.8: Degree_of_conversion_for_different_feed_conditions.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "// Y.V.C.Rao ,1997.Chemical Engineering Thermodynamics.Universities Press,Hyderabad,India.\n", "\n", "//Chapter-14,Example 8,Page 498\n", "//Title: Degree of conversion for different feed conditions\n", "//================================================================================================================\n", "clear \n", "clc\n", "\n", "//INPUT\n", "//Industrial methanol is produced by the following reaction:\n", "//CO(g)+2H2(g)--->CH3OH(g)\n", "T0=298.15;//standard temperature in K\n", "T=500;//temperature in K\n", "P=5;//pressure in bar\n", "del_Hv=37.988;//enthalpy of vapourization of CH3OH at 298.15K in kJ/mol\n", "R=8.314;//universal gas constant in J/molK\n", "del_Gf=[-161.781;-137.327;0]//Standard Gibbs free energies of formation of CH3OH(g) from Example(14.2),CO(g) and H2(g) respectively in kJ\n", "del_Hf=[-238.648;-110.532;0]//Standard enthalpies of formation of CH3OH(l), CO(g) and H2(g) respectively in kJ\n", "//The isobaric molar capacity is given by Cp=a+bT+cT^2+dT^3+eT^-2 in J/molK and T is in K from Appendix A.3\n", "//coefficient in the expression for computing the isobaric molar heat capacity from Appendix A.3 (for CH3OH(g),CO(g),H2(g) respectively)\n", "a=[18.382;28.068;27.012];\n", "//coefficient in the expression for computing the isobaric molar heat capacity from Appendix A.3 (for CH3OH(g),CO(g),H2(g) respectively)\n", "b=[101.564*10^-3;4.631*10^-3;3.509*10^-3];\n", "//coefficient in the expression for computing the isobaric molar heat capacity from Appendix A.3 (for CH3OH(g),CO(g),H2(g) respectively)\n", "c=[-28.683*10^-6;0;0];\n", "//coefficient in the expression for computing the isobaric molar heat capacity from Appendix A.3 (for CH3OH(g),CO(g),H2(g) respectively)\n", "d=[0;0;0];\n", "//coefficient in the expression for computing the isobaric molar heat capacity from Appendix A.3 (for CH3OH(g),CO(g),H2(g) respectively)\n", "e=[0;-0.258*10^5;0.690*10^5];\n", "n=[1;-1;-2];//stoichiometric coefficients of CH3OH(g),CO(g) and H2(g) respectively (no unit)\n", "//The degree of conversion has been determined for 3 different feed conditions:\n", "//a) an equimolar mixture of CO(g) and H2(g) is fed to the reactor\n", "//b) stoichiometric mixture of CO(g) and H2(g) is fed to the reactor\n", "//c) CO(g) and H2(g) in the ratio 1:4 enter the reactor\n", "m_a=[0;1;1];//mole number in feed (for CH3OH(g),CO(g),H2(g) respectively for condition (a))\n", "m_b=[0;1;2];//mole number in feed (for CH3OH(g),CO(g),H2(g) respectively for condition (b))\n", "m_c=[0;1;4];//mole number in feed (for CH3OH(g),CO(g),H2(g) respectively for condition (c))\n", "\n", "//CALCULATION\n", "del_Hf_CH3OH_g=del_Hf(1,:)+del_Hv;//calculation of the standard enthalpy of formation of CH3OH(g) in kJ\n", "del_G=(n(1,:)*del_Gf(1,:))+(n(2,:)*del_Gf(2,:))+(n(3,:)*del_Gf(3,:));//calculation of the Gibbs free energy of reaction in kJ\n", "del_H=del_Hf_CH3OH_g+(n(2,:)*del_Hf(2,:))+(n(3,:)*del_Hf(3,:));//calculation of the enthalpy of the reaction in kJ\n", "//Framing the isobaric molar heat capacity expression\n", "del_a=(n(1,:)*a(1,:))+(n(2,:)*a(2,:))+(n(3,:)*a(3,:));\n", "del_b=(n(1,:)*b(1,:))+(n(2,:)*b(2,:))+(n(3,:)*b(3,:));\n", "del_c=(n(1,:)*c(1,:))+(n(2,:)*c(2,:))+(n(3,:)*c(3,:));\n", "del_d=(n(1,:)*d(1,:))+(n(2,:)*d(2,:))+(n(3,:)*d(3,:));\n", "del_e=(n(1,:)*e(1,:))+(n(2,:)*e(2,:))+(n(3,:)*e(3,:));\n", "//Using Eq.14.21 to compute the value of del_H0 in kJ\n", "del_H0=((del_H*10^3)-((del_a*T0)+((del_b/2)*T0^2)+((del_c/3)*T0^3)+((del_d/4)*T0^4)-(del_e/T0)))*10^-3;\n", "//Using Eq.14.23 to compute the integration constant (no unit)\n", "I=(1/(R*T0))*((del_H0*10^3)-(del_a*T0*log(T0))-((del_b/2)*T0^2)-((del_c/6)*T0^3)-((del_d/12)*T0^4)-((del_e/2)*(1/T0))-(del_G*10^3));\n", "//Using Eq.14.23 to compute the Gibbs free energy of the reaction at T in kJ\n", "del_G_T=((del_H0*10^3)-(del_a*T*log(T))-((del_b/2)*T^2)-((del_c/6)*T^3)-((del_d/12)*T^4)-((del_e/2)*(1/T))-(I*R*T))*10^-3;\n", "Ka=exp((-del_G_T*10^3)/(R*T));//calculation of the equilibrium constant (no unit)\n", "del_n=n(1,:)+n(2,:)+n(3,:);//calculation of the total mole number (no unit)\n", "Ky=Ka/((P)^del_n);//calculation of the equilibrium constant in terms of the mole fractions using Eq.(14.30) (no unit) (K_phi=1.0,assuming ideal gas behaviour)\n", "mtot_a=m_a(1,:)+m_a(2,:)+m_a(3,:);//calculation of the total mole number of feed entering (no unit) (for condition (a))\n", "mtot_b=m_b(1,:)+m_b(2,:)+m_b(3,:);//calculation of the total mole number of feed entering (no unit) (for condition (b))\n", "mtot_c=m_c(1,:)+m_c(2,:)+m_c(3,:);//calculation of the total mole number of feed entering (no unit) (for condition (c))\n", "//To determine the degree of conversion, the inbuilt function fsolve is used to solve the equation given by Ky=(y_CH3OH)/(y_CO*y_H2^2), where y_CH3OH,y_CO,y_H2 are the mole fractions of CH3OH,CO,H2 respectively. Let the equilibrium conversion be denoted as E. This is done for all the three conditions (a,b and c)\n", "E_guess=0.1;//taking a guess value for the degree of conversion,to be used in the inbuilt function fsolve (no unit)\n", "tol=1e-6;//tolerance limit for convergence of the system when using fsolve\n", "//For condition (a)\n", "function[fn]=solver_func1(Ei)\n", " //Function defined for solving the system \n", " fn=Ky-((((m_a(1,:)+(n(1,:)*Ei))/(mtot_a+(del_n*Ei)))^n(1,:))*(((m_a(2,:)+(n(2,:)*Ei))/(mtot_a+(del_n*Ei)))^n(2,:))*(((m_a(3,:)+(n(3,:)*Ei))/(mtot_a+(del_n*Ei)))^n(3,:)));\n", "endfunction\n", "[E_a]=fsolve(E_guess,solver_func1,tol)//using inbuilt function fsolve for solving the system of equations\n", "//For condition (b)\n", "function[fn]=solver_func2(Ei)\n", " //Function defined for solving the system \n", " fn=Ky-((((m_b(1,:)+(n(1,:)*Ei))/(mtot_b+(del_n*Ei)))^n(1,:))*(((m_b(2,:)+(n(2,:)*Ei))/(mtot_b+(del_n*Ei)))^n(2,:))*(((m_b(3,:)+(n(3,:)*Ei))/(mtot_b+(del_n*Ei)))^n(3,:)));\n", "endfunction\n", "[E_b]=fsolve(E_guess,solver_func2,tol)//using inbuilt function fsolve for solving the system of equations\n", "//For condition (c)\n", "function[fn]=solver_func3(Ei)\n", " //Function defined for solving the system \n", " fn=Ky-((((m_c(1,:)+(n(1,:)*Ei))/(mtot_c+(del_n*Ei)))^n(1,:))*(((m_c(2,:)+(n(2,:)*Ei))/(mtot_c+(del_n*Ei)))^n(2,:))*(((m_c(3,:)+(n(3,:)*Ei))/(mtot_c+(del_n*Ei)))^n(3,:)));\n", "endfunction\n", "[E_c]=fsolve(E_guess,solver_func3,tol)//using inbuilt function fsolve for solving the system of equations\n", "\n", "//OUTPUT\n", "mprintf('The degree of conversion at 500K and 5bar pressure, for an equimolar mixture of CO(g) and H2(g) as feed=%f\n',E_a);\n", "mprintf('The degree of conversion at 500K and 5bar pressure, for a stoichiometric mixture of CO(g) and H2(g) as feed=%0.4f\n',E_b);\n", "mprintf('The degree of conversion at 500K and 5bar pressure, for a feed of CO(g) and H2(g) in the ratio of 1:4=%f\n',E_c);\n", "\n", "\n", "//===============================================END OF PROGRAM===================================================" ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 14.9: Degree_of_conversion.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "// Y.V.C.Rao ,1997.Chemical Engineering Thermodynamics.Universities Press,Hyderabad,India.\n", "\n", "//Chapter-14,Example 9,Page 499\n", "//Title: Degree of conversion\n", "//================================================================================================================\n", "clear \n", "clc\n", "\n", "//INPUT\n", "//Industrial methanol is produced by the following reaction:\n", "//CO(g)+2H2(g)--->CH3OH(g)\n", "T0=298.15;//standard temperature in K\n", "T=500;//temperature in K\n", "P=5;//pressure in bar\n", "del_Hv=37.988;//enthalpy of vapourization of CH3OH at 298.15K in kJ/mol\n", "R=8.314;//universal gas constant in J/molK\n", "del_Gf=[-161.781;-137.327;0]//Standard Gibbs free energies of formation of CH3OH(g) from Example(14.2),CO(g) and H2(g) respectively in kJ\n", "del_Hf=[-238.648;-110.532;0]//Standard enthalpies of formation of CH3OH(l), CO(g) and H2(g) respectively in kJ\n", "//The isobaric molar capacity is given by Cp=a+bT+cT^2+dT^3+eT^-2 in J/molK and T is in K from Appendix A.3\n", "//coefficient in the expression for computing the isobaric molar heat capacity from Appendix A.3 (for CH3OH(g),CO(g),H2(g) respectively)\n", "a=[18.382;28.068;27.012];\n", "//coefficient in the expression for computing the isobaric molar heat capacity from Appendix A.3 (for CH3OH(g),CO(g),H2(g) respectively)\n", "b=[101.564*10^-3;4.631*10^-3;3.509*10^-3];\n", "//coefficient in the expression for computing the isobaric molar heat capacity from Appendix A.3 (for CH3OH(g),CO(g),H2(g) respectively)\n", "c=[-28.683*10^-6;0;0];\n", "//coefficient in the expression for computing the isobaric molar heat capacity from Appendix A.3 (for CH3OH(g),CO(g),H2(g) respectively)\n", "d=[0;0;0];\n", "//coefficient in the expression for computing the isobaric molar heat capacity from Appendix A.3 (for CH3OH(g),CO(g),H2(g) respectively)\n", "e=[0;-0.258*10^5;0.690*10^5];\n", "n=[1;-1;-2];//stoichiometric coefficients of CH3OH(g),CO(g) and H2(g) respectively (no unit)\n", "m=[0.02;1;2];//mole number in feed (for CH3OH(g),CO(g),H2(g) respectively)\n", "\n", "//CALCULATION\n", "del_Hf_CH3OH_g=del_Hf(1,:)+del_Hv;//calculation of the standard enthalpy of formation of CH3OH(g) in kJ\n", "del_G=(n(1,:)*del_Gf(1,:))+(n(2,:)*del_Gf(2,:))+(n(3,:)*del_Gf(3,:));//calculation of the Gibbs free energy of reaction in kJ\n", "del_H=del_Hf_CH3OH_g+(n(2,:)*del_Hf(2,:))+(n(3,:)*del_Hf(3,:));//calculation of the enthalpy of the reaction in kJ\n", "//Framing the isobaric molar heat capacity expression\n", "del_a=(n(1,:)*a(1,:))+(n(2,:)*a(2,:))+(n(3,:)*a(3,:));\n", "del_b=(n(1,:)*b(1,:))+(n(2,:)*b(2,:))+(n(3,:)*b(3,:));\n", "del_c=(n(1,:)*c(1,:))+(n(2,:)*c(2,:))+(n(3,:)*c(3,:));\n", "del_d=(n(1,:)*d(1,:))+(n(2,:)*d(2,:))+(n(3,:)*d(3,:));\n", "del_e=(n(1,:)*e(1,:))+(n(2,:)*e(2,:))+(n(3,:)*e(3,:));\n", "//Using Eq.14.21 to compute the value of del_H0 in kJ\n", "del_H0=((del_H*10^3)-((del_a*T0)+((del_b/2)*T0^2)+((del_c/3)*T0^3)+((del_d/4)*T0^4)-(del_e/T0)))*10^-3;\n", "//Using Eq.14.23 to compute the integration constant (no unit)\n", "I=(1/(R*T0))*((del_H0*10^3)-(del_a*T0*log(T0))-((del_b/2)*T0^2)-((del_c/6)*T0^3)-((del_d/12)*T0^4)-((del_e/2)*(1/T0))-(del_G*10^3));\n", "//Using Eq.14.23 to compute the Gibbs free energy of the reaction at T in kJ\n", "del_G_T=((del_H0*10^3)-(del_a*T*log(T))-((del_b/2)*T^2)-((del_c/6)*T^3)-((del_d/12)*T^4)-((del_e/2)*(1/T))-(I*R*T))*10^-3;\n", "Ka=exp((-del_G_T*10^3)/(R*T));//calculation of the equilibrium constant (no unit)\n", "del_n=n(1,:)+n(2,:)+n(3,:);//calculation of the total mole number (no unit)\n", "Ky=Ka/((P)^del_n);//calculation of the equilibrium constant in terms of the mole fractions using Eq.(14.30) (no unit) (K_phi=1.0,assuming ideal gas behaviour)\n", "mtot=m(1,:)+m(2,:)+m(3,:);//calculation of the total mole number of feed entering (no unit)\n", "//To determine the degree of conversion, the inbuilt function fsolve is used to solve the equation given by Ky=(y_CH3OH)/(y_CO*y_H2^2), where y_CH3OH,y_CO,y_H2 are the mole fractions of CH3OH,CO,H2 respectively. Let the equilibrium conversion be denoted as E\n", "E_guess=0.1;//taking a guess value for the degree of conversion,to be used in the inbuilt function fsolve (no unit)\n", "tol=1e-6;//tolerance limit for convergence of the system when using fsolve\n", "function[fn]=solver_func(Ei)\n", " //Function defined for solving the system \n", " fn=Ky-((((m(1,:)+(n(1,:)*Ei))/(mtot+(del_n*Ei)))^n(1,:))*(((m(2,:)+(n(2,:)*Ei))/(mtot+(del_n*Ei)))^n(2,:))*(((m(3,:)+(n(3,:)*Ei))/(mtot+(del_n*Ei)))^n(3,:)));\n", "endfunction\n", "[E]=fsolve(E_guess,solver_func,tol)//using inbuilt function fsolve for solving the system of equations\n", "\n", "\n", "//OUTPUT\n", "mprintf('The degree of conversion at 500K and 5bar pressure=%f\n',E);\n", "\n", "//===============================================END OF PROGRAM===================================================" ] } ], "metadata": { "kernelspec": { "display_name": "Scilab", "language": "scilab", "name": "scilab" }, "language_info": { "file_extension": ".sce", "help_links": [ { "text": "MetaKernel Magics", "url": "https://github.com/calysto/metakernel/blob/master/metakernel/magics/README.md" } ], "mimetype": "text/x-octave", "name": "scilab", "version": "0.7.1" } }, "nbformat": 4, "nbformat_minor": 0 }