{ "metadata": { "name": "", "signature": "sha256:0a1da29e7840a18bf7735e26f0a43477053969d9c5f5a2bfceee638c83ec8906" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "Chapter 12 : Chemical Equilibrium" ] }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ " Example 12.1 Page: 311\n" ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "import math \n", "\n", "T = 298.15 #[K] temperature\n", "P = 1. #[atm] pressure \n", "R = 8.314*10**(-3) #[kJ/(mol*K)]\n", "\n", "\n", "\n", "\n", "g_a_0 = -20.9 #[kJ/mol]\n", "g_b_0 = -17.2 #[kJ/mol]\n", "\n", "x_a = math.exp((g_b_0-g_a_0)/(R*T))/(1+math.exp((g_b_0-g_a_0)/(R*T)))\n", "x_b = 1-x_a\n", "\n", "print \" The chemical equilibrium composition of the gaseous mixture contains %f mol fraction isobutane \\t\\t\\t\\t\\t\\t\\t\\tan %f mol fraction n-bumath.tane\"%(x_a,x_b)\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " The chemical equilibrium composition of the gaseous mixture contains 0.816475 mol fraction isobutane \t\t\t\t\t\t\t\tan 0.183525 mol fraction n-bumath.tane\n" ] } ], "prompt_number": 14 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ " Example 12.2 Page: 319\n" ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "import math \n", "\n", "T = 298.15 #[K] temperature\n", "P = 0.987 #[atm] pressure\n", "g_0_NO = 86.6 #[kJ/mol] Free energy of formation the NO from elements\n", "R = 8.314 #[J/(mol*K)]\n", "\n", "g_0_O2 = 0.00\n", "g_0_N2 = 0.00\n", "\n", "\n", "delta_g_0 = 2*g_0_NO - g_0_O2 - g_0_N2 #[kJ/mol]\n", "delta_g_01 = delta_g_0*1000 #[J/mol]\n", "\n", "K_298 = math.exp((-delta_g_01)/(R*T))\n", "\n", "f_0_N2 = 1. #[bar]\n", "f_0_O2 = 1. #[bar]\n", "f_0_NO = 1. #[bar]\n", "\n", "\n", "\n", "y_N2 = 0.78\n", "y_O2 = 0.21\n", "\n", "y_NO_298 = math.sqrt(K_298*y_N2*y_O2)\n", "\n", "T_1 = 2000 #[K]\n", "K_2000 = 4.0*10**-4\n", "\n", "y_NO_2000 = math.sqrt(K_2000*y_N2*y_O2)*10**(6) #[ppm]\n", "\n", "print \" The equilibrium constant for the reaction at 298.15 K is \\t\\t\\t %.1e\"%(K_298)\n", "print \" The concentration of NO at equilibrium at temperature 298.15 K is \\t\\t %.1e\"%(y_NO_298)\n", "print \" The equilibrium consmath.tant for the reaction at 2000 K is \\t\\t\\t %.1e\"%(K_2000)\n", "print \" The concentration of NO at equilibrium at temperature 2000 K is \\t\\t %.0f ppm\"%(round(y_NO_2000,-2))\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " The equilibrium constant for the reaction at 298.15 K is \t\t\t 4.5e-31\n", " The concentration of NO at equilibrium at temperature 298.15 K is \t\t 2.7e-16\n", " The equilibrium consmath.tant for the reaction at 2000 K is \t\t\t 4.0e-04\n", " The concentration of NO at equilibrium at temperature 2000 K is \t\t 8100 ppm\n" ] } ], "prompt_number": 8 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ " Example 12.3 Page: 321\n" ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "from scipy.optimize import fsolve \n", "import math \n", "\n", "Temp = 2000. #[K]\n", "n_air = 1. #[mol] no of moles of the air\n", "\n", "\n", "K_2000 = 4*10**(-4)\n", "\n", "def f(x): \n", "\t return (2*x)**(2) - K_2000*(0.78-x)*(0.21-x)\n", "\t #return (K_2000-2)*x**(2)-K_2000*(0.78+0.21)*x+K_2000*0.78*0.21\n", "x = fsolve(f,0)\n", "c_NO = 2*x*10**(6) #[ppm]\n", "p = c_NO/8100.*100\n", "\n", "print \" The calculated NO cocentration is %f ppm, which %f%% of the value computed in example 12.1\"%(c_NO,p)\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " The calculated NO cocentration is 7996.442873 ppm, which 98.721517% of the value computed in example 12.1\n" ] } ], "prompt_number": 16 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ " Example 12.5 Page: 324\n" ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "\n", "from scipy.optimize import fsolve \n", "import math \n", "\n", "Temp = 298. #[K]\n", "K = 29.6 # equilibrium consmath.tant at 298 K \n", "P = 1. #[bar]\n", "n_water_0 = 0.833 #[mol]\n", "n_ethylene_0 = 1. #[mol]\n", "n_ethanol_0 = 0. #[mol]\n", "\n", "n_T_0 = (n_water_0+n_ethylene_0+n_ethanol_0) #[mol]\n", "\n", "def f(e): \n", "\t return ((0+e)/(1.833-e))/(((1-e)/(1.833-e))*((0.833-e)/(1.833-e)))-K*P/(1)\n", "e_1 = fsolve(f,0)\n", "e_2 = fsolve(f,0.5)\n", "\n", "y_ethanol = ((0+e_2)/(1.833-e_2))\n", "y_ethylene = ((1-e_2)/(1.833-e_2))\n", "y_water = ((0.833-e_2)/(1.833-e_2))\n", "\n", "print \"Concentration of the ethylene at the equilibrium is %f\"%(y_ethylene)\n", "print \" Concentration of the water at the equilibrium is %f\"%(y_water)\n", "print \" Concentration of the ethanol at the equilibrium is %f\"%(y_ethanol)\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "Concentration of the ethylene at the equilibrium is 0.243702\n", " Concentration of the water at the equilibrium is 0.092079\n", " Concentration of the ethanol at the equilibrium is 0.664219\n" ] } ], "prompt_number": 18 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ " Example 12.6 Page: 324\n" ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "\n", "from scipy.optimize import fsolve \n", "import math \n", "\n", "Temp = 273.15+25 #[C]\n", "P = 1. #[bar]\n", "R = 8.314 #[J/(mol*K)]\n", "\n", "g_H2O_0 = -237.1 #[kJ/mol]\n", "g_O2_0 = 0 #[kJ/mol]\n", "g_H2_0 = 0 #[kJ/mol]\n", "\n", "delta_g_0 = g_H2O_0 - 0.5*g_O2_0-g_H2_0 #[kJ/mol]\n", "delta_g_1 = delta_g_0*1000 #[J/mol]\n", "\n", "K = math.exp((-delta_g_1)/(R*Temp))\n", "\n", "n_T_0 = 1.5#[mol]\n", "\n", "\n", "def f(e): \n", "\t return (e/(1.5-0.5*e))/(((1-e)/(1.5-0.5*e))*((0.5-0.5*e)/(1.5-0.5*e))**(0.5))\n", "\n", "y_H2 = 2.4e-28\n", "y_O2 = 0.5*y_H2\n", "\n", "print \" The equilibrium mol fraction of the hydrogen is %0.3e\"%(y_H2)\n", "print \" And the equilibrium mol fraction of the oxygen is %e \"%(y_O2)\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " The equilibrium mol fraction of the hydrogen is 2.400e-28\n", " And the equilibrium mol fraction of the oxygen is 1.200000e-28 \n" ] } ], "prompt_number": 19 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ " Example 12.7 Page: 327\n" ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "import math \n", "from scipy.integrate import quad \n", "\n", "Temp = 298.15 #[K]\n", "Press = 1*10**(5) #[Pa]\n", "R = 8.314 #[J/(mol*K)]\n", "\n", "v_liquid = 1.805*10**(-5) #[m**(3)/mol] this liquid specific volume and we will treat is as a consmath.tant\n", "\n", "P_vapour_25 = 0.0317*10**(5) #[Pa]\n", "\n", "\n", "def f0(P): \n", "\t return v_liquid*P**(0)\n", "\n", "delta_g_0_1 = quad(f0,Press,P_vapour_25)[0]\n", "\n", "\n", "delta_g_0_2 = 0 #[J/mol]\n", "\n", "\n", "def f1(P): \n", "\t return 1./P\n", "\n", "delta_g_0_3 = (R*Temp)* quad(f1,P_vapour_25,Press)[0]\n", "\n", "\n", "delta_g_0 = delta_g_0_1+delta_g_0_2+delta_g_0_3 #[J/mol]\n", "delta_g_1 = delta_g_0/1000 #[kJ/mol]\n", "\n", "print \" Total change in the free energy of water going under given conditions is %0.2f kJ/mol\"%(delta_g_1)\n", "\n", "delta_g_0_ideal_gas = -228.6 #[kJ/mol]\n", "delta_g_0_liquid = -237.1 #[kJ/mol]\n", "delta_g_o = delta_g_0_ideal_gas-delta_g_0_liquid #[kJ/mol]\n", "\n", "print \" From the values of Table A.8 given in the book the free energy change is %0.2f kJ/mol\"%(delta_g_o)\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " Total change in the free energy of water going under given conditions is 8.55 kJ/mol\n", " From the values of Table A.8 given in the book the free energy change is 8.50 kJ/mol\n" ] } ], "prompt_number": 20 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ " Example 12.8 Page: 330\n" ] }, { "cell_type": "code", "collapsed": false, "input": [ "import math \n", "from scipy.integrate import quad \n", "\n", "T1 = 273.15+25 #[K]\n", "T2 = 273.15+400 #[K]\n", "R = 8.314 #[J/(mol*K)]\n", "\n", "g0_NH3 = -16.5 #[kJ/mol]\n", "g0_N2 = 0 #[kJ/mol]\n", "g0_H2 = 0 #[kJ/mol]\n", "\n", "\n", "delta_g_0 = g0_NH3 - 0.5*g0_N2 - 1.5*g0_H2 #[kJ/mol]\n", "\n", "K_1 = math.exp(-delta_g_0*1000/(R*T1)) # Equilibrium consmath.tant of the reaction at temperature 298.15 K\n", "\n", "h0_NH3 = -46.1 #[kJ/mol]\n", "h0_N2 = 0 #[kJ/mol]\n", "h0_H2 = 0 #[kJ/mol]\n", "\n", "del_h_1 = h0_NH3 - 0.5*h0_N2 - 1.5*h0_H2 #[kJ/mol]\n", "\n", "a_NH3 = 3.578\n", "a_H2 = 3.249\n", "a_N2 = 3.280\n", "b_NH3 = 3.020*10**(-3) #[1/K]\n", "b_H2 = 0.422*10**(-3)\n", "b_N2 = 0.593*10**(-3)\n", "c_NH3 = 0 #[1/K**(2)]\n", "c_H2 = 0 #[1/K**(2)]\n", "c_N2 = 0 #[1/K**(2)]\n", "d_NH3 = -0.186*10**(5) #[K**(2)]\n", "d_H2 = 0.083*10**(5) #[K**(2)]\n", "d_N2 = 0.040*10**(5) #[K**(2)]\n", "\n", "del_a = a_NH3 - 0.5*a_N2 - 1.5*a_H2\n", "del_b = b_NH3 - 0.5*b_N2 - 1.5*b_H2\n", "del_c = c_NH3 - 0.5*c_N2 - 1.5*c_H2\n", "del_d = d_NH3 - 0.5*d_N2 - 1.5*d_H2\n", "\n", "I = R*( del_a*T1 + del_b*T1**(2)/2 + del_c*T1**(3)/3 - del_d/T1) #[J/mol]\n", "\n", "\n", "def f5(T): \n", "\t return (del_h_1*1000 - I + R*(del_a*T + del_b*T**(2)/2 + del_c*T**(3)/3 - del_d/T))/T**(2)\n", "\n", "X = (1/R)* quad(f5,T1,T2)[0]\n", "\n", "\n", "K_2 = K_1*math.exp(X)\n", "\n", "print \" Equilibrium consmath.tants for the formation of ammonia from hydrogen and nitrogen are \"\n", "print \" K = %0.0f at temperature 25 deg C\"%(K_1)\n", "print \" K = %f at temperature 400 deg C\"%(K_2)\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " Equilibrium consmath.tants for the formation of ammonia from hydrogen and nitrogen are \n", " K = 778 at temperature 25 deg C\n", " K = 0.013588 at temperature 400 deg C\n" ] } ], "prompt_number": 21 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ " Example 12.9 Page: 335\n" ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "\n", "from scipy.optimize import fsolve \n", "import math \n", "\n", "n_H2_0 = 1.5 #[mol]\n", "n_N2_0 = 0.5 #[mol]\n", "n_NH3_0 = 0 #[mol]\n", "T_1 = 298.15 #[K]\n", "T_2 = 673.15 #[K]\n", "P = 1. #[bar]\n", "\n", "\n", "\n", "\n", "K_298 = 778. # at temperature 298.15K\n", "K_673 = 0.013 # at temperature 673.15K\n", "\n", "def g(e_1): \n", "\t return ((0+e_1)/(2-e_1))/(((0.5-0.5*e_1)/(2-e_1))**(0.5)*((1.5-1.5*e_1)/(2-e_1))**(1.5))-K_298\n", " \n", "e_1 = fsolve(g,0.97)\n", "y_NH3_298 = e_1/(2-e_1)\n", "\n", "def h(e_2): \n", "\t return ((0+e_2)/(2-e_2))/(((0.5-0.5*e_2)/(2-e_2))**(0.5)*((1.5-1.5*e_2)/(2-e_2))**(1.5))-K_673\n", "\n", "e_2 = fsolve(h,0)\n", "y_NH3_673 = e_2/(2-e_2)\n", "\n", "print \" The mole fraction of NH3 in the equilibrium at the temperature 298.15K and 1 bar is %f\"%(y_NH3_298)\n", "print \" The mole fraction of NH3 in the equilibrium at the temperature 673.15K and 1 bar is %f\"%(y_NH3_673)\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " The mole fraction of NH3 in the equilibrium at the temperature 298.15K and 1 bar is 0.939036\n", " The mole fraction of NH3 in the equilibrium at the temperature 673.15K and 1 bar is 0.004187\n" ] } ], "prompt_number": 22 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ " Example 12.10 Page: 337\n" ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "from scipy.optimize import fsolve \n", "import math \n", "\n", "Temp = 273.15+400 #[K]\n", "P = 150*1.01325 #[bar]\n", "\n", "K_673 = 0.013\n", "\n", "K = K_673*(P/1)**(1.5+0.5-1)\n", "\n", "def f(e): \n", "\t return ((0+e)/(2-e))/(((0.5-0.5*e)/(2-e))**(0.5)*((1.5-1.5*e)/(2-e))**(1.5))-K\n", "e=fsolve(f,0.5)\n", "\n", "y_NH3 = (0+e)/(2-e)\n", "\n", "print \"The mole fraction of the ammonia in the equilibrium is %0.2f\"%(y_NH3)\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "The mole fraction of the ammonia in the equilibrium is 0.31\n" ] } ], "prompt_number": 23 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ " Example 12.11 Page: 338\n" ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "from scipy.optimize import fsolve \n", "import math \n", "\n", "T = 273.15+400 #[K] given temperature\n", "P = 150*1.01325 #[bar] given pressure\n", "\n", "K_673 = 0.013\n", "\n", "K_v = (10**((0.1191849/T + 91.87212/T**(2) + 25122730/T**(4))*P))**(-1)\n", "\n", "K = (K_673/K_v)*(P/1)**(1.5+0.5-1)\n", "\n", "\n", "def f(e): \n", "\t return ((0+e)/(2-e))/(((0.5-0.5*e)/(2-e))**(0.5)*((1.5-1.5*e)/(2-e))**(1.5))-K\n", "e = fsolve(f,0.2)\n", "\n", "y_NH3 = (0+e)/(2-e)\n", "\n", "print \" The mole fraction of the ammonia in the equilibrium is %0.2f\"%(y_NH3)\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " The mole fraction of the ammonia in the equilibrium is 0.34\n" ] } ], "prompt_number": 24 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ " Example 12.12 Page: 340\n" ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "\n", "from scipy.optimize import fsolve \n", "import math \n", "\n", "p_i = 1. #[atm] initial pressure \n", "P = 150. #[atm] final pressure\n", "T = 273+25. #[K] Given temperature\n", "R = 8.314 #[J/(mol*K)]\n", "\n", "delta_g_0 = 10.54*1000 #[J/mol]\n", "\n", "K = math.exp((-delta_g_0)/(R*T))\n", "\n", "\n", "\n", "def f(e): \n", "\t return (e*e)/((1-e)*(1-e))-K\n", "e = fsolve(f,0)\n", "\n", "v_C2H5OOC2H5 = 97.67 #[ml/mol]\n", "v_H2O = 18.03 #[ml/mol]\n", "v_C2H5OH = 58.30 #[ml/mol]\n", "v_CH3COOH = 57.20 #[ml/mol]\n", "\n", "delta_v = v_C2H5OOC2H5 + v_H2O - v_C2H5OH - v_CH3COOH #[ml/mol]\n", "\n", "\n", "\n", "def g(e_1): \n", "\t return (e_1*e_1)/((1-e_1)*(1-e_1))*math.exp((delta_v)/(R*T)*(P-p_i))-K\n", "e_1 = fsolve(g,0.2)\n", "\n", "a = e_1/e\n", "\n", "\n", "print \"On increamath.sing the pressure from 1 atm to 150 atm the reacted amount of the equimolar \\\n", "reacmath.tants at equilibrium becomes %f times of initial\"%(a)\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "On increamath.sing the pressure from 1 atm to 150 atm the reacted amount of the equimolar reacmath.tants at equilibrium becomes 0.994639 times of initial\n" ] } ], "prompt_number": 25 }, { "cell_type": "heading", "level": 3, "metadata": {}, "source": [ " Example 12.13 Page: 342\n" ] }, { "cell_type": "code", "collapsed": false, "input": [ "\n", "import math \n", "\n", "P = 150. #[atm] given pressure\n", "T = 400. #[C] temperature\n", "K = 0.013\n", "K_v = 0.84\n", "delta_v = 1.5+0.5-1\n", "\n", "\n", "K_p = (K/K_v)*(1/1)**(delta_v) #[1/bar]\n", "\n", "print \" Value of the K_p at the given condition is %f 1/bar)\"%(K_p)\n", "print \" The basic K is dimensionless%( but K_p has the dimensions of pressure to the power.\"\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ " Value of the K_p at the given condition is 0.015476 1/bar)\n", " The basic K is dimensionless%( but K_p has the dimensions of pressure to the power.\n" ] } ], "prompt_number": 26 }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] } ], "metadata": {} } ] }