{
 "metadata": {
  "name": "",
  "signature": "sha256:25ad1e2d44436c7f3601ad03c17827fcc9d4a9726e4cce4d60e192c21e28061e"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter6-Combustion Chambers and After burners"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex1-pg309"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#determine number of mole of hydrogen and oxygen\n",
      "nH2=12/2. ##molecular mass og hydrogen =2kg/kmol\n",
      "nO2=8/32. ##Molecular mass of O2=32kg/kmol\n",
      "print'%s %.f %s'%(\"No. of kilomoles of H2\",nH2,\"\")\n",
      "print'%s %.2f %s'%(\"No. of kilomoles of O2\",nO2,\"\")"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "No. of kilomoles of H2 6 \n",
        "No. of kilomoles of O2 0.25 \n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Ex3-pg317"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#calculate lower and higher heating values of hydrogen\n",
      "T=298.16 ##in K\n",
      "dhf=-241827. ##heat of formation of H2O(g in kJ.\n",
      "n=1 ##kmol\n",
      "Qr=n*dhf ##kJ/kmol\n",
      "LHV=(-1.)*Qr/2.\n",
      "print'%s %.1f %s'%(\"LHV in\",LHV,\"kJ/kg\")\n",
      "HHV=LHV+9*2443\n",
      "print'%s %.1f %s'%(\"HHV in \",HHV,\"kJ/kg\")"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "LHV in 120913.5 kJ/kg\n",
        "HHV in  142900.5 kJ/kg\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Ex5-pg320"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#calcualte the ratio Nh2/no2 of the reactants and fuel oxdizer and adiabatic flame temperature\n",
      "##from equation CH4+2.4(O2+3.76N2)-->CO2+2H2O+0.4O2+9.02N2\n",
      "f=(12+4.)/(2.4*(32.+3.76*28.)) ##fuel to air ratio based on mass.\n",
      "fs=(12+4.)/(2.*(32.+3.76*28.)) ##fuel to air ratio based on stoichometric condition.\n",
      "feq=f/fs\n",
      "print'%s %.7f %s'%(\"fuel to air ratio based on mass\",f,\"\")\n",
      "print'%s %.7f %s'%(\"fuel to air ratio based on stoichometric condition\",fs,\"\")\n",
      "print'%s %.7f %s'%(\"Equivalent ratio\",feq,\"\")\n",
      "dH=-802303 ##kJ\n",
      "dC=484.7 ##kJ\n",
      "Dt=(-1)*dH/dC ##Dt=T2-Tf\n",
      "Tf=25+273\n",
      "T2=Dt+Tf\n",
      "print'%s %.4f %s'%(\"The diabatic flame temperature in\",T2,\" K\")"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "fuel to air ratio based on mass 0.0485625 \n",
        "fuel to air ratio based on stoichometric condition 0.0582751 \n",
        "Equivalent ratio 0.8333333 \n",
        "The diabatic flame temperature in 1953.2569  K\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex6-pg323"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#calculate mole fraction of N2 at equlibrium when pm is 1 atm and 10 atms\n",
      "print(\"Example 6.6\")\n",
      "Kp=0.1\n",
      "x=poly(0,\"x\")\n",
      "pm=1\n",
      "y=4*(x)^2*pm-Kp+Kp*(x)^2\n",
      "d=roots(y)\n",
      "for i=1:1:2\n",
      "\n",
      "if real(d(i))>0 then\n",
      "    print(d(i),\"(a)Mole fraction of N2 at equilibrium when pm is 1 atm:\")\n",
      "end\n",
      "end\n",
      "//part (b)\n",
      "Kp=0.1\n",
      "x=poly(0,\"x\")\n",
      "pm=10\n",
      "y=4*(x)^2*pm-Kp+Kp*(x)^2\n",
      "d=roots(y)\n",
      "for i=1:1:2\n",
      "\n",
      "if real(d(i))>0 then\n",
      "    print(d(i),\"(b)Mole fraction of N2 at equilibrium when pm is 10 atm:\")\n",
      "end\n",
      "end\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    }
   ],
   "metadata": {}
  }
 ]
}