{
 "metadata": {
  "name": "",
  "signature": "sha256:4c4dfb370e475e99da4c5056464d38bcfd8f5f2d436b23af2eaa8055bd431fec"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 14:CHEMICAL REACTIONS AND COMBUSTION"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 14.1, Page No:644"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "# From the Table 14.1 \n",
      "del_hfHCL=92307; # Enthalpy of Heat in kJ/kmol\n",
      "del_hfH2O=-241818; # Enthalpy of Heat kJ/kmol\n",
      "\n",
      "#Calculation\n",
      "del_Ho=4*del_hfHCL-2*del_hfH2O; # The standard heat of reaction from enthalpy equation\n",
      "\n",
      "#Result\n",
      "print \"The standard heat of reaction for the process = \",del_Ho,\"kJ   (answer mentioned in the textbook is wrong)\"\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The standard heat of reaction for the process =  852864 kJ   (answer mentioned in the textbook is wrong)\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 14.2, Page No:645"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "del_Ho=5640000; # Heat released during the process\n",
      "# From the Table 14.1 \n",
      "del_hfO2=-393509; del_hfH2O=-285830; # Enthalpy of Heat in kJ/kmol\n",
      "\n",
      "#Calculation\n",
      "del_hfsucrose=12*del_hfO2+11*del_hfH2O+del_Ho; # The enthalpy formation of sucrose\n",
      "\n",
      "#Result\n",
      "print \"The enthalpy formation of sucrose = \",del_hfsucrose,\"kJ/kmol   (answer mentioned in the textbook is wrong)\"\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The enthalpy formation of sucrose =  -2226238 kJ/kmol   (answer mentioned in the textbook is wrong)\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 14.3, Page No:649"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "# (a).Balancing of chemical equation\n",
      "# The unbalanced equation for the process is C8H18 + O2 + N2 \u2192 CO2 + H2O + N2\n",
      "x=8; # Carbon balance\n",
      "y=9; # Hydrogen balance\n",
      "z=12.5; # Oxygen balance in reverse order\n",
      "n=z*3.76; # Nitrogen Balance\n",
      "\n",
      "#Result for (a)\n",
      "print \"(a).Balancing of chemical equation\"\n",
      "print \" C8H18 + z O2 + n N2 \u2192 x CO2 + y H2O + n1 N2 \\n \"\n",
      "print \" z =\",z,\"\\n n =\",n,\"\\n x =\",x,\"\\n y =\",y,\"\\n n1 =\",5*n\n",
      "\n",
      "#Calculation for (b)\n",
      "# (b).The theoretical air-fuel ratio\n",
      "a=1; # Mole of C8H18\n",
      "AF1=(z+n)/a; #The theoretical air-fuel ratio on mole basis\n",
      "ma=28.84; # Molecular mass of air \n",
      "mc=114; # Molecular mass of C8H18\n",
      "AF2=(AF1*ma)/(a*mc); # The theoretical air-fuel ratio on mass basis\n",
      "\n",
      "#Result for (b)\n",
      "print \"\\n(b).The theoretical air-fuel ratio\",\"\\nThe theoretical air-fuel ratio on mole basis = \",AF1,\"kmol air / kmol C8H18\"\n",
      "print \"The theoretical air-fuel ratio on mass basis = \",round(AF2,0),\"kg air / kmol C8H18\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a).Balancing of chemical equation\n",
        " C8H18 + z O2 + n N2 \u2192 x CO2 + y H2O + n1 N2 \n",
        " \n",
        " z = 12.5 \n",
        " n = 47.0 \n",
        " x = 8 \n",
        " y = 9 \n",
        " n1 = 235.0\n",
        "\n",
        "(b).The theoretical air-fuel ratio \n",
        "The theoretical air-fuel ratio on mole basis =  59.5 kmol air / kmol C8H18\n",
        "The theoretical air-fuel ratio on mass basis =  15.0 kg air / kmol C8H18\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 14.4, Page No:650"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import numpy as np\n",
      "#Variable declaration\n",
      "# The combustion equation for C4H10 with 80% theoretical air is C4H10 +5.2(O2 + 3.76 N2) \u2192 a(1)CO + a(2)CO2 + 5H2O + 19.55N2\n",
      "# The following matrix shows the balance of C and O\n",
      "\n",
      "#Calculation\n",
      "A = np.array([(1, 1),(1,2)])\n",
      "B = np.array([4,5.4])\n",
      "m = np.linalg.solve(A,B)\n",
      "\n",
      "#Result\n",
      "print \"The equation for the combustion of butane with 80% theoretical air is \"\n",
      "print \"\\nC4H10 +5.2(O2 + 3.76 N2) \u2192\", m.item(0), \"CO + \",m.item(1), \"CO2 + 5H2O + 19.55N2\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The equation for the combustion of butane with 80% theoretical air is \n",
        "\n",
        "C4H10 +5.2(O2 + 3.76 N2) \u2192 2.6 CO +  1.4 CO2 + 5H2O + 19.55N2\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 14.5, Page No:650"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "p=101.325; # Atmospheric pressure in kPa\n",
      "# The complete combustion equation for actane\n",
      " # yC8H18+ x (O2+3.76N2)  \u2192 n1 CO2+n2 H2O+n3 O2+n3 N2\n",
      "x=12.5*1.5; y=1;\n",
      "n1=8; n2=9; n3=6.28; n4=70.5;\n",
      "\n",
      "#calculation\n",
      "n=n1+n2+n3+n4; # Total number of moles of the products\n",
      "AFm=(x+x*3.76)/y ;# Air fuel ratio\n",
      "m=28.84;\n",
      "M=116; # Molecular weight of octane\n",
      "AF=AFm*m/M;\n",
      "yco2=n1/n; yH2O=n2/n; yO2=n3/n; yN2=n4/n;\n",
      "pH2O=p*yH2O; # Partial pressure of water vapour in the products\n",
      "Tsat=45.21; # In oC\n",
      "\n",
      "#Result\n",
      "print \"Air fuel ratio = \",round(AF,2),\"kg air/kg octane\"\n",
      "print \"Dew point temperature = \",Tsat,\"oC\"\n",
      "print \"\\nIf the products are cooled below 25 oC then,  the water vapour will condense.\"\n",
      "print \"Because the cooled temperature is less than dew point temperature of water vapour i.e., T < Tsat.\"\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Air fuel ratio =  22.19 kg air/kg octane\n",
        "Dew point temperature =  45.21 oC\n",
        "\n",
        "If the products are cooled below 25 oC then,  the water vapour will condense.\n",
        "Because the cooled temperature is less than dew point temperature of water vapour i.e., T < Tsat.\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 14.6, Page No:651"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "# The complete chemical equation is\n",
      "#[0.14H2+0.03CH4+0.27CO+0.045CO2+0.01O2+0.505N2]+0.255(O2+3.75N2) \u21920.2H2O+0.345CO2+1.44N2\n",
      "a=0.14; # Composition of H2 in air\n",
      "b=0.03; # Composition of CH4 in air\n",
      "c=0.27; # Composition of CO in air\n",
      "d=0.045; # Composition of CO2 in air\n",
      "e=0.01; # Composition of O2 in air\n",
      "f=0.505; # Composition of N2 in air\n",
      "g=(0.265-0.01); # O2 requirement from atmospheric air with 1% O2 already in fuel\n",
      "h=3.76; # By nitrogen balance \n",
      "i=1; # mole of the air\n",
      "\n",
      "#Calculation\n",
      "#Air fuel ratio on mol (volume) basis\n",
      "AFvol=(g+(g*h))/i; # Air fuel ratio (theroretical)\n",
      "AFv=1.1*AFvol; # Air fuel ratio on mol (volume) basis\n",
      "#Air fuel ratio on mass basis\n",
      "M1=2; # Molecular mass of H2\n",
      "M2=16; # Molecular mass of CH4\n",
      "M3=28; # Molecular mass of CO\n",
      "M4=44; # Molecular mass of CO2\n",
      "M5=32; # Molecular mass of O2\n",
      "M=a*M1+b*M2+c*M3+d*M4+e*M5+f*M3; # Molecular mass of Fuel\n",
      "Ma=28.84; # Molecular mass of air\n",
      "AFm=AFv*Ma/(i*M); # Air fuel ratio on mass basis\n",
      "\n",
      "#Results\n",
      "print \"Air fuel ratio on mol (volume) basis =\",round(AFv,3),\"kmol actual air/kmol fuel\"\n",
      "print \"\\nAir fuel ratio on mass basis = \",round(AFm,2),\"kg air / kg fuel\"\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Air fuel ratio on mol (volume) basis = 1.335 kmol actual air/kmol fuel\n",
        "\n",
        "Air fuel ratio on mass basis =  1.56 kg air / kg fuel\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 14.7, Page No:653"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "#From table 14.2 at 25 oC and 1 atm for C8H8\n",
      "del_Ho=-2039.7; # LHV in MJ/kmol\n",
      "# Combustion equation is C3H8+ 5O2 +18.8N2 \u2192 3CO2 +4H2O +18.8N2\n",
      "# From table 14.3\n",
      "h333_C3H8=2751; # h333_h298 of C3H8 in kJ/kmol\n",
      "h333_O2=147; # h333_h298 of O2 in kJ/kmol\n",
      "h333_N2=145; # h333_h298 of N2 in kJ/kmol\n",
      "h1333_CO2=52075; # h1333_h298 of CO2 in kJ/kmol\n",
      "h1333_H2O=32644; # h1333_h298 of H2O in kJ/kmol\n",
      "h1333_N2=32644; # h1333_h298 of N2 in kJ/kmol\n",
      "M=44; # molecular mass of C3H8\n",
      "\n",
      "#Calculation\n",
      "Ha_H1=h333_C3H8+5*h333_C3H8+18.8*h333_N2; # The enthalpy differences\n",
      "Hb_H2=3*h1333_CO2+4*h1333_H2O+18.8*h1333_N2; # The enthalpy differences\n",
      "Q=(del_Ho+Hb_H2/1000-Ha_H1/1000)/M; # Heat transfer from combustion chamber\n",
      "\n",
      "#Result\n",
      "print \"Heat transfer from combustion chamber =\",round(abs (Q),2),\"MJ/kg C3H8\"\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Heat transfer from combustion chamber = 26.33 MJ/kg C3H8\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 14.8, Page No:656"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "Ha_H1=6220; # From example 14.7 in kJ/kmol\n",
      "del_Ho=-2039.7; # From example 14.7 LHV in MJ/kmol\n",
      "\n",
      "#Calculation\n",
      "Hb_H2=-del_Ho+Ha_H1; # For adiabatic combustion of C3H8\n",
      "# Hb_H2=3*h1333_CO2+4*h1333_H2O+18.8*h1333_N2 By iteration process and making use of the values from Table A.3, A.13, A.15\n",
      "# we can get the adiabatic flame temperature is\n",
      "Tad=2300;# The adiabatic flame temperature in kelvin\n",
      "\n",
      "#Result\n",
      "print \"The adiabatic flame temperature =\",Tad,\"K\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The adiabatic flame temperature = 2300 K\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 14.9, Page No:658"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "# (a).Entropy change per kmol of C\n",
      "# From table 14.1 at 298 K and 1 atm\n",
      "s_c=5.686; # Absolute entropies of C in kJ/kmol K\n",
      "s_o2=205.142; # Absolute entropies of o2 in kJ/kmol K\n",
      "s_co2=213.795; # Absolute entropies of CO2 in kJ/kmol K\n",
      "\n",
      "#Calculation for (a)\n",
      "del_s=s_co2-(s_c+s_o2); # The entropy change \n",
      "\n",
      "#Result for (a)\n",
      "print \"(a).The entropy change = \",del_s,\"kJ/K/kmol C\"\n",
      "\n",
      "#Variable declaration for(b)\n",
      "# (b).Entropy change of universe\n",
      "Tsurr=298; # Temperature of surroundings in kelvin\n",
      "\n",
      "#Calculation for (b)\n",
      "# From table 14.1 \n",
      "del_Ho=-393509; # del_hfco2 in kJ/kmol CO2\n",
      "Q=abs (del_Ho);\n",
      "del_Ssurr=Q/Tsurr; # Entropy change of surroundings\n",
      "del_Suniv=del_s+del_Ssurr; #Entropy change of universe\n",
      "\n",
      "#Result for (b)\n",
      "print \"\\n(b).Entropy change of universe = \",del_Suniv,\"kJ/K\"\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a).The entropy change =  2.967 kJ/K/kmol C\n",
        "\n",
        "(b).Entropy change of universe =  1322.967 kJ/K\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 14.10, Page No:659"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "from __future__ import division\n",
      "\n",
      "#Variable declaration\n",
      "# (a).The product CO2 is also at 298K\n",
      "Pco=2/3; # Paratial pressure of CO in atm \n",
      "Po2=1/3; # Paratial pressure of O2 in atm\n",
      "Pco2=1; # Paratial pressure of CO2 in atm\n",
      "T0=298; # Temperature of surroundings in kelvin\n",
      "R_1=8.3143; # Universal gas constant of air in kJ/kmol K\n",
      "\n",
      "#Calculation for (a)\n",
      "# From table 14.1 at 298 K and 1 atm\n",
      "s_co2=213.795-R_1*math.log (Pco2); # entropies in kJ/kmol K\n",
      "s_co=197.653-(R_1*math.log (Pco)); # entropies in kJ/kmol K\n",
      "s_o2=205.03-R_1*math.log (Po2); # entropies in kJ/kmol K\n",
      "del_Scv=s_co2-s_co-1/2*s_o2; # Entropy change of comtrol volume \n",
      "# From table 14.1\n",
      "del_hfco2=-393509; del_hfco=-110525; # Enthalpy of Heat in kJ/kmol\n",
      "Q= del_hfco2- del_hfco; # Heat transfer (to surroundings)\n",
      "del_Ssurr=abs(Q)/T0; # Entropy change of surroundings\n",
      "del_Sgen=del_Scv+del_Ssurr; #Entropy change of universe\n",
      "\n",
      "#Result for (a)\n",
      "print \"(a).The product CO2 is also at 298 K\",\"\\nEntropy change of comtrol volume  = \",round(del_Scv,2),\"kJ/K\"\n",
      "print \"Entropy change of surroundings = \",round(del_Ssurr,2),\"kJ/K\",\"\\nEntropy change of universe = \",round(del_Sgen,3),\"kJ/K\"\n",
      "\n",
      "#Calculation for (b)\n",
      "# (b).The reaction is adiabatic\n",
      "# Let the adiabatic flame temperature be T. Then since\n",
      "Q=0;\n",
      "C_p=44*0.8414;\n",
      "# From table A.16\n",
      "T=5057.5; #adiabatic flame temperature in kelvin\n",
      "s_CO2=213.795+C_p*math.log (T/T0); # entropies in kJ/kmol K\n",
      "del_Scv=s_CO2-s_co-1/2*s_o2; # Entropy change of comtrol volume \n",
      "del_Ssurr=abs(Q)/T0; # Entropy change of surroundings\n",
      "del_Sgen=del_Scv+del_Ssurr; #Entropy change of universe\n",
      "\n",
      "#Result for (b)\n",
      "print \"\\n(b).The reaction is adiabatic\",\"\\nEntropy change of comtrol volume  = \",round(del_Scv,3),\"kJ/K\"\n",
      "print \"Entropy change of surroundings = \",round(del_Ssurr,3),\"kJ/K\",\"\\nEntropy change of universe = \",round(del_Sgen,3),\"kJ/K\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a).The product CO2 is also at 298 K \n",
        "Entropy change of comtrol volume  =  -94.31 kJ/K\n",
        "Entropy change of surroundings =  949.61 kJ/K \n",
        "Entropy change of universe =  855.299 kJ/K\n",
        "\n",
        "(b).The reaction is adiabatic \n",
        "Entropy change of comtrol volume  =  10.517 kJ/K\n",
        "Entropy change of surroundings =  0.0 kJ/K \n",
        "Entropy change of universe =  10.517 kJ/K\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 14.11, Page No:661"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "# The Combustion of H2 with Q2 from H2O\n",
      "#H2(g)+1/2 O2 (g)\u2192H2O(l)+285830 kJ/kmol H2\n",
      "T0=298; # Temperature of surroundings in kelvin\n",
      "# From table 14.1 at 298 K\n",
      "del_hfH2O=-285830; # Enthalpy of Heat in kJ/kmol\n",
      "s_298H2O=69.94; s_298H2=130.684; s_298O2=205.142; # entropies in kJ/kmol K\n",
      "\n",
      "#Calculation\n",
      "GP_GR=del_hfH2O-T0*(s_298H2O-s_298H2-1/2*s_298O2); # Formation of Gibbs function\n",
      "GR=0;\n",
      "GP=GP_GR-GR; # Standard Gibbs function of formation of liquid H2O\n",
      "\n",
      "#Result\n",
      "print \"Standard Gibbs function of formation of liquid H2O = \",round(GP,0),\"kJ/kmol\"\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Standard Gibbs function of formation of liquid H2O =  -237162.0 kJ/kmol\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 14.12, Page No:662"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "# the combustion equation\n",
      "# n1C3H8+n2O2+n3 N2 \u2192 n4 CO2+ n5 H2O+n6 O2+n7 N2\n",
      "T0=298; # Temperature of surroundings in kelvin\n",
      "# (a).Product species at 25 oC and 1 atm\n",
      "d_gfC3H8=-24290; d_gfCO2=-394359; d_gfH2O=-228570; # in kJ/kmol\n",
      "GR=d_gfC3H8;\n",
      "\n",
      "#Calculation for (a)\n",
      "GP=3*d_gfCO2+4*d_gfH2O;\n",
      "Wmax=GR-GP; # Maximum possible work output\n",
      "M=44;#Molecular weight\n",
      "Wmax=Wmax/M;\n",
      "\n",
      "#Result for (a)\n",
      "print \"(a).\",\"\\nMaximum possible work output = \",round(Wmax,3),\"kJ/kg fuel   (answer mentioned in the textbook is wrong)\"\n",
      "\n",
      "#Calculation for (b)\n",
      "# (b).The actual partial pressures of products\n",
      "n1=1; n2=20; n3=75.2;\n",
      "n4=3; n5=4; n6=15; n7=75.2; # refer equation\n",
      "SR=19233; SP=19147; # in kJ/K from table\n",
      "HR=-104680; # in kJ/kmol fuel\n",
      "d_h0fCO2=-393509; d_h0fH2O=-241818; # in kJ/kmol\n",
      "HP=3*d_h0fCO2+4*d_h0fH2O;\n",
      "Wmax=HR-HP-T0*(SR-SP); # Maximum possible work output\n",
      "Wmax=Wmax/M;\n",
      "\n",
      "#Result for (b)\n",
      "print \"\\n(b).\",\"\\nMaximum possible work output = \",round(Wmax,3),\"kJ/kg   (round off error)\"\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a). \n",
        "Maximum possible work output =  47115.159 kJ/kg fuel   (answer mentioned in the textbook is wrong)\n",
        "\n",
        "(b). \n",
        "Maximum possible work output =  45852.068 kJ/kg   (round off error)\n"
       ]
      }
     ],
     "prompt_number": 12
    }
   ],
   "metadata": {}
  }
 ]
}