{
 "metadata": {
  "name": "",
  "signature": "sha256:f32ce99f1a0136b5cca3224fda443fb508c92875ffc981f9eb147519b1c553ca"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 5 : Flow of a Compressible Ideal Fluid"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.1 Page No : 152"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\t\t\n",
      "\n",
      "# variables\n",
      "v1 = 100.;\t\t# fps\n",
      "p1 = 50.;\t\t# psia\n",
      "T1 = 300.;\t\t# degreeF\n",
      "v2 = 500.;\t\t# fps\n",
      "Cp = 186.5;\n",
      "gam = 1.4;\n",
      "\n",
      "# calculations \n",
      "T2 = T1 - (v2**2 - v1**2)/(2*36.2*Cp);\n",
      "p2 = p1*(1 - (v2**2 - v1**2)/(2*36.2*53.3*(T1+460)*(gam/(gam-1))))**(1/0.286);\n",
      "\n",
      "# results \n",
      "print 'T2 = %d degreeF'%(round(T2,-1));\n",
      "print 'p2 = %.1f psia'%(p2);\n",
      "\n",
      "#there is an error in the answer given in textbook"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "T2 = 280 degreeF\n",
        "p2 = 46.0 psia\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.2 Page No : 153"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "\t\t\n",
      "# variables\n",
      "p1 = 300.;\t\t# psia\n",
      "T1 = 900.;\t\t# degreeF\n",
      "p2 = 200.;\t\t# psia\n",
      "T2 = 780.;\t\t# degreeF\n",
      "H2 = 1414.;\t\t#Btu/lb\n",
      "H1 = 1471.;\t\t# Btu/lb\n",
      "\n",
      "# calculations \n",
      "V2 = math.sqrt(2*31.1*778*(H1-H2));\n",
      "\n",
      "# results \n",
      "print 'T2 = %d degreeF and V2 = %d fps'%(T2,V2);"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "T2 = 780 degreeF and V2 = 1660 fps\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.3 Page No : 155"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "\t\t\n",
      "# variables\n",
      "v = 586.;\t\t# fps\n",
      "p = 13.;\t\t# psia\n",
      "T = 0.;\t\t# degreeF\n",
      "gam = 1.4;\n",
      "\n",
      "# calculations \n",
      "rho_0 = p*144/(32.2*53.3*(460+T));\n",
      "a_0 = math.sqrt(gam*32.2*53.3*(T+460));\n",
      "M_0 = v/a_0;\n",
      "p_8_approx = p+(0.5/144)*rho_0*v**2 *(1+0.25*M_0**2);\n",
      "p_8_exact = p*(1+M_0**2 *(gam-1)/2)**(gam/(gam-1));\n",
      "T_8 = v**2 /(2*32.2*186.5) +460;\n",
      "rho_8 = p_8_exact*144/(T_8*32.2*53.3);\n",
      "\n",
      "# results \n",
      "print 'At stagnetion point, p = %.2f psia, T = %.1f degreeR and density = %.5f slug/cuft'%(p_8_exact,T_8,rho_8);"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "At stagnetion point, p = 16.05 psia, T = 488.6 degreeR and density = 0.00276 slug/cuft\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.4 pageno : 159"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "# variables\n",
      "g = 32.2\n",
      "k = 1.40\n",
      "R = 53.3\n",
      "A2 = 0.005454\n",
      "p1 = 114.7 * 144\n",
      "T1 = 560\n",
      "\n",
      "# calculations\n",
      "y1 = p1 /(R * T1)\n",
      "p2 = 0.528 * 114.7\n",
      "G1 = math.sqrt(g*k/R * (2/(k+1))**((k+1)/(k-1))) * A2*p1/math.sqrt(T1)\n",
      "\n",
      "p2 = 94.7     # psia\n",
      "p2byp1 = 0.825\n",
      "G = A2*math.sqrt( (2*g*k)/(k-1) * p1*y1 * ((p2byp1)**(2/k) - (p2byp1)**((k+1)/k)))\n",
      "# result\n",
      "print \"part a\"\n",
      "print \"G = %.2f lb/sec\"%G1\n",
      "print \"\\npart b\"\n",
      "print \"G = %.2f lb/sec\"%G"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "part a\n",
        "G = 2.03 lb/sec\n",
        "\n",
        "part b\n",
        "G = 1.58 lb/sec\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.5 Page No : 161"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "\t\t\n",
      "# variables\n",
      "d = 1.;\t\t    # in\n",
      "p = 100.;\t\t# psi\n",
      "T = 10.;\t\t# degreeF\n",
      "p_i = 80.;\t\t#psi\n",
      "p_b = 14.7;\t\t#psi\n",
      "p1 = 16520.;\t# psfa\n",
      "gam1 = 0.553;\t# lb/cuft\n",
      "k = 0.874;\n",
      "\n",
      "# calculations \n",
      "G = (0.5*k*0.25*math.pi*(d/12)**2 /(1-(2./3)**4)) *math.sqrt(2*32.2*(p-p_i)*144/gam1);\n",
      "\n",
      "# results \n",
      "print 'flow rate = %.2f lb/sec'%(G);"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "flow rate = 1.72 lb/sec\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.6 Page No : 163"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "\n",
      "# variables\t\t\n",
      "d = 1.;\t\t# in\n",
      "p_r = 100.;\t\t#psi\n",
      "T_r = 100.;\t\t# degreeF\n",
      "p_b = 14.7;\t\t# psi\n",
      "p3 = 14.7;\t\t#psi\n",
      "G = 2.03;\t\t# lb/sec\n",
      "gam1 = 0.553;\n",
      "gam = 1.4;\n",
      "\n",
      "# calculations \n",
      "V3 = math.sqrt(2*32.2*(gam/(gam-1))*(p_r+p_b)*144/gam1 *(1-(p3/(p_r+p_b))**((gam-1)/gam)));\n",
      "T3 = (T_r+460) - V3**2 /(2*32.2*186.5);\n",
      "a3 = math.sqrt(gam*32.2*53.3*T3);\n",
      "M3 = V3/a3;\n",
      "A3 = G/(gam1*V3);\n",
      "d3 = (A3/(0.25*math.pi))**(1./2);\n",
      "p3_dash = 103.3;\t\t# psia\n",
      "p_B = p3*(1+ (2*gam/(gam+1))*(M3**2 -1));\n",
      "\n",
      "# results \n",
      "print 'V3 = %d fps, a3 = %d fps,  M3 = %.2f '%(V3,a3,M3);\n",
      "print 'p3_dash = %.1f psia, p_B = %.1f psia'%(p3_dash,p_B);\n",
      "\n",
      "#there are rounding-off errors in the answer given in textbook"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "V3 = 1728 fps, a3 = 864 fps,  M3 = 2.00 \n",
        "p3_dash = 103.3 psia, p_B = 66.1 psia\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.7 Page No : 166"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "\t\t\n",
      "# variables\n",
      "V_0 = 586.;\t\t# fps\n",
      "t_0 = 0;\t\t# degreeF\n",
      "P_0 = 13.;\t\t# psia\n",
      "a_0 = 1052.;\t\t# fps\n",
      "M_0 = 0.557;\n",
      "V_A = 800.;\t\t#fps\n",
      "V_B = 900.;\t\t#fps\n",
      "gam = 1.4;\n",
      "\n",
      "# calculations \n",
      "T_A = 488.5- V_A**2 /(2*32.2*186.5);\n",
      "T_B = 488.5- V_B**2 /(2*32.2*186.5); \n",
      "p_A = 16.18*(T_A/488.5)**(gam/(gam-1));\n",
      "p_B = 16.18*(T_B/488.5)**(gam/(gam-1));\n",
      "a_A = math.sqrt(gam*32.2*53.3*T_A);\n",
      "a_B = math.sqrt(gam*32.2*53.3*T_B);\n",
      "M_A = V_A/a_A;\n",
      "M_B = V_B/a_B;\n",
      "\n",
      "# results \n",
      "print 'At point A, p = %.2f psia, T = %.1f degreeR, a = %d fps, M = %.3f'%(p_A,T_A,a_A,M_A);\n",
      "print 'At point B, p = %.2f psia, T = %.1f degreeR, a = %d fps, M = %.1f'%(p_B,T_B,a_B,M_B);\n",
      "\n",
      "#answer differs due to rounding-off errors in textbook"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "At point A, p = 10.80 psia, T = 435.2 degreeR, a = 1022 fps, M = 0.782\n",
        "At point B, p = 9.62 psia, T = 421.1 degreeR, a = 1005 fps, M = 0.9\n"
       ]
      }
     ],
     "prompt_number": 12
    }
   ],
   "metadata": {}
  }
 ]
}