{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 15 - Basic Flow equations"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1 - Pg 407"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calcualte the final temperature and pressure of the gas\n",
      "#Initialization of variables\n",
      "print '%s' %(\"From Table B-4,\")\n",
      "h=1187.2 #Btu/lbm\n",
      "t=328. #F\n",
      "#calculations\n",
      "p2=100 #psia\n",
      "u2=1187.2 #Btu/lbm\n",
      "t2=540. #F\n",
      "dt=t2-t\n",
      "#results\n",
      "print '%s %d %s' %(\"Final temperature of steam =\",t2,\"F\")\n",
      "print '%s %d %s' %(\"\\n Final pressure =\",p2,\"psia\")\n",
      "print '%s %d %s' %(\"\\n Change in temperature =\",dt,\"F\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "From Table B-4,\n",
        "Final temperature of steam = 540 F\n",
        "\n",
        " Final pressure = 100 psia\n",
        "\n",
        " Change in temperature = 212 F\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3 - Pg 409"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the work done in the process\n",
      "#Initialization of variables\n",
      "import math\n",
      "p1=100. #psia\n",
      "p2=14.7 #psia\n",
      "k=1.4\n",
      "T1=700. #R\n",
      "R=10.73/29\n",
      "V=50.\n",
      "cv=0.171\n",
      "cp=0.24\n",
      "R2=1.986/29.\n",
      "#calculations\n",
      "T2=T1/ math.pow((p1/p2),((k-1)/k))\n",
      "m1=p1*V/(R*T1)\n",
      "m2=p2*V/(R*T2)\n",
      "Wrev= cv*(m1*T1 - m2*T2) - (m1-m2)*(T2)*cp\n",
      "#results\n",
      "print '%s %d %s' %(\"Work done in case 1 =\",Wrev,\" Btu\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Work done in case 1 = 572  Btu\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4 - Pg 420"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the friction of the process\n",
      "#Initialization of variables\n",
      "import math\n",
      "p1=100. #psia\n",
      "p2=10. #psia\n",
      "n=1.3\n",
      "T1=800. #R\n",
      "cv=0.172\n",
      "R=1.986/29.\n",
      "T0=537. #R\n",
      "cp=0.24\n",
      "#calculations\n",
      "T2=T1*math.pow((p2/p1),((n-1)/n))\n",
      "dwir=cv*(T1-T2)\n",
      "dwr=R*(T2-T1)/(1-n)\n",
      "dq=dwr-dwir\n",
      "#results\n",
      "print '%s %.1f %s' %(\"The friction of the process per pound of air =\",dq,\"Btu/lbm\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The friction of the process per pound of air = 18.6 Btu/lbm\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5 - Pg 421"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the friction in the process\n",
      "#Initialization of variables\n",
      "ms=10 #lbm\n",
      "den=62.3 #lbm/ft^3\n",
      "A1=0.0218 #ft^2\n",
      "A2=0.00545 #ft^2\n",
      "p2=50. #psia\n",
      "p1=100. #psia\n",
      "gc=32.2 #ft/s^2\n",
      "dz=30. #ft\n",
      "T0=537. #R\n",
      "T1=620. #R\n",
      "T2=420. #R\n",
      "#calculations\n",
      "V1=ms/(A1*den)\n",
      "V2=ms/(A2*den)\n",
      "df=-144/den*(p2-p1) - (V2*V2 -V1*V1)/(2*gc) - dz\n",
      "#results\n",
      "print '%s %.1f %s' %(\"Friction =\",df,\"ft-lbf/lbm\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Friction = 72.9 ft-lbf/lbm\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6 - Pg 432"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the efficiency of the cycle and the loss of available energy\n",
      "#Initialization of variables\n",
      "cp1=0.25\n",
      "T=3460 #R\n",
      "T0=946.2 #R\n",
      "T00=520 #R\n",
      "dG=1228 #Btu/lbm\n",
      "cp=0.45\n",
      "#calculations\n",
      "dqa=cp1*(T-T0)\n",
      "w=cp*dqa\n",
      "dg=489.\n",
      "eff=w/dg*100\n",
      "dI=-dg+w\n",
      "#results\n",
      "print '%s %.1f %s' %(\"\\n Efficiency of cycle =\",eff,\" percent\")\n",
      "print '%s %.1f %s' %(\"\\n Loss of available energy =\",dI,\"Btu/lbm\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        " Efficiency of cycle = 57.8  percent\n",
        "\n",
        " Loss of available energy = -206.2 Btu/lbm\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7 - Pg 434"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the engine efficiency and effectiveness. Also, calculate the loss of available energy\n",
      "#Initialization of variables\n",
      "p1=400. #psia\n",
      "t1=600. #F\n",
      "h1=1306.9 #Btu/lbm\n",
      "b1=480.9 #Btu/lbm\n",
      "p2=50 #psia\n",
      "h2=1122 #Btu/lbm\n",
      "h3=1169.5 #Btu/lbm\n",
      "b3=310.9 #Btu/lbm\n",
      "#calculations\n",
      "print '%s' %(\"All the values are obtained from Mollier chart,\")\n",
      "dw13=h1-h3\n",
      "dw12=h1-h2\n",
      "dasf=b3-b1\n",
      "etae=dw13/dw12*100\n",
      "eta=abs(dw13/dasf)*100\n",
      "dq=dw13+dasf\n",
      "#results\n",
      "print '%s %.1f %s' % (\"Engine efficiency =\",etae,\"percent\")\n",
      "print '%s %.1f %s' %(\"\\n Effectiveness =\",eta,\"percent\")\n",
      "print '%s %.1f %s' %(\"\\n Loss of available energy  =\",dq,\"Btu/lbm\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "All the values are obtained from Mollier chart,\n",
        "Engine efficiency = 74.3 percent\n",
        "\n",
        " Effectiveness = 80.8 percent\n",
        "\n",
        " Loss of available energy  = -32.6 Btu/lbm\n"
       ]
      }
     ],
     "prompt_number": 6
    }
   ],
   "metadata": {}
  }
 ]
}