{
 "metadata": {
  "name": "",
  "signature": "sha256:1aee5040b10cb0c8b88b1f2c29303ab365a0d0e9e802f10ac15f3026e0ae4c4a"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 16 : Reactive Systems"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 16.2 Page No : 657"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "# Variables\n",
      "eps_e = 0.27; \n",
      "P = 1. ;\n",
      "\n",
      "# Calculation\n",
      "K = (4*eps_e**2*P)/(1-eps_e**2);\n",
      "P1 = 100./760; \t\t\t# in Pa\n",
      "eps_e_1 = math.sqrt((K/P1)/(4+(K/P1)));\n",
      "T1 = 318.; T2 = 298.;\n",
      "R = 8.3143; K1 = 0.664; K2 = 0.141;\n",
      "dH = 2.30*R*((T1*T2)/(T1-T2))*(math.log(K1/K2));\n",
      "\n",
      "# Results\n",
      "print \"K is\",round(K,4),\"atm\"\n",
      "print \"epislon is \",round(eps_e_1,3)\n",
      "print \"The heat of reaction is\",round(dH,0),\"kJ/kg mol\"\n",
      "\n",
      "# note : book answer is wrong. please check."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "K is 0.3145 atm\n",
        "epislon is  0.612\n",
        "The heat of reaction is 140399.0 kJ/kg mol\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 16.3 Page No : 659"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "v1 = 1.\n",
      "v2 = v1; \n",
      "v3 = v2; \n",
      "v4 = v2;\n",
      "e = 0.56; \t\t\t# Degree of reaction\n",
      "P = 1.; \t\t\t# Dummy\n",
      "T = 1200.\n",
      "R = 8.3143;\n",
      "\n",
      "# Calculation\n",
      "x1 = (1-e)/2; x2 = (1-e)/2;\n",
      "x3 = e/2; x4 = e/2;\n",
      "K = (((x3**v3)*(x4**v4))/((x1**v1)*(x2**v2)))*P**(v3+v4-v1-v2); \t\t\t# Equillibrium consmath.tant\n",
      "dG = -R*T*math.log(K);\n",
      "\n",
      "# Results\n",
      "print \"Equillibrium constant is\",round(K,2)\n",
      "print \"Gibbs function change is\",round(dG,1),\"J/gmol\"\n",
      "\n",
      "# note : rounding off error is there."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Equillibrium constant is 1.62\n",
        "Gibbs function change is -4812.2 J/gmol\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 16.5 Page No : 662"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "Veo = 1.777; \t\t\t# Ve/Vo\n",
      "e = 1-Veo; \t\t\t# Degree of dissociation\n",
      "P = 0.124; \t\t\t# in atm\n",
      "\n",
      "# Calculation\n",
      "K = (4*e**2*P)/(1-e**2);\n",
      "\n",
      "# Results\n",
      "print \"The value of equillibrium constant is\",round(K,3),\"atm\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of equillibrium constant is 0.756 atm\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 16.6 Page No : 663"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "v1 = 1.; \n",
      "v2 = 0.; \n",
      "v3 = 1.; v4 = 1./2;\n",
      "dH = 250560.; e = 3.2e-03;\n",
      "R = 8.3143; T = 1900.;\n",
      "\n",
      "# Calculation\n",
      "Cp = ((dH**2)*(1+e/2)*e*(1+e))/(R*T**2*(v1+v2)*(v3+v4));\n",
      "\n",
      "# Results\n",
      "print \"Cp is\",round(Cp,3),\"j/gmol K\"\n",
      "\n",
      "# note : rounding off error."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Cp is 4.484 j/gmol K\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 16.7 Page No : 663"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "a = 21.89;\n",
      "y = 18.5;\n",
      "x = 8.9;\n",
      "\n",
      "# Calculation\n",
      "PC = 100.*(x*12.)/((8.9*12)+(18.5*1));\n",
      "PH = 100-PC;\n",
      "AFR = ((32*a)+(3.76*a*28))/((12*x)+y);\n",
      "EAU = (8.8*32)/((21.89*32)-(8.8*32));\n",
      "\n",
      "# Results\n",
      "print \"carbon = \",round(PC,2),\"% and Hydrogen = \",round(PH,2),\"%\"\n",
      "print \"Air fuel ratio is\",round(AFR,0)\n",
      "print \"Percentage of excess air used is\",round((EAU*100),2),\"%\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "carbon =  85.24 % and Hydrogen =  14.76 %\n",
        "Air fuel ratio is 24.0\n",
        "Percentage of excess air used is 67.23 %\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 16.8 Page No : 664"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "hf_co2 = -393522;\n",
      "hf_h20 = -285838;\n",
      "hf_ch4 = -74874;\n",
      "\n",
      "# Calculation\n",
      "D = hf_co2 + (2*hf_h20);\n",
      "QCV = D - (hf_ch4+1);\n",
      "\n",
      "# Results\n",
      "print \"Heat transfer per kg mol of fuel is\",D,\"kJ\"\n",
      "print \"Qcv = %.f kJ\"%QCV\n",
      "\n",
      "# note : rounding off error."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Heat transfer per kg mol of fuel is -965198 kJ\n",
        "Qcv = -890325 kJ\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 16.9 Page No : 664"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Below values are taken fron table 16.4\n",
      "\n",
      "# Variables\n",
      "Hr = -249952.+(18.7*560)+(70*540);\n",
      "Hp = 8.*(-393522.+20288)+9*(-241827+16087)+6.25*14171+70*13491;\n",
      "Wcv = 150.; \t\t\t# Energy out put from engine in kW\n",
      "Qcv = -205.; \t\t\t# Heat transfer from engine in kW\n",
      "\n",
      "# Calculation\n",
      "n = (Wcv-Qcv)*3600/(Hr-Hp);\n",
      "\n",
      "# Results\n",
      "print \"Fuel consumption rate is\",round((n*114),1),\"kg/h\"\n",
      "\n",
      "# rounding error is there."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Fuel consumption rate is 38.5 kg/h\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 16.10 Page No : 665"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from numpy import interp\n",
      "\n",
      "# Variables\n",
      "Hr1 = -249952.; \t\t\t# For ocmath.tane\n",
      "Hp1 = Hr1;\n",
      "# Below values are calculated umath.sing value fron table 16.4\n",
      "T2 = 1000.; \n",
      "Hp2 = -1226577.\n",
      "T3 = 1200.;\n",
      "Hp3 = 46537.;\n",
      "T4 = 1100.;\n",
      "Hp4 = -595964.;\n",
      "\n",
      "# Calculation\n",
      "Hp = [Hp2 ,Hp3, Hp4]\n",
      "T = [T2 ,T3, T4]\n",
      "T1 = interp(Hp1,Hp , T); \t\t\t# Interpolation to find temperature at Hp1\n",
      "\n",
      "# Results\n",
      "print \"the adeabatic flame temperature is\",T1,\"K\"\n",
      "\n",
      "# note : answer varies because the method - interp gives some different answer. please check."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "the adeabatic flame temperature is 1100.0 K\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 16.11 Page No : 666"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "T0 = 298.;\n",
      "Wrev = -23316-3*(-394374)-4*(-228583);\n",
      "Wrev_ = Wrev/44.; \t\t\t# in kJ/kg\n",
      "Hr = -103847.;\n",
      "T = 980.; \t\t\t# Through trial and error\n",
      "\n",
      "# Calculation\n",
      "Sr = 270.019+20*205.142+75.2*191.611;\n",
      "Sp = 3*268.194 + 4*231.849 + 15*242.855 + 75.2*227.485;\n",
      "IE = Sp-Sr; \t\t\t# Increase in entropy\n",
      "I = T0*3699.67/44;\n",
      "Si = Wrev_ - I;\n",
      "\n",
      "# Results\n",
      "print \"Reversible work is\",Wrev_,\"kJ/kg\"\n",
      "print \"Increase in entropy during combustion is\",round(Sp-Sr,2),\"kj/kg mol K\"\n",
      "print \"Irreversibility of the process\",round(I,0),\"kJ/kg\"\n",
      "print \"Availability of products of combustion is\",round(Si,1),\"kJ/kg\"\n",
      "\n",
      "# note : there are rounding off errors. please check."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Reversible work is 47139.5 kJ/kg\n",
        "Increase in entropy during combustion is 3699.67 kj/kg mol K\n",
        "Irreversibility of the process 25057.0 kJ/kg\n",
        "Availability of products of combustion is 22082.6 kJ/kg\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 16.12 Page No : 667"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "# Variables\n",
      "T0 = 298.15; P0 = 1; R = 8.3143;\n",
      "xn2 = 0.7567\n",
      "xo2 = 0.2035\n",
      "xh2o = 0.0312\n",
      "xco2 = 0.0003;\n",
      "\n",
      "# Calculation and Results\n",
      "# Part (a)\n",
      "g_o2 = 0; g_c = 0; g_co2 = -394380; \n",
      "A = -g_co2 + R*T0*math.log(xo2/xco2);\n",
      "print \"The chemical energy of carbon is\",round(A,0),\"kJ/k mol\"\n",
      "\n",
      "# Part (b)\n",
      "g_h2 = 0; g_h2o_g = -228590;\n",
      "B = g_h2 + g_o2/2 - g_h2o_g + R*T0*math.log(xo2**0.5/xh2o);\n",
      "print \"The chemical energy of hydrogen is\",round(B,0),\"kJ/k mol\"\n",
      "\n",
      "# Part (c)\n",
      "g_ch4 = -50790;\n",
      "C = g_ch4 + 2*g_o2 - g_co2 - 2*g_h2o_g + R*T0*math.log((xo2**2)/(xco2*xh2o));\n",
      "print \"The chemical energy of methane is\",round(C,0),\"kJ/k mol\"\n",
      "\n",
      "# Part (d)\n",
      "g_co = -137150;\n",
      "D =  g_co + g_o2/2 - g_co2 + R*T0*math.log((xo2**0.5)/xco2);\n",
      "print \"The chemical energy of Carbonmonoxide is\",round(D,0),\"kJ/k mol\"\n",
      "\n",
      "# Part (e)\n",
      "g_ch3oh = -166240;\n",
      "E = g_ch3oh + 1.5*g_o2 - g_co2 - 2*g_h2o_g + R*T0*math.log((xo2**1.5)/(xco2*(xh2o**2)))\n",
      "print \"The chemical energy of methanol is\",round(E,0),\"kJ/k mol\"\n",
      "\n",
      "# Part (f)\n",
      "F = R*T0*math.log(1./xn2);\n",
      "print \"The chemical energy of nitrogen is\",round(F,1),\"kJ/k mol\"\n",
      "\n",
      "# Part (g)\n",
      "G = R*T0*math.log(1./xo2);\n",
      "print \"The chemical energy of Oxygen is\",round(G,0),\"kJ/k mol\"\n",
      "\n",
      "# Part (h)\n",
      "H = R*T0*math.log(1./xco2);\n",
      "print \"The chemical energy of carbondioxide is\",round(H,0),\"kJ/k mol\"\n",
      "\n",
      "# Part (i)\n",
      "g_h2o_l = -237180;\n",
      "I = g_h2o_l - g_h2o_g + R*T0*math.log(1./xh2o);\n",
      "print \"The chemical energy of water is\",round(I,1),\"kJ/k mol\"\n",
      "\n",
      "\n",
      "# note : rounding off error is there. please check."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The chemical energy of carbon is 410542.0 kJ/k mol\n",
        "The chemical energy of hydrogen is 235212.0 kJ/k mol\n",
        "The chemical energy of methane is 821580.0 kJ/k mol\n",
        "The chemical energy of Carbonmonoxide is 275365.0 kJ/k mol\n",
        "The chemical energy of methanol is 716699.0 kJ/k mol\n",
        "The chemical energy of nitrogen is 691.1 kJ/k mol\n",
        "The chemical energy of Oxygen is 3947.0 kJ/k mol\n",
        "The chemical energy of carbondioxide is 20108.0 kJ/k mol\n",
        "The chemical energy of water is 5.2 kJ/k mol\n"
       ]
      }
     ],
     "prompt_number": 23
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 16.13 Page No : 669"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "b = 8./(0.114+0.029); \t\t\t# By carbon balance\n",
      "C = 18./2            \t\t\t# By hydrogen balance\n",
      "a = b*0.114 + (b/2)*0.029 + b*0.016 + C/2 ; \t\t\t# By oxygen balance\n",
      "Wcv = 1. \t\t\t# Power developed by engine in kW \n",
      "\n",
      "# Calculation and Results\n",
      "n_fuel = (0.57*1)/(3600*114.22);\n",
      "Qcv = Wcv-n_fuel*3845872; \t\t\t# 5.33 \n",
      "print \"The rate of heat transfer from the engine is\",round(Qcv,2),\"kW\"\n",
      "# Part (b)\n",
      "ach = 5407843.; \t\t\t# chemical energy of liquid ocmath.tane\n",
      "n2 = Wcv/(n_fuel*ach);\n",
      "print \"The second law efficiency is\",round((n2*100),1),\"%\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The rate of heat transfer from the engine is -4.33 kW\n",
        "The second law efficiency is 13.3 %\n"
       ]
      }
     ],
     "prompt_number": 25
    }
   ],
   "metadata": {}
  }
 ]
}