{
 "metadata": {
  "name": "",
  "signature": "sha256:fb635a7892259910462c375c5cd6000ddf39095d8593a85d6b876d44f34c4760"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 12 - Non steady flow, friction and availability"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1 - Pg 210"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the work done\n",
      "#Initialization of variables\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/ (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": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2 - Pg 212"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the Engine efficiency and Effectiveness\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": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3 - Pg 214"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the friction of the process per pound of air\n",
      "#Initialization of variables\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",
      "#calculations\n",
      "T2=T1*(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 4 - Pg 215"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Calculate the Friction\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",
      "#calculations\n",
      "V1=ms/(A1*den)\n",
      "V2=ms/(A2*den)\n",
      "df=-144./den*(p2-p1) - (V2**2 -V1**2)/(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
    }
   ],
   "metadata": {}
  }
 ]
}