{
 "metadata": {
  "name": "",
  "signature": "sha256:fb647d6d0a9fd1fab503f1e20b9cd4c1b8f196f963f97a28e2375980e25dde26"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 7 : Steady, One-Dimensional, Irreversible Flow"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.1 Page No : 213"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\t\n",
      "#initialisation of variables\n",
      "r= 1.5\n",
      "f= 0.025   # friction factor\n",
      "\t\n",
      "#CALCULATIONS\n",
      "r1= (2/f)*(r**2-1)\n",
      "\t\n",
      "#RESULTS\n",
      "print  'ratio L/D2 = %.f'%(r1)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "ratio L/D2 = 100\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.2 Page No : 214"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\t\n",
      "#initialisation of variables\n",
      "a= 6.    \t#degrees angle\n",
      "r= 1.5\n",
      "l= 100.  \t#ft\n",
      "f= 0.025\n",
      "K= 0.15\n",
      "\t\n",
      "#CALCULATIONS\n",
      "R= r**4-1\n",
      "R1= 1/math.tan(math.radians(a/2))*(1-(1./r))\n",
      "p1= f*l\n",
      "p2= 2.5*(l-p1)/l\n",
      "p3= (1-r**2)**2\n",
      "p4= K*p3\n",
      "pt= p4+p2\n",
      "\t\n",
      "#RESULTS\n",
      "print  ' lowest ratio = %.2f'%(R)\n",
      "print  ' contribtuion of friction in pipe = %.3f lbf/ft**2'%(p1)\n",
      "print  ' contribtuion of diffuser in pipe = %.3f lbf/ft**2'%(p2)\n",
      "print  ' stagnant pressure drop = %.3f lbf/ft**2'%(p3)\n",
      "print  ' contribtuion of friction in pipe after reduction = %.3f lbf/ft**2'%(pt)\n",
      "\n",
      "# note : rounding off error"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " lowest ratio = 4.06\n",
        " contribtuion of friction in pipe = 2.500 lbf/ft**2\n",
        " contribtuion of diffuser in pipe = 2.438 lbf/ft**2\n",
        " stagnant pressure drop = 1.562 lbf/ft**2\n",
        " contribtuion of friction in pipe after reduction = 2.672 lbf/ft**2\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.3 Page No : 219"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\n",
      "#initialisation of variables\n",
      "d= 4. \t    #in galvanised iron pipe diameter\n",
      "q= 0.5 \t    #ft**3/sec  flow rate\n",
      "w= 62.4 \t#lb/ft**3 density\n",
      "u= 2.7*10**-5 \t#lbf sec/ft**2 viscosity\n",
      "e= 0.0005 \t#ft\n",
      "g= 32.1 \t#ft/sec**2 acceleration\n",
      "f= 0.0235\n",
      "lt= 400. \t#ft long\n",
      "\t\n",
      "#CALCULATIONS\n",
      "V= 4*q/(math.pi*(d/12)**2)\n",
      "Re= w*V*(d/12)/(u*g)\n",
      "r= e/(d/12)\n",
      "dz= (V**2/(2*g))*(1.7+f*lt/(d/12))\n",
      "\t\n",
      "#RESULTS\n",
      "print  ' mean flow velocity = %.2f ft/sec'%(V)\n",
      "print  ' Reynolds number = %.2e'%(Re)\n",
      "print  ' Relative roughness = %.4f'%(r)\n",
      "print  ' difference in the levels of water = %.1f ft'%(dz)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " mean flow velocity = 5.73 ft/sec\n",
        " Reynolds number = 1.38e+05\n",
        " Relative roughness = 0.0015\n",
        " difference in the levels of water = 15.3 ft\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.4 Page No : 220"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\n",
      "#initialisation of variables\n",
      "d= 4.    \t#in\n",
      "v= 6.64 \t#ft/sec\n",
      "\t\n",
      "#CALCULATIONS\n",
      "Q= math.pi*0.25*(d/12)**2*v\n",
      "\t\n",
      "#RESULTS\n",
      "print  'Flow rate= %.3f ft**3/sec'%(Q)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Flow rate= 0.579 ft**3/sec\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.5 Page No : 221"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\t\n",
      "#initialisation of variables\n",
      "d= 0.366 \t#ft\n",
      "i= 12\n",
      "\t\n",
      "#CALCULATIONS\n",
      "pd= d*i\n",
      "\t\n",
      "#RESULTS\n",
      "print  'Required pipe diameter = %.2f in'%(pd)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Required pipe diameter = 4.39 in\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.6 Page No : 222"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\t\n",
      "#initialisation of variables\n",
      "Ps1= 1050. \t#lbf/ft**2\n",
      "fr= 10.7\n",
      "p= 36.6 \t#lbf/ft**2\n",
      "p1= 195. \t#lbf/ft**2\n",
      "fr1= 16.\n",
      "fr2= 1.8\n",
      "\t\n",
      "#CALCULATIONS\n",
      "deltap = (p+957+p1+Ps1)\n",
      "p2= round(fr*p)\n",
      "dp= Ps1-p2\n",
      "lc= round(dp/p)\n",
      "sp= Ps1+p1-p*(fr1+fr2)\n",
      "lc1= sp/p\n",
      "\n",
      "#RESULTS\n",
      "print  ' Pressure = %.f lbf/ft**2'%(round(deltap,-1))\n",
      "print  ' pressure difference = %.f lbf/ft**2'%(dp)\n",
      "print  ' Loss coefficient = %.f '%(lc)\n",
      "print  ' Loss coefficient = %.1f '%(lc1)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " Pressure = 2240 lbf/ft**2\n",
        " pressure difference = 658 lbf/ft**2\n",
        " Loss coefficient = 18 \n",
        " Loss coefficient = 16.2 \n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.7 Page No : 232"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\n",
      "#initialisation of variables\n",
      "p1= 50. \t#lbf/in**2 pressure\n",
      "R= 96.3 \t#ft lbf/lbm R\n",
      "T= 80. \t    #F temperature\n",
      "p2= 20. \t#lbf/in**2 pressure\n",
      "r= 1.31\n",
      "u= 2.34*10**-7 \t#lbf sec/ft**2\n",
      "e= 0.00005 \t    #ft\n",
      "m= 5.*10**4 \t#lbm/sec\n",
      "d= 1.5 \t        #ft\n",
      "g= 32.2 \t    #ft/sec**2\n",
      "f= 0.113\n",
      "\t\n",
      "#CALCULATIONS\n",
      "w1= p1*144/(R*(460+T))\n",
      "V1= 4*(m/3600)/(math.pi*w1*d**2)\n",
      "Ma1= V1/(r*R*g*(460+T))**0.5\n",
      "Re= w1*V1*d/(u*g)\n",
      "dx= (((1/(r*Ma1**2))*10*(1-(p2/p1)**2))+math.log(p2/p1))*d/f\n",
      "\t\n",
      "#RESULTS\n",
      "print  ' density = %.3f lbm/ft**3'%(w1)\n",
      "print  ' mean flow velocity = %.1f ft/sec'%(V1)\n",
      "print  ' Match number = %.4f '%(Ma1)\n",
      "print  ' Reynolds number = %.2e '%(Re)\n",
      "print  ' Length of pipe = %.2e ft'%(dx)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " density = 0.138 lbm/ft**3\n",
        " mean flow velocity = 56.8 ft/sec\n",
        " Match number = 0.0383 \n",
        " Reynolds number = 1.56e+06 \n",
        " Length of pipe = 5.79e+04 ft\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.9 Page No : 238"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\n",
      "#initialisation of variables\n",
      "r= 1.4\n",
      "R= 53.3 \t#ft lbf/lbm R\n",
      "g= 32.2 \t#ft/sec**2\n",
      "T1= 410. \t#R temperature\n",
      "v= 2500. \t#ft/sec steadility\n",
      "P1= 628. \t#lbf/in**2 pressure\n",
      "\t\n",
      "#CALCULATIONS\n",
      "v1= int(math.sqrt(r*g*R*T1))\n",
      "Ma1= round(v/v1,2)\n",
      "Ts1= int(T1*(1+0.5*(r-1)*Ma1**2))\n",
      "Ps1= P1*(1+0.5*(r-1)*Ma1**2)**(r/(r-1))\n",
      "Ps2= Ps1*((r+1)/(2*r*Ma1**2-r+1))**(1/(r-1))*(0.5*(r+1)*Ma1**2/(1+0.5*(r-1)*Ma1**2))**(r/(r-1))\n",
      "\n",
      "#RESULTS\n",
      "print  ' acoustic velocity = %.f ft/sec'%(v1)\n",
      "print  ' Match number = %.2f '%(Ma1)\n",
      "print  ' Stagnition temperature = %.f R'%(Ts1)\n",
      "print  ' Stagnition pressure = %.f lbf/ft**2'%(Ps1)\n",
      "print  ' Stagnition pressure = %.f lbf/ft**2'%(Ps2)\n",
      "\n",
      "# note : answer in book is wrong. Please check manually.\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " acoustic velocity = 992 ft/sec\n",
        " Match number = 2.52 \n",
        " Stagnition temperature = 930 R\n",
        " Stagnition pressure = 11069 lbf/ft**2\n",
        " Stagnition pressure = 5435 lbf/ft**2\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.10 Page No : 245"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "#initialisation of variables\n",
      "p2= 67.2 \t#lbf/in**2 pressure\n",
      "p1= 63. \t#lbf/in62 pressure\n",
      "r= 1.4\n",
      "n= 0.6      # efficiency\n",
      "T1= 870. \t#R temperature\n",
      "ma1= 0.8 \t#ft/sec mach number\n",
      "\n",
      "#CALCULATIONS\n",
      "dt= (p2/p1)**((r-1)/r)-1\n",
      "dt1= dt/n\n",
      "T2= T1*(1+dt1)\n",
      "Ts1= T1*(1+0.5*(r-1)*ma1**2)\n",
      "ps1= p1*(1+0.5*(r-1)*ma1**2)**(r/(r-1))\n",
      "ps2= p2*(Ts1/T2)**(r/(r-1))\n",
      "dp= ps1-ps2\n",
      "\n",
      "#RESULTS\n",
      "print  ' dT = %.5f '%(dt)\n",
      "print  ' dT1 = %.5f '%(dt1)\n",
      "print  ' Temperature = %.f R'%(T2)\n",
      "print  ' Temperature = %.1f R'%(Ts1)\n",
      "print  ' Pressure = %.1f lbf/in**2'%(ps1)\n",
      "print  ' Pressure = %.1f lbf/in**2'%(ps2)\n",
      "print  ' pressure difference = %.1f lbf/in**2'%(dp)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " dT = 0.01861 \n",
        " dT1 = 0.03102 \n",
        " Temperature = 897 R\n",
        " Temperature = 981.4 R\n",
        " Pressure = 96.0 lbf/in**2\n",
        " Pressure = 92.0 lbf/in**2\n",
        " pressure difference = 4.0 lbf/in**2\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.11 Page No : 246"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "#initialisation of variables\n",
      "r= 1.4\n",
      "ma3= 3. \t#ft/sec mach number\n",
      "ps= 80. \t#lbf/ft**2 pressure\n",
      "Ts= 840. \t#R temperature\n",
      "r1= 53.3 \t#ft lbm/ft**3\n",
      "A3= 2.   \t#in**2 flow area\n",
      "g= 32.2 \t#ft/sec**2\n",
      "ma1= 1.6\n",
      "\n",
      "#CALCULATIONS\n",
      "R= (1+(r-1)*0.5*ma3**2)**(r/(r-1))\n",
      "p3= ps/R\n",
      "R1= 1+0.5*(r-1)*ma3**2\n",
      "T3= Ts/R1\n",
      "w3= p3*144/(r1*T3)\n",
      "V3= ma3*math.sqrt(r*r1*g*T3)\n",
      "m= w3*V3*A3/144\n",
      "ra= ((r+1)/(2*r*ma1**2-(r-1)))**(1/(r-1))*(0.5*(r+1)*ma1**2/(1+0.5*(r-1)*ma1**2))**(r/(r-1))\n",
      "ps2= ps*ra\n",
      "dp= ps-ps2\n",
      "\n",
      "#RESULTS\n",
      "print  ' outlet pressure = %.2f lbf/in**2'%(p3)\n",
      "print  ' outlet temperature = %.f R'%(T3)\n",
      "print  ' mass flow rate = %.3f lbm/sec'%(m)\n",
      "print  ' ps2 = %.1f lbf/in**2'%(ps2)\n",
      "print  ' Stagnation pressure loss = %.1f lbf/in**2'%(dp)\n",
      "\n",
      "# rounding off error"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " outlet pressure = 2.18 lbf/in**2\n",
        " outlet temperature = 300 R\n",
        " mass flow rate = 0.694 lbm/sec\n",
        " ps2 = 71.6 lbf/in**2\n",
        " Stagnation pressure loss = 8.4 lbf/in**2\n"
       ]
      }
     ],
     "prompt_number": 7
    }
   ],
   "metadata": {}
  }
 ]
}