{
 "metadata": {
  "name": "",
  "signature": "sha256:694b356fc4f85fd8aa841dd0d02eae327738df2eb161cb913631664ccceb9a07"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 4 : principles of energy analysis"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.1 pg : 79"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\t\t\t\n",
      "# Variables\n",
      "m = 1.\n",
      "he = 1148.8 \t\t\t#B/lbm\n",
      "hi = 1357. \t\t\t#B/lbm\n",
      "Ve = 100. \t\t\t#ft/sec\n",
      "Vi = 800. \t\t\t#ft/sec\n",
      "\t\t\t\n",
      "# Calculations\n",
      "dW =  m*(he-hi) + m*(Ve**2 - Vi**2)/(2*32.2*778)\n",
      "dWhr = dW*3600\n",
      "hp = -dWhr/2545.\n",
      "\t\t\t\n",
      "# Results\n",
      "print \"Horsepower output  =  %d hp\"%(hp+1)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Horsepower output  =  313 hp\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.2 pg:79"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\t\t\t\n",
      "# Variables\n",
      "rate = 80. \t\t\t#lbm/min\n",
      "T1 = 100. \t\t\t#F\n",
      "P1 = 100. \t\t\t#psia\n",
      "P2 = 1000. \t\t\t#psia\n",
      "\t\t\t\n",
      "# Calculations\n",
      "v = 0.01613 \t\t\t#ft**3/lbm\n",
      "W = rate*(P2-P1)*144*v\n",
      "\t\t\t\n",
      "# Results\n",
      "print \"Work done  =  %.2f ft-lbf/min\"%(round(W,-3))\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Work done  =  167000.00 ft-lbf/min\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.3 pg : 81"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\t\t\t\n",
      "# Variables\n",
      "hi = 1279.1 \t\t\t#B/lbm\n",
      "\t\t\t\n",
      "# Calculations\n",
      "u2 = hi\n",
      "T2 = 564. \t\t\t#F\n",
      "\t\t\t\n",
      "# Results\n",
      "print \"Temperature of steam  =  %d F\"%(T2)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Temperature of steam  =  564 F\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.4 pg : 82"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\t\t\t\n",
      "# Variables\n",
      "import math \n",
      "P1 = 20. \t\t\t#psia\n",
      "P2 = 100. \t\t\t#psia\n",
      "V = 3. \t    \t\t#ft**3\n",
      "T = 560. \t\t\t#R\n",
      "ma = 0.289\n",
      "\t\t\t\n",
      "# Calculations\n",
      "ma = P1*V/(53.35*T)\n",
      "Wa = -ma*53.35*T*math.log(P1/P2)\n",
      "Qa = -Wa\n",
      "Va2 = 3/5.\n",
      "V2s = V-Va2\n",
      "hi = 1279.1 \t\t\t#B/lbm\n",
      "T2s = 536. \t\t\t#F\n",
      "\t\t\t\n",
      "# Results\n",
      "print \"Final temperature  =  %d F\"%(T2s)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Final temperature  =  536 F\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.5 pg : 87"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "# Variables\n",
      "P1 = 200. \t\t\t#psia\n",
      "P2 = 100. \t\t\t#psia\n",
      "T1 = 300.+460 \t\t\t#R\n",
      "g = 1.4\n",
      "cp = 0.24\n",
      "\t\t\t\n",
      "# Calculations\n",
      "T2 = (T1)*(P2/P1)**((g-1)/g)\n",
      "V2 = math.sqrt(2*32.2*778*cp*(T1-T2))\n",
      "\t\t\t\n",
      "# Results\n",
      "print \"Final velocity   =  %d ft/sec\"%(V2)\n",
      "\n",
      "# check answer using calculator"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Final velocity   =  1281 ft/sec\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.6 pg : 88"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\t\t\t\n",
      "# Variables\n",
      "T1 = 500.+460 \t\t\t#R\n",
      "P1 = 50. \t\t\t#psia\n",
      "P2 = 15. \t\t\t#psia\n",
      "g = 1.4\n",
      "cp = 0.24\n",
      "\t\t\t\n",
      "# Calculations\n",
      "T2 = T1*(P2/P1)**((g-1)/g)\n",
      "W = cp*(T2-T1) + (T1-460)**2 /(2*32.2*778)\n",
      "\t\t\t\n",
      "# Results\n",
      "print \"Net work output from turbine  =  %.1f B/lbm\"%(W)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Net work output from turbine  =  -62.1 B/lbm\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.7 pg : 91"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\t\t\t\n",
      "# Variables\n",
      "T1 = 150.+460 \t\t\t#R\n",
      "T1 = 40.+460 \t\t\t#R\n",
      "\t\t\t\n",
      "# Calculations\n",
      "h2 = 43.850 \t\t\t#B/lbm\n",
      "hf2 = 17.273\n",
      "hfg2 = 64.163\n",
      "x2 = (h2-hf2)/hfg2\n",
      "\t\t\t\n",
      "# Results\n",
      "print \"Quality of freon vapor  =  %.3f\"%(x2)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Quality of freon vapor  =  0.414\n"
       ]
      }
     ],
     "prompt_number": 9
    }
   ],
   "metadata": {}
  }
 ]
}