{
 "metadata": {
  "name": "",
  "signature": "sha256:48ba3152e0507fdec1fb7b61f0c70216b3a6f652a3d1e87f4355bb850157326b"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 20 - Vapor Power Cycles"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1 - Pg 420"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the thermal efficiency in both cases\n",
      "#Initalization of variables\n",
      "Qs=825.1 #Btu/lb\n",
      "ds=0.9588\n",
      "t1=101.74 #F\n",
      "th=400.95 #F\n",
      "#calculations\n",
      "Qr=ds*(t1+459.69)\n",
      "work=Qs-Qr\n",
      "eta=work/Qs*100.\n",
      "eta2=(th-t1)/(th+459.69) *100.\n",
      "#results\n",
      "print '%s %.2f %s' %(\"In case 1, Thermal efficiency =\",eta,\"percent\")\n",
      "print '%s %.2f %s' %(\"\\n In case 2, Thermal efficiency =\",eta2,\" percent\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "In case 1, Thermal efficiency = 34.76 percent\n",
        "\n",
        " In case 2, Thermal efficiency = 34.77  percent\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2 - Pg 425"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the thermal efficiency in both cases\n",
      "#Initalization of variables\n",
      "s2=1.5263\n",
      "sfg=1.8456\n",
      "sf=1.9782 \n",
      "h2=1201.1 #Btu/lb\n",
      "hf=1106 #Btu/lb\n",
      "hfg=1036.3 #Btu/lb\n",
      "v=0.01616 #m^3/kg\n",
      "p2=250 #psia\n",
      "p1=1#psia\n",
      "J=778\n",
      "#calculations\n",
      "x3=1+ (s2-sf)/sfg\n",
      "h3=hf-(1-x3)*hfg\n",
      "h4=69.7\n",
      "Wp=v*144*(p2-p1)/J\n",
      "h1=h4+Wp\n",
      "etat=((h2-h3)-Wp)/(h2-h1) *100.\n",
      "eta2=(h2-h3)/(h2-h4)*100.\n",
      "#results\n",
      "print '%s %.2f %s' %(\"\\n In case 1, Efficieny =\",etat,\"percent\")\n",
      "print '%s %.2f %s' %(\"\\n In case 2, Efficieny =\",eta2,\"percent\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        " In case 1, Efficieny = 30.79 percent\n",
        "\n",
        " In case 2, Efficieny = 30.83 percent\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3 - Pg 428"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the steam rate, enthalpy of exhaust steam, internal engine efficiency and excess heat removed\n",
      "#Initalization of variables\n",
      "p=40000 #kW\n",
      "ef=0.98\n",
      "rate=302000. #lb\n",
      "s3=1.6001\n",
      "h2=1490.1\n",
      "loss=600.\n",
      "v=400. #ft/s\n",
      "g=32.2 #ft/s^2\n",
      "J=778.\n",
      "#calculations\n",
      "out=p/(0.746*ef)\n",
      "srate=rate/out\n",
      "X=-(s3-1.9782)/1.8456\n",
      "h3=1106 - X*1036.3\n",
      "theoturb=h2-h3\n",
      "intturb=(out+loss)*2544/rate\n",
      "Ie=intturb/theoturb *100\n",
      "h3d=h2-intturb-v*v /(2*g*J)\n",
      "hexa=h3d+ v*v /(2*g*J)\n",
      "excess=rate*(hexa-h3)\n",
      "#results\n",
      "print '%s %.2f %s' %(\"Steam rate =\",srate,\"lb/shaft hp-hr\")\n",
      "print '%s %.1f %s' %(\"\\n Internal engine efficiency =\",Ie,\" percent\")\n",
      "print '%s %.1f %s' %(\"\\n Enthalpy of exhaust steam =\",h3d,\" Btu/lb\")\n",
      "print '%s %d %s' %(\"\\n Excess heat to be removed =\",excess,\"Btu/hr\")\n",
      "print '%s' %(\"The answers are a bit different due to rounding off error in textbook\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Steam rate = 5.52 lb/shaft hp-hr\n",
        "\n",
        " Internal engine efficiency = 78.1  percent\n",
        "\n",
        " Enthalpy of exhaust steam = 1021.0  Btu/lb\n",
        "\n",
        " Excess heat to be removed = 39395745 Btu/hr\n",
        "The answers are a bit different due to rounding off error in textbook\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4 - Pg 436"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the thermal efficiency\n",
      "#Initalization of variables\n",
      "s2=1.5263\n",
      "sf=1.6993\n",
      "sfg=1.3313\n",
      "hf=1164.1 #Btu/lb\n",
      "hfg=945.3 #Btu/lb\n",
      "h2=1201.1 #Btu/lb\n",
      "h1=852.3 #Btu/lb\n",
      "#calculations\n",
      "X3=-(s2-sf)/sfg\n",
      "h3=hf-X3*hfg\n",
      "h4=218.82\n",
      "h6=h4\n",
      "h5=69.7\n",
      "x=(h4-h5)/(h3-h5)\n",
      "W= h2-h3+ (1-x)*(h3-h1)\n",
      "Qs=h2-h4\n",
      "eff=W/Qs *100\n",
      "#results\n",
      "print '%s %.2f %s' %(\"Thermal efficiency =\",eff,\"percent\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Thermal efficiency = 32.56 percent\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5 - Pg 442"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the thermal efficiency\n",
      "#Initalization of variables\n",
      "h6=157.933 #Btu/lb\n",
      "s2=0.11626\n",
      "sf=0.16594\n",
      "sfg=0.14755\n",
      "hf=139.095 #Btu/lb\n",
      "hfg=126.98 #Btu/lb\n",
      "h5=12.016 #Btu/lb\n",
      "h2=1201.1 #Btu/lb\n",
      "h1=69.7  #Btu/lb\n",
      "w=348.8 #Btu/lb\n",
      "m=0.0745 #lb\n",
      "#calculations\n",
      "x7=-(s2-sf)/sfg\n",
      "h7=hf-x7*hfg\n",
      "dh6=h6-h7\n",
      "mr=(h7-h5)/(h2-h1)\n",
      "work=w*m\n",
      "tw=work+dh6\n",
      "dh65=h6-h5\n",
      "eff=tw/dh65 *100\n",
      "#results\n",
      "print '%s %.2f %s' %(\"Thermal efficiency =\",eff,\"percent\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Thermal efficiency = 60.02 percent\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6 - Pg 443"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the available portion of heat transferred\n",
      "#Initalization of variables\n",
      "import math\n",
      "m=1 #lb\n",
      "cp=0.26\n",
      "t2=1800+460. #R\n",
      "t1=400.95+460 #R\n",
      "x=0.6\n",
      "sink=100+460. #R\n",
      "tm=2600+460. #R\n",
      "#calculations\n",
      "Q=m*cp*(t2-t1)\n",
      "ds=m*cp*math.log((t2/t1))\n",
      "tds=ds*(sink)\n",
      "avail=Q-tds\n",
      "hf=Q*x/(1-x)\n",
      "av2=hf*(tm-sink)/(tm)\n",
      "Qt=Q+hf\n",
      "av=avail+av2\n",
      "per=av/Qt *100.\n",
      "#results\n",
      "print '%s %.1f %s' %(\"Available portion of heat transferred =\",per,\"percent\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Available portion of heat transferred = 73.6 percent\n"
       ]
      }
     ],
     "prompt_number": 6
    }
   ],
   "metadata": {}
  }
 ]
}