{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h1>Chapter 9: GAS POWER SYSTEMS</h1>"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h2>Example 9.01, page: 228</h2>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "import math\n",
      "\n",
      "# Initialization  of  Variable\n",
      "r = 8 #compression ratio\n",
      "T1 = 540 #degR\n",
      "V1 = 0.02 #ft3\n",
      "T3 = 3600 #degR\n",
      "P1 = 1 #atm\n",
      "R = 1545/28.97 #ft*lbf/lb-degR\n",
      "\n",
      "#calculations:\n",
      "#from Table T-9E\n",
      "u1 = 92.04 #Btu/lb\n",
      "vr1 = 144.32\n",
      "#from isentropic process 1-2\n",
      "vr2 = vr1/r\n",
      "#from Table T-9E\n",
      "T2 = 1212 #degR\n",
      "u2 = 211.3 #Btu/lb\n",
      "#Pressure\n",
      "P2 = P1*T2*r/T1\n",
      "P3 = P2*T3/T2\n",
      "#from Table T-9E\n",
      "u3 = 721.44 #Btu/lb\n",
      "vr3 = 0.6449\n",
      "#from isentropic process 3-4\n",
      "vr4 = vr3*r\n",
      "#from Table T-9E\n",
      "T4 = 1878 #degR\n",
      "u4 = 342.2 #Btu/lb\n",
      "#pressure\n",
      "P4 = P1*T4/T1\n",
      "#Thermal Eff\n",
      "n = 1 - (u4 - u1)/(u3 - u2)\n",
      "#net work per cycle\n",
      "m = P1*14.696*144*V1/(R*T1)\n",
      "Wcycle = m*((u3-u4)-(u2-u1))\n",
      "#mean effective pressure\n",
      "mep = Wcycle/(V1*(1 - 1/r))*778/(144*14.696)\n",
      "\n",
      "#Results\n",
      "print  \"a)pressure and temperature at 2 are\", round(P2,2),\"atm and\", T2,\"degR\"\n",
      "print  \"  pressure and temperature at 3 are\", round(P3,2),\"atm and\", T3,\"degR\"\n",
      "print  \"  pressure and temperature at 4 are\", round(P4,2),\"atm and\", T4,\"degR\"\n",
      "print  \"b)thermal  efficiency  is\", round(n*100,0),\"%\"\n",
      "print  \"c)mean  effective  pressure is\",round(mep,2),\"atm\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "a)pressure and temperature at 2 are 17.96 atm and 1212 degR\n",
        "  pressure and temperature at 3 are 53.33 atm and 3600 degR\n",
        "  pressure and temperature at 4 are 3.48 atm and 1878 degR\n",
        "b)thermal  efficiency  is 51.0 %\n",
        "c)mean  effective  pressure is 8.03 atm\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h2>Example 9.02, page: 232</h2>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "import math\n",
      "\n",
      "# Initialization  of  Variable\n",
      "r = 18 #compression ratio\n",
      "T1 = 300 #K\n",
      "rc = 2 #cut-off ratio\n",
      "P1 = 0.1 #MPa\n",
      "R = 8314/28.97 #J/kg-K\n",
      "\n",
      "#calculations:\n",
      "#from Table T-9\n",
      "u1 = 214.07 #kJ/kg\n",
      "vr1 = 621.2\n",
      "#from isentropic process 1-2\n",
      "vr2 = vr1/r\n",
      "#from Table T-9\n",
      "T2 = 898.3 #K\n",
      "h2 = 930.98 #kJ/kg\n",
      "#Pressure\n",
      "P2 = P1*T2*r/T1\n",
      "P3 = P2\n",
      "#temp\n",
      "T3 = rc*T2\n",
      "#from Table T-9\n",
      "h3 = 1999.1 #kJ/kg\n",
      "vr3 = 0.6449\n",
      "#from isentropic process 3-4\n",
      "vr4 = vr3*r/rc\n",
      "#from Table T-9\n",
      "T4 = 887.7 #degR\n",
      "u4 = 664.3 #kJ/kg\n",
      "#pressure\n",
      "P4 = P1*T4/T1\n",
      "#Thermal Eff\n",
      "n = 1 - (u4 - u1)/(h3 - h2)\n",
      "#net work per cycle per unit mass\n",
      "Wmcycle = (h3-h2)-(u4-u1)\n",
      "#specific vol at 1\n",
      "v1 = R*T1/(P1*1000000)\n",
      "#mean effective pressure\n",
      "mep = Wmcycle/(v1*(1 - 1/r)*1000)\n",
      "\n",
      "#Results\n",
      "print  \"a)pressure and temperature at 2 are\", round(P2,2),\"MPa and\", T2,\"degR\"\n",
      "print  \"  pressure and temperature at 3 are\", round(P3,2),\"MPa and\", T3,\"degR\"\n",
      "print  \"  pressure and temperature at 4 are\", round(P4,2),\"MPa and\", T4,\"degR\"\n",
      "print  \"b)thermal  efficiency  is\", round(n*100,1),\"%\"\n",
      "print  \"c)mean  effective  pressure is\",round(mep,2),\"MPa\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "a)pressure and temperature at 2 are 5.39 MPa and 898.3 degR\n",
        "  pressure and temperature at 3 are 5.39 MPa and 1796.6 degR\n",
        "  pressure and temperature at 4 are 0.3 MPa and 887.7 degR\n",
        "b)thermal  efficiency  is 57.8 %\n",
        "c)mean  effective  pressure is 0.76 MPa\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h2>Example 9.03, page: 238</h2>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "import math\n",
      "\n",
      "# Initialization  of  Variable\n",
      "r = 10 #compression ratio\n",
      "T1 = 300 #K\n",
      "AV1 = 5 #m3/s\n",
      "P1 = 100 #kPa\n",
      "R = 8314/28.97 #J/kg-K\n",
      "\n",
      "#calculations:\n",
      "#from Table T-9\n",
      "h1 = 300.19 #kJ/kg\n",
      "Pr1 = 1.386\n",
      "#reduced pressure at 2\n",
      "Pr2 = r*Pr1\n",
      "#from Table T-9\n",
      "h2 = 579.9 #kJ/kg\n",
      "T3 = 1400 #K\n",
      "h3 = 1515.4 #kJ/kg\n",
      "Pr3 = 450.5\n",
      "#reduced pressure at 4\n",
      "Pr4 = Pr3/r\n",
      "#from Table T-9\n",
      "h4 = 808.5 #kJ/kg\n",
      "\n",
      "#Thermal Eff\n",
      "n = 1 - (h4 - h1)/(h3 - h2)\n",
      "#back work ratio\n",
      "bwr = (h2 - h1)/(h3-h4)\n",
      "#net wpower developed\n",
      "mdot = AV1*P1*1000/(R*T1)\n",
      "Wmcycledot = mdot*((h3-h4)-(h2-h1))\n",
      "\n",
      "#Results\n",
      "print  \"a)thermal  efficiency  is\", round(n*100,1),\"%\"\n",
      "print  \"b)back work ratio is\", round(bwr*100,1),\"%\"\n",
      "print  \"c)mean  effective  pressure is\",round(Wmcycledot,0),\"kW\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "a)thermal  efficiency  is 45.7 %\n",
        "b)back work ratio is 39.6 %\n",
        "c)mean  effective  pressure is 2481.0 kW\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h2>Example 9.04, page: 242</h2>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "import math\n",
      "\n",
      "# Initialization  of  Variable\n",
      "r = 10 #compression ratio\n",
      "T1 = 300 #K\n",
      "AV1 = 5 #m3/s\n",
      "P1 = 100 #kPa\n",
      "R = 8314/28.97 #J/kg-K\n",
      "nt = 0.8\n",
      "nc = nt\n",
      "\n",
      "#calculations:\n",
      "#from Table T-9\n",
      "h1 = 300.19 #kJ/kg\n",
      "Pr1 = 1.386\n",
      "#reduced pressure at 2\n",
      "Pr2 = r*Pr1\n",
      "#from Table T-9\n",
      "h2 = 579.9 #kJ/kg\n",
      "T3 = 1400 #K\n",
      "h3 = 1515.4 #kJ/kg\n",
      "Pr3 = 450.5\n",
      "#reduced pressure at 4\n",
      "Pr4 = Pr3/r\n",
      "#from Table T-9\n",
      "h4 = 808.5 #kJ/kg\n",
      "#turbine work per unit mass\n",
      "Wtmdot = nt*(h3-h4)\n",
      "#Compressor work per unit mass\n",
      "Wcmdot = (h2 - h1)/nc\n",
      "#new enthalpy at 2\n",
      "h2 = h1 + Wcmdot\n",
      "#heat transfer to the working fluid per unit of mass flow\n",
      "Qinmdot = h3 - h2\n",
      "#Thermal Eff\n",
      "n = (Wtmdot - Wcmdot)/Qinmdot\n",
      "#back work ratio\n",
      "bwr = Wcmdot/Wtmdot\n",
      "#net wpower developed\n",
      "mdot = AV1*P1*1000/(R*T1)\n",
      "Wmcycledot = mdot*(Wtmdot - Wcmdot)\n",
      "\n",
      "#Results\n",
      "print  \"a)thermal  efficiency  is\", round(n*100,1),\"%\"\n",
      "print  \"b)back work ratio is\", round(bwr*100,1),\"%\"\n",
      "print  \"c)mean  effective  pressure is\",round(Wmcycledot,0),\"kW\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "a)thermal  efficiency  is 24.9 %\n",
        "b)back work ratio is 61.8 %\n",
        "c)mean  effective  pressure is 1254.0 kW\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h2>Example 9.05, page: 245</h2>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "import math\n",
      "\n",
      "# Initialization  of  Variable\n",
      "nreg = 0.8\n",
      "\n",
      "#calculations:\n",
      "#from Example 9.3\n",
      "h1 = 300.19 #kJ/kg\n",
      "h2 = 579.9 #kJ/kg\n",
      "h3 = 1515.4 #kJ/kg\n",
      "h4 = 808.5 #kJ/kg\n",
      "\n",
      "#specific enthalpy hx\n",
      "hx = nreg*(h4 - h2) + h2\n",
      "\n",
      "#Thermal Eff\n",
      "n = ((h3 - h4) - (h2 - h1))/(h3 - hx)\n",
      "\n",
      "#Results\n",
      "print  \"a)thermal  efficiency  is\", round(n*100,1),\"%\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "a)thermal  efficiency  is 56.8 %\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h2>Example 9.06, page: 247</h2>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "import math\n",
      "\n",
      "# Initialization  of  Variable\n",
      "Pa = 11.8 #lbf/in2\n",
      "Ta = 430 #degR\n",
      "Va = 620 #mi/hr\n",
      "V1 = 0\n",
      "P2P1 = 8 #P2/P1\n",
      "T3 = 2150 #degR\n",
      "P5 = 11.8 #lbf/in2\n",
      "\n",
      "#Calculations:\n",
      "#from Table T-9E\n",
      "ha = 102.7 #Btu/lb\n",
      "h1 = ha + (Va**2)/(2*32.2*778)\n",
      "#\n",
      "Pr1 = 1.051\n",
      "Pra = 0.6268\n",
      "P1 = Pr1*Pa/Pra\n",
      "#\n",
      "P2 = P2P1*P1\n",
      "#\n",
      "Pr2 = Pr1*P2P1\n",
      "h2 = 216.2 #Btu/lb\n",
      "h3 = 546.54 #Btu/lb\n",
      "P3=P2\n",
      "h4 = h3 + h1 - h2\n",
      "#\n",
      "Pr4 = 113.8\n",
      "Pr3 = 233.5\n",
      "P4 = P3*Pr4/Pr3\n",
      "#\n",
      "P5 = Pr4*P5/P4\n",
      "#\n",
      "h5 = 265.8 #Btu/lb\n",
      "V5 = (2*(h4 - h5)*32.2*778)**0.5\n",
      "\n",
      "#Results\n",
      "print  \"Pressure  at 1 is\", round(P1,2),\"lbf/in2\"\n",
      "print  \"Pressure  at 2 is\", round(P2,1),\"lbf/in2\"\n",
      "print  \"Pressure  at 4 is\", round(P4,1),\"lbf/in2\"\n",
      "print  \"velocity  at nozzle exit is\", round(V5,0),\"ft/s\"\n",
      "#answer wrong in book\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Pressure  at 1 is 19.79 lbf/in2\n",
        "Pressure  at 2 is 158.3 lbf/in2\n",
        "Pressure  at 4 is 77.1 lbf/in2\n",
        "velocity  at nozzle exit is 2960.0 ft/s\n"
       ]
      }
     ],
     "prompt_number": 6
    }
   ],
   "metadata": {}
  }
 ]
}