{
 "metadata": {
  "name": "",
  "signature": "sha256:82090567853b966deac889dc0128f75e1e99033e5ed66e328546471b278bffea"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 12 :\n",
      "conventional power and\n",
      "refrigeration cycles"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 12.1 pg : 321"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\t\t\t\n",
      "# Variables\n",
      "h1 = 1357. \t\t\t#500 psia, 700 F\n",
      "h2 = 935. \t\t\t#P2 = 2 psia\n",
      "h3 = 93.99 \t\t\t#sat liq at 2 psia\n",
      "vf = 0.01613\n",
      "P4 = 500. \t\t\t#psia\n",
      "P3 = 2. \t\t\t#psia\n",
      "\t\t\t\n",
      "# Calculations\n",
      "dh4 = vf*(P4-P3)*144/778.\n",
      "h4 = h3+dh4\n",
      "eta =  ((h1-h2)-(h4-h3))/(h1-h4)\n",
      "\t\t\t\n",
      "# Results\n",
      "print \"Thermal efficiency  =  %.1f percent \"%(eta*100)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Thermal efficiency  =  33.3 percent \n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 12.2 pg : 323"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\t\t\t\n",
      "# Variables\n",
      "h1 = 1357. \t\t\t#500 psia 700F\n",
      "h2 = 1194. \t\t\t#P2 = 100 psia\n",
      "h3 = 1379. \t\t\t#100 psia, 700 F\n",
      "h4 = 1047. \t\t\t#p4 = 2 psia\n",
      "h5 = 93.99 \t\t\t#sat liq at 2 psia\n",
      "h6 = 95.02 \t\t\t#example 12.1\n",
      "\t\t\t\n",
      "# Calculations\n",
      "W = h1-h2+h3-h4-(h6-h5)\n",
      "Q = (h1-h6)+(h3-h2)\n",
      "eta = W/Q\n",
      "\t\t\t\n",
      "# Results\n",
      "print \"Thermal efficiency  =  %.2f percent\"%(eta*100)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Thermal efficiency  =  34.14 percent\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 12.3 pg : 327"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\t\t\t\n",
      "# Variables\n",
      "P = 100. \t\t\t#psia\n",
      "\t\t\t\n",
      "# Calculations\n",
      "h1 = 1357. \t\t\t#500 psia, 700F\n",
      "h2 = 1194. \t\t\t#100 psia\n",
      "h3 = 935.\t\t\t#2 psia\n",
      "h4 = 93.99 \t\t\t#sat liq at 2 psia\n",
      "vf = 0.01613 \n",
      "vf2 = 0.01774\n",
      "P5 = 100. \t\t\t#psia\n",
      "P4 = 2. \t\t\t#psia\n",
      "dh4 = vf*(P5-P4)*144/778.\n",
      "h5 = h4+dh4\n",
      "h6 = 298.4\n",
      "P7 = 500. \t\t\t#psia\n",
      "P6 = 100. \t\t\t#psia\n",
      "dh6 = vf2*(P7-P6)*144./778\n",
      "h7 = dh6+h6\n",
      "m = (h6-h5)/(h2-h5)\n",
      "W = h1-h2 + (1-m)*(h2-h3) - (1-m)*(h5-h4) -(h7-h6)\n",
      "Q = h1-h7\n",
      "etath = W/Q\n",
      "\t\t\t\n",
      "# Results\n",
      "print \"Thermal efficiency  =  %.1f percent\"%(etath*100)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Thermal efficiency  =  35.2 percent\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 12.4 pg : 330"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\t\t\t\n",
      "# Variables\n",
      "x = 0.8\n",
      "\t\t\t\n",
      "# Calculations\n",
      "h1 = 1357. \t\t\t#500 psia 700F\n",
      "h2 = 1194. \t\t\t#P2 = 100 psia\n",
      "h3 = 1379. \t\t\t#100 psia, 700 F\n",
      "h4 = 1047. \t\t\t#p4 = 2 psia\n",
      "h5 = 93.99 \t\t\t#sat liq at 2 psia\n",
      "h6 = 95.02 \t\t\t#example 12.1\n",
      "h2d = h1- x*(h1-h2) \n",
      "h4d = h3- x*(h3-h4)\n",
      "W = (h1-h2d) +(h3-h4d) - (h6-h5)\n",
      "Q = (h1-h6) + (h3-h2d)\n",
      "eta = W/Q\n",
      "\t\t\t\n",
      "# Results\n",
      "print \"Thermal efficiency  =  %d percent\"%(eta*100+1)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Thermal efficiency  =  28 percent\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 12.5 pg : 335"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\t\t\t\n",
      "# Variables\n",
      "P4 = 50. \t\t\t#psia\n",
      "P1 = 14.7 \t\t\t#psia\n",
      "P3 = 50. \t\t\t#psia\n",
      "P2 = 14.7 \t\t\t#psia\n",
      "g = 1.4\n",
      "\t\t\t\n",
      "# Calculations\n",
      "V1r = (P4/P1)**(1/g)\n",
      "V2r = (P3/P2)**(1/g)\n",
      "#After solving,\n",
      "V4 = 5.38    \t\t\t#ft**3/min\n",
      "V1 = 12.9 \t    \t\t#ft**3/min\n",
      "V2 = 112.9  \t\t\t#ft**3/min\n",
      "PD = V2-V4\n",
      "etavol = (V2-V1)/(V2-V4)\n",
      "W32 = g*P2*144*V2*((P3/P2)**((g-1)/g) -1 ) /(1-g)\n",
      "W41 = g*P4*144*V4*((P1/P4)**((g-1)/g) -1 ) /(1-g)\n",
      "Wt = W32+W41\n",
      "\t\t\t\n",
      "# Results\n",
      "print \"Total work  =  %.2e ft-lbf /min\"%(Wt)\n",
      "\t\t\t#The answer given in textbook is wrong . please verify it umath.sing a calculator\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Total work  =  -3.10e+05 ft-lbf /min\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 12.6 pg : 337"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\t\t\t\n",
      "# Variables\n",
      "import math \n",
      "P1 = 14.7 \t\t\t#psia\n",
      "P4 = 100. \t\t\t#psia\n",
      "T1 = 530. \t\t\t#R\n",
      "T3 = T1\n",
      "g = 1.4\n",
      "m = 10. \t\t\t#lbm\n",
      "cp = 0.24\n",
      "\t\t\t\n",
      "# Calculations\n",
      "P2 = math.sqrt(P1*P4)\n",
      "T2 = T1*(P2/P1)**((g-1)/g)\n",
      "T4 = T2\n",
      "W = 2*cp*(T2-T1)\n",
      "Wt = W*m\n",
      "hp = Wt*60./2545\n",
      "Q = m*cp*(T2-T3)\n",
      "T4 = T1*(P4/P1)**((g-1)/g)\n",
      "W2 = m*cp*(T4-T1)\n",
      "\t\t\t\n",
      "# Results\n",
      "print \"Work required in case 1   =  %d Btu/min\"%(Wt+1)\n",
      "print \" Work required in case 2  =  %d Btu/min\"%(W2+1)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Work required in case 1   =  802 Btu/min\n",
        " Work required in case 2  =  928 Btu/min\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 12.7 pg : 342"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\t\t\t\n",
      "# Variables\n",
      "g = 1.4\n",
      "r1 = 10.\n",
      "r2 = 12.\n",
      "r3 = 15.\n",
      "Tl = 530. \t\t\t#R\n",
      "Th = 1960. \t\t\t#R\n",
      "\t\t\t\n",
      "# Calculations\n",
      "eta1 = 1- (r1)**(1-g)\n",
      "eta2 = 1- (r2)**(1-g)\n",
      "eta3 = 1- (r3)**(1-g)\n",
      "etac = 1-Tl/Th\n",
      "\t\t\t\n",
      "# Results\n",
      "print \"Efficiency in case 1  =  %.1f percent\"%(eta1*100)\n",
      "print \" Efficiency in case 2  =  %.1f percent\"%(eta2*100)\n",
      "print \" Efficiency in case 3  =  %.1f percent\"%(eta3*100)\n",
      "print \" Carnot efficiency  =  %.f percent\"%(etac*100)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Efficiency in case 1  =  60.2 percent\n",
        " Efficiency in case 2  =  63.0 percent\n",
        " Efficiency in case 3  =  66.1 percent\n",
        " Carnot efficiency  =  73 percent\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 12.8 pg : 344"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\t\t\t\n",
      "# Variables\n",
      "T1 = 70.+460 \t\t\t#R\n",
      "P1 = 14.7 \t\t\t#psia\n",
      "g = 1.4\n",
      "r = 15.\n",
      "rc = 2.\n",
      "cp = 0.24\n",
      "cp2 = 0.1715\n",
      "\t\t\t\n",
      "# Calculations\n",
      "T2 = T1*(r)**(g-1)\n",
      "T3 = rc*T2\n",
      "T4 = T3*(rc/r)**(g-1)\n",
      "Qh = cp*(T3-T2)\n",
      "Ql = cp2*(T4-T1)\n",
      "W = Qh-Ql\n",
      "eta = W/Qh\n",
      "\t\t\t\n",
      "# Results\n",
      "print \"Work output  =  %.f B/lbm\"%(W)\n",
      "print \" Efficiency  =  %.1f percent\"%(eta*100)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Work output  =  227 B/lbm\n",
        " Efficiency  =  60.4 percent\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 12.9 pg : 351"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\t\t\t\n",
      "# Variables\n",
      "P1 = 14.7 \t\t\t#psia\n",
      "P4 = 14.7 \t\t\t#psia\n",
      "T1 = 530. \t\t\t#R\n",
      "T3 = 1960. \t\t\t#R\n",
      "P2 = 60. \t\t\t#psia\n",
      "P3 = P2\n",
      "g = 1.4\n",
      "eta1 = 0.85\n",
      "eta2 = 0.9\n",
      "\t\t\t\n",
      "# Calculations\n",
      "T2 = T1*(P2/P1)**((g-1)/g)\n",
      "T4 = T3*(P4/P3)**((g-1)/g)\n",
      "T2d = (T2-T1)/eta1 + T1\n",
      "T4d = -eta2*(T3-T4) +T3\n",
      "Wact = 0.24*(T3-T4d - (T2d-T1))\n",
      "Qh = 0.24*(T3-T2d)\n",
      "etath = Wact/Qh\n",
      "\t\t\t\n",
      "# Results\n",
      "print \"Thermal efficiency  =  %.1f percent\"%(etath*100)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Thermal efficiency  =  24.5 percent\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 12.10 pg : 352"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\t\t\t\n",
      "# Variables\n",
      "e = 0.83\n",
      "\t\t\t\n",
      "# Calculations\n",
      "T1 = 530. \t\t\t#R\n",
      "T2d = 838. \t\t\t#R\n",
      "T6d = T2d\n",
      "T3 = 1960. \t\t\t#R\n",
      "T4d = 1375. \t\t\t#R\n",
      "T5d = T4d\n",
      "T5 = e*(T5d-T2d) +T2d\n",
      "W = 0.24*((T3-T4d)- (T2d-T1))\n",
      "Q = 0.24*(T3-T5)\n",
      "eta = W/Q\n",
      "\t\t\t\n",
      "# Results\n",
      "print \"Thermal efficiency  =  %d percent\"%(eta*100+1)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Thermal efficiency  =  41 percent\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 12.11 pg : 354"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\t\t\t\n",
      "# Variables\n",
      "import math \n",
      "T1 = 420. \t\t\t#R\n",
      "T11 = 530. \t\t\t#R\n",
      "T3 = 2460. \t\t\t#R\n",
      "V1 = 300. \t\t\t#ft/sec\n",
      "P1 = 5. \t\t\t#psia\n",
      "P5 = P1\n",
      "P2 = 50. \t\t\t#psia\n",
      "P3 = 5. \t\t\t#psia\n",
      "P4 = 50. \t\t\t#psia\n",
      "g = 1.4\n",
      "cp = 0.24\n",
      "m = 1.\n",
      "\t\t\t\n",
      "# Calculations\n",
      "T2 = T1*(P2/P1)**((g-1)/g)\n",
      "T4 = T3-T2+T11\n",
      "T5 = T3*(P3/P4)**((g-1)/g)\n",
      "V5 = math.sqrt(2*32.2*cp*(T4-T5)*778)\n",
      "T = m*(V1-V5)/32.2\n",
      "Qh = cp*(T3-T2)\n",
      "P = -T*V1\n",
      "\t\t\t\n",
      "# Results\n",
      "print \"Thrust  =  %.1f lbf\"%(T)\n",
      "print \" Heat input  =  %d B/lbm\"%(Qh)\n",
      "print \" Power  =  %d ft-lbf /sec\"%(round(P,-3))\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Thrust  =  -93.1 lbf\n",
        " Heat input  =  395 B/lbm\n",
        " Power  =  28000 ft-lbf /sec\n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 12.12 pg : 360"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\t\t\t\n",
      "# Variables\n",
      "import math \n",
      "h1 = 80.419 \t\t\t#B/lbm\n",
      "h3 = 36.013 \t\t\t#B/lbm\n",
      "h4 = h3\n",
      "P3 = 172.35 \t\t\t#psia\n",
      "P2 = P3\n",
      "m = 5.       \t\t\t#tons\n",
      "Q = 12000.\n",
      "\t\t\t\n",
      "# Calculations\n",
      "h2 = 91.5 \t\t\t#B/lbm\n",
      "COP = (h1-h4)/(h2-h1)\n",
      "W = h2-h1\n",
      "md = m*Q/(h1-h4)\n",
      "Wt = md*(h2-h1)\n",
      "Wt2 = Wt/2545.\n",
      "\t\t\t\n",
      "# Results\n",
      "print \"Coefficient of performance  =  %.1f\"%(COP)\n",
      "print \" Input work  =  %.1f hp\"%(Wt2)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Coefficient of performance  =  4.0\n",
        " Input work  =  5.9 hp\n"
       ]
      }
     ],
     "prompt_number": 15
    }
   ],
   "metadata": {}
  }
 ]
}