{
 "metadata": {
  "name": "",
  "signature": "sha256:aba24805b98ee0919f2ef39d5927b5007d2ce98264adcd2e65263a9fbffd1f67"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 15:CHEMICAL EQUILIBRIUM"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 15.1, Page No:676"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "# (b).Number of moles of each constituents\n",
      "nCH4=2; # Number of moles of CH4\n",
      "\n",
      "#Calculation\n",
      "E=3-nCH4; # Amount of reaction from (a) and refer example 15.1 (a)\n",
      "nH2O=1-E;# Number of moles of H2O\n",
      "nCO=1+E;# Number of moles of CO\n",
      "nH2=4+3*E;# Number of moles of H2\n",
      "\n",
      "#Results\n",
      "print \"(b).Number of moles of each constituents\",\"\\nNumber of moles of H2O = \",nH2O\n",
      "print \"Number of moles of CO = \",nCO,\"\\nNumber of moles of H2 = \",nH2"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(b).Number of moles of each constituents \n",
        "Number of moles of H2O =  0\n",
        "Number of moles of CO =  2 \n",
        "Number of moles of H2 =  7\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 15.2, Page No:680"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "T0=298; # Given temperature in kelvin\n",
      "R_1=8.314; # Universal gas constant in kJ/kg mol K\n",
      "# (a).CO+1/2 O2 = CO2\n",
      "# From table of properties of combustion\n",
      "del_hfco2=-393509;# Enthalpy of heat \n",
      "del_hfco=-110525;# Enthalpy of heat \n",
      "s_co2=213.795;# Entropy of heat \n",
      "s_co=197.652;# Entropy of heat \n",
      "s_o2=205.142;# Entropy of heat \n",
      "\n",
      "#Calculation for (a)\n",
      "del_Ga=(del_hfco2-del_hfco-T0*(s_co2-s_co-(1/2*s_o2)));\n",
      "Ka=math.exp (abs (del_Ga)/(R_1*1000*T0));\n",
      "\n",
      "#Result for (a)\n",
      "print \"(a).CO+1/2 O2 = CO2\"\n",
      "print (\" The equilibrium constant at 298 K = %0.3f (Error in textbook) \")%Ka\n",
      "\n",
      "#Calculation for (b)\n",
      "# (b).2CO + O2 = 2CO2\n",
      "Kb=math.exp (2*abs (del_Ga)/(R_1*1000*T0));\n",
      "\n",
      "#Result for (b)\n",
      "print \"\\n(b).2CO + O2 = 2CO2\"\n",
      "print (\"The equilibrium constant at 298 K = %0.3f (Error in textbook)\")%Kb\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a).CO+1/2 O2 = CO2\n",
        " The equilibrium constant at 298 K = 1.123 (Error in textbook) \n",
        "\n",
        "(b).2CO + O2 = 2CO2\n",
        "The equilibrium constant at 298 K = 1.262 (Error in textbook)\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 15.3, Page No:686"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "from __future__ import division\n",
      "\n",
      "#Variable declaration\n",
      "T0=298; # Temperature of surroundings in kelvin\n",
      "R_1=8.314; # Universal gas constant in kJ/kg mol K\n",
      "T=2800; # Given Temperature in kelvin\n",
      "\n",
      "#Calculation\n",
      "# From table of properties of combustion\n",
      "del_hfco2=-393509; # Enthalpy of heat \n",
      "del_hfco=-110525; # Enthalpy of heat \n",
      "del_H=del_hfco2-del_hfco; # Standard enthalpy of reaction\n",
      "Ka=1.202*10**45; # The equilibrium constant From the example 15.2\n",
      "K1=math.log (Ka);\n",
      "K=math.exp(-(del_H/R_1)*((1/T)-(1/T0))+K1);\n",
      "\n",
      "#Result\n",
      "print\"K =\",round(K,3),\"  (roundoff error)\"\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "K = 5.687   (roundoff error)\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 15.5, Page No:689"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "T=2800; # Temperature of combustion in kelvin\n",
      "p=1; # Pressure of combustion in atm\n",
      "# For this reverse reaction at 2800K and 1atm, from Table 15.1\n",
      "K=44.168; # K=e^3.788;\n",
      "\n",
      "#Calculation\n",
      "K=math.sqrt (K); # For stoichiometric equation CO+1/2 O2 = CO2 which is halved\n",
      "# From equation 15.24a and by the iteration process we get the following\n",
      "a=0.198;\n",
      "b=(1+a)/2;\n",
      "c=1-a;\n",
      "\n",
      "#Results\n",
      "print \"The balance for the actual reaction equation CO + O2 \u2192 aCO + bO2 + cCO2 is given by \"\n",
      "print \"a =\",a,\"\\nb =\",b,\"\\nc =\",c\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The balance for the actual reaction equation CO + O2 \u2192 aCO + bO2 + cCO2 is given by \n",
        "a = 0.198 \n",
        "b = 0.599 \n",
        "c = 0.802\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 15.6, Page No:691"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "from __future__ import division\n",
      "\n",
      "#Variable declaration\n",
      "# By driving the equation for equilibrium constant as shown in example 15.6 we get 6.646(6)^(1/6)=((1-a)/a)((3+a)/(1+a))^1/2\n",
      "# by simple iteration process we get\n",
      "a=0.095;\n",
      "\n",
      "#Calculations\n",
      "b=(1+a)/2;\n",
      "c=1-a;\n",
      "\n",
      "#Results\n",
      "print \"The equilibrium composition of CO = \",a,\"mol   (roundoff error)\"\n",
      "print \"The equilibrium composition of O2 = \",b,\"mol   (roundoff error)\"\n",
      "print \"The equilibrium composition of CO2 = \",c,\"mol   (roundoff error)\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The equilibrium composition of CO =  0.095 mol   (roundoff error)\n",
        "The equilibrium composition of O2 =  0.5475 mol   (roundoff error)\n",
        "The equilibrium composition of CO2 =  0.905 mol   (roundoff error)\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 15.7, Page NO:691"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "T=2800; # Temperature of combustion in kelvin\n",
      "p=1; # Pressure of combustion in atm\n",
      "# For this reverse reaction at 2800K and 1atm, from Table 15.1\n",
      "K=44.168; # K=e^3.788;\n",
      "\n",
      "#Calculations\n",
      "K=math.sqrt (K); # For stoichiometric equation CO+1/2 O2 = CO2 which is halved\n",
      "# From equation 15.24a and by the iteration process we get the following\n",
      "a=0.302;\n",
      "b=(1+a)/2;\n",
      "c=1-a;\n",
      "\n",
      "#Results\n",
      "print \"The balance for the actual reaction equation CO + 1/2O2 + 1.88N2 \u2194 aCO + bO2 + cCO2 +3.76N2 is given  by \"\n",
      "print  \"a =\",a,\"\\nb =\",b,\"\\nc =\",c"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The balance for the actual reaction equation CO + 1/2O2 + 1.88N2 \u2194 aCO + bO2 + cCO2 +3.76N2 is given  by \n",
        "a = 0.302 \n",
        "b = 0.651 \n",
        "c = 0.698\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 15.8, Page No:693"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "T=3000; # Temperature of combustion in kelvin\n",
      "p=1; # Pressure of combustion in atm\n",
      "T0=298; # Temperature of surroundings in kelvin\n",
      "R_1=8.314; # Universal gas constant in kJ/kg mol K\n",
      "# Gibbs functions at 298K from Table 14.1\n",
      "del_gNO=86550; # In kJ/kmol\n",
      "del_gNO2=51310; # In kJ/kmol\n",
      "# From table of properties of combustion\n",
      "del_hfNO=90250; # Enthalpy of heat \n",
      "del_hfNO2=33180; # Enthalpy of heat \n",
      "\n",
      "#Calculations\n",
      "K1=math.exp (-(del_hfNO/R_1)*((1/T)-(1/T0))-((del_gNO)/(R_1*T0)));\n",
      "K2=math.exp (-(del_hfNO2/R_1)*((1/T)-(1/T0))-((del_gNO2)/(R_1*T0)));\n",
      "# By solving equilibrium equations by iteration method\n",
      "E1=0.228; E2=0.0007;\n",
      "yNO=E1/4.76; # Mole fraction of NO in exhaust gas\n",
      "yNO2=E2/4.76; # Mole fraction of NO2 in exhaust gas\n",
      "\n",
      "#Results\n",
      "print \"Percentage of NOx present in the exhaust gas \",\"\\nMole fraction of NO in exhaust gas = \",round(yNO*100,2),\"%\"\n",
      "print \"Mole fraction of NO2 in exhaust gas = \",round(yNO2*100,4),\"%\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Percentage of NOx present in the exhaust gas  \n",
        "Mole fraction of NO in exhaust gas =  4.79 %\n",
        "Mole fraction of NO2 in exhaust gas =  0.0147 %\n"
       ]
      }
     ],
     "prompt_number": 7
    }
   ],
   "metadata": {}
  }
 ]
}