{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Chapter 17: Chemical Reactions Equilibria" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 17.10: Tabulation_of_equilibrium_constant_values.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "clear;\n", "clc;\n", "\n", "//Example - 17.10\n", "//Page number - 609\n", "printf('Example - 17.10 and Page number - 606\n\n');\n", "\n", "// Given\n", "// (1/2)*N2 + (1/2)*O2 - NO\n", "\n", "R = 1.987;//[cal/mol-K]\n", "\n", "delta_H_NO_298 = 21.600;//[kcal/mol] - Enthalpy of formation of S02 at 298.15 K\n", "delta_G_NO_298 = 20.719;//[kcal/mol] - Gibbs free energy change for formation of SO2 at 298.15 K\n", "\n", "// Cp_0 = a + b*T + c*T^(2) + d*T^(3)\n", "\n", "a_N2 = 6.157;\n", "a_O2 = 6.085;\n", "a_NO = 6.461;\n", "b_N2 = -0.03753*10^(-2);\n", "b_O2 = 0.3631*10^(-2);\n", "b_NO = 0.2358*10^(-2);\n", "c_N2 = 0.1930*10^(-5);\n", "c_O2 = -0.1709*10^(-5);\n", "c_NO = -0.07705*10^(-5);\n", "d_N2 = -0.6861*10^(-9);\n", "d_O2 = 0.3133*10^(-9);\n", "d_NO = 0.08729*10^(-9);\n", "\n", "//(1)\n", "T_1 = 298.15;//[K]\n", "\n", "delta_H_rkn_298 = delta_H_NO_298;//[kcal]\n", "delta_H_rkn_298 = delta_H_rkn_298*10^(3);//[cal]\n", "delta_G_rkn_298 = delta_G_NO_298;//[kcal]\n", "delta_G_rkn_298 = delta_G_rkn_298*10^(3);//[cal]\n", "\n", "delta_a = a_NO - (a_N2/2) - (a_O2/2);\n", "delta_b = b_NO - (b_N2/2) - (b_O2/2);\n", "delta_c = c_NO - (c_N2/2) - (c_O2/2);\n", "delta_d = d_NO - (d_N2/2) - (d_O2/2);\n", "\n", "// delta_H_rkn_T = delta_H_rkn_298 + integrate('delta_a+(delta_b*T)+(delta_c*T^(2))+(delta_d*T^(3))','T',T_1,T);\n", "// On simplification we get\n", "// delta_H_rkn_T = 21584.63 - 0.033*T + 0.0365*10^(-2)*T^(2) - 0.0293*10^(-5)*T^(3) + 0.0685*10^(-9)*T^(4)\n", "\n", "printf(' The expression for delta_H_rkn_T as a function of T is given by\n');\n", "printf(' delta_H_rkn_T = 21584.63 - 0.033*T + 0.0365*10^(-2)*T^(2) - 0.0293*10^(-5)*T^(3) + 0.0685*10^(-9)*T^(4)\n\n');\n", "\n", "// Now let us calculate K_298 (at 298 K)\n", "// We know delta_G_rkn_298 = -R*T*log(K_298) \n", "K_298 = exp(-delta_G_rkn_298/(R*T_1));// Equilibrium constant at 298.15 K\n", "\n", "// log(K_2/K_1) = integrate('delta_H_rkn_298/(R*T^(2))','T',T_1,T)\n", "// On substituting the values and simplifying we get the expression\n", "// log(K) = 1.5103 - 10862.92/T - 0.0166*log(T) + 1.84*10^(-4)*T - 7.35*10^(-8)*T^(2) + 1.15*10^(-11)*T^(3)\n", "\n", "printf(' The expression for log(K) as a function of T is given by\n');\n", "printf(' log(K) = 1.5103 - 10862.92/T - 0.0166*log(T) + 1.84*10^(-4)*T - 7.35*10^(-8)*T^(2) + 1.15*10^(-11)*T^(3)\n\n\n\n')\n", "\n", "T = [500,1000,1500,2000,2500];\n", "K = zeros(5);\n", "\n", "printf(' T (K) \t\t\t K \n\n');\n", "\n", "for i=1:5;\n", " K(i) = exp(1.5103-10862.92/T(i) - 0.0166*log(T(i)) + 1.84*10^(-4)*T(i) - 7.35*10^(-8)*T(i)^(2) + 1.15*10^(-11)*T(i)^(3));\n", " \n", " printf(' %f \t\t %e \n\n',T(i),K(i));\n", "end\n", "\n", "printf('\n\n');\n", "\n", "// It can be seen that for endothermic reactions equilibrium constant increases with temperature.\n", "printf(' It can be seen that for endothermic reactions equilibrium constant increases with temperature\n');\n", "" ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 17.11: Determination_of_mean_standard_enthalpy_of_reaction.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "clear;\n", "clc;\n", "\n", "//Example - 17.11\n", "//Page number - 611\n", "printf('Example - 17.11 and Page number - 611\n\n');\n", "\n", "// Given\n", "// SO2 + (1/2)*O2 - SO3\n", "R = 8.314;//[J/mol-K]\n", "\n", "K_800 = 0.0319;// Equilibrium constant at 800 K\n", "K_900 = 0.153;// Equilibrium constant at 900 K\n", "T_1 = 800;//[K]\n", "T_2 = 900;//[K]\n", "\n", "// We have the relation \n", "// log(K_2/K_1) = -(delta_H_rkn/R)*(1/T_2 - 1/T_1)\n", "// log(K_900/K_800) = -(delta_H_rkn_850/R)*(1/T_2 - 1/T_1)\n", "delta_H_rkn_850 = -R*log(K_900/K_800)/(1/T_2 - 1/T_1);//[J]\n", "delta_H_rkn_850 = delta_H_rkn_850*10^(-3);//[kJ]\n", "\n", "printf(' The mean standard enthalpy change of reaction in the region 800 t0 900 is given by delta_H_rkn_850 = %f \n',delta_H_rkn_850);\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "" ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 17.12: Derivation_of_expression_for_enthalpy_of_reaction.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "clear;\n", "clc;\n", "\n", "//Example - 17.12\n", "//Page number - 611\n", "printf('Example - 17.12 and Page number - 611\n\n');\n", "\n", "// Given\n", "// log(K) = -2.61 + 23672.62/T - 7.17*log(T) + 1.24*10^(-2)*T - 0.148*10^(-5)*T^(2) + 0.039*10^(-9)*T^(3)\n", "\n", "// We know that\n", "// dlog(K)/dT = delta_H_rkn/(R*T^(2))\n", "\n", "// Differentiating the above expression of log(K),we get\n", "// dlog(K)/dT = -23672.62/T^(2) - 7.17/T + 1.24*10^(-2) - 2*0.148*10^(-5)*T + 3*0.039*10^(-9)*T^(2)\n", "\n", "// On further simplification we get \n", "// delta_H_rkn = -47037.5 - 14.24*T + 2.46*10^(-2)*T^(2) - 0.59*10^(-5)*T^(3) + 0.23*10^(-9)*T^(4)\n", "printf(' delta_H_rkn = -47037.5 - 14.24*T + 2.46*10^(-2)*T^(2) - 0.59*10^(-5)*T^(3) + 0.23*10^(-9)*T^(4)\n');\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "" ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 17.13: Determination_of_equilibrium_composition.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "clear;\n", "clc;\n", "\n", "//Example - 17.13\n", "//Page number - 611\n", "printf('Example - 17.13 and Page number - 611\n\n');\n", "\n", "// Given\n", "T_1 = 298.15;//[K]\n", "T = 2600;//[K]\n", "R = 1.987;//[cal/mol-K] - Universal gas constant\n", "\n", "// Cp_0 = a + b*T + c*T^(2) + d*T^(3)\n", "delta_H_CO_298 = -26.416;//[kcal/mol] - Enthalpy of formation of CO at 298.15 K\n", "delta_G_CO_298 = -32.808;//[kcal/mol] - Gibbs free energy change for formation of CO at 298.15 K\n", "delta_H_CO2_298 = -94.052;//[kcal/mol] - Enthalpy of formation of C02 at 298.15 K\n", "delta_G_CO2_298 = -94.260;//[kcal/mol] - Gibbs free energy change for formation of CO2 at 298.15 K\n", "\n", "// CO + (1/2)*O2 - CO2\n", "\n", "a_CO = 6.726;\n", "a_O2 = 6.0685;\n", "a_CO2 = 5.316;\n", "b_CO = 0.04001*10^(-2);\n", "b_O2 = 0.3631*10^(-2);\n", "b_CO2 = 1.4285*10^(-2);\n", "c_CO = 0.1283*10^(-5);\n", "c_O2 = -0.1709*10^(-5);\n", "c_CO2 = -0.8362*10^(-5);\n", "d_CO = -0.5307*10^(-9);\n", "d_O2 = 0.3133*10^(-9);\n", "d_CO2 = 1.784*10^(-9);\n", "\n", "\n", "delta_H_rkn_298 = delta_H_CO2_298 - delta_H_CO_298;//[kcal]\n", "delta_H_rkn_298 = delta_H_rkn_298*10^(3);//[cal]\n", "delta_G_rkn_298 = delta_G_CO2_298 - delta_G_CO_298;//[kcal]\n", "delta_G_rkn_298 = delta_G_rkn_298*10^(3);//[cal]\n", "\n", "delta_a = a_CO2 - (a_CO) - (a_O2/2);\n", "delta_b = b_CO2 - (b_CO) - (b_O2/2);\n", "delta_c = c_CO2 - (c_CO) - (c_O2/2);\n", "delta_d = d_CO2 - (d_CO) - (d_O2/2);\n", "\n", "// delta_H_rkn_T = delta_H_rkn_298 + integrate('delta_a+(delta_b*T)+(delta_c*T^(2))+(delta_d*T^(3))','T',T_1,T);\n", "// On simplification we get\n", "delta_H_rkn_T = -66773.56 - 4.45*T + 0.605*10^(-2)*T^(2) - 0.29*10^(-5)*T^(3) + 0.54*10^(-9)*T^(4);\n", "\n", "// log(K/K_298) = integrate('delta_H_rkn_T/(R*T^(2))','T',T_1,T)\n", "\n", "// We know that delta_G_rkn_T = -R*T*log(K)\n", "// At 298.15 K\n", "K_298 = exp(-delta_G_rkn_298/(R*T_1) );\n", "\n", "// Therfore on simplification we get\n", "//log(K) = 2.94 + 33605.2/T - 2.24*log(T) + 0.304*10(-2)*T - 0.073*10^(-5)*T^(2) + 0.09*10^(-9)*T^(3)\n", "K = exp(2.94 + 33605.2/T - 2.24*log(T) + 0.304*10^(-2)*T - 0.073*10^(-5)*T^(2) + 0.09*10^(-9)*T^(3));\n", "\n", "printf(' The value of equilibrium constant at 2600 K is given by, K_298 = %f\n\n',K);\n", "\n", "\n", "//(a)\n", "P_1 = 1;//[atm]\n", "Kp_1 = P_1^(-1/2);\n", "Ky_1 = K/Kp_1;\n", "\n", "// Let the reaction coordinate at equilibrium for the reaction be X\n", "// At equilibrium, the moles of the components be\n", "// n_CO_1_eq = 1 - X\n", "// n_02_1_eq = 0.5- 0.5X\n", "// n_CO2_1_eq = X\n", "// Total moles = 1.5 - 0.5*X\n", "\n", "// Ky = y_CO2/(y_CO^(1/2)*y_CO)\n", "//ky = (X*(1.5-0.5*X)^(1/2))/((1-X)*(0.5-0.5*X)^(1/2))\n", "\n", "deff('[y]=f(X)','y= Ky_1-(X*(1.5-0.5*X)^(1/2))/((1-X)*(0.5-0.5*X)^(1/2))');\n", "X_1 = fsolve(0.9,f);\n", "\n", "y_CO2_1 = X_1/(1.5-0.5*X_1);\n", "y_CO_1 = (1-X_1)/(1.5-0.5*X_1);\n", "y_O2_1 = (0.5-0.5*X_1)/(1.5-0.5*X_1);\n", "\n", "printf(' (a).The equilibrium composition (at 1 atm) is given by, y_CO2 = %f, y_CO = %f and y_O2 = %f\n\n',y_CO2_1,y_CO_1,y_O2_1);\n", "\n", "//(b)\n", "P_2 = 10;//[atm]\n", "Kp_2 = P_2^(-1/2);\n", "Ky_2 = K/Kp_2;\n", "\n", "// Ky = y_CO2/(y_CO^(1/2)*y_CO)\n", "//ky = (X*(1.5-0.5*X)^(1/2))/((1-X)*(0.5-0.5*X)^(1/2))\n", "\n", "deff('[y]=f1(X)','y= Ky_2-(X*(1.5-0.5*X)^(1/2))/((1-X)*(0.5-0.5*X)^(1/2))');\n", "X_2 = fsolve(0.9,f1);\n", "\n", "y_CO2_2 = X_2/(1.5-0.5*X_2);\n", "y_CO_2 = (1-X_2)/(1.5-0.5*X_2);\n", "y_O2_2 = (0.5-0.5*X_2)/(1.5-0.5*X_2);\n", "\n", "printf(' (b).The equilibrium composition (at 10 atm) is given by, y_CO2 = %f, y_CO = %f and y_O2 = %f\n\n',y_CO2_2,y_CO_2,y_O2_2);\n", "\n", "//(c)\n", "P_3 = 1;//[atm]\n", "Kp_3 = P_3^(-1/2);\n", "Ky_3 = K/Kp_3;\n", "\n", "// Ky = y_CO2/(y_CO^(1/2)*y_CO)\n", "//ky = (X*(1.5-0.5*X)^(1/2))/((1-X)*(0.5-0.5*X)^(1/2))\n", "\n", "// At equilibrium, the moles of the components be\n", "// n_CO_3_eq = 1 - X\n", "// n_02_3_eq = 0.5- 0.5X\n", "// n_CO2_3_eq = X\n", "// n_N2_eq = 1;\n", "// Total moles = 2.5 - 0.5*X\n", "\n", "deff('[y]=f2(X)','y= Ky_3-(X*(2.5-0.5*X)^(1/2))/((1-X)*(0.5-0.5*X)^(1/2))');\n", "X_3 = fsolve(0.9,f2);\n", "\n", "y_CO2_3 = X_3/(2.5-0.5*X_3);\n", "y_CO_3 = (1-X_3)/(2.5-0.5*X_3);\n", "y_O2_3 = (0.5-0.5*X_3)/(2.5-0.5*X_3);\n", "y_N2 = 1/(2.5-0.5*X_3);\n", "\n", "printf(' (c).The equilibrium composition (at 1 atm and 1 mol N2) is given by, y_CO2 = %f, y_CO = %f , y_O2 = %f and y_N2 = %f\n\n',y_CO2_3,y_CO_3,y_O2_3,y_N2);\n", "" ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 17.14: Determination_of_equilibrium_composition.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "clear;\n", "clc;\n", "\n", "//Example - 17.14\n", "//Page number - 614\n", "printf('Example - 17.14 and Page number - 614\n\n');\n", "\n", "// Given\n", "T = 25 + 298.15;//[K] - Temperature\n", "R = 8.314;//[J/mol-K]\n", "delta_G_298 = -1000;//[J] - Gibbs free energy change at 298 K\n", "\n", "// G_E/(R*T) = x_1*x_2\n", "\n", "// We know that delta_G_rkn = - R*T*log(K), therefore\n", "K = exp(-delta_G_298/(R*T));\n", "\n", "//(1)\n", "// Let x_1 is the mole fraction of A and x_2 be the mole fraction of B\n", "// If A and B form an ideal mixture then,\n", "Ky = 1;\n", "// and K = Kx = x_2/x_1\n", "// and at equilibrium x_2/x_1 = K\n", "// (1-x_1)/x_1 = K\n", "x_1 = 1/(1+K);\n", "\n", "printf(' (1).The equilibrium composition (for ideal behaviour) is given by x_1 = %f\n\n',x_1);\n", "\n", "//(2)\n", "// The activity coefficients are given by\n", "// log(Y1) = [del(n*G_E/(R*T))/del(n_1)]_T,P,n_2 = x_2^(2)\n", "// similarly, log(Y2) = x_1^(2)\n", "\n", "// The equilibrium constant for the liquid phase reaction is given by\n", "// K = Kx*Ky = (x_2*Y2)/(x_1*Y1) = (x_2*exp(x_1^(2)))/(x_1*exp(x_2^(2)))\n", "// Solving the above equation we get\n", "\n", "deff('[y]=f2(x_1)','y= K -((1-x_1)*exp(x_1^(2)))/(x_1*exp((1-x_1)^(2)))');\n", "x_1_prime = fsolve(0.9,f2);\n", "\n", "printf(' (2).The equilibrium composition (for non-ideal behaviour) is given by x_1 = %f\n\n',x_1_prime);\n", "\n", "" ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 17.15: Determination_of_the.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "clear;\n", "clc;\n", "\n", "//Example - 17.15\n", "//Page number - 615\n", "printf('Example - 17.15 and Page number - 615\n\n');\n", "\n", "// Given\n", "T_1 = 298.15;//[K] - Standard reaction temperature\n", "T_2 = 373;//[K] - Reaction temperature\n", "P = 1;//[atm]\n", "R = 1.987;//[cal/mol-K] - Universal gas constant\n", "\n", "// CH3COOH (l) + C2H5OH (l) - CH3COOC2H5 (l) + H2O (l)\n", "\n", "delta_H_CH3COOH_298 = -116.2*10^(3);// [cal/mol]\n", "delta_H_C2H5OH_298 = -66.35*10^(3);// [cal/mol]\n", "delta_H_CH3COOC2H5_298 = -110.72*10^(3);// [cal/mol]\n", "delta_H_H2O_298 = -68.3174*10^(3);// [cal/mol]\n", "\n", "delta_G_CH3COOH_298 = -93.56*10^(3);// [cal/mol]\n", "delta_G_C2H5OH_298 = -41.76*10^(3);// [cal/mol]\n", "delta_G_CH3COOC2H5_298 = -76.11*10^(3);// [cal/mol]\n", "delta_G_H2O_298 = -56.6899*10^(3);// [cal/mol]\n", "\n", "delta_H_rkn_298 = delta_H_CH3COOC2H5_298 + delta_H_H2O_298 - delta_H_CH3COOH_298 - delta_H_C2H5OH_298;//[cal/mol]\n", "delta_G_rkn_298 = delta_G_CH3COOC2H5_298 + delta_G_H2O_298 - delta_G_CH3COOH_298 - delta_G_C2H5OH_298;//[cal/mol]\n", "\n", "// We know that delta_G_rkn_T = -R*T*log(K)\n", "// At 298.15 K\n", "K_298 = exp(-delta_G_rkn_298/(R*T_1) );\n", "\n", "// We know that dlog(K)/dT = delta_H_rkn/(R*T^(2))\n", "// If delta_H_rkn is assumed constant we get\n", "// log(K_2/K_1) = (-delta_H_rkn/R)*(1/T_2 - 1/T_1)\n", "// log(K_373/K_298) = (-delta_H_rkn_298/R)*(1/T_2 - 1/T_1)\n", "\n", "K_373 = exp(log(K_298) + (-delta_H_rkn_298/R)*(1/T_2 - 1/T_1));\n", "// Note that the equilibrium constant value rises becauses the reaction is endothermic\n", "\n", "printf(' The value of equilibrium constant at 373 K is , K_373 = %f\n\n',K_373);\n", "\n", "// Let the reaction coordinate at equilibrium for the reaction be X\n", "// At equilibrium, the moles of the components be\n", "// n_CH3COOH = 1 - X\n", "// n_C2H5OH = 1 - X\n", "// n_CH3COOC2H5 = X\n", "// n_H20 = X\n", "// Total moles = 2\n", "\n", "// Kx = (x_CH3COOH*x_C2H5OH)/(x_CH3COOC2H5*x_H2O)\n", "// Assuming the liquid mixture to be ideal,that is Ky = 1, therefore K_x = K\n", "K_x = K_373;\n", "// X^(2)/(1-X)^(2) = K_x\n", "X = (K_x)^(1/2)/(1+(K_x)^(1/2));\n", "\n", "// The mole fraction of ethyl acetate is given by\n", "x_CH3COOC2H5 = X/2;\n", "\n", "printf(' The mole fraction of ethyl acetate in the equilibrium reaction mixture is given by, x_CH3COOC2H5 = %f\n',x_CH3COOC2H5);\n", "\n", "\n", "\n", "\n", "" ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 17.16: Calculation_of_the_value_of_Gibbs_free_energy.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "clear;\n", "clc;\n", "\n", "//Example - 17.16\n", "//Page number - 617\n", "printf('Example - 17.16 and Page number - 617\n\n');\n", "\n", "// Given\n", "// CaCO3 (s1) - CaO (s2) + CO2 (g)\n", "T_1 = 898 + 273.15;//[K]\n", "T_2 = 700 + 273.15;//[K]\n", "R = 8.314;//[J/mol-K] - Universal gas constant\n", "\n", "P_CO2_T_1 = 1;//[atm] - Decomposition pressure of CO2 over CaCO3 at 898 C\n", "P_CO2_T_2 = 0.0333;//[atm] - Decomposition pressure of CO2 over CaCO3 at 700 C\n", "\n", "// The equilibrium constant of the reaction is given by\n", "// K = (a_CO2*a_CaO)/a_CaCO3\n", "\n", "// Since the pressure is small therefore carbon dioxide can be assumed to behave as ideal gas and thus\n", "// a_CO2 = y_CO2*P/1 = P_CO2\n", "\n", "// The activity of CaO is (CaO is pure)\n", "// a_CaO = f_CaO/f_0_CaO = exp[V_CaO*(P - P_0)/(R*T)] = 1 (since pressure is low)\n", "\n", "// The activity of CaCO3 is (CaCO3 is pure)\n", "// a_CaCO3 = f_CaCO3/f_0_CaCO3 = exp[V_CaCO3*(P - P_0)/(R*T)] = 1 (since pressure is low)\n", "\n", "//Since pressures are around 1 atm,therefore Poynting factors are also near 1, and thus activity of CaO and CaCO3 is unity and equilibrium constant is given by\n", "//K = P_CO2 , therefore\n", " \n", "// At 898 C\n", "K_T_1 = P_CO2_T_1;\n", "delta_G_T_1 = -R*T_1*log(K_T_1);\n", "\n", "// At 700 C\n", "K_T_2 = P_CO2_T_2;\n", "delta_G_T_2 = -R*T_2*log(K_T_2);\n", "\n", "printf(' The value of delta_G_rkn at 700 C is %f J\n\n',delta_G_T_1);\n", "printf(' The value of delta_G_rkn at 898 C is %f J\n\n',delta_G_T_2);\n", "" ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 17.17: Calculation_of_nu.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "clear;\n", "clc;\n", "\n", "//Example - 17.17\n", "//Page number - 618\n", "printf('Example - 17.17 and Page number - 618\n\n');\n", "\n", "// Given\n", "T = 700 + 273.15;//[K]\n", "K = 7.403;// Equilibrium constant for the reaction at 700 C\n", "\n", "// CH4 - C (s) + 2*H2 \n", "\n", "// The equilibrium constant of the reaction is given by\n", "// K = (a_C*a_H2^(2))/a_CH4\n", "\n", "// Since carbon is pure therefore its activity is given by\n", "// a_C = f/f_0 = 1 as pressure is 1 atm.\n", "// Since the pressure is low,therefore the gas phase can be taken to be ideal,therefore\n", "// K = (y_H2^(2)*P^(2))/(y_CH4*P) = y_H2^(2)/y_CH4 (as P = 1 atm)\n", "Ky = K;// (Kp = 1 atm)\n", "\n", "// Initial moles of the species are\n", "n_CH4 = 1;\n", "n_H2 = 0;\n", "n_C = 0;\n", "\n", "// Let the reaction coordinate at equilibrium for the reaction be X\n", "// Moles at equilibrium be\n", "// n_CH4_eq = 1 -X\n", "// n_H2_eq = 2*x\n", "// n_C_eq = X\n", "\n", "// Moles present in gas phase\n", "// n_CH4_gas = 1 -X\n", "// n_H2_gas = 2*x\n", "// Total moles = 1 + X\n", "\n", "// gas phase mole fraction \n", "// y_CH4_gas = (1 -X)/(1+X)\n", "// y_H2_gas = 2*x/(1+X)\n", "\n", "// Ky = y_H2_gas^(2)/y_CH4_gaS\n", "X = (K/(4+K))^(1/2);\n", "\n", "printf(' The number of moles of carbon black formed from one mole of methane is %f mol\n\n',X);\n", "\n", "// Therefore mole fraction of components in the gas phase at equilibrium is \n", "y_CH4 = (1-X)/(1+X);\n", "y_H2 = 2*X/(1+X);\n", "\n", "printf(' The mole fraction of components in the gas phase at equilibrium is given by y_CH4 = %f and y_H2 = %f \n',y_CH4,y_H2);\n", "\n", "\n", "" ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 17.18: Determination_of_value_of_the_equilibrium_constant.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "clear;\n", "clc;\n", "\n", "//Example - 17.18\n", "//Page number - 619\n", "printf('Example - 17.18 and Page number - 619\n\n');\n", "\n", "// Given\n", "T_1 = 298.15;//[K] - Standard reaction temperature\n", "T_2 = 1042;//[K] - Reaction temperature\n", "R = 1.987;//[cal/mol-K] - Universal gas constant\n", "\n", "// CaCO3 (s1) - CaO (s2) + CO2 (g)\n", "\n", "delta_H_CaCO3_298 = -289.5;//[kcal/mol] - Enthalpy of formation of CaCO3 at 298.15 K\n", "delta_H_CaO_298 = -151.7;//[kcal/mol] - Enthalpy of formation of CaO at 298.15 K\n", "delta_H_CO2_298 = -94.052;//[kcal/mol] - Enthalpy of formation of CO2 at 298.15 K\n", "delta_G_CaCO3_298 = -270.8;//[kcal/mol] - Gibbs free energy change for formation of CaCO3 at 298.15 K\n", "delta_G_CaO_298 = -144.3;//[kcal/mol] - Gibbs free energy change for formation of CaO at 298.15 K\n", "delta_G_CO2_298 = -94.260;//[kcal/mol] - Gibbs free energy change for formation of CO2 at 298.15 K\n", "\n", "// The standard heat capacity data as a function of temperature are given below\n", "// Cp_CO2 = 5.316 + 1.4285*10^(2)*T - 0.8362*10^(-5)*T^(2) + 1.784*10^(-9)*T^(3)\n", "// Cp_CaO = 12.129 + 0.88*10^(-3)*T - 2.08*10^(5)*T^(-2)\n", "// Cp_CaCO3 = 24.98 + 5.240*10^(-3)*T - 6.199*10^(5)*T^(-2)\n", "// Therefore Cp_0 is given by\n", "// Cp_0 = Cp_CO2 + Cp_CaO - Cp_CaCO3\n", "// Cp_0 = -7.535 + 9.925*10^(-3)*T - 0.8362*10^(-5)*T^(2) + 1.784*10^(-9)*T^(3) + 4.119*10^(5)*T^(-2)\n", "\n", "// The standard enthalpy change of the reaction at 298.15 K is given by\n", "delta_H_rkn_298 = delta_H_CO2_298 + delta_H_CaO_298 - delta_H_CaCO3_298;//[kcal]\n", "delta_H_rkn_298 = delta_H_rkn_298*10^(3);//[cal]\n", "delta_G_rkn_298 = delta_G_CO2_298 + delta_G_CaO_298 - delta_G_CaCO3_298;//[kcal]\n", "delta_G_rkn_298 = delta_G_rkn_298*10^(3);//[cal]\n", "\n", "// The standard enthalpy change of the reaction at temperature T is given by\n", "// delta_H_rkn_T = delta_H_rkn_298 + integrate('-7.535 + 9.925*10^(-3)*T - 0.8362*10^(-5)*T^(2) + 1.784*10^(-9)*T^(3) + 4.119*10^(5)*T^(-2)','T',T_1,T);\n", "// On simplification we get\n", "// delta_H_rkn_T = 47005.3 - 7.535*T + 4.9625*10^(-3)*T^(2) - 0.2787*10^(-5)*T^(3) + 0.446*10^(-9)*T^(4) - 4.119*10^(5)*T^(-1)\n", "\n", "\n", "// log(K_2/K_1) = integrate('delta_H_rkn_T/(R*T^(2))','T',T_1,T)\n", "log_K2_K1 = integrate('(47005.3-7.535*T+4.9625*10^(-3)*T^(2)-0.2787*10^(-5)*T^(3)+0.446*10^(-9)*T^(4) - 4.119*10^(5)*T^(-1))/T^(2)','T',T_1,T_2);// log(K_2/K_1)\n", "\n", "// We know that delta_G_rkn_T = -R*T*log(K)\n", "// At 298.15 K\n", "K_298 = exp(-delta_G_rkn_298/(R*T_1) );\n", "\n", "// Putting the values in the above expression we get\n", "// log(K_1042/K_298) = log_K2_K1/R\n", "K_1042 = K_298*exp(log_K2_K1/R);\n", "\n", "printf(' The value of equilibrium constant at 1042 K is, K_1042 = %f\n\n',K_1042);\n", "\n", "// Since for the given reaction K = P_CO2,where P is in atm, therefore,\n", "P_CO2 = K_1042;\n", "// and thus decomposition takes place till the partial pressure of CO2 reaches 0.095 atm\n", "// After that the decomposition in the closed vessel stops as equilibrium is achieved.\n", "\n", "printf(' The equilibrium pressure of CO2 is, P_CO2 = %f atm \n',P_CO2);\n", "\n", "\n", "\n", "\n", "" ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 17.19: Determination_of_the_value_of_equilibrium_constant.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "clear;\n", "clc;\n", "\n", "//Example - 17.19\n", "//Page number - 620\n", "printf('Example - 17.19 and Page number - 620\n\n');\n", "\n", "// Given\n", "T_1 = 298.15;//[k] - Standard reaction temperature\n", "T_2 = 1200;//[K] - Reaction temperature\n", "R = 1.987;//[cal/mol-K] - Universal gas consatnt\n", "\n", "// C (s) + CO2 (g) - 2*CO2 (g) // Reaction 1\n", "// CO2 + H2 - CO + H2O // Reacction 2\n", "\n", "K_1 = 63;// Equilibrium constant for the first reaction\n", "K_2 = 1.4;// Equilibrium constant for the secind reaction\n", "\n", "delta_G_H2O_298 = -54640;//[cal/mol] - Standard Gibbs free energy of formation of water vapour\n", "delta_H_H2O_298 = -57800;//[cal/mol] - Standard enthalpy change of formation of water vapour\n", "delta_G_rkn_298 = delta_G_H2O_298;\n", "\n", "// The standard heat capacity data of the components in cal/mol-K are given below\n", "// Cp_H2 = 6.947 - 0.2*10^(-3)*T + 4.8*10^(-7)*T^(2)\n", "// Cp_O2 = 6.148 + 3.1*10^(-3)*T - 9.2*10^(-7)*T^(2)\n", "// Cp_H2O = 7.256 + 2.3*10^(-3)*T + 2.8*10^(-7)*T^(2)\n", "\n", "// Let us consider two more reactions\n", "// C (s) + (1/2)*O2 - CO // Reaction 3\n", "// H2 + (1/2)*O2 - H2O // Reaction 4\n", "\n", "// Considering the above 4 reactions, it can be shown that reaction (3) = reaction (1) + reaction (4) - reaction (2)\n", "// Thus, delta_G_rkn_3 = delta_G_rkn_1 + delta_G_rkn_4 - delta_G_rkn_2\n", "// or, -R*T*log(K_3) = -R*T*log(K_1) + -R*T*log(K_4) - -R*T*log(K_2)\n", "// K_3 = (K_1*K_4/K_2)\n", "\n", "// Now we have to determine K_4 at 1200 K.\n", "// The standard enthalpy change of reaction (4) as a fuction of temperature is given by\n", "// delta_H_rkn_T = -57020 - 2.765*T + 0.475*10^(-3)*T^(2) + 8.67*10^(-8)*T^(3);\n", "\n", "// log(K_4_2/K_4_1) = integrate('delta_H_rkn_T/(R*T^(2))','T',T_1,T)\n", "log_K2_K1_4 = integrate('(-57020-2.765*T+0.475*10^(-3)*T^(2)+8.67*10^(-8)*T^(3))/T^(2)','T',T_1,T_2);\n", "\n", "// We know that delta_G_rkn_T = -R*T*log(K)\n", "// At 298.15 K\n", "K_4_298 = exp(-delta_G_rkn_298/(R*T_1) );\n", "\n", "// Putting the values in the above expression we get\n", "// log(K_4_1200/K_4_298) = log_K2_K1_R/R\n", "K_4_1200 = K_4_298*exp(log_K2_K1_4/R);\n", "K_4 = K_4_1200;\n", "\n", "// Therefore the equilibrium constant for reaction (3) at 1200 K is given by\n", "K_3 = (K_1*K_4)/K_2;\n", "\n", "printf(' The equilibrium constant at 1200 K for the given reaction is, K = %e\n',K_3);\n", "" ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 17.1: Proving_a_mathematical_relation.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "clear;\n", "clc;\n", "\n", "//Example - 17.1\n", "//Page number - 595\n", "printf('Example - 17.1 and Page number - 595\n\n');\n", "\n", "//This problem involves proving a relation in which no mathematical components are involved.\n", "//For prove refer to this example 17.1 on page number 595 of the book.\n", "printf('This problem involves proving a relation in which no mathematical components are involved.\n\n');\n", "printf('For prove refer to this example 17.1 on page number 595 of the book.')\n", "\n", "" ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 17.20: Calculation_of_standard_equilibrium_cell_voltage.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "clear;\n", "clc;\n", "\n", "//Example - 17.20\n", "//Page number - 622\n", "printf('Example - 17.20 and Page number - 622\n\n');\n", "\n", "// Given\n", "delta_G_H2O_298 = -237.034;//[kJ/mol] - Standard Gibbs free energy of formation of H2O (l) at 298 K\n", "F = 96485;//[C/mol] - Faraday constant\n", "\n", "//(1)\n", "// For the reaction\n", "// H2 (g) + (1/2)*O2 (g) - H2O (l)\n", "n = 2;// Number of electrons transferred in the reaction\n", "\n", "// The standard Gibbs free energy change of the reaction is given by\n", "// delta_G_rkn = delta_G_for_H2O(l) - delta_G_for_H2(g) - (1/2/)*delta_G_for_O2(g)\n", "// Since delta_G_for_H2 = 0 and delta_G_for_O2 = 0 (pure components)\n", "delta_G_rkn = delta_G_H2O_298;//[kJ]\n", "delta_G_rkn = delta_G_rkn*10^(3);//[J]\n", "\n", "// delta_G_rkn = -n*F*E_0\n", "// Thus standard equilibrium cell voltage is given by\n", "E_0 = - delta_G_rkn/(n*F);///[V]\n", "\n", "printf(' (1).The standard equilibrium cell voltage is %f V\n\n',E_0);\n", "\n", "//(2)\n", "// For the reaction\n", "// 2*H2 (g) + O2 (g) - 2*H2O (l)\n", "n_prime = 4;// Number of electrons transferred in the reaction\n", "\n", "// The standard Gibbs free energy change of the reaction is given by\n", "// delta_G_rkn = 2*delta_G_for_H2O(l) - 2*delta_G_for_H2(g) - delta_G_for_O2(g)\n", "// Since delta_G_for_H2 = 0 and delta_G_for_O2 = 0 (pure components)\n", "delta_G_rkn_prime = 2*delta_G_H2O_298;//[kJ]\n", "delta_G_rkn_prime = delta_G_rkn_prime*10^(3);//[J]\n", "\n", "// delta_G_rkn = -n*F*E_0\n", "// Thus standard equilibrium cell voltage is given by\n", "E_0_prime = - delta_G_rkn_prime/(n_prime*F);///[V]\n", "\n", "printf(' (2).The standard equilibrium cell voltage is %f V\n\n',E_0_prime);\n", "\n", "// Thus the result obtained is same for both the reactions\n", "\n", "\n", "" ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 17.21: Calculation_of_number_of_chemical_reactions.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "clear;\n", "clc;\n", "\n", "//Example - 17.21\n", "//Page number - 624\n", "printf('Example - 17.21 and Page number - 624\n\n');\n", "\n", "// Given\n", "P = 2;// Number of phases\n", "C = 5;// Number of components\n", "\n", "// First we write chemical equations for formation of each component from basic elements\n", "// C + 2*H2 = CH4 // (reaction 1) \n", "// H2 + (1/2)*O2 = H20 // (reaction 2)\n", "// C + (1/2)*O2 = CO // (reaction 3)\n", "// C + O2 = CO2 // (reaction 4)\n", "\n", "// We do not have C in the equilibrium reaction mixture, therefore we have to eliminate it.\n", "// Substituting for C from reaction (1) into reactions (3) and (4) we get the following set of reactions\n", "// H2 + (1/2)*O2 = H20\n", "// CH4 - 2*H2 + (1/2)*O2 = CO\n", "// CH4 - 2*H2 + O2 = CO2\n", "\n", "// or,\n", "// H2 + (1/2)*O2 = H2O\n", "// CH4 + (1/2)*O2 = CO + 2*H2\n", "// CH4 + O2 = CO2 + 2*H2\n", "\n", "// We do not have O2 in the equilibrium reaction mixture,therefore we have to eliminateit\n", "// Substituting for O2 from the first reaction of the above set into seecond and third reactions of the above set we get the following set of reactions.\n", "// CH4 + H2O - H2 = CO + 2*H2\n", "// CH4 + 2*H20 - 2*H2 = CO2 + 2*H2 \n", "\n", "// Therefore one set of independent reactions is\n", "// CH4 + H20 = CO + 3*H2\n", "// CH4 + 2*H2O = CO2 + 4*H2\n", "\n", "// Another set of independent reactions can be obtained by substituting for CH4 from the first reaction into second and we get\n", "// CH4 + H2O = CO + 3*H2\n", "// CO + 3*H2 - H2O + 2*H2O = CO2 4*H2\n", "\n", "// Or, \n", "// CH4 + H2O = CO + 3*H2\n", "// CO + H2O = CO2 + H2\n", "// This is another set of independent reactions. Thus whatever be the set of independent reactions, the number of independent reactions are two\n", "// If different set of reactions are considered, then we get different equilibrium constants,different reaction coordinates but the final composition will be same\n", "// Thus only 2 independent reactions occur,therefore \n", "r = 2;\n", "\n", "// and the number of degree of freedom becomes,\n", "F = r - P + C;\n", "\n", "printf(' The number of independent chemical reactions are %f \n\n',r);\n", "\n", "printf(' The first set of independent reactions are given below\n');\n", "printf(' CH4 + H20 = CO + 3*H2\n');\n", "printf(' CH4 + 2*H2O = CO2 + 4*H2\n\n');\n", "\n", "printf(' The second set of independent reactions are given below\n');\n", "printf(' CH4 + H20 = CO + 3*H2\n');\n", "printf(' CO + H2O = CO2 + H2');\n", "\n", "\n", "\n", "" ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 17.22: Calculation_of_number_of_chemical_reactions.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "clear;\n", "clc;\n", "\n", "//Example - 17.22\n", "//Page number - 626\n", "printf('Example - 17.22 and Page number - 626\n\n');\n", "\n", "// Given\n", "T = 400;//[K] - Temperature\n", "P = 1;//[atm] - Pressure\n", "R = 1.987;//[cal/mol-K] - Universal gas consatnt\n", "\n", "delta_G_n_pentane_400 = 9600;//[cal/mol] - Standard Gibbs free energy of formation of n-pentane at 400 K\n", "delta_G_iso_pentane_400 = 8200;//[cal/mol] - Standard Gibbs free energy of formation of iso-pentane at 400 K\n", "delta_G_neo_pentane_400 = 9000;//[cal/mol] - Standard Gibbs free energy of formation of neo-pentane at 400 K\n", "\n", "// The three reactions for the formation of these isomers can be written as follows\n", "// 5*C + 6*H2 = n-pentane\n", "// 5*C + 6*H2 = iso-pentane\n", "// 5*C + 6*H2 = neo-pentane\n", "\n", "// We can eliminate elemental carbon and hydrogen as they are not present in equilibrium reaction mixture and get the following two sets of independent reactions\n", "// n-pentane = iso-pentane \n", "// n-pentane = neo-pentane \n", "\n", "// or,\n", "// iso-pentane = n-pentane \n", "// iso-pentane = neo-pentane \n", "\n", "// or,\n", "// noe-pentane = iso-pentane \n", "// neo-pentane = n-pentane \n", "\n", "// Let us take the following set of independent reactions\n", "// iso-pentane = n-pentane // (reaction 1)\n", "delta_G_rkn_1 = delta_G_n_pentane_400 - delta_G_iso_pentane_400;//[cal]\n", "K_1 = exp(-delta_G_rkn_1/(R*T));\n", "// iso-pentane = neo-pentane // (reaction 2)\n", "delta_G_rkn_2 = delta_G_neo_pentane_400 - delta_G_iso_pentane_400;//[cal]\n", "K_2 = exp(-delta_G_rkn_2/(R*T));\n", "\n", "// Let the initial number of moles be\n", "// n_iso_pentane = 1\n", "// n_n_pentane = 0\n", "// n_neo_pentane = 0\n", "\n", "// Let the reaction coordinate at equilibrium for the two reaction be X_1 and X_2 respectively\n", "// At equilibrium, the moles of the components be\n", "// n_iso_pentane_eq = 1 - X_1 - X_2\n", "// n_n_pentane_eq = X_1\n", "// n_neo_pentane_eq = X_2\n", "// Total moles = 1 \n", "\n", "// Pressure has no effect on these reactions ( P = 1 atm) and therefore\n", "Ky_1 = K_1;\n", "Ky_2 = K_2;\n", "\n", "// From reaction (1), we get\n", "// Ky_1 = X_1/(1-X_1-X_2)\n", "\n", "// From reaction (2), we get\n", "// Ky_2 = X_2/(1-X_1-X_2)\n", "\n", "// Putting the value of X_1 from first equation into the second we get\n", "// X_1 = (Ky_1*(1-X_2))/(1+Ky_1)\n", "// Now putting it into the second equation we grt\n", "// Ky_2 = X_2/(1-((Ky_1*(1-X_2))/(1+Ky_1))-X_2)\n", "// Now solving for X_2\n", "deff('[y]=f(X_2)','y= Ky_2 - X_2/(1-((Ky_1*(1-X_2))/(1+Ky_1))-X_2)');\n", "X_2 = fsolve(0.8,f);\n", "\n", "// Therefore X_1 can be calculated as\n", "X_1 = (Ky_1*(1-X_2))/(1+Ky_1);\n", "\n", "// Finally the mole fractions of the components at equilibrium\n", "y_n_pentane = X_1;\n", "y_neo_pentane = X_2;\n", "y_iso_pentane = 1 -X_1 - X_2;\n", "\n", "printf(' The equilibrium composition is given by, y_n_pentane = %f, y_neo_pentane = %f and y_iso_pentane = %f\n\n\n',y_n_pentane,y_neo_pentane,y_iso_pentane);\n", "\n", "// Let us consider another set of independent reactions\n", "\n", "// n-pentane = iso-pentane // (reaction 3)\n", "delta_G_rkn_3 = delta_G_iso_pentane_400 - delta_G_n_pentane_400;//[cal]\n", "K_3 = exp(-delta_G_rkn_3/(R*T));\n", "// n-pentane = neo-pentane // (reaction 4)\n", "delta_G_rkn_4 = delta_G_neo_pentane_400 - delta_G_n_pentane_400;//[cal]\n", "K_4 = exp(-delta_G_rkn_4/(R*T));\n", "\n", "// Let the initial number of moles be\n", "// n_n_pentane = 1\n", "// n_iso_pentane = 0\n", "// n_neo_pentane = 0\n", "\n", "// Let the reaction coordinate at equilibrium for the two reaction be X_3 and X_4 respectively\n", "// At equilibrium, the moles of the components be\n", "// n_n_pentane_eq = 1 - X_3 - X_4\n", "// n_iso_pentane_eq = X_4\n", "// n_neo_pentane_eq = X_4\n", "// Total moles = 1 \n", "\n", "// Pressure has no effect on these reactions (P = 1 atm) and therefore\n", "Ky_3 = K_3;\n", "Ky_4 = K_4;\n", "\n", "// From reaction (3), we get\n", "// Ky_3 = X_3/(1-X_3-X_4)\n", "\n", "// From reaction (4), we get\n", "// Ky_4 = X_4/(1-X_3-X_4)\n", "\n", "// Putting the value of X_3 from first equation into the second we get\n", "// X_3 = (Ky_3*(1-X_4))/(1+Ky_3)\n", "// Now putting it into the second equation we grt\n", "// Ky_4 = X_4/(1-((Ky_1*(1-X_4))/(1+Ky_3))-X_4)\n", "// Now solving for X_4\n", "deff('[y]=f1(X_4)','y= Ky_4 - X_4/(1-((Ky_3*(1-X_4))/(1+Ky_3))-X_4)');\n", "X_4 = fsolve(0.8,f1);\n", "\n", "// Therefore X_3 can be calculated as\n", "X_3 = (Ky_3*(1-X_4))/(1+Ky_3);\n", "\n", "// Finally the mole fractions of the components at equilibrium\n", "y_n_pentane1 = 1 - X_3 - X_4;\n", "y_neo_pentane1 = X_4;\n", "y_iso_pentane1 = X_3;\n", "\n", "// The final composition does not depend on the set of reactions considered. \n", "\n", "printf(' For another set of independent reactions considered\n');\n", "printf(' The equilibrium composition is given by, y_n_pentane = %f, y_neo_pentane = %f and y_iso_pentane = %f\n\n\n',y_n_pentane1,y_neo_pentane1,y_iso_pentane1);\n", "printf(' Thus the final composition does not depend on the set of reactions considered\n\n\n');\n", "printf(' The number of independent reactions taking place is two');\n", "" ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 17.23: Calculation_of_equilibrium_composition.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "clear;\n", "clc;\n", "\n", "//Example - 17.23\n", "//Page number - 628\n", "printf('Example - 17.23 and Page number - 628\n\n');\n", "\n", "// Given\n", "T = 600;//[K] - Temperature\n", "P = 1;//[atm] - Pressure\n", "R = 1.987;//[cal/mol-K] - Universal gas consatnt\n", "\n", "// CH4 + H2O = CO + 3*H2 // (Reaction 1)\n", "// CO + H2O = CO2 + H2 // (Reaction 2)\n", "\n", "K_1 = 0.574;// Equilibrium constant of first reaction\n", "K_2 = 2.21;// Equilibrium constant of second reaction\n", "\n", "// Initial number of moles of the components are\n", "// n_CH4 = 1\n", "// n_H2O = 5\n", "// n_CO = 0\n", "// n_H2 = O\n", "// n_CO2 = 0\n", "\n", "// Let the reaction coordinate at equilibrium for the two reaction be X_1 and X_2 respectively\n", "// At equilibrium, the moles of the components be\n", "// n_CH4_eq = 1 - X_1\n", "// n_H20_eq = 5 - X_1 - X_2\n", "// n_CO_eq = X_1 - X_2\n", "// n_H2_eq = 3*X_1 + X_2\n", "// n_CO2_eq = X_2\n", "// Total moles = 6 + 2*X_1\n", "\n", "// Since the pressure is 1 atm, K = Kp, Ky = K\n", "Ky_1 = K_1;\n", "Ky_2 = K_2;\n", "\n", "// From reaction (1), we get\n", "// Ky_1 = ((X_1-X_2)*(3*X_1+X_2)^(3))/((1-X_1)*(5-X_1-X_2)*(6+2*X_1)^(2))\n", "\n", "// From reaction (2), we get\n", "// Ky_2 = (X_2*(3*X_1+X_2))/((X_1-X_2)*(5-X_1-X_2))\n", "\n", "// Let us assume a value of X_1\n", "X_1 = 0.1;\n", "\n", "fault = 10;\n", "while(fault>0.05)\n", " deff('[y]=f(X_2)','y= Ky_1-((X_1-X_2)*(3*X_1+X_2)^(3))/((1-X_1)*(5-X_1-X_2)*(6+2*X_1)^(2))');\n", " X_2 = fsolve(0.8,f);\n", " X_2_prime = X_2;\n", " deff('[y]=f1(X_1_prime)','y= Ky_2-(X_2_prime*(3*X_1_prime+X_2_prime))/((X_1_prime-X_2_prime)*(5-X_1_prime-X_2_prime))');\n", " X_1_prime = fsolve(0.8,f1);\n", " fault=abs(X_1 - X_1_prime);\n", " X_1 = X_1 + 0.001;\n", "end\n", "\n", "n_CH4 = 1 - X_1;\n", "n_H20 = 5 - X_1 - X_2;\n", "n_CO = X_1 - X_2;\n", "n_H2 = 3*X_1 + X_2;\n", "n_CO2 = X_2;\n", "Total_moles = 6 + 2*X_1;\n", "\n", "printf(' The equilibrium composition of the resulting mixture is given by\n');\n", "printf(' n_CH4 = % f mol\n n_H2O = %f mol\n n_CO = %f mol\n n_H2 = %f mol and\n n_CO2 = %f mol\n\n',n_CH4,n_H20,n_CO,n_H2,n_CO2);\n", "printf(' The total number of moles is %f mol\n',Total_moles);\n", "" ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 17.24: Determination_of_number_of_moles.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "clear;\n", "clc;\n", "\n", "//Example - 17.24\n", "//Page number - 631\n", "printf('Example - 17.24 and Page number - 631\n\n');\n", "\n", "// Given\n", "T = 600 + 273.15;//[K] - Reaction temperature\n", "P = 1;//[atm] - Reaction pressure\n", "\n", "// The Gibbs free energy of formation of various species at 873.15 K are\n", "delta_G_CH4_RT = -2.82;// delta_G_CH4/(R*T)\n", "delta_G_H2O_RT = -29.73;// delta_G_CH4/(R*T)\n", "delta_G_CO_RT = -27.51;// delta_G_CH4/(R*T)\n", "delta_G_H2_RT = -1.46;// delta_G_CH4/(R*T)\n", "delta_G_CO2_RT = -56.68;// delta_G_CH4/(R*T)\n", "\n", "// Initial number of moles of the components are\n", "// n_CH4 = 1\n", "// n_H2O = 5\n", "// n_CO = 0\n", "// n_H2 = O\n", "// n_CO2 = 0\n", "\n", "// The del(F)/del(n_i) = 0 equations for CH4 (1), H2O (2), CO (3), H2 (4) and CO2 (5) becomes\n", "// delta_G_1_T + R*T*log((n_1*P)/n) + lambda_C + 4*lambda_H = 0\n", "// delta_G_2_T + R*T*log((n_2*P)/n) + 2*lambda_C + lambda_O = 0\n", "// delta_G_3_T + R*T*log((n_3*P)/n) + lambda_c + lambda_O = 0\n", "// delta_G_4_T + R*T*log((n_4*P)/n) + 2*lambda_H = 0\n", "// delta_G_5_T + R*T*log((n_5*P)/n) + lambda_C + 2*lambda_O = 0\n", "\n", "// Where n is the total number of moles in the equilibrium reaction mixture. Dividing the above equations by R*T we get\n", "// delta_G_1_T/(R*T) + log((n_1*P)/n) + lambda_C/(R*T) + 4*lambda_H/(R*T) = 0\n", "// delta_G_2_T/(R*T) + log((n_2*P)/n) + 2*lambda_C/(R*T) + lambda_O/(R*T) = 0\n", "// delta_G_3_T/(R*T) + log((n_3*P)/n) + lambda_c/(R*T) + lambda_O/(R*T) = 0\n", "// delta_G_4_T/(R*T) + log((n_4*P)/n) + 2*lambda_H/(R*T) = 0\n", "// delta_G_5_T/(R*T) + log((n_5*P)/n) + lambda_C/(R*T) + 2*lambda_O/(R*T) = 0\n", "\n", "// Substituting the values of delta_G_i_T/(R*T) in the above equations,the full set of equations (including elemental balance) becomes\n", "// -2.82 + log(n_1/n) + lambda_C/(R*T) + 4*lambda_H/(R*T) = 0\n", "// -29.73 + log(n_2/n) + 2*lambda_H/(R*T) + lambda_O/(R*T) = 0\n", "// -27.51 + log(n_3/n) + lambda_C/(R*T) + lambda_O/(R*T) = 0\n", "// -1.46 + log(n_4/n) + 2*lambda_H/(R*T) = 0\n", "// -56.68 + log(n_5/n) + lambda_C/(R*T) + 2*lambda_O/(R*T) = 0\n", "\n", "// The constraint equations are\n", "// n_1 + n_3 + n_5 = 1 // (moles of C in the reaction mixture = 1)\n", "// 4*n_1 + 2*n_2 + 2*n_4 = 14 // (moles of H in the reaction mixture = 14)\n", "// n_2 + n_3 + 2*n_5 = 5 // (moles of O in the raection mixture = 5)\n", "\n", "// The total moles are given by\n", "// n = n_1 + n_2 + n_3 + n_4 + n_5\n", "\n", "function[f]=solution(x)\n", "f(1) = -2.82 + log(x(1)/x(6)) + x(7) + 4*x(8);\n", "f(2) = -29.73 + log(x(2)/x(6)) + 2*x(8) + x(9);\n", "f(3) = -27.51 + log(x(3)/x(6)) + x(7) + x(9);\n", "f(4) = -1.46 + log(x(4)/x(6)) + 2*x(8);\n", "f(5) = -56.68 + log(x(5)/x(6)) + x(7) + 2*x(9);\n", "f(6) = x(1) + x(3) +x(5) - 1;\n", "f(7) = 4*x(1) + 2*x(2) + 2*x(4) - 14;\n", "f(8) = x(2) + x(3) +2*x(5) - 5;\n", "f(9) = x(1)+ x(2) + x(3) + x(4) + x(5) - x(6); \n", "\n", "funcprot(0);\n", "endfunction\n", "x = [0.01,3.5,0.2,3.0,0.5,5.0,2.0,1.0,25.0];\n", "y = fsolve(x,solution);\n", "\n", "printf(' n_1 = %f mol\n',y(1));\n", "printf(' n_2 = %f mol\n',y(2));\n", "printf(' n_3 = %f mol\n',y(3));\n", "printf(' n_4 = %f mol\n',y(4));\n", "printf(' n_5 = %f mol\n',y(5));\n", "printf(' n = %f mol\n',y(6));\n", "printf(' lambda_C/RT = %f\n',y(7));\n", "printf(' lambda_H/RT = %f\n',y(8));\n", "printf(' lambda_O/RT = %f\n\n',y(9));\n", "\n", "printf(' The Lagrange multiplier values do not have any physical significance\n');\n", "" ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 17.2: Determination_of_number_of_moles.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "clear;\n", "clc;\n", "\n", "//Example - 17.2\n", "//Page number - 598\n", "printf('Example - 17.2 and Page number - 598\n\n');\n", "\n", "// Given\n", "P = 1;//[atm] - Reactor pressure\n", "T = 749;//[K] - Reactor temperature\n", "K = 74;// Equlibrium constant\n", "\n", "// SO2 + (1/2)*O2 - SO3\n", "\n", "Kp = P^(1);\n", "Ky = K/Kp;\n", "\n", "//(1)\n", "// Initial number of moles of the components are\n", "n_SO2_1_in = 12;\n", "n_O2_1_in = 9;\n", "n_SO3_1_in = 0;\n", "\n", "// Let the reaction coordinate at equilibrium for the reaction be X\n", "// At equilibrium, the moles of the components be\n", "// n_SO2_1_eq = 12 - X\n", "// n_O2_1_eq = 9 - 0.5*X\n", "// n_SO3_1_eq = X\n", "// Total moles = 21 - 0.5*X\n", "\n", "// The mole fractions of the components at equilibrium are\n", "// y_SO3 = X/(21-0.5*X)\n", "// y_SO2 = (12-X)/(21-0.5*X)\n", "// y_O2 = (9-0.5*X)/(21-0.5*X)\n", "\n", "// Ky = y_SO3/(y_SO2*y_O2^(2))\n", "// Ky = (X*(21-0.5*X)^(1/2))/((12-X)*(9-0.5*X)^(1/2))\n", "deff('[y]=f(X)','y= Ky-(X*(21-0.5*X)^(1/2))/((12-X)*(9-0.5*X)^(1/2))');\n", "X_1 = fsolve(11,f);\n", "\n", "y_SO3_1 = X_1/(21-0.5*X_1);\n", "y_SO2_1 = (12-X_1)/(21-0.5*X_1);\n", "y_O2_1 = (9-0.5*X_1)/(21-0.5*X_1);\n", "\n", "printf(' (1).The moles of SO3 formed = %f mol\n',X_1);\n", "printf(' The mole fractions at equilibrium are y_S03 = %f, y_SO2 = %f and y_O2 = %f\n\n',y_SO3_1,y_SO2_1,y_O2_1);\n", "\n", "//(2)\n", "// Initial number of moles of the components are\n", "n_SO2_2_in = 24;\n", "n_O2_2_in = 18;\n", "n_SO3_2_in = 0;\n", "\n", "// At equilibrium, the moles of the components be\n", "// n_SO2_1_eq = 24 - X\n", "// n_O2_1_eq = 18 - 0.5*X\n", "// n_SO3_1_eq = X\n", "// Total moles = 42 - 0.5*X\n", "\n", "// The mole fractions of the components at equilibrium are\n", "// y_SO3 = X/(42-0.5*X)\n", "// y_SO2 = (24-X)/(42-0.5*X)\n", "// y_O2 = (18-0.5*X)/(42-0.5*X)\n", "\n", "// Ky = y_SO3/(y_SO2*y_O2^(2))\n", "// Ky = (X*(42-0.5*X)^(1/2))/((24-X)*(18-0.5*X)^(1/2))\n", "deff('[y]=f1(X)','y= Ky-(X*(42-0.5*X)^(1/2))/((24-X)*(18-0.5*X)^(1/2))');\n", "X_2 = fsolve(22,f1);\n", "\n", "y_SO3_2 = X_2/(42-0.5*X_2);\n", "y_SO2_2 = (24-X_2)/(42-0.5*X_2);\n", "y_O2_2 = (18-0.5*X_2)/(42-0.5*X_2);\n", "printf(' (2).The moles of SO3 formed = %f mol\n',X_2);\n", "printf(' The mole fractions at equilibrium are y_S03 = %f, y_SO2 = %f and y_O2 = %f\n\n',y_SO3_2,y_SO2_2,y_O2_2);\n", "\n", "//(3)\n", "// Initial number of moles of the components are\n", "n_SO2_3_in = 12;\n", "n_O2_3_in = 9;\n", "n_SO3_3_in = 0;\n", "n_N2 = 79;\n", "\n", "// At equilibrium, the moles of the components be\n", "// n_SO2_1_eq = 12 - X\n", "// n_O2_1_eq = 9 - 0.5*X\n", "// n_SO3_1_eq = X\n", "// Total moles = 100 - 0.5*X\n", "\n", "// The mole fractions of the components at equilibrium are\n", "// y_SO3 = X/(100-0.5*X)\n", "// y_SO2 = (12-X)/(100-0.5*X)\n", "// y_O2 = (9-0.5*X)/(100-0.5*X)\n", "\n", "// Ky = y_SO3/(y_SO2*y_O2^(2))\n", "// Ky = (X*(100-0.5*X)^(1/2))/((12-X)*(9-0.5*X)^(1/2))\n", "deff('[y]=f2(X)','y= Ky-(X*(100-0.5*X)^(1/2))/((12-X)*(9-0.5*X)^(1/2))');\n", "X_3 = fsolve(10,f2);\n", "\n", "y_SO3_3 = X_3/(100-0.5*X_3);\n", "y_SO2_3 = (12-X_3)/(100-0.5*X_3);\n", "y_O2_3 = (9-0.5*X_3)/(100-0.5*X_3);\n", "\n", "printf(' (3).The moles of SO3 formed = %f mol\n',X_3);\n", "printf(' The mole fractions at equilibrium are y_S03 = %f, y_SO2 = %f and y_O2 = %f\n\n',y_SO3_3,y_SO2_3,y_O2_3);\n", "\n", "\n", "\n", "\n", "" ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 17.3: Determination_of_equilibrium_composition.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "clear;\n", "clc;\n", "\n", "//Example - 17.3\n", "//Page number - 599\n", "printf('Example - 17.3 and Page number - 599\n\n');\n", "\n", "// Given\n", "T = 600;//[K] - Reactor temperature\n", "P = 300;//[atm] - Reactor pressure\n", "K = 0.91*10^(-4);// Equilibrium constant\n", "\n", "// The fugacity coefficients of the components are\n", "phi_CO = 1.0;\n", "phi_H2 = 1.2;\n", "phi_CH3OH = 0.47;\n", "\n", "// CO + 2*H2 - CH3OH \n", "\n", "// For gas phase reactions the standard state is pure ideal gas and thus fi_0 = 1 atm and thus\n", "// ai_cap = fi_cap/fi_0 = yi*P*phi_i_cap/1\n", "// Thus K = Ky*Kp*K_phi\n", "Kp = P^(1-3);\n", "K_phi = phi_CH3OH/(phi_CO*phi_H2^(2));\n", "Ky = K/(Kp*K_phi);\n", "\n", "// Let the reaction coordinate at equilibrium for the reaction be X\n", "// At equilibrium ,the moles of the components be \n", "// n_CO = 1 - X\n", "// n_H2 = 3 - 2*X\n", "// n_CH3OH = X\n", "// Total moles = 4 - 2*X\n", "\n", "// The mole fractions of the components at equilibrium are\n", "// y_CO = (1-X)/(4-2*X)\n", "// y_H2 = (3-2*X)/(4-2*X)\n", "// y_CH3OH = (X)/(4-2*X)\n", "\n", "// Ky = y_CH3OH/(y_CO*y_H2^(2)) = (X/(4-2*X))/(((1-X)/(4-2*X))*((3-2*X)/(4-2*X))^(2))\n", "deff('[y]=f(X)','y=Ky-(X/(4-2*X))/(((1-X)/(4-2*X))*((3-2*X)/(4-2*X))^(2))');\n", "X = fsolve(0.1,f);\n", "\n", "// Therefore at equilibrium \n", "y_CO = (1-X)/(4-2*X);\n", "y_H2 = (3-2*X)/(4-2*X);\n", "y_CH3OH = (X)/(4-2*X);\n", "\n", "printf(' The mole fractions at equilibrium are y_CO = %f, y_H2 = %f and y_CH3OH = %f',y_CO,y_H2,y_CH3OH);\n", "\n", "\n", "" ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 17.4: Determination_of_the_value_of_equilibrium_constant.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "clear;\n", "clc;\n", "\n", "//Example - 17.4\n", "//Page number - 600\n", "printf('Example - 17.4 and Page number - 600\n\n');\n", "\n", "// Given\n", "T = 600;//[K] - Reactor temperature\n", "P = 4;//[atm] - Reactor pressure\n", "K = 1.175;// Equilibrium constant\n", "\n", "// (1/2)*N2 + (3/2)*H_2 - NH3\n", "\n", "// Initial number of moles of the components are\n", "n_N2 = 1;\n", "n_H2 = 3;\n", "n_HN3 = 0;\n", "\n", "// Let the reaction coordinate at equilibrium for the reaction be X.\n", "// At equilibrium ,the moles of the components be \n", "// n_N2 = 1 - 0.5*X\n", "// n_H2 = 3 - 1.5*X\n", "// n_NH3 = X\n", "// Total moles = 4 - X\n", "\n", "// We have, K = Ky*Kp\n", "Kp = P^(1-2);//[atm^(-1)]\n", "Ky = K/(Kp);\n", "\n", "// Ky = y_NH3/(y_N2^(1/2)*y_H2^(3/2)) = (X/(4-X))/(((1-0.5*X)/(4-X))^(1/2)*((3-1.5*X)/(4-X))^(3/2))\n", "// Solving the above equation we get\n", "deff('[y]=f(X)','y=Ky - (X/(4-X))/(((1-0.5*X)/(4-X))^(1/2)*((3-1.5*X)/(4-X))^(3/2))');\n", "X = fsolve(0.1,f);\n", "\n", "y_NH3 = X/(4-X);// Mole fraction of NH3 at equilibrium\n", "\n", "printf(' The value of Kp = %f and Ky = %f \n',Kp,Ky);\n", "printf(' The mole fractions of NH3 at equilibrium is %f\n\n',y_NH3);\n", "\n", "// If reaction carried out at constant temperature and volume\n", "\n", "// We know that for ideal gas, P*V = n*R*T and thus P is directly proportional to n at constant V and T.\n", "// Let P = k*n\n", "// Initially P = 4 atm and n = 4 moles, thus K = 1 and we get p = n, where P is in atm. \n", "// Thus at equilibrium P = 4 - X\n", "\n", "// Ky = K/Kp = 1.175*P = 1.175*(4 - X)\n", "// (X/(4-X))/(((1-0.5*X)/(4-X))^(1/2)*((3-1.5*X)/(4-X))^(3/2)) = 1.175*(4 - X)\n", "// Solving the above equation we get\n", "deff('[y]=f1(X)','y=(X/(4-X))/(((1-0.5*X)/(4-X))^(1/2)*((3-1.5*X)/(4-X))^(3/2))-1.175*(4-X)');\n", "X_prime = fsolve(1,f1);\n", "\n", "// Therefore at equilibrium \n", "P_prime = 4 - X_prime;\n", "y_NH3_prime = X_prime/(4-X_prime);\n", "\n", "printf(' If reaction is carried out at constant temperature and volume,then\n');\n", "printf(' The equilibrium pressure is %f atm\n',P_prime);\n", "printf(' The equilibrium mole fractions of NH3 in the reactor is %f\n\n',y_NH3_prime);\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "" ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 17.5: Determination_of_mole_fraction.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "clear;\n", "clc;\n", "\n", "//Example - 17.5\n", "//Page number - 601\n", "printf('Example - 17.5 and Page number - 601\n\n');\n", "\n", "// Given\n", "T = 400;//[K] - Reactor temperature\n", "P = 1;//[atm] - Reactor pressure\n", "K = 1.52;// Equilibrium constant\n", "y_H2 = 0.4;// Equilibrium mole fraction of hydrogen\n", "\n", "// CO(g) + 2*H_2(g) - CH3OH(g)\n", "\n", "// K = y_CH3OH/(y_CO*y_H2^(2)*P^(2))\n", "// Let total number of moles at equilibrium be 1\n", "// y_CH3OH = 0.6 - y_CO;\n", "// (0.6 - y_CO)/y_CO = K*P^(2)*y_H2^(2)\n", "\n", "y_CO = 0.6/(1 + K*P^(2)*y_H2^(2));\n", "y_CH3OH = 0.6 - y_CO;\n", "\n", "printf(' The mole fractions are, y_CO = %f and y_CH3OH = %f \n',y_CO,y_CH3OH);\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "" ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 17.6: Determination_of_number_of_moles.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "clear;\n", "clc;\n", "\n", "//Example - 17.6\n", "//Page number - 602\n", "printf('Example - 17.6 and Page number - 602\n\n');\n", "\n", "// Given\n", "T = 749;//[K] - Reactor temperature\n", "P = 1;//[atm] - Reactor pressure\n", "K = 74;\n", "\n", "Kp = P^(-1/2);//[atm^(-1/2)]\n", "Ky = K/Kp;\n", "\n", "// SO2 + (1/2)*O2 - SO3\n", "\n", "// Initial number of moles of the components are\n", "n_SO2_1_in = 10;\n", "n_O2_1_in = 8;\n", "n_SO3_1_in = 0;\n", "\n", "// Let the reaction coordinate at equilibrium for the reaction be X\n", "// At equilibrium, the moles of the components be\n", "// n_SO2_1_eq = 10 - X\n", "// n_O2_1_eq = 8 - 0.5*X\n", "// SO3_1_eq = X\n", "// Total moles = 18 - 0.5*X\n", "\n", "// The mole fractions of the components at equilibrium are\n", "// y_SO3 = X/(18-0.5*X)\n", "// y_SO2 = (10-X)/(18-0.5*X)\n", "// y_O2 = (8-0.5*X)/(18-0.5*X)\n", "\n", "// Ky = y_SO3/(y_SO2*y_O2^(2))\n", "// Ky = (X*(18-0.5*X)^(1/2))/((10-X)*(8-0.5*X)^(1/2))\n", "deff('[y]=f(X)','y= Ky-(X*(18-0.5*X)^(1/2))/((10-X)*(8-0.5*X)^(1/2))');\n", "X_1 = fsolve(11,f);\n", "\n", "n_SO3 = X_1;\n", "n_SO2 = 10 - X_1;\n", "n_O2 = 8 - 0.5*X_1;\n", "\n", "printf(' (1).The moles of the components at equilibrium are, n_SO3 = %f mol, n_SO2 = %f mol and n_O2 = %f mol\n\n',n_SO3,n_SO2,n_O2);\n", "\n", "// Now for the reaction\n", "// 2*SO2 + O2 - 2*SO3\n", "\n", "// The equilibrium constant for this reaction is KP^(2)\n", "Ky_prime = Ky^(2);\n", "\n", "// At equilibrium, the moles of the components be\n", "// n_SO2_1_eq = 10 - 2*X\n", "// n_O2_1_eq = 8 - X\n", "// SO3_1_eq = 2*X\n", "// Total moles = 18 - X\n", "\n", "// The mole fractions of the components at equilibrium are\n", "// y_SO3 = 2*X/(18-X)\n", "// y_SO2 = (10-2*X)/(18-X)\n", "// y_O2 = (8- X)/(18-X)\n", "\n", "// Ky_prime = y_SO3^(2)/(y_SO2^(2)*y_O2)\n", "// Ky_prime = ((2*X)^(2)*(18-X))/((10-2*X)^(2)*(8-X))\n", "deff('[y]=f1(X)','y= Ky_prime-((2*X)^(2)*(18-X))/(((10-2*X)^(2))*(8-X))');\n", "X_2 = fsolve(6,f1);\n", "\n", "n_SO3_prime = 2*X_2;\n", "n_SO2_prime = 10 - 2*X_2;\n", "n_O2_prime = 8 - X_2;\n", "\n", "printf(' (2).The moles of the components at equilibrium are, n_SO3 = %f mol, n_SO2 = %f mol and n_O2 = %f mol\n\n',n_SO3_prime,n_SO2_prime,n_O2_prime);\n", "printf(' Thus the number of moles remains the same irrespective of the stoichoimetry of the reaction')" ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 17.7: Calculation_of_mole_fraction.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "clear;\n", "clc;\n", "\n", "//Example - 17.7\n", "//Page number - 603\n", "printf('Example - 17.7 and Page number - 603\n\n');\n", "\n", "// Given\n", "T = 500;//[K]\n", "// For the reaction, 0.5*A2 + 0.5*B2 - AB\n", "delta_G = -4200;//[J/mol]\n", "R = 8.314;//[J/mol*K] - Universal gas constant\n", "\n", "//(1)\n", "// A2 + B2 - 2*AB\n", "\n", "// We know delta_G_rkn_0 = -R*T*log(K) \n", "delta_G_1 = 2*delta_G;\n", "K_1 = exp(-delta_G_1/(R*T));// Equilibrium constant at 500 K for the above reaction\n", "// As can be seen the reaction is not affected by pressure and therefore K = Ky as Kp = 1 \n", "Ky = K_1;\n", "\n", "// Initial number of moles of the components are\n", "n_A2_1_in = 0.5;\n", "n_B2_1_in = 0.5;\n", "n_AB_1_in = 0;\n", "\n", "// Let the reaction coordinate at equilibrium for the reaction be X\n", "// At equilibrium, the moles of the components be\n", "// n_A2_1_eq = 0.5 - X\n", "// n_B2_1_eq = 0.5- X\n", "// n_AB_1_eq = 2*X\n", "// Total moles = 1\n", "\n", "// Ky = (2*X)^(2)/(0.5-X)^(2)\n", "deff('[y]=f(X)','y= Ky-(2*X)^(2)/(0.5-X)^(2)');\n", "X_1 = fsolve(0.2,f);\n", "\n", "// The mole fractions of the components at equilibrium are\n", "y_A2_1 = 0.5 - X_1;\n", "y_B2_1 = 0.5- X_1;\n", "y_AB_1 = 2*X_1;\n", "\n", "printf(' (1).The mole fractions at equilibrium are y_A2 = %f, y_B2 = %f and y_AB = %f\n\n',y_A2_1,y_B2_1,y_AB_1);\n", "\n", "//(2)\n", "// 0.5*A2 + 0.5*B2 - AB\n", "\n", "// We know delta_G_rkn_0 = -R*T*log(K) \n", "delta_G_2 = delta_G;\n", "K_2 = exp(-delta_G_2/(R*T));// Equilibrium constant at 500 K for the above reaction\n", "\n", "// As can be seen the reaction is not affected by pressure and therefore K = Ky as Kp = 1 \n", "Ky_2 = K_2;\n", "\n", "// Initial number of moles of the components are\n", "n_A2_2_in = 0.5;\n", "n_B2_2_in = 0.5;\n", "n_AB_2_in = 0;\n", "\n", "// Let the reaction coordinate at equilibrium for the reaction be X\n", "// At equilibrium, the moles of the components be\n", "// n_A2_2_eq = 0.5 - 0.5*X\n", "// n_B2_2_eq = 0.5- 0.5*X\n", "// n_AB_2_eq = X\n", "// Total moles = 1\n", "\n", "// Ky = y_AB/(y_A2^(1/2)*y_B2^(1/2))\n", "// Ky = X/(0.5 - 0.5*X)\n", "X_2 = 0.5*Ky_2/(1+0.5*Ky_2);\n", "\n", "// The mole fractions of the components at equilibrium are\n", "y_A2_2 = 0.5 - 0.5*X_2;\n", "y_B2_2 = 0.5- 0.5*X_2;\n", "y_AB_2 = X_2;\n", "\n", "printf(' (2).The mole fractions at equilibrium are y_A2 = %f, y_B2 = %f and y_AB = %f\n\n',y_A2_2,y_B2_2,y_AB_2);\n", "\n", "//(3)\n", "// 2*AB - A2 + B2\n", "\n", "K_3 = 1/K_1;// Equilibrium constant at 500 K for the above reaction\n", "// As can be seen the reaction is not affected by pressure and therefore K = Ky as Kp = 1 \n", "Ky_3 = K_3;\n", "\n", "// Initial number of moles of the components are\n", "n_AB_3_in = 1;\n", "n_A2_3_in = 0;\n", "n_B2_3_in = 0;\n", "\n", "// Let the reaction coordinate at equilibrium for the reaction be X\n", "// At equilibrium, the moles of the components be\n", "// n_AB_3_eq = 1 - X\n", "// n_A2_3_eq = X/2\n", "// n_B2_3_eq = X/2\n", "// Total moles = 1\n", "\n", "// Ky = (X/2)^(2)/(1-X)^(2)\n", "deff('[y]=f1(X)','y= Ky_3-(X/2)^(2)/(1-X)^(2)');\n", "X_3 = fsolve(0.4,f1);\n", "\n", "// The mole fractions of the components at equilibrium are\n", "y_A2_3 = X_3/2;\n", "y_B2_3 = X_3/2;\n", "y_AB_3 = 1-X_3;\n", "\n", "printf(' (3).The mole fractions at equilibrium are y_A2 = %f, y_B2 = %f and y_AB = %f\n\n',y_A2_3,y_B2_3,y_AB_3);\n", "" ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 17.8: Calculation_of_heat_exchange.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "clear;\n", "clc;\n", "\n", "//Example - 17.8\n", "//Page number - 606\n", "printf('Example - 17.8 and Page number - 606\n\n');\n", "\n", "// Given\n", "// P*P +q*Q - r*R + s*S\n", "// Let Cp_P = p, Cp_Q = Q, Cp_R = R and Cp_S = S\n", "\n", "//(1)\n", "// When reactants are heated from 10 to 25 C,reaction takes place at 25 C and products are raised from 25 C to 1500 K the heat exchange is given by\n", "T_1 = 10 + 273.15;//[K]\n", "T_2 = 25 + 273.15;//[K]\n", "T_3 = 1500;//[K]\n", "// Q = integrate('(p*Cp_P + q*Cp_q)*dT','T',T_1,T_2) + delta_H_rkn_298 + integrate('(r*Cp_R + s*Cp_S)*dT','T'T_2,T_3);\n", "printf(' (1).The expression for the heat exchange with the surrounding by the first path is given below\n');\n", "printf(' Q = integrate((p*Cp_P + q*Cp_q)*dT,T,T_1,T_2) + delta_H_rkn_298 + integrate((r*Cp_R + s*Cp_S)*dT,TT_2,T_3);\n\n')\n", "\n", "//(2)\n", "// When reactants are heated from 10 C to 1500 K,reaction take place at 1500 K the heat exchange is given by\n", "// Q = integrate('(p*Cp_P + q*Cp_q)*dT','T',T_1,T_3) + delta_H_rkn_1500\n", "// where, delta_H_rkn_1500 = delta_H_rkn_298 + integrate('(r*Cp_R + s*Cp_S - p*Cp_P - q*Cp_q)*dT','T'T_2,T_3);\n", "// Therefore\n", "// Q = integrate('(p*Cp_P + q*Cp_q)*dT','T',T_1,T_3) + delta_H_rkn_298 + integrate('(r*Cp_R + s*Cp_S - p*Cp_P - q*Cp_q)*dT','T'T_2,T_3);\n", "// Q = integrate('(p*Cp_P + q*Cp_q)*dT','T',T_1,T_2) + delta_H_rkn_298 + integrate('(r*Cp_R + s*Cp_S)*dT','T'T_2,T_3);\n", "\n", "// which is same as in method (1). The total enthalpy change between two fixed ponts is a function only of state and not the path taken.\n", "\n", "printf(' (2).The expression for the heat exchange with the surrounding by the second path is given below\n');\n", "printf(' Q = integrate((p*Cp_P + q*Cp_q)*dT,T,T_1,T_2) + delta_H_rkn_298 + integrate((r*Cp_R + s*Cp_S)*dT,TT_2,T_3);\n\n')\n", "\n", "\n", "" ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 17.9: Dtermination_of_heat_of_reaction.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "clear;\n", "clc;\n", "\n", "//Example - 17.9\n", "//Page number - 606\n", "printf('Example - 17.9 and Page number - 606\n\n');\n", "\n", "// Given\n", "// SO2 + (1/2)*O2 - SO3\n", "R = 1.987;//[cal/mol-K]\n", "\n", "delta_H_SO2_298 = -70.96;//[kcal/mol] - Enthalpy of formation of S02 at 298.15 K\n", "delta_H_SO3_298 = -94.45;//[kcal/mol] - Enthalpy of formation of S03 at 298.15 K\n", "delta_G_SO2_298 = -71.79;//[kcal/mol] - Gibbs free energy change for formation of SO2 at 298.15 K\n", "delta_G_SO3_298 = -88.52;//[kcal/mol] - Gibbs free energy change for formation of SO3 at 298.15 K\n", "\n", "// Cp_0 = a + b*T + c*T^(2) + d*T^(3)\n", "\n", "a_SO2 = 6.157;\n", "a_SO3 = 3.918;\n", "a_O2 = 6.085;\n", "b_SO2 = 1.384*10^(-2);\n", "b_SO3 = 3.483*10^(-2);\n", "b_O2 = 0.3631*10^(-2);\n", "c_SO2 = -0.9103*10^(-5);\n", "c_SO3 = -2.675*10^(-5);\n", "c_O2 = -0.1709*10^(-5);\n", "d_SO2 = 2.057*10^(-9);\n", "d_SO3 = 7.744*10^(-9);\n", "d_O2 = 0.3133*10^(-9);\n", "\n", "//(1)\n", "T_1 = 298.15;//[K]\n", "\n", "delta_H_rkn_298 = delta_H_SO3_298 - delta_H_SO2_298;//[kcal]\n", "delta_H_rkn_298 = delta_H_rkn_298*10^(3);//[cal]\n", "delta_G_rkn_298 = delta_G_SO3_298 - delta_G_SO2_298;//[kcal]\n", "delta_G_rkn_298 = delta_G_rkn_298*10^(3);//[cal]\n", "\n", "delta_a = a_SO3 - a_SO2 - (a_O2/2);\n", "delta_b = b_SO3 - b_SO2 - (b_O2/2);\n", "delta_c = c_SO3 - c_SO2 - (c_O2/2);\n", "delta_d = d_SO3 - d_SO2 - (d_O2/2);\n", "\n", "// delta_H_rkn_T = delta_H_rkn_298 + integrate('delta_a+(delta_b*T)+(delta_c*T^(2))+(delta_d*T^(3))','T',T_1,T);\n", "// On simplification we get\n", "// delta_H_rkn_T = -22630.14 - 5.2815*T + 0.9587*10^(-2)*T^(2) - 0.5598*10^(-5)*T^(3) + 1.3826*10^(-9)*T^(4)\n", "\n", "printf(' (1).The expression for delta_H_rkn_T as a function of T is given by\n');\n", "printf(' delta_H_rkn_T = -22630.14 - 5.2815*T + 0.9587*10^(-2)*T^(2) - 0.5598*10^(-5)*T^(3) + 1.3826*10^(-9)*T^(4)\n\n');\n", "\n", "//(2)\n", "// R*log(K_T/K_298) = integrate('delta_H_rkn_T/T^(2)',T,T_1,T)\n", "// First let us calculate K_298.\n", "// delta_G_rkn_T = - R*T*log(K)\n", "K_298 = exp(-delta_G_rkn_298/(R*T_1));\n", "\n", "// On substituting the values and simplifying we get the expression\n", "// log(K) = 3.87 + 11380.10/T - 2.6580*log(T) + 0.4825*10^(-2)*T - 0.1409*10^(-5)*T^(2) + 0.2320*10^(-9)*T^(3)\n", "\n", "printf(' (2).The expression for log(K) as a function of T is given by\n');\n", "printf(' log(K) = 3.87 + 11380.10/T - 2.6580*log(T) + 0.4825*10^(-2)*T - 0.1409*10^(-5)*T^(2) + 0.2320*10^(-9)*T^(3)\n\n');\n", "\n", "//(3)\n", "P = 1;//[atm]\n", "T = 880;//[K]\n", "K = exp(3.87 + 11380.10/T - 2.6580*log(T) + 0.4825*10^(-2)*T - 0.1409*10^(-5)*T^(2) + 0.2320*10^(-9)*T^(3));\n", "Kp = P^(-1/2);//[atm^(-1/2)]\n", "Ky = K/Kp;\n", "\n", "// Let the reaction coordinate at equilibrium for the reaction be X\n", "// At equilibrium, the moles of the components be\n", "// n_SO2_eq = 1 - X\n", "// n_O2_eq = 0.5- 0.5*X\n", "// n_SO3_1_eq = X\n", "// Total moles = 1.5-0.5*X\n", "\n", "// Ky = (X*(1.5-0.5*X)^(1/2))/((1-X)*(0.5-0.5*X)^(1/2))\n", "deff('[y]=f(X)','y= Ky - (X*(1.5-0.5*X)^(1/2))/((1-X)*(0.5-0.5*X)^(1/2))');\n", "X = fsolve(0.8,f);\n", "\n", "// The mole fraction of SO3 at equilibrium is given by\n", "y_SO3 = X/(1.5-0.5*X);\n", "\n", "printf(' (3).The mole fraction of SO3 at equilibrium is given by, y_SO3 = %f\n',y_SO3);\n", "" ] } ], "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 }