{ "metadata": { "name": "ch17_1", "signature": "sha256:e354b0525ce1aff27214eb76f8a2c9be56cfff2939a8a4b8688a7fe1cea4959c" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "Chapter 17 : Chemical Reactions Equilibria" ] }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 17.2 Page Number : 598" ] }, { "cell_type": "code", "collapsed": false, "input": [ " \n", "from scipy.optimize import fsolve \n", "import math \n", "\n", "\n", "# Variables\n", "P = 1;\t\t\t#[atm] - Reactor pressure\n", "T = 749;\t\t\t#[K] - Reactor temperature\n", "K = 74;\t\t\t# Equlibrium constant\n", "\n", "\t\t\t# SO2 + (1/2)*O2 - SO3\n", "\n", "# Calculations and Results\n", "Kp = P**(1);\n", "Ky = K/Kp;\n", "\n", "\t\t\t#(1)\n", "\t\t\t# 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", "\t\t\t# Let the reaction coordinate at equilibrium for the reaction be X\n", "\t\t\t# At equilibrium, the moles of the components be\n", "\t\t\t# n_SO2_1_eq = 12 - X\n", "\t\t\t# n_O2_1_eq = 9 - 0.5*X\n", "\t\t\t# n_SO3_1_eq = X\n", "\t\t\t# Total moles = 21 - 0.5*X\n", "\n", "\t\t\t# The mole fractions of the components at equilibrium are\n", "\t\t\t# y_SO3 = X/(21-0.5*X)\n", "\t\t\t# y_SO2 = (12-X)/(21-0.5*X)\n", "\t\t\t# y_O2 = (9-0.5*X)/(21-0.5*X)\n", "\n", "\t\t\t# Ky = y_SO3/(y_SO2*y_O2**(2))\n", "\t\t\t# Ky = (X*(21-0.5*X)**(1/2))/((12-X)*(9-0.5*X)**(1/2))\n", "def f(X): \n", "\t return Ky-(X*(21-0.5*X)**(1./2))/((12-X)*(9-0.5*X)**(1./2))\n", "X_1 = fsolve(f,11)\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", "print \" 1).The moles of SO3 formed = %f mol\"%(X_1);\n", "print \" The mole fractions at equilibrium are y_S03 = %f y_SO2 = %f and y_O2 = %f\"%(y_SO3_1,y_SO2_1,y_O2_1);\n", "\n", "\t\t\t#(2)\n", "\t\t\t# 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", "\t\t\t# At equilibrium, the moles of the components be\n", "\t\t\t# n_SO2_1_eq = 24 - X\n", "\t\t\t# n_O2_1_eq = 18 - 0.5*X\n", "\t\t\t# n_SO3_1_eq = X\n", "\t\t\t# Total moles = 42 - 0.5*X\n", "\n", "\t\t\t# The mole fractions of the components at equilibrium are\n", "\t\t\t# y_SO3 = X/(42-0.5*X)\n", "\t\t\t# y_SO2 = (24-X)/(42-0.5*X)\n", "\t\t\t# y_O2 = (18-0.5*X)/(42-0.5*X)\n", "\n", "\t\t\t# Ky = y_SO3/(y_SO2*y_O2**(2))\n", "\t\t\t# Ky = (X*(42-0.5*X)**(1/2))/((24-X)*(18-0.5*X)**(1/2))\n", "def f1(X): \n", "\t return Ky-(X*(42-0.5*X)**(1./2))/((24-X)*(18-0.5*X)**(1./2))\n", "X_2 = fsolve(f1,22)\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", "print \" 2).The moles of SO3 formed = %f mol\"%(X_2);\n", "print \" The mole fractions at equilibrium are y_S03 = %f, y_SO2 = %f and y_O2 = %f\"%(y_SO3_2,y_SO2_2,y_O2_2);\n", "\n", "\t\t\t#(3)\n", "\t\t\t# 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", "\t\t\t# At equilibrium, the moles of the components be\n", "\t\t\t# n_SO2_1_eq = 12 - X\n", "\t\t\t# n_O2_1_eq = 9 - 0.5*X\n", "\t\t\t# n_SO3_1_eq = X\n", "\t\t\t# Total moles = 100 - 0.5*X\n", "\n", "\t\t\t# The mole fractions of the components at equilibrium are\n", "\t\t\t# y_SO3 = X/(100-0.5*X)\n", "\t\t\t# y_SO2 = (12-X)/(100-0.5*X)\n", "\t\t\t# y_O2 = (9-0.5*X)/(100-0.5*X)\n", "\n", "\t\t\t# Ky = y_SO3/(y_SO2*y_O2**(2))\n", "\t\t\t# Ky = (X*(100-0.5*X)**(1/2))/((12-X)*(9-0.5*X)**(1/2))\n", "def f2(X): \n", "\t return Ky-(X*(100-0.5*X)**(1./2))/((12-X)*(9-0.5*X)**(1./2))\n", "X_3 = fsolve(f2,10)\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", "print \" 3).The moles of SO3 formed = %f mol\"%(X_3);\n", "print \" The mole fractions at equilibrium are y_S03 = %f y_SO2 = %f and y_O2 = %f\"%(y_SO3_3,y_SO2_3,y_O2_3);\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " 1).The moles of SO3 formed = 11.655537 mol\n", " The mole fractions at equilibrium are y_S03 = 0.768215 y_SO2 = 0.022704 and y_O2 = 0.209081\n", " 2).The moles of SO3 formed = 23.311074 mol\n", " The mole fractions at equilibrium are y_S03 = 0.768215, y_SO2 = 0.022704 and y_O2 = 0.209081\n", " 3).The moles of SO3 formed = 11.202213 mol\n", " The mole fractions at equilibrium are y_S03 = 0.118669 y_SO2 = 0.008451 and y_O2 = 0.036006\n" ] } ], "prompt_number": 1 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 17.3 Page Number : 599" ] }, { "cell_type": "code", "collapsed": false, "input": [ " \n", "# Variables\n", "T = 600;\t\t\t#[K] - Reactor temperature\n", "P = 300;\t\t\t#[atm] - Reactor pressure\n", "K = 0.91*10**(-4);\t\t\t# Equilibrium constant\n", "\n", "\t\t\t# The fugacity coefficients of the components are\n", "phi_CO = 1.0;\n", "phi_H2 = 1.2;\n", "phi_CH3OH = 0.47;\n", "\n", "\t\t\t# CO + 2*H2 - CH3OH \n", "\n", "\t\t\t# For gas phase reactions the standard state is pure ideal gas and thus fi_0 = 1 atm and thus\n", "\t\t\t# ai_cap = fi_cap/fi_0 = yi*P*phi_i_cap/1\n", "\t\t\t# Thus K = Ky*Kp*K_phi\n", "# Calculations and Results \n", "Kp = P**(1-3);\n", "K_phi = phi_CH3OH/(phi_CO*phi_H2**(2));\n", "Ky = K/(Kp*K_phi);\n", "\n", "\t\t\t# Let the reaction coordinate at equilibrium for the reaction be X\n", "\t\t\t# At equilibrium ,the moles of the components be \n", "\t\t\t# n_CO = 1 - X\n", "\t\t\t# n_H2 = 3 - 2*X\n", "\t\t\t# n_CH3OH = X\n", "\t\t\t# Total moles = 4 - 2*X\n", "\n", "\t\t\t# The mole fractions of the components at equilibrium are\n", "\t\t\t# y_CO = (1-X)/(4-2*X)\n", "\t\t\t# y_H2 = (3-2*X)/(4-2*X)\n", "\t\t\t# y_CH3OH = (X)/(4-2*X)\n", "\n", "\t\t\t# 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", "def f(X): \n", "\t return Ky-(X/(4-2*X))/(((1-X)/(4-2*X))*((3-2*X)/(4-2*X))**(2))\n", "X = fsolve(f,0.1)\n", "\n", "\t\t\t# 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", "print \" The mole fractions at equilibrium are y_CO = %f y_H2 = %f and y_CH3OH = %f\"%(y_CO,y_H2,y_CH3OH);\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " The mole fractions at equilibrium are y_CO = 0.051857 y_H2 = 0.551857 and y_CH3OH = 0.396286\n" ] } ], "prompt_number": 2 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 17.4 Page Number : 600" ] }, { "cell_type": "code", "collapsed": false, "input": [ " \n", "# Variables\t\t\n", "T = 600;\t\t\t#[K] - Reactor temperature\n", "P = 4;\t\t\t#[atm] - Reactor pressure\n", "K = 1.175;\t\t\t# Equilibrium constant\n", "\n", "\t\t\t# (1/2)*N2 + (3/2)*H_2 - NH3\n", "\n", "\t\t\t# Initial number of moles of the components are\n", "n_N2 = 1;\n", "n_H2 = 3;\n", "n_HN3 = 0;\n", "\n", "# Calculations and Results\n", "\t\t\t# Let the reaction coordinate at equilibrium for the reaction be X.\n", "\t\t\t# At equilibrium ,the moles of the components be \n", "\t\t\t# n_N2 = 1 - 0.5*X\n", "\t\t\t# n_H2 = 3 - 1.5*X\n", "\t\t\t# n_NH3 = X\n", "\t\t\t# Total moles = 4 - X\n", "\n", "\t\t\t# We have, K = Ky*Kp\n", "Kp = P**(1-2);\t\t\t#[atm**(-1)]\n", "Ky = K/(Kp);\n", "\n", "\t\t\t# 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", "\t\t\t# Solving the above equation we get\n", "def f(X): \n", "\t return Ky - (X/(4-X))/(((1-0.5*X)/(4-X))**(1./2)*((3-1.5*X)/(4-X))**(3./2))\n", "X = fsolve(f,0.1)\n", "\n", "y_NH3 = X/(4-X);\t\t\t# Mole fraction of NH3 at equilibrium\n", "\n", "print \" The value of Kp = %f and Ky = %f \"%(Kp,Ky);\n", "print \" The mole fractions of NH3 at equilibrium is %f\"%(y_NH3);\n", "\n", "\t\t\t\n", "\n", "\t\t\t# 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", "\t\t\t# Let P = k*n\n", "\t\t\t# Initially P = 4 atm and n = 4 moles, thus K = 1 and we get p = n, where P is in atm. \n", "\t\t\t# Thus at equilibrium P = 4 - X\n", "\n", "\t\t\t# Ky = K/Kp = 1.175*P = 1.175*(4 - X)\n", "\t\t\t# (X/(4-X))/(((1-0.5*X)/(4-X))**(1/2)*((3-1.5*X)/(4-X))**(3/2)) = 1.175*(4 - X)\n", "\t\t\t# Solving the above equation we get\n", "def f1(X): \n", "\t return (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(f1,1)\n", "\n", "\t\t\t# Therefore at equilibrium \n", "P_prime = 4 - X_prime;\n", "y_NH3_prime = X_prime/(4-X_prime);\n", "\n", "print \" If reaction is carried out at constant temperature and volumethen\"\n", "print \" The equilibrium pressure is %f atm\"%(P_prime);\n", "print \" The equilibrium mole fractions of NH3 in the reactor is %f\"%(y_NH3_prime);\n", "\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " The value of Kp = 0.250000 and Ky = 4.700000 \n", " The mole fractions of NH3 at equilibrium is 0.454388\n", " If reaction is carried out at constant temperature and volumethen" ] }, { "output_type": "stream", "stream": "stdout", "text": [ "\n", " The equilibrium pressure is 2.863057 atm\n", " The equilibrium mole fractions of NH3 in the reactor is 0.397108\n" ] } ], "prompt_number": 3 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 17.5 Page Number : 601" ] }, { "cell_type": "code", "collapsed": false, "input": [ " \n", "# Variables\n", "T = 400;\t\t\t#[K] - Reactor temperature\n", "P = 1;\t\t\t#[atm] - Reactor pressure\n", "K = 1.52;\t\t\t# Equilibrium constant\n", "y_H2 = 0.4;\t\t\t# Equilibrium mole fraction of hydrogen\n", "\n", "# Calculations\n", "\t\t\t# CO(g) + 2*H_2(g) - CH3OH(g)\n", "\n", "\t\t\t# K = y_CH3OH/(y_CO*y_H2**(2)*P**(2))\n", "\t\t\t# Let total number of moles at equilibrium be 1\n", "\t\t\t# y_CH3OH = 0.6 - y_CO;\n", "\t\t\t# (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", "\n", "# Results\n", "print \" The mole fractions are y_CO = %f and y_CH3OH = %f \"%(y_CO,y_CH3OH);" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " The mole fractions are y_CO = 0.482625 and y_CH3OH = 0.117375 \n" ] } ], "prompt_number": 4 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 17.6 Page Number : 602" ] }, { "cell_type": "code", "collapsed": false, "input": [ " \n", "\n", "# Variables\n", "T = 749.;\t\t\t#[K] - Reactor temperature\n", "P = 1.;\t\t\t#[atm] - Reactor pressure\n", "K = 74.;\n", "\n", "# Calculations and Results\n", "Kp = P**(-1./2);\t\t\t#[atm**(-1/2)]\n", "Ky = K/Kp;\n", "\n", "\t\t\t# SO2 + (1/2)*O2 - SO3\n", "\n", "\t\t\t# 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", "\t\t\t# Let the reaction coordinate at equilibrium for the reaction be X\n", "\t\t\t# At equilibrium, the moles of the components be\n", "\t\t\t# n_SO2_1_eq = 10 - X\n", "\t\t\t# n_O2_1_eq = 8 - 0.5*X\n", "\t\t\t# SO3_1_eq = X\n", "\t\t\t# Total moles = 18 - 0.5*X\n", "\n", "\t\t\t# The mole fractions of the components at equilibrium are\n", "\t\t\t# y_SO3 = X/(18-0.5*X)\n", "\t\t\t# y_SO2 = (10-X)/(18-0.5*X)\n", "\t\t\t# y_O2 = (8-0.5*X)/(18-0.5*X)\n", "\n", "\t\t\t# Ky = y_SO3/(y_SO2*y_O2**(2))\n", "\t\t\t# Ky = (X*(18-0.5*X)**(1/2))/((10-X)*(8-0.5*X)**(1/2))\n", "def f(X): \n", "\t return Ky-(X*(18-0.5*X)**(1./2))/((10-X)*(8-0.5*X)**(1./2))\n", "X_1 = fsolve(f,11)\n", "\n", "n_SO3 = X_1;\n", "n_SO2 = 10 - X_1;\n", "n_O2 = 8 - 0.5*X_1;\n", "\n", "print \" 1).The moles of the components at equilibrium are n_SO3 = %f mol n_SO2 = %f mol and n_O2 = %f mol\"%(n_SO3,n_SO2,n_O2);\n", "\n", "\t\t\t# Now for the reaction\n", "\t\t\t# 2*SO2 + O2 - 2*SO3\n", "\n", "\t\t\t# The equilibrium constant for this reaction is KP**(2)\n", "Ky_prime = Ky**(2);\n", "\n", "\t\t\t# At equilibrium, the moles of the components be\n", "\t\t\t# n_SO2_1_eq = 10 - 2*X\n", "\t\t\t# n_O2_1_eq = 8 - X\n", "\t\t\t# SO3_1_eq = 2*X\n", "\t\t\t# Total moles = 18 - X\n", "\n", "\t\t\t# The mole fractions of the components at equilibrium are\n", "\t\t\t# y_SO3 = 2*X/(18-X)\n", "\t\t\t# y_SO2 = (10-2*X)/(18-X)\n", "\t\t\t# y_O2 = (8- X)/(18-X)\n", "\n", "\t\t\t# Ky_prime = y_SO3**(2)/(y_SO2**(2)*y_O2)\n", "\t\t\t# Ky_prime = ((2*X)**(2)*(18-X))/((10-2*X)**(2)*(8-X))\n", "def f1(X): \n", "\t return Ky_prime-((2*X)**(2)*(18-X))/(((10-2*X)**(2))*(8-X))\n", "X_2 = fsolve(f1,6)\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", "print \" 2).The moles of the components at equilibrium are n_SO3 = %f mol n_SO2 = %f mol and n_O2 = %f mol\"%(n_SO3_prime,n_SO2_prime,n_O2_prime);\n", "print \" Thus the number of moles remains the same irrespective of the stoichoimetry of the reaction\"\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " 1).The moles of the components at equilibrium are n_SO3 = 9.730824 mol n_SO2 = 0.269176 mol and n_O2 = 3.134588 mol\n", " 2).The moles of the components at equilibrium are n_SO3 = 9.730824 mol n_SO2 = 0.269176 mol and n_O2 = 3.134588 mol\n", " Thus the number of moles remains the same irrespective of the stoichoimetry of the reaction\n" ] } ], "prompt_number": 5 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 17.7 Page Number : 603" ] }, { "cell_type": "code", "collapsed": false, "input": [ " \n", "\n", "# Variables\n", "T = 500;\t\t\t#[K]\n", "\t\t\t# For the reaction, 0.5*A2 + 0.5*B2 - AB\n", "delta_G = -4200;\t\t\t#[J/mol]\n", "R = 8.314;\t\t\t#[J/mol*K] - Universal gas constant\n", "\n", "\t\t\t#(1)\n", "\t\t\t# A2 + B2 - 2*AB\n", "\n", "# Calculations and Results\n", "\t\t\t# We know delta_G_rkn_0 = -R*T*math.log(K) \n", "delta_G_1 = 2*delta_G;\n", "K_1 = math.exp(-delta_G_1/(R*T));\t\t\t# Equilibrium constant at 500 K for the above reaction\n", "\t\t\t# As can be seen the reaction is not affected by pressure and therefore K = Ky as Kp = 1 \n", "Ky = K_1;\n", "\n", "\t\t\t# 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", "\t\t\t# Let the reaction coordinate at equilibrium for the reaction be X\n", "\t\t\t# At equilibrium, the moles of the components be\n", "\t\t\t# n_A2_1_eq = 0.5 - X\n", "\t\t\t# n_B2_1_eq = 0.5- X\n", "\t\t\t# n_AB_1_eq = 2*X\n", "\t\t\t# Total moles = 1\n", "\n", "\t\t\t# Ky = (2*X)**(2)/(0.5-X)**(2)\n", "def f(X): \n", "\t return Ky-(2*X)**(2)/(0.5-X)**(2)\n", "X_1 = fsolve(f,0.2)\n", "\n", "\t\t\t# 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", "print \" 1).The mole fractions at equilibrium are y_A2 = %f y_B2 = %f and y_AB = %f\"%(y_A2_1,y_B2_1,y_AB_1);\n", "\n", "\t\t\t#(2)\n", "\t\t\t# 0.5*A2 + 0.5*B2 - AB\n", "\n", "\t\t\t# We know delta_G_rkn_0 = -R*T*math.log(K) \n", "delta_G_2 = delta_G;\n", "K_2 = math.exp(-delta_G_2/(R*T));\t\t\t# Equilibrium constant at 500 K for the above reaction\n", "\n", "\t\t\t# 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", "\t\t\t# 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", "\t\t\t# Let the reaction coordinate at equilibrium for the reaction be X\n", "\t\t\t# At equilibrium, the moles of the components be\n", "\t\t\t# n_A2_2_eq = 0.5 - 0.5*X\n", "\t\t\t# n_B2_2_eq = 0.5- 0.5*X\n", "\t\t\t# n_AB_2_eq = X\n", "\t\t\t# Total moles = 1\n", "\n", "\t\t\t# Ky = y_AB/(y_A2**(1/2)*y_B2**(1/2))\n", "\t\t\t# Ky = X/(0.5 - 0.5*X)\n", "X_2 = 0.5*Ky_2/(1+0.5*Ky_2);\n", "\n", "\t\t\t# 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", "print \" 2).The mole fractions at equilibrium are y_A2 = %f y_B2 = %f and y_AB = %f\"%(y_A2_2,y_B2_2,y_AB_2);\n", "\n", "\t\t\t#(3)\n", "\t\t\t# 2*AB - A2 + B2\n", "\n", "K_3 = 1/K_1;\t\t\t# Equilibrium constant at 500 K for the above reaction\n", "\t\t\t# 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", "\t\t\t# 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", "\t\t\t# Let the reaction coordinate at equilibrium for the reaction be X\n", "\t\t\t# At equilibrium, the moles of the components be\n", "\t\t\t# n_AB_3_eq = 1 - X\n", "\t\t\t# n_A2_3_eq = X/2\n", "\t\t\t# n_B2_3_eq = X/2\n", "\t\t\t# Total moles = 1\n", "\n", "\t\t\t# Ky = (X/2)**(2)/(1-X)**(2)\n", "def f1(X): \n", "\t return Ky_3-(X/2)**(2)/(1-X)**(2)\n", "X_3 = fsolve(f1,0.4)\n", "\n", "\t\t\t# 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", "print \" 3).The mole fractions at equilibrium are y_A2 = %f y_B2 = %f and y_AB = %f\"%(y_A2_3,y_B2_3,y_AB_3);" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " 1).The mole fractions at equilibrium are y_A2 = 0.210680 y_B2 = 0.210680 and y_AB = 0.578641\n", " 2).The mole fractions at equilibrium are y_A2 = 0.210680 y_B2 = 0.210680 and y_AB = 0.578641\n", " 3).The mole fractions at equilibrium are y_A2 = 0.210680 y_B2 = 0.210680 and y_AB = 0.578641\n" ] } ], "prompt_number": 7 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 17.9 Page Number : 606" ] }, { "cell_type": "code", "collapsed": false, "input": [ " \n", "\n", "from scipy.optimize import fsolve \n", "import math \n", "from scipy.integrate import quad \n", "\t\t\n", "\n", "# Variables\n", "R = 1.987;\t\t\t#[cal/mol-K]\n", "\n", "delta_H_SO2_298 = -70.96;\t\t\t#[kcal/mol] - Enthalpy of formation of S02 at 298.15 K\n", "delta_H_SO3_298 = -94.45;\t\t\t#[kcal/mol] - Enthalpy of formation of S03 at 298.15 K\n", "delta_G_SO2_298 = -71.79;\t\t\t#[kcal/mol] - Gibbs free energy change for formation of SO2 at 298.15 K\n", "delta_G_SO3_298 = -88.52;\t\t\t#[kcal/mol] - Gibbs free energy change for formation of SO3 at 298.15 K\n", "\n", "\t\t\t# 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", "\t\t\t#(1)\n", "T_1 = 298.15;\t\t\t#[K]\n", "\n", "# Calculations and Results\n", "delta_H_rkn_298 = delta_H_SO3_298 - delta_H_SO2_298;\t\t\t#[kcal]\n", "delta_H_rkn_298 = delta_H_rkn_298*10**(3);\t\t\t#[cal]\n", "delta_G_rkn_298 = delta_G_SO3_298 - delta_G_SO2_298;\t\t\t#[kcal]\n", "delta_G_rkn_298 = delta_G_rkn_298*10**(3);\t\t\t#[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", "\n", "def f60(T): \n", "\t return delta_a+(delta_b*T)+(delta_c*T**(2))+(delta_d*T**(3))\n", "\n", "\t\t\t# delta_H_rkn_T = delta_H_rkn_298 + quad(f60,T_1,T)[0]\n", "\n", "\t\t\t# On simplification we get\n", "\t\t\t# 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", "print \" 1.The math.expression for delta_H_rkn_T as a function of T is given by\";\n", "print \" 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", "\t\t\t#(2)\n", "\n", "\n", "\t\t\t#def f61(T): \n", "\t\t\t#\t return K_T/K_298) = integrate(delta_H_rkn_T/T**(2)\n", "\n", "\t\t\t# R*math.log(K_T/K_298) = quad(f61,T_1,T)[0]\n", "\n", "\t\t\t# First let us calculate K_298.\n", "\t\t\t# delta_G_rkn_T = - R*T*math.log(K)\n", "K_298 = math.exp(-delta_G_rkn_298/(R*T_1));\n", "\n", "\t\t\t# On substituting the values and simplifying we get the math.expression\n", "\t\t\t# math.log(K) = 3.87 + 11380.10/T - 2.6580*math.log(T) + 0.4825*10**(-2)*T - 0.1409*10**(-5)*T**(2) + 0.2320*10**(-9)*T**(3)\n", "\n", "print \" 2.The math.expression for math.logK as a function of T is given by\";\n", "print \" math.logK = 3.87 + 11380.10/T - 2.6580*math.logT + 0.4825*10**-2*T - 0.1409*10**-5*T**2 + 0.2320*10**-9*T**3\";\n", "\n", "\t\t\t#(3)\n", "P = 1;\t\t\t#[atm]\n", "T = 880;\t\t\t#[K]\n", "K = math.exp(3.87 + 11380.10/T - 2.6580*math.log(T) + 0.4825*10**(-2)*T - 0.1409*10**(-5)*T**(2) + 0.2320*10**(-9)*T**(3));\n", "Kp = P**(-1./2);\t\t\t#[atm**(-1/2)]\n", "Ky = K/Kp;\n", "\n", "\t\t\t# Let the reaction coordinate at equilibrium for the reaction be X\n", "\t\t\t# At equilibrium, the moles of the components be\n", "\t\t\t# n_SO2_eq = 1 - X\n", "\t\t\t# n_O2_eq = 0.5- 0.5*X\n", "\t\t\t# n_SO3_1_eq = X\n", "\t\t\t# Total moles = 1.5-0.5*X\n", "\n", "\t\t\t# Ky = (X*(1.5-0.5*X)**(1/2))/((1-X)*(0.5-0.5*X)**(1/2))\n", "def f(X): \n", "\t return Ky - (X*(1.5-0.5*X)**(1./2))/((1-X)*(0.5-0.5*X)**(1./2))\n", "X = fsolve(f,0.8)\n", "\n", "\t\t\t# The mole fraction of SO3 at equilibrium is given by\n", "y_SO3 = X/(1.5-0.5*X);\n", "\n", "print \" 3).The mole fraction of SO3 at equilibrium is given by y_SO3 = %f\"%(y_SO3);\n", "\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " 1.The math.expression for delta_H_rkn_T as a function of T is given by\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", " 2.The math.expression for math.logK as a function of T is given by\n", " math.logK = 3.87 + 11380.10/T - 2.6580*math.logT + 0.4825*10**-2*T - 0.1409*10**-5*T**2 + 0.2320*10**-9*T**3\n", " 3).The mole fraction of SO3 at equilibrium is given by y_SO3 = 0.649167\n" ] } ], "prompt_number": 8 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 17.10 Page Number : 609" ] }, { "cell_type": "code", "collapsed": false, "input": [ " \n", "\n", "from numpy import *\n", "\n", "# Variables\n", "\t\t\t# (1/2)*N2 + (1/2)*O2 - NO\n", "\n", "R = 1.987;\t\t\t#[cal/mol-K]\n", "\n", "delta_H_NO_298 = 21.600;\t\t\t#[kcal/mol] - Enthalpy of formation of S02 at 298.15 K\n", "delta_G_NO_298 = 20.719;\t\t\t#[kcal/mol] - Gibbs free energy change for formation of SO2 at 298.15 K\n", "\n", "\t\t\t# 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", "\t\t\t#(1)\n", "T_1 = 298.15;\t\t\t#[K]\n", "\n", "# Calculations and Results\n", "delta_H_rkn_298 = delta_H_NO_298;\t\t\t#[kcal]\n", "delta_H_rkn_298 = delta_H_rkn_298*10**(3);\t\t\t#[cal]\n", "delta_G_rkn_298 = delta_G_NO_298;\t\t\t#[kcal]\n", "delta_G_rkn_298 = delta_G_rkn_298*10**(3);\t\t\t#[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", "\n", "def f49(T): \n", "\t return delta_a+(delta_b*T)+(delta_c*T**(2))+(delta_d*T**(3))\n", "\n", "\t\t\t# delta_H_rkn_T = delta_H_rkn_298 + quad(f49,T_1,T)[0]\n", "\n", "\t\t\t# On simplification we get\n", "\t\t\t# 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", "print \" The math.expression for delta_H_rkn_T as a function of T is given by\";\n", "print \" 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", "\t\t\t# Now let us calculate K_298 (at 298 K)\n", "\t\t\t# We know delta_G_rkn_298 = -R*T*math.log(K_298) \n", "K_298 = math.exp(-delta_G_rkn_298/(R*T_1));\t\t\t# Equilibrium constant at 298.15 K\n", "\n", "\n", "\t\t\t#def f50(T): \n", "\t\t\t#\t return K_2/K_1) = integrate(delta_H_rkn_298/(R*T**(2))\n", "\n", "\t\t\t# math.log(K_2/K_1) = quad(f50,T_1,T)[0]\n", "\n", "\t\t\t# On substituting the values and simplifying we get the math.expression\n", "\t\t\t# math.log(K) = 1.5103 - 10862.92/T - 0.0166*math.log(T) + 1.84*10**(-4)*T - 7.35*10**(-8)*T**(2) + 1.15*10**(-11)*T**(3)\n", "\n", "print \" The math.expression for math.logK as a function of T is given by\";\n", "print \" math.logK = 1.5103 - 10862.92/T - 0.0166*math.logT + 1.84*10**-4*T - 7.35*10**-8*T**2 + 1.15*10**-11*T**3\"\n", "\n", "T = [500,1000,1500,2000,2500];\n", "K = zeros(5);\n", "\n", "print \" T K \\t\\t\\t K \";\n", "\n", "for i in range(5):\n", " K[i] = math.exp(1.5103-10862.92/T[i] - 0.0166*math.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", " print \" %f \\t\\t %e \"%(T[i],K[i]);\n", "\n", "\n", "\t\t\t# It can be seen that for endothermic reactions equilibrium constant increases with temperature.\n", "print \" It can be seen that for endothermic reactions equilibrium constant increases with temperature\";\n", "\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " The math.expression for delta_H_rkn_T as a function of T is given by\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", " The math.expression for math.logK as a function of T is given by\n", " math.logK = 1.5103 - 10862.92/T - 0.0166*math.logT + 1.84*10**-4*T - 7.35*10**-8*T**2 + 1.15*10**-11*T**3\n", " T K \t\t\t K \n", " 500.000000 \t\t 1.615470e-09 \n", " 1000.000000 \t\t 8.737610e-05 \n", " 1500.000000 \t\t 3.333913e-03 \n", " 2000.000000 \t\t 2.062328e-02 \n", " 2500.000000 \t\t 6.176400e-02 \n", " It can be seen that for endothermic reactions equilibrium constant increases with temperature\n" ] } ], "prompt_number": 9 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 17.11 Page Number : 611" ] }, { "cell_type": "code", "collapsed": false, "input": [ " \n", "\n", "# Variables\n", "\t\t\t# SO2 + (1/2)*O2 - SO3\n", "R = 8.314;\t\t\t#[J/mol-K]\n", "\n", "K_800 = 0.0319;\t\t\t# Equilibrium constant at 800 K\n", "K_900 = 0.153;\t\t\t# Equilibrium constant at 900 K\n", "T_1 = 800.;\t\t\t#[K]\n", "T_2 = 900.;\t\t\t#[K]\n", "\n", "# Calculations\n", "\t\t\t# We have the relation \n", "\t\t\t# math.log(K_2/K_1) = -(delta_H_rkn/R)*(1/T_2 - 1/T_1)\n", "\t\t\t# math.log(K_900/K_800) = -(delta_H_rkn_850/R)*(1/T_2 - 1/T_1)\n", "delta_H_rkn_850 = -R*math.log(K_900/K_800)/(1/T_2 - 1/T_1);\t\t\t#[J]\n", "delta_H_rkn_850 = delta_H_rkn_850*10**(-3);\t\t\t#[kJ]\n", "\n", "# Results\n", "print \" The mean standard enthalpy change of reaction in the region 800 t0 900 is given by delta_H_rkn_850 = %f KJ\"%(delta_H_rkn_850);\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " The mean standard enthalpy change of reaction in the region 800 t0 900 is given by delta_H_rkn_850 = 93.851672 KJ\n" ] } ], "prompt_number": 2 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 17.13 Page Number : 611" ] }, { "cell_type": "code", "collapsed": false, "input": [ " \n", "\n", "# Variables\n", "T_1 = 298.15;\t\t\t#[K]\n", "T = 2600;\t\t\t#[K]\n", "R = 1.987;\t\t\t#[cal/mol-K] - Universal gas constant\n", "\n", "\t\t\t# Cp_0 = a + b*T + c*T**(2) + d*T**(3)\n", "delta_H_CO_298 = -26.416;\t\t\t#[kcal/mol] - Enthalpy of formation of CO at 298.15 K\n", "delta_G_CO_298 = -32.808;\t\t\t#[kcal/mol] - Gibbs free energy change for formation of CO at 298.15 K\n", "delta_H_CO2_298 = -94.052;\t\t\t#[kcal/mol] - Enthalpy of formation of C02 at 298.15 K\n", "delta_G_CO2_298 = -94.260;\t\t\t#[kcal/mol] - Gibbs free energy change for formation of CO2 at 298.15 K\n", "\n", "\t\t\t# 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", "# Calculations and Results\n", "delta_H_rkn_298 = delta_H_CO2_298 - delta_H_CO_298;\t\t\t#[kcal]\n", "delta_H_rkn_298 = delta_H_rkn_298*10**(3);\t\t\t#[cal]\n", "delta_G_rkn_298 = delta_G_CO2_298 - delta_G_CO_298;\t\t\t#[kcal]\n", "delta_G_rkn_298 = delta_G_rkn_298*10**(3);\t\t\t#[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", "\n", "def f47(T): \n", "\t return delta_a+(delta_b*T)+(delta_c*T**(2))+(delta_d*T**(3))\n", "\n", "\t\t\t# delta_H_rkn_T = delta_H_rkn_298 + quad(f47,T_1,T)[0]\n", "\n", "\t\t\t# 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", "\n", "\t\t\t#def f48(T): \n", "\t\t\t#\t return K/K_298) = integrate(delta_H_rkn_T/(R*T**(2))\n", "\n", "\t\t\t# math.log(K/K_298) = quad(f48,T_1,T)[0]\n", "\n", "\n", "\t\t\t# We know that delta_G_rkn_T = -R*T*math.log(K)\n", "\t\t\t# At 298.15 K\n", "K_298 = math.exp(-delta_G_rkn_298/(R*T_1) );\n", "\n", "\t\t\t# Therfore on simplification we get\n", "\t\t\t#math.log(K) = 2.94 + 33605.2/T - 2.24*math.log(T) + 0.304*10(-2)*T - 0.073*10**(-5)*T**(2) + 0.09*10**(-9)*T**(3)\n", "K = math.exp(2.94 + 33605.2/T - 2.24*math.log(T) + 0.304*10**(-2)*T - 0.073*10**(-5)*T**(2) + 0.09*10**(-9)*T**(3));\n", "\n", "print \" The value of equilibrium constant at 2600 K is given by K_298 = %f\"%(K);\n", "\n", "\n", "\t\t\t#(a)\n", "P_1 = 1;\t\t\t#[atm]\n", "Kp_1 = P_1**(-1./2);\n", "Ky_1 = K/Kp_1;\n", "\n", "\t\t\t# Let the reaction coordinate at equilibrium for the reaction be X\n", "\t\t\t# At equilibrium, the moles of the components be\n", "\t\t\t# n_CO_1_eq = 1 - X\n", "\t\t\t# n_02_1_eq = 0.5- 0.5X\n", "\t\t\t# n_CO2_1_eq = X\n", "\t\t\t# Total moles = 1.5 - 0.5*X\n", "\n", "\t\t\t# Ky = y_CO2/(y_CO**(1/2)*y_CO)\n", "\t\t\t#ky = (X*(1.5-0.5*X)**(1/2))/((1-X)*(0.5-0.5*X)**(1/2))\n", "\n", "def f(X): \n", "\t return Ky_1-(X*(1.5-0.5*X)**(1./2))/((1-X)*(0.5-0.5*X)**(1./2))\n", "X_1 = fsolve(f,0.9)\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", "print \" a).The equilibrium composition at 1 atm) is given by y_CO2 = %f y_CO = %f and y_O2 = %f\"%(y_CO2_1,y_CO_1,y_O2_1);\n", "\n", "\t\t\t#(b)\n", "P_2 = 10;\t\t\t#[atm]\n", "Kp_2 = P_2**(-1./2);\n", "Ky_2 = K/Kp_2;\n", "\n", "\t\t\t# Ky = y_CO2/(y_CO**(1/2)*y_CO)\n", "\t\t\t#ky = (X*(1.5-0.5*X)**(1/2))/((1-X)*(0.5-0.5*X)**(1/2))\n", "\n", "def f1(X): \n", "\t return Ky_2-(X*(1.5-0.5*X)**(1./2))/((1-X)*(0.5-0.5*X)**(1./2))\n", "X_2 = fsolve(f1,0.9)\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", "print \" b).The equilibrium composition at 10 atm) is given by y_CO2 = %f y_CO = %f and y_O2 = %f\"%(y_CO2_2,y_CO_2,y_O2_2);\n", "\n", "\t\t\t#(c)\n", "P_3 = 1;\t\t\t#[atm]\n", "Kp_3 = P_3**(-1./2);\n", "Ky_3 = K/Kp_3;\n", "\n", "\t\t\t# Ky = y_CO2/(y_CO**(1/2)*y_CO)\n", "\t\t\t#ky = (X*(1.5-0.5*X)**(1/2))/((1-X)*(0.5-0.5*X)**(1/2))\n", "\n", "\t\t\t# At equilibrium, the moles of the components be\n", "\t\t\t# n_CO_3_eq = 1 - X\n", "\t\t\t# n_02_3_eq = 0.5- 0.5X\n", "\t\t\t# n_CO2_3_eq = X\n", "\t\t\t# n_N2_eq = 1;\n", "\t\t\t# Total moles = 2.5 - 0.5*X\n", "\n", "def f2(X): \n", "\t return Ky_3-(X*(2.5-0.5*X)**(1./2))/((1-X)*(0.5-0.5*X)**(1./2))\n", "X_3 = fsolve(f2,0.9)\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", "print \" 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\"%(y_CO2_3,y_CO_3,y_O2_3,y_N2);\n", "\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " The value of equilibrium constant at 2600 K is given by K_298 = 16.484152\n", " a).The equilibrium composition at 1 atm) is given by y_CO2 = 0.757531 y_CO = 0.161646 and y_O2 = 0.080823\n", " b).The equilibrium composition at 10 atm) is given by y_CO2 = 0.876008 y_CO = 0.082662 and y_O2 = 0.041331\n", " c).The equilibrium composition at 1 atm and 1 mol N2) is given by y_CO2 = 0.373822 y_CO = 0.100943 y_O2 = 0.050471 and y_N2 = 0.474764\n" ] } ], "prompt_number": 12 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 17.14 Page Number : 614" ] }, { "cell_type": "code", "collapsed": false, "input": [ " \n", "\n", "# Variables\n", "T = 25 + 298.15;\t\t\t#[K] - Temperature\n", "R = 8.314;\t\t\t#[J/mol-K]\n", "delta_G_298 = -1000;\t\t\t#[J] - Gibbs free energy change at 298 K\n", "\n", "\t\t\t# G_E/(R*T) = x_1*x_2\n", "# Calculations and Results\n", "\t\t\t# We know that delta_G_rkn = - R*T*math.log(K), therefore\n", "K = math.exp(-delta_G_298/(R*T));\n", "\n", "\t\t\t#(1)\n", "\t\t\t# Let x_1 is the mole fraction of A and x_2 be the mole fraction of B\n", "\t\t\t# If A and B form an ideal mixture then,\n", "Ky = 1;\n", "\t\t\t# and K = Kx = x_2/x_1\n", "\t\t\t# and at equilibrium x_2/x_1 = K\n", "\t\t\t# (1-x_1)/x_1 = K\n", "x_1 = 1/(1+K);\n", "\n", "print \" 1).The equilibrium composition for ideal behaviour) is given by x_1 = %f\"%(x_1);\n", "\n", "\t\t\t#(2)\n", "\t\t\t# The activity coefficients are given by\n", "\t\t\t# math.log(Y1) = [del(n*G_E/(R*T))/del(n_1)]_T,P,n_2 = x_2**(2)\n", "\t\t\t# similarly, math.log(Y2) = x_1**(2)\n", "\n", "\t\t\t# The equilibrium constant for the liquid phase reaction is given by\n", "\t\t\t# K = Kx*Ky = (x_2*Y2)/(x_1*Y1) = (x_2*math.exp(x_1**(2)))/(x_1*math.exp(x_2**(2)))\n", "\t\t\t# Solving the above equation we get\n", "\n", "def f2(x_1): \n", "\t return K -((1-x_1)*math.exp(x_1**(2)))/(x_1*math.exp((1-x_1)**(2)))\n", "x_1_prime = fsolve(f2,0.9)\n", "\n", "print \" 2).The equilibrium composition for non-ideal behaviour) is given by x_1 = %f\"%(x_1_prime);\n", "\n", "\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " 1).The equilibrium composition for ideal behaviour) is given by x_1 = 0.408008\n", " 2).The equilibrium composition for non-ideal behaviour) is given by x_1 = 0.328409\n" ] } ], "prompt_number": 13 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 17.15 Page Number : 615" ] }, { "cell_type": "code", "collapsed": false, "input": [ " \n", "\n", "# Variables\t\t\t\n", "T_1 = 298.15;\t\t\t#[K] - Smath.tan(math.radiansard reaction temperature\n", "T_2 = 373.;\t\t\t#[K] - Reaction temperature\n", "P = 1.;\t\t\t#[atm]\n", "R = 1.987;\t\t\t#[cal/mol-K] - Universal gas constant\n", "\n", "\t\t\t# CH3COOH (l) + C2H5OH (l) - CH3COOC2H5 (l) + H2O (l)\n", "\n", "delta_H_CH3COOH_298 = -116.2*10**(3.);\t\t\t# [cal/mol]\n", "delta_H_C2H5OH_298 = -66.35*10**(3.);\t\t\t# [cal/mol]\n", "delta_H_CH3COOC2H5_298 = -110.72*10**(3.);\t\t\t# [cal/mol]\n", "delta_H_H2O_298 = -68.3174*10**(3.);\t\t\t# [cal/mol]\n", "\n", "delta_G_CH3COOH_298 = -93.56*10**(3.);\t\t\t# [cal/mol]\n", "delta_G_C2H5OH_298 = -41.76*10**(3.);\t\t\t# [cal/mol]\n", "delta_G_CH3COOC2H5_298 = -76.11*10**(3.);\t\t\t# [cal/mol]\n", "delta_G_H2O_298 = -56.6899*10**(3.);\t\t\t# [cal/mol]\n", "\n", "# Calculations and Results\n", "delta_H_rkn_298 = delta_H_CH3COOC2H5_298 + delta_H_H2O_298 - delta_H_CH3COOH_298 - delta_H_C2H5OH_298;\t\t\t#[cal/mol]\n", "delta_G_rkn_298 = delta_G_CH3COOC2H5_298 + delta_G_H2O_298 - delta_G_CH3COOH_298 - delta_G_C2H5OH_298;\t\t\t#[cal/mol]\n", "\n", "\t\t\t# We know that delta_G_rkn_T = -R*T*math.log(K)\n", "\t\t\t# At 298.15 K\n", "K_298 = math.exp(-delta_G_rkn_298/(R*T_1) );\n", "\n", "\t\t\t# We know that dmath.log(K)/dT = delta_H_rkn/(R*T**(2))\n", "\t\t\t# If delta_H_rkn is assumed constant we get\n", "\t\t\t# math.log(K_2/K_1) = (-delta_H_rkn/R)*(1/T_2 - 1/T_1)\n", "\t\t\t# math.log(K_373/K_298) = (-delta_H_rkn_298/R)*(1/T_2 - 1/T_1)\n", "\n", "K_373 = math.exp(math.log(K_298) + (-delta_H_rkn_298/R)*(1./T_2 - 1./T_1));\n", "\t\t\t# Note that the equilibrium constant value rises becauses the reaction is endothermic\n", "\n", "print \" The value of equilibrium constant at 373 K is K_373 = %f\"%(K_373);\n", "\n", "\t\t\t# Let the reaction coordinate at equilibrium for the reaction be X\n", "\t\t\t# At equilibrium, the moles of the components be\n", "\t\t\t# n_CH3COOH = 1 - X\n", "\t\t\t# n_C2H5OH = 1 - X\n", "\t\t\t# n_CH3COOC2H5 = X\n", "\t\t\t# n_H20 = X\n", "\t\t\t# Total moles = 2\n", "\n", "\t\t\t# Kx = (x_CH3COOH*x_C2H5OH)/(x_CH3COOC2H5*x_H2O)\n", "\t\t\t# Assuming the liquid mixture to be ideal,that is Ky = 1, therefore K_x = K\n", "K_x = K_373;\n", "\t\t\t# X**(2)/(1-X)**(2) = K_x\n", "X = (K_x)**(1./2)/(1+(K_x)**(1./2));\n", "\n", "\t\t\t# The mole fraction of ethyl acetate is given by\n", "x_CH3COOC2H5 = X/2;\n", "\n", "print \" The mole fraction of ethyl acetate in the equilibrium reaction mixture is given by x_CH3COOC2H5 = %f\"%(x_CH3COOC2H5);\n", "\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " The value of equilibrium constant at 373 K is K_373 = 0.046697\n", " The mole fraction of ethyl acetate in the equilibrium reaction mixture is given by x_CH3COOC2H5 = 0.088848\n" ] } ], "prompt_number": 14 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 17.16 Page Number : 617" ] }, { "cell_type": "code", "collapsed": false, "input": [ " \n", "\n", "# Variables\n", "\t\t\t# CaCO3 (s1) - CaO (s2) + CO2 (g)\n", "T_1 = 898 + 273.15;\t\t\t#[K]\n", "T_2 = 700 + 273.15;\t\t\t#[K]\n", "R = 8.314;\t\t\t#[J/mol-K] - Universal gas constant\n", "\n", "P_CO2_T_1 = 1;\t\t\t#[atm] - Decomposition pressure of CO2 over CaCO3 at 898 C\n", "P_CO2_T_2 = 0.0333;\t\t\t#[atm] - Decomposition pressure of CO2 over CaCO3 at 700 C\n", "\n", "\t\t\t# The equilibrium constant of the reaction is given by\n", "\t\t\t# K = (a_CO2*a_CaO)/a_CaCO3\n", "\n", "\t\t\t# Since the pressure is small therefore carbon dioxide can be assumed to behave as ideal gas and thus\n", "\t\t\t# a_CO2 = y_CO2*P/1 = P_CO2\n", "\n", "\t\t\t# The activity of CaO is (CaO is pure)\n", "\t\t\t# a_CaO = f_CaO/f_0_CaO = exp[V_CaO*(P - P_0)/(R*T)] = 1 (since pressure is low)\n", "\n", "\t\t\t# The activity of CaCO3 is (CaCO3 is pure)\n", "\t\t\t# a_CaCO3 = f_CaCO3/f_0_CaCO3 = exp[V_CaCO3*(P - P_0)/(R*T)] = 1 (since pressure is low)\n", "\n", "\t\t\t#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", "\t\t\t#K = P_CO2 , therefore\n", "# Calculations \n", "\t\t\t# At 898 C\n", "K_T_1 = P_CO2_T_1;\n", "delta_G_T_1 = -R*T_1*math.log(K_T_1);\n", "\n", "\t\t\t# At 700 C\n", "K_T_2 = P_CO2_T_2;\n", "delta_G_T_2 = -R*T_2*math.log(K_T_2);\n", "\n", "# Results\n", "print \" The value of delta_G_rkn at 700 C is %f J\"%(delta_G_T_1);\n", "print \" The value of delta_G_rkn at 898 C is %f J\"%(delta_G_T_2);\n", "\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " The value of delta_G_rkn at 700 C is -0.000000 J\n", " The value of delta_G_rkn at 898 C is 27526.397496 J\n" ] } ], "prompt_number": 15 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 17.17 Page Number : 618" ] }, { "cell_type": "code", "collapsed": false, "input": [ " \n", "\n", "# Variables\n", "T = 700 + 273.15;\t\t\t#[K]\n", "K = 7.403;\t\t\t# Equilibrium constant for the reaction at 700 C\n", "\n", "\t\t\t# CH4 - C (s) + 2*H2 \n", "\n", "\t\t\t# The equilibrium constant of the reaction is given by\n", "\t\t\t# K = (a_C*a_H2**(2))/a_CH4\n", "\n", "\t\t\t# Since carbon is pure therefore its activity is given by\n", "\t\t\t# a_C = f/f_0 = 1 as pressure is 1 atm.\n", "\t\t\t# Since the pressure is low,therefore the gas phase can be taken to be ideal,therefore\n", "\t\t\t# K = (y_H2**(2)*P**(2))/(y_CH4*P) = y_H2**(2)/y_CH4 (as P = 1 atm)\n", "Ky = K;\t\t\t# (Kp = 1 atm)\n", "\n", "\t\t\t# Initial moles of the species are\n", "n_CH4 = 1;\n", "n_H2 = 0;\n", "n_C = 0;\n", "\n", "\t\t\t# Let the reaction coordinate at equilibrium for the reaction be X\n", "\t\t\t# Moles at equilibrium be\n", "\t\t\t# n_CH4_eq = 1 -X\n", "\t\t\t# n_H2_eq = 2*x\n", "\t\t\t# n_C_eq = X\n", "\n", "\t\t\t# Moles present in gas phase\n", "\t\t\t# n_CH4_gas = 1 -X\n", "\t\t\t# n_H2_gas = 2*x\n", "\t\t\t# Total moles = 1 + X\n", "\n", "\t\t\t# gas phase mole fraction \n", "\t\t\t# y_CH4_gas = (1 -X)/(1+X)\n", "\t\t\t# y_H2_gas = 2*x/(1+X)\n", "\n", "# Calculations and Results\n", "# Ky = y_H2_gas**(2)/y_CH4_gaS\n", "X = (K/(4+K))**(1./2);\n", "\n", "print \" The number of moles of carbon black formed from one mole of methane is %f mol\"%(X);\n", "\n", "\t\t\t# 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", "print \" The mole fraction of components in the gas phase at equilibrium is given by y_CH4 = %f and y_H2 = %f \"%(y_CH4,y_H2);\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " The number of moles of carbon black formed from one mole of methane is 0.805739 mol\n", " The mole fraction of components in the gas phase at equilibrium is given by y_CH4 = 0.107580 and y_H2 = 0.892420 \n" ] } ], "prompt_number": 3 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 17.18 Page Number : 619" ] }, { "cell_type": "code", "collapsed": false, "input": [ " \n", "# Variables \n", "T_1 = 298.15;\t\t\t#[K] - Smath.tan(math.radiansard reaction temperature\n", "T_2 = 1042;\t\t\t#[K] - Reaction temperature\n", "R = 1.987;\t\t\t#[cal/mol-K] - Universal gas constant\n", "\n", "\t\t\t# CaCO3 (s1) - CaO (s2) + CO2 (g)\n", "\n", "delta_H_CaCO3_298 = -289.5;\t\t\t#[kcal/mol] - Enthalpy of formation of CaCO3 at 298.15 K\n", "delta_H_CaO_298 = -151.7;\t\t\t#[kcal/mol] - Enthalpy of formation of CaO at 298.15 K\n", "delta_H_CO2_298 = -94.052;\t\t\t#[kcal/mol] - Enthalpy of formation of CO2 at 298.15 K\n", "delta_G_CaCO3_298 = -270.8;\t\t\t#[kcal/mol] - Gibbs free energy change for formation of CaCO3 at 298.15 K\n", "delta_G_CaO_298 = -144.3;\t\t\t#[kcal/mol] - Gibbs free energy change for formation of CaO at 298.15 K\n", "delta_G_CO2_298 = -94.260;\t\t\t#[kcal/mol] - Gibbs free energy change for formation of CO2 at 298.15 K\n", "\n", "\t\t\t# The standard heat capacity data as a function of temperature are given below\n", "\t\t\t# Cp_CO2 = 5.316 + 1.4285*10**(2)*T - 0.8362*10**(-5)*T**(2) + 1.784*10**(-9)*T**(3)\n", "\t\t\t# Cp_CaO = 12.129 + 0.88*10**(-3)*T - 2.08*10**(5)*T**(-2)\n", "\t\t\t# Cp_CaCO3 = 24.98 + 5.240*10**(-3)*T - 6.199*10**(5)*T**(-2)\n", "\t\t\t# Therefore Cp_0 is given by\n", "\t\t\t# Cp_0 = Cp_CO2 + Cp_CaO - Cp_CaCO3\n", "\t\t\t# 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", "# Calculations and Results\n", "\t\t\t# The smath.tan(math.radiansard 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;\t\t\t#[kcal]\n", "delta_H_rkn_298 = delta_H_rkn_298*10**(3);\t\t\t#[cal]\n", "delta_G_rkn_298 = delta_G_CO2_298 + delta_G_CaO_298 - delta_G_CaCO3_298;\t\t\t#[kcal]\n", "delta_G_rkn_298 = delta_G_rkn_298*10**(3);\t\t\t#[cal]\n", "\n", "\t\t\t# The smath.tan(math.radiansard enthalpy change of the reaction at temperature T is given by\n", "\n", "def f7(T): \n", "\t return -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", "\t\t\t# delta_H_rkn_T = delta_H_rkn_298 + quad(f7,T_1,T)[0]\n", "\n", "\t\t\t# On simplification we get\n", "\t\t\t# 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", "\n", "\t\t\t#def f8(T): \n", "\t\t\t#\t return K_2/K_1) = integrate(delta_H_rkn_T/(R*T**(2))\n", "\n", "\t\t\t# math.log(K_2/K_1) = quad(f8,T_1,T)[0]\n", "\n", "\n", "def f9(T): \n", "\t return (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)\n", "\n", "math.log_K2_K1 = quad(f9,T_1,T_2)[0];\t\t\t# math.log(K_2/K_1)[0]\n", "\n", "\n", "\t\t\t# We know that delta_G_rkn_T = -R*T*math.log(K)\n", "\t\t\t# At 298.15 K\n", "K_298 = math.exp(-delta_G_rkn_298/(R*T_1) );\n", "\n", "\t\t\t# Putting the values in the above math.expression we get\n", "\t\t\t# math.log(K_1042/K_298) = math.log_K2_K1/R\n", "K_1042 = K_298*math.exp(math.log_K2_K1/R);\n", "\n", "print \" The value of equilibrium constant at 1042 K is K_1042 = %f\"%(K_1042);\n", "\n", "\t\t\t# Since for the given reaction K = P_CO2,where P is in atm, therefore,\n", "P_CO2 = K_1042;\n", "\t\t\t# and thus decomposition takes place till the partial pressure of CO2 reaches 0.095 atm\n", "\t\t\t# After that the decomposition in the closed vessel stops as equilibrium is achieved.\n", "\n", "print \" The equilibrium pressure of CO2 is P_CO2 = %f atm \"%(P_CO2);\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " The value of equilibrium constant at 1042 K is K_1042 = 0.095017\n", " The equilibrium pressure of CO2 is P_CO2 = 0.095017 atm \n" ] } ], "prompt_number": 17 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 17.19 Page Number : 620" ] }, { "cell_type": "code", "collapsed": false, "input": [ " \n", "\n", "# Variables \n", "T_1 = 298.15;\t\t\t#[k] - Smath.tan(math.radiansard reaction temperature\n", "T_2 = 1200;\t\t\t#[K] - Reaction temperature\n", "R = 1.987;\t\t\t#[cal/mol-K] - Universal gas consatnt\n", "\n", "\t\t\t# C (s) + CO2 (g) - 2*CO2 (g) \t\t\t# Reaction 1\n", "\t\t\t# CO2 + H2 - CO + H2O \t\t\t# Reacction 2\n", "\n", "K_1 = 63;\t\t\t# Equilibrium constant for the first reaction\n", "K_2 = 1.4;\t\t\t# Equilibrium constant for the secind reaction\n", "\n", "delta_G_H2O_298 = -54640;\t\t\t#[cal/mol] - Smath.tan(math.radiansard Gibbs free energy of formation of water vapour\n", "delta_H_H2O_298 = -57800;\t\t\t#[cal/mol] - Smath.tan(math.radiansard enthalpy change of formation of water vapour\n", "delta_G_rkn_298 = delta_G_H2O_298;\n", "\n", "\t\t\t# The smath.tan(math.radiansard heat capacity data of the components in cal/mol-K are given below\n", "\t\t\t# Cp_H2 = 6.947 - 0.2*10**(-3)*T + 4.8*10**(-7)*T**(2)\n", "\t\t\t# Cp_O2 = 6.148 + 3.1*10**(-3)*T - 9.2*10**(-7)*T**(2)\n", "\t\t\t# Cp_H2O = 7.256 + 2.3*10**(-3)*T + 2.8*10**(-7)*T**(2)\n", "\n", "\t\t\t# Let us consider two more reactions\n", "\t\t\t# C (s) + (1/2)*O2 - CO \t\t\t# Reaction 3\n", "\t\t\t# H2 + (1/2)*O2 - H2O \t\t\t# Reaction 4\n", "\n", "\t\t\t# Considering the above 4 reactions, it can be shown that reaction (3) = reaction (1) + reaction (4) - reaction (2)\n", "\t\t\t# Thus, delta_G_rkn_3 = delta_G_rkn_1 + delta_G_rkn_4 - delta_G_rkn_2\n", "\t\t\t# or, -R*T*math.log(K_3) = -R*T*math.log(K_1) + -R*T*math.log(K_4) - -R*T*math.log(K_2)\n", "\t\t\t# K_3 = (K_1*K_4/K_2)\n", "\n", "\t\t\t# Now we have to determine K_4 at 1200 K.\n", "\t\t\t# The smath.tan(math.radiansard enthalpy change of reaction (4) as a fuction of temperature is given by\n", "\t\t\t# delta_H_rkn_T = -57020 - 2.765*T + 0.475*10**(-3)*T**(2) + 8.67*10**(-8)*T**(3);\n", "\n", "\n", "\t\t\t#def f2(T): \n", "\t\t\t#\t return K_4_2/K_4_1) = integrate(delta_H_rkn_T/(R*T**(2))\n", "\n", "\t\t\t# math.log(K_4_2/K_4_1) = quad(f2,T_1,T)[0]\n", "\n", "# Calculations\n", "def f3(T): \n", "\t return (-57020-2.765*T+0.475*10**(-3)*T**(2)+8.67*10**(-8)*T**(3))/T**(2)\n", "\n", "math.log_K2_K1_4 = quad(f3,T_1,T_2)[0]\n", "\n", "\n", "\t\t\t# We know that delta_G_rkn_T = -R*T*math.log(K)\n", "\t\t\t# At 298.15 K\n", "K_4_298 = math.exp(-delta_G_rkn_298/(R*T_1) );\n", "\n", "\t\t\t# Putting the values in the above math.expression we get\n", "\t\t\t# math.log(K_4_1200/K_4_298) = math.log_K2_K1_R/R\n", "K_4_1200 = K_4_298*math.exp(math.log_K2_K1_4/R);\n", "K_4 = K_4_1200;\n", "\n", "\t\t\t# Therefore the equilibrium constant for reaction (3) at 1200 K is given by\n", "K_3 = (K_1*K_4)/K_2;\n", "\n", "# Results\n", "print \" The equilibrium constant at 1200 K for the given reaction is K = %e\"%(K_3);\n", "\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " The equilibrium constant at 1200 K for the given reaction is K = 3.622432e+09\n" ] } ], "prompt_number": 18 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 17.20 Page Number : 622" ] }, { "cell_type": "code", "collapsed": false, "input": [ " \n", "# Variables\n", "delta_G_H2O_298 = -237.034;\t\t\t#[kJ/mol] - Smath.tan(math.radiansard Gibbs free energy of formation of H2O (l) at 298 K\n", "F = 96485;\t\t\t#[C/mol] - Faraday constant\n", "\n", "\t\t\t#(1)\n", "\t\t\t# For the reaction\n", "\t\t\t# H2 (g) + (1/2)*O2 (g) - H2O (l)\n", "n = 2;\t\t\t# Number of electrons transferred in the reaction\n", "\n", "# Calculations and Results\n", "\t\t\t# The standard Gibbs free energy change of the reaction is given by\n", "\t\t\t# delta_G_rkn = delta_G_for_H2O(l) - delta_G_for_H2(g) - (1/2/)*delta_G_for_O2(g)\n", "\t\t\t# Since delta_G_for_H2 = 0 and delta_G_for_O2 = 0 (pure components)\n", "delta_G_rkn = delta_G_H2O_298;\t\t\t#[kJ]\n", "delta_G_rkn = delta_G_rkn*10**(3);\t\t\t#[J]\n", "\n", "\t\t\t# delta_G_rkn = -n*F*E_0\n", "\t\t\t# Thus standard equilibrium cell voltage is given by\n", "E_0 = - delta_G_rkn/(n*F);\t\t\t#/[V]\n", "\n", "print \" 1).The standard equilibrium cell voltage is %f V\"%(E_0);\n", "\n", "\t\t\t#(2)\n", "\t\t\t# For the reaction\n", "\t\t\t# 2*H2 (g) + O2 (g) - 2*H2O (l)\n", "n_prime = 4;\t\t\t# Number of electrons transferred in the reaction\n", "\n", "\t\t\t# The standard Gibbs free energy change of the reaction is given by\n", "\t\t\t# delta_G_rkn = 2*delta_G_for_H2O(l) - 2*delta_G_for_H2(g) - delta_G_for_O2(g)\n", "\t\t\t# Since delta_G_for_H2 = 0 and delta_G_for_O2 = 0 (pure components)\n", "delta_G_rkn_prime = 2*delta_G_H2O_298;\t\t\t#[kJ]\n", "delta_G_rkn_prime = delta_G_rkn_prime*10**(3);\t\t\t#[J]\n", "\n", "\t\t\t# delta_G_rkn = -n*F*E_0\n", "\t\t\t# Thus standard equilibrium cell voltage is given by\n", "E_0_prime = - delta_G_rkn_prime/(n_prime*F);\t\t\t#/[V]\n", "\n", "print \" 2).The standard equilibrium cell voltage is %f V\"%(E_0_prime);\n", "\n", "\t\t\t# Thus the result obtained is same for both the reactions\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " 1).The standard equilibrium cell voltage is 1.228346 V\n", " 2).The standard equilibrium cell voltage is 1.228346 V\n" ] } ], "prompt_number": 5 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 17.21 Page Number : 624" ] }, { "cell_type": "code", "collapsed": false, "input": [ " \n", "# Variables\t\t\t\n", "P = 2;\t\t\t# Number of phases\n", "C = 5;\t\t\t# Number of components\n", "\n", "# Calculations\t\n", "\t\t\t# C + 2*H2 = CH4 \t\t\t# (reaction 1) \n", "\t\t\t# H2 + (1/2)*O2 = H20 \t\t\t# (reaction 2)\n", "\t\t\t# C + (1/2)*O2 = CO \t\t\t# (reaction 3)\n", "\t\t\t# C + O2 = CO2 \t\t\t# (reaction 4)\n", "\n", "\t\t\t# We do not have C in the equilibrium reaction mixture, therefore we have to eliminate it.\n", "\t\t\t# Substituting for C from reaction (1) into reactions (3) and (4) we get the following set of reactions\n", "\t\t\t# H2 + (1/2)*O2 = H20\n", "\t\t\t# CH4 - 2*H2 + (1/2)*O2 = CO\n", "\t\t\t# CH4 - 2*H2 + O2 = CO2\n", "\n", "\t\t\t# We do not have O2 in the equilibrium reaction mixture,therefore we have to eliminateit\n", "\t\t\t# 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", "\t\t\t# CH4 + H2O - H2 = CO + 2*H2\n", "\t\t\t# CH4 + 2*H20 - 2*H2 = CO2 + 2*H2 \n", "\n", "\t\t\t# Therefore one set of independent reactions is\n", "\t\t\t# CH4 + H20 = CO + 3*H2\n", "\t\t\t# CH4 + 2*H2O = CO2 + 4*H2\n", "\n", "\t\t\t# Another set of independent reactions can be obtained by substituting for CH4 from the first reaction into second and we get\n", "\t\t\t# CH4 + H2O = CO + 3*H2\n", "\t\t\t# CO + 3*H2 - H2O + 2*H2O = CO2 4*H2\n", "\n", "\t\t\t# Or, \n", "\t\t\t# CH4 + H2O = CO + 3*H2\n", "\t\t\t# CO + H2O = CO2 + H2\n", "\t\t\t\n", "r = 2;\n", "\n", "\t\t\t# and the number of degree of freedom becomes,\n", "F = r - P + C;\n", "\n", "# Results\n", "print \" The number of independent chemical reactions are %f \"%(r);\n", "\n", "print \" The first set of independent reactions are given below\";\n", "print \" CH4 + H20 = CO + 3*H2\";\n", "print \" CH4 + 2*H2O = CO2 + 4*H2\";\n", "\n", "print \" The second set of independent reactions are given below\";\n", "print \" CH4 + H20 = CO + 3*H2\";\n", "print \" CO + H2O = CO2 + H2\";\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " The number of independent chemical reactions are 2.000000 \n", " The first set of independent reactions are given below\n", " CH4 + H20 = CO + 3*H2\n", " CH4 + 2*H2O = CO2 + 4*H2\n", " The second set of independent reactions are given below\n", " CH4 + H20 = CO + 3*H2\n", " CO + H2O = CO2 + H2\n" ] } ], "prompt_number": 20 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 17.22 Page Number : 626" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import math \n", "from scipy.optimize import fsolve \n", "# Variables\t\t\t\n", "T = 400.;\t\t\t#[K] - Temperature\n", "P = 1.;\t\t\t#[atm] - Pressure\n", "R = 1.987;\t\t\t#[cal/mol-K] - Universal gas consatnt\n", "\n", "delta_G_n_pentane_400 = 9600.;\t\t\t#[cal/mol] - standard Gibbs free energy of formation of n-pentane at 400 K\n", "delta_G_iso_pentane_400 = 8200.;\t\t\t#[cal/mol] - standard Gibbs free energy of formation of iso-pentane at 400 K\n", "delta_G_neo_pentane_400 = 9000.;\t\t\t#[cal/mol] - standard Gibbs free energy of formation of neo-pentane at 400 K\n", "\n", "\t\t\t# The three reactions for the formation of these isomers can be written as follows\n", "\t\t\t# 5*C + 6*H2 = n-pentane\n", "\t\t\t# 5*C + 6*H2 = iso-pentane\n", "\t\t\t# 5*C + 6*H2 = neo-pentane\n", "\n", "# Calculations and Results\n", "\t\t\t# Let us take the following set of independent reactions\n", "\t\t\t# iso-pentane = n-pentane \t\t\t# (reaction 1)\n", "delta_G_rkn_1 = delta_G_n_pentane_400 - delta_G_iso_pentane_400;\t\t\t#[cal]\n", "K_1 = math.exp(-delta_G_rkn_1/(R*T));\n", "\t\t\t# iso-pentane = neo-pentane \t\t\t# (reaction 2)\n", "delta_G_rkn_2 = delta_G_neo_pentane_400 - delta_G_iso_pentane_400;\t\t\t#[cal]\n", "K_2 = math.exp(-delta_G_rkn_2/(R*T));\n", "\n", "\t\t\t# Let the initial number of moles be\n", "\t\t\t# n_iso_pentane = 1\n", "\t\t\t# n_n_pentane = 0\n", "\t\t\t# n_neo_pentane = 0\n", "\n", "\t\t\t# Let the reaction coordinate at equilibrium for the two reaction be X_1 and X_2 respectively\n", "\t\t\t# At equilibrium, the moles of the components be\n", "\t\t\t# n_iso_pentane_eq = 1 - X_1 - X_2\n", "\t\t\t# n_n_pentane_eq = X_1\n", "\t\t\t# n_neo_pentane_eq = X_2\n", "\t\t\t# Total moles = 1 \n", "\n", "\t\t\t# Pressure has no effect on these reactions ( P = 1 atm) and therefore\n", "Ky_1 = K_1;\n", "Ky_2 = K_2;\n", "\n", "\t\t\t# From reaction (1), we get\n", "\t\t\t# Ky_1 = X_1/(1-X_1-X_2)\n", "\n", "\t\t\t# From reaction (2), we get\n", "\t\t\t# Ky_2 = X_2/(1-X_1-X_2)\n", "\n", "\t\t\t# Putting the value of X_1 from first equation into the second we get\n", "\t\t\t# X_1 = (Ky_1*(1-X_2))/(1+Ky_1)\n", "\t\t\t# Now putting it into the second equation we grt\n", "\t\t\t# Ky_2 = X_2/(1-((Ky_1*(1-X_2))/(1+Ky_1))-X_2)\n", "\t\t\t# Now solving for X_2\n", "def f(X_2): \n", "\t return Ky_2 - X_2/(1-((Ky_1*(1-X_2))/(1+Ky_1))-X_2)\n", "X_2 = fsolve(f,0.8)\n", "\n", "\t\t\t# Therefore X_1 can be calculated as\n", "X_1 = (Ky_1*(1-X_2))/(1+Ky_1);\n", "\n", "\t\t\t# 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", "print \" The equilibrium composition is given by y_n_pentane = %f y_neo_pentane = %f and y_iso_pentane = %f\"%(y_n_pentane,y_neo_pentane,y_iso_pentane);\n", "\n", "\t\t\t# Let us consider another set of independent reactions\n", "\n", "\t\t\t# n-pentane = iso-pentane \t\t\t# (reaction 3)\n", "delta_G_rkn_3 = delta_G_iso_pentane_400 - delta_G_n_pentane_400;\t\t\t#[cal]\n", "K_3 = math.exp(-delta_G_rkn_3/(R*T));\n", "\t\t\t# n-pentane = neo-pentane \t\t\t# (reaction 4)\n", "delta_G_rkn_4 = delta_G_neo_pentane_400 - delta_G_n_pentane_400;\t\t\t#[cal]\n", "K_4 = math.exp(-delta_G_rkn_4/(R*T));\n", "\n", "\t\t\t# Let the initial number of moles be\n", "\t\t\t# n_n_pentane = 1\n", "\t\t\t# n_iso_pentane = 0\n", "\t\t\t# n_neo_pentane = 0\n", "\n", "\t\t\t# Let the reaction coordinate at equilibrium for the two reaction be X_3 and X_4 respectively\n", "\t\t\t# At equilibrium, the moles of the components be\n", "\t\t\t# n_n_pentane_eq = 1 - X_3 - X_4\n", "\t\t\t# n_iso_pentane_eq = X_4\n", "\t\t\t# n_neo_pentane_eq = X_4\n", "\t\t\t# Total moles = 1 \n", "\n", "\t\t\t# Pressure has no effect on these reactions (P = 1 atm) and therefore\n", "Ky_3 = K_3;\n", "Ky_4 = K_4;\n", "\n", "\t\t\t# From reaction (3), we get\n", "\t\t\t# Ky_3 = X_3/(1-X_3-X_4)\n", "\n", "\t\t\t# From reaction (4), we get\n", "\t\t\t# Ky_4 = X_4/(1-X_3-X_4)\n", "\n", "\t\t\t# Putting the value of X_3 from first equation into the second we get\n", "\t\t\t# X_3 = (Ky_3*(1-X_4))/(1+Ky_3)\n", "\t\t\t# Now putting it into the second equation we grt\n", "\t\t\t# Ky_4 = X_4/(1-((Ky_1*(1-X_4))/(1+Ky_3))-X_4)\n", "\t\t\t# Now solving for X_4\n", "def f1(X_4): \n", "\t return Ky_4 - X_4/(1-((Ky_3*(1-X_4))/(1+Ky_3))-X_4)\n", "X_4 = fsolve(f1,0.8)\n", "\n", "\t\t\t# Therefore X_3 can be calculated as\n", "X_3 = (Ky_3*(1-X_4))/(1+Ky_3);\n", "\n", "\t\t\t# 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", "\t\t\t# The final composition does not depend on the set of reactions considered. \n", "\n", "print \" For another set of independent reactions considered\";\n", "print \" The equilibrium composition is given by y_n_pentane = %f y_neo_pentane = %f and y_iso_pentane = %f\"%(y_n_pentane1,y_neo_pentane1,y_iso_pentane1);\n", "\n", "\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " The equilibrium composition is given by y_n_pentane = 0.111753 y_neo_pentane = 0.237745 and y_iso_pentane = 0.650501\n", " For another set of independent reactions considered\n", " The equilibrium composition is given by y_n_pentane = 0.111753 y_neo_pentane = 0.237745 and y_iso_pentane = 0.650501\n" ] } ], "prompt_number": 3 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 17.23 Page Number : 628" ] }, { "cell_type": "code", "collapsed": false, "input": [ " \n", "T = 600;\t\t\t#[K] - Temperature\n", "P = 1;\t\t\t#[atm] - Pressure\n", "R = 1.987;\t\t\t#[cal/mol-K] - Universal gas consatnt\n", "\n", "\t\t\t# CH4 + H2O = CO + 3*H2 \t\t\t# (Reaction 1)\n", "\t\t\t# CO + H2O = CO2 + H2 \t\t\t# (Reaction 2)\n", "\n", "K_1 = 0.574;\t\t\t# Equilibrium constant of first reaction\n", "K_2 = 2.21;\t\t\t# Equilibrium constant of second reaction\n", "\n", "\t\t\t# Initial number of moles of the components are\n", "\t\t\t# n_CH4 = 1\n", "\t\t\t# n_H2O = 5\n", "\t\t\t# n_CO = 0\n", "\t\t\t# n_H2 = O\n", "\t\t\t# n_CO2 = 0\n", "\n", "\t\t\t# Let the reaction coordinate at equilibrium for the two reaction be X_1 and X_2 respectively\n", "\t\t\t# At equilibrium, the moles of the components be\n", "\t\t\t# n_CH4_eq = 1 - X_1\n", "\t\t\t# n_H20_eq = 5 - X_1 - X_2\n", "\t\t\t# n_CO_eq = X_1 - X_2\n", "\t\t\t# n_H2_eq = 3*X_1 + X_2\n", "\t\t\t# n_CO2_eq = X_2\n", "\t\t\t# Total moles = 6 + 2*X_1\n", "\n", "\t\t\t# Since the pressure is 1 atm, K = Kp, Ky = K\n", "Ky_1 = K_1;\n", "Ky_2 = K_2;\n", "\n", "\t\t\t# From reaction (1), we get\n", "\t\t\t# 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", "\t\t\t# From reaction (2), we get\n", "\t\t\t# Ky_2 = (X_2*(3*X_1+X_2))/((X_1-X_2)*(5-X_1-X_2))\n", "\n", "# Calculations\n", "\t\t\t# Let us assume a value of X_1\n", "X_1 = 0.1;\n", "def f(X_2): \n", "\t return 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", "def f1(X_1_prime): \n", "\t return 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", "\n", "fault = 10;\n", "while(fault>0.05):\n", " X_2 = fsolve(f,0.8)\n", " X_2_prime = X_2;\n", " X_1_prime = fsolve(f1,0.8)\n", " fault=abs(X_1 - X_1_prime);\n", " X_1 = X_1 + 0.001;\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", "# Results\n", "print \" The equilibrium composition of the resulting mixture is given by\";\n", "print \" n_CH4 = % f mol n_H2O = %f mol n_CO = %f mol n_H2 = %f mol and n_CO2 = %f mol\"%(n_CH4,n_H20,n_CO,n_H2,n_CO2);\n", "print \" The total number of moles is %f mol\"%(Total_moles);\n", "\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " The equilibrium composition of the resulting mixture is given by\n", " n_CH4 = 0.089000 mol n_H2O = 3.471420 mol n_CO = 0.293420 mol n_H2 = 3.350580 mol and n_CO2 = 0.617580 mol\n", " The total number of moles is 7.822000 mol\n" ] }, { "output_type": "stream", "stream": "stderr", "text": [ "/home/jovina/virtualenvs/scipy/local/lib/python2.7/site-packages/scipy/optimize/minpack.py:236: RuntimeWarning: The iteration is not making good progress, as measured by the \n", " improvement from the last ten iterations.\n", " warnings.warn(msg, RuntimeWarning)\n", "/home/jovina/virtualenvs/scipy/local/lib/python2.7/site-packages/scipy/optimize/minpack.py:236: RuntimeWarning: The iteration is not making good progress, as measured by the \n", " improvement from the last five Jacobian evaluations.\n", " warnings.warn(msg, RuntimeWarning)\n" ] } ], "prompt_number": 6 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ "Example 17.24 Page Number : 631" ] }, { "cell_type": "code", "collapsed": false, "input": [ " \n", "T = 600 + 273.15;\t\t\t#[K] - Reaction temperature\n", "P = 1;\t\t\t#[atm] - Reaction pressure\n", "\n", "\t\t\t# The Gibbs free energy of formation of various species at 873.15 K are\n", "delta_G_CH4_RT = -2.82;\t\t\t# delta_G_CH4/(R*T)\n", "delta_G_H2O_RT = -29.73;\t\t\t# delta_G_CH4/(R*T)\n", "delta_G_CO_RT = -27.51;\t\t\t# delta_G_CH4/(R*T)\n", "delta_G_H2_RT = -1.46;\t\t\t# delta_G_CH4/(R*T)\n", "delta_G_CO2_RT = -56.68;\t\t\t# delta_G_CH4/(R*T)\n", "\n", "# Calculations\t\t\n", " \t# Initial number of moles of the components are\n", "\t\t\t# n_CH4 = 1\n", "\t\t\t# n_H2O = 5\n", "\t\t\t# n_CO = 0\n", "\t\t\t# n_H2 = O\n", "\t\t\t# n_CO2 = 0\n", "\n", "\t\t\t# The del(F)/del(n_i) = 0 equations for CH4 (1), H2O (2), CO (3), H2 (4) and CO2 (5) becomes\n", "\t\t\t# delta_G_1_T + R*T*math.log((n_1*P)/n) + lambda_C + 4*lambda_H = 0\n", "\t\t\t# delta_G_2_T + R*T*math.log((n_2*P)/n) + 2*lambda_C + lambda_O = 0\n", "\t\t\t# delta_G_3_T + R*T*math.log((n_3*P)/n) + lambda_c + lambda_O = 0\n", "\t\t\t# delta_G_4_T + R*T*math.log((n_4*P)/n) + 2*lambda_H = 0\n", "\t\t\t# delta_G_5_T + R*T*math.log((n_5*P)/n) + lambda_C + 2*lambda_O = 0\n", "\n", "\t\t\t# 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_5_T/(R*T) + math.log((n_5*P)/n) + lambda_C/(R*T) + 2*lambda_O/(R*T) = 0\n", "\n", "\t\t\t# Substituting the values of delta_G_i_T/(R*T) in the above equations,the full set of equations (including elemental balance) becomes\n", "\t\t\t# -56.68 + math.log(n_5/n) + lambda_C/(R*T) + 2*lambda_O/(R*T) = 0\n", "\n", "\t\t\t# The constraint equations are\n", "\t\t\t# n_1 + n_3 + n_5 = 1 \t\t\t# (moles of C in the reaction mixture = 1)\n", "\t\t\t# 4*n_1 + 2*n_2 + 2*n_4 = 14 \t\t\t# (moles of H in the reaction mixture = 14)\n", "\t\t\t# n_2 + n_3 + 2*n_5 = 5 \t\t\t# (moles of O in the raection mixture = 5)\n", "\n", "\t\t\t# The total moles are given by\n", "\t\t\t# n = n_1 + n_2 + n_3 + n_4 + n_5\n", "\n", "def solution(x):\n", " f = [0,0,0,0,0,0,0,0,0]\n", " f[0]= -2.82 + math.log(x[0]/x[5]) + x[6] + 4*x[7];\n", " f[1] = -29.73 + math.log(x[1]/x[5]) + 2*x[7] + x[8];\n", " f[2] = -27.51 + math.log(x[2]/x[5]) + x[6] + x[8];\n", " f[3] = -1.46 + math.log(x[3]/x[5]) + 2*x[7];\n", " f[4] = -56.68 + math.log(x[4]/x[5]) + x[6] + 2*x[8];\n", " f[5] = x[0] + x[2] +x[4] - 1;\n", " f[6] = 4*x[0] + 2*x[1] + 2*x[3] - 14;\n", " f[7] = x[1] + x[2] +2*x[4] - 5;\n", " f[8] = x[0]+ x[1] + x[2] + x[3] + x[4] - x[5]; \n", " return f\n", "\n", "\n", "x = [0.01,3.5,0.2,3.0,0.5,5.0,2.0,1.0,25.0];\n", "y = fsolve(solution,x)\n", "\n", "# Results\n", "print \" n_1 = %f mol\"%(y[0]);\n", "print \" n_2 = %f mol\"%(y[1]);\n", "print \" n_3 = %f mol\"%(y[2]);\n", "print \" n_4 = %f mol\"%(y[3]);\n", "print \" n_5 = %f mol\"%(y[4]);\n", "print \" n = %f mol\"%(y[5]);\n", "print \" lambda_C/RT = %f\"%(y[6]);\n", "print \" lambda_H/RT = %f\"%(y[7]);\n", "print \" lambda_O/RT = %f\"%(y[8]);\n", "\n", "print \" The Lagrange multiplier values do not have any physical significance\";\n", "\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " n_1 = 0.091556 mol\n", " n_2 = 3.442034 mol\n", " n_3 = 0.258922 mol\n", " n_4 = 3.374855 mol\n", " n_5 = 0.649522 mol\n", " n = 7.816888 mol\n", " lambda_C/RT = 2.667225\n", " lambda_H/RT = 1.149967\n", " lambda_O/RT = 28.250290\n", " The Lagrange multiplier values do not have any physical significance\n" ] } ], "prompt_number": 23 } ], "metadata": {} } ] }