{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 16 : Compressible Flow"
     ]
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 16.1 page no : 859"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "# Variables\n",
      "V1 = 300.; \t\t\t#m/s\n",
      "p1 = 78.; \t\t\t#kN/m**2\n",
      "T1 = 313.; \t\t\t#K\n",
      "p2 = 117.; \t\t\t#kN/m**2\n",
      "R = 287.; \t\t\t#J/kg K\n",
      "y = 1.4;\n",
      "\n",
      "# Calculations\n",
      "#Let r1 = p1/rho1\n",
      "r1 = R*T1;\n",
      "V2 = math.sqrt(2*(y/(y-1)*r1*(1-(p2/p1)**((y-1)/y)) + V1**2/2));\n",
      "\n",
      "# Results\n",
      "print (\"Velocity of gas at section 2  = %.3f\")% (V2), (\"m/s\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Velocity of gas at section 2  = 112.987 m/s\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 16.2 page no : 861"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Variables\n",
      "p1 = 35.; \t\t\t#kN/m**2\n",
      "V1 = 30.; \t\t\t#m/s\n",
      "T1 = 423.; \t\t\t#K\n",
      "V2 = 150.; \t\t\t#m/s\n",
      "R = 290.; \t\t\t#J/kg K\n",
      "y = 1.4;\n",
      "\n",
      "# Calculations\n",
      "#Let r1 = p2/p1\n",
      "r1 = R*T1; \n",
      "p2 = p1*(1-((V2**2/2-V1**2/2)*(y-1)/y/r1))**(y/(y-1));\n",
      "print (\"pressure = %.3f\")% (p2), (\"kN/m**2\")\n",
      "\n",
      "T2 = T1*(p2/p1)**((y-1)/y);\n",
      "t2 = T2-273;\n",
      "print (\"temperature  = %.3f\")% (t2), (\"\u00b0C\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "pressure = 32.014 kN/m**2\n",
        "temperature  = 139.360 \u00b0C\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 16.3 page no : 866"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "# Variables\n",
      "SG = 0.8;\n",
      "rho_oil = 800.; \t\t\t#kg/m**3\n",
      "K_oil = 1.5*10**9; \t\t\t#N/m**2; crude oil\n",
      "K_Hg = 27*10.**9; \t\t\t#N/m**2; Mercury\n",
      "rho_Hg = 13600.; \t\t\t#kg/m**3\n",
      "\n",
      "# Calculations and Results\n",
      "C_oil = math.sqrt(K_oil/rho_oil);\n",
      "print (\"Sonic velocity of crude oil  = %.3f\")% (C_oil), (\"m/s\")\n",
      "\n",
      "C_Hg = math.sqrt(K_Hg/rho_Hg)\n",
      "print (\"Sonic velocity of Mercury  = %.3f\")% (C_Hg), (\"m/s\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Sonic velocity of crude oil  = 1369.306 m/s\n",
        "Sonic velocity of Mercury  = 1409.005 m/s\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 16.4 page no : 866"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "# Variables\n",
      "T = 228.; \t\t\t#K\n",
      "M = 2.;\n",
      "R = 287.; \t\t\t#Jkg K\n",
      "y = 1.4;\n",
      "\n",
      "# Calculations\n",
      "C = math.sqrt(y*R*T);\n",
      "V = M*C*3600./1000;\n",
      "\n",
      "# Results\n",
      "print (\"Velocity of the plane  = %.3f\")% (V), (\"km/h\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Velocity of the plane  = 2179.239 km/h\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 16.5 page no : 868"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Variables\n",
      "a = 40*math.pi/180; \t\t\t#Mach angle in radians\n",
      "y = 1.4;\n",
      "R = 287.; \t\t\t#J/kg K\n",
      "T = 288.; \t\t\t#K\n",
      "\n",
      "# Calculations\n",
      "C = math.sqrt(y*R*T);\n",
      "V = C/math.sin(a);\n",
      "\n",
      "# Results\n",
      "print (\"Velocity of bullet  = %.3f\")% (V), (\"m/s\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Velocity of bullet  = 529.217 m/s\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 16.6 page no : 868"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "# Variables\n",
      "p = 88.3; \t\t\t#kN/m**2\n",
      "T = 271.; \t\t\t#K\n",
      "M = 40.*math.pi/180;\n",
      "y = 1.4;\n",
      "R = 287.; \t\t\t#J/kg K\n",
      "\n",
      "# Calculations\n",
      "C = math.sqrt(y*R*T);\n",
      "V = C/math.sin(M);\n",
      "\n",
      "# Results\n",
      "print (\"Velocity of the projectile  = %.3f\")% (V), (\"m/s\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Velocity of the projectile  = 513.360 m/s\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 16.7 page no : 868"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "# Variables\n",
      "h = 1800.; \t\t\t#m\n",
      "T = 277.; \t\t\t#K\n",
      "t = 4.; \t\t\t#s\n",
      "y = 1.4;\n",
      "R = 287.; \t\t\t#J/kg K\n",
      "\n",
      "# Calculations\n",
      "C = math.sqrt(y*R*T);\n",
      "a = (math.cos(C/h*t));\n",
      "V = C/math.sin(a)*3600/1000;\n",
      "\n",
      "# Results\n",
      "print (\"Speed of the aircraft  = %.3f\")% (V), (\"km/h\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Speed of the aircraft  = 1785.959 km/h\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 16.8 page no : 873"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "# Variables\n",
      "R = 287.; \t\t\t#J/kg K\n",
      "y = 1.4;\n",
      "V0 = 1000.*1000/3600; \t\t\t#m/s\n",
      "p0 = 78.5; \t\t\t#kN/m**2\n",
      "T0 = 265.; \t\t\t#K\n",
      "\n",
      "# Calculations and Results\n",
      "C0 = math.sqrt(y*R*T0);\n",
      "M0 = V0/C0;\n",
      "\n",
      "ps = p0*(1+((y-1)/2*M0**2))**(y/(y-1));\n",
      "print (\"(i) Stagnation pressure  = %.3f\")%(ps), (\"kN/m**2\")\n",
      "\n",
      "Ts = T0*(1+((y-1)/2*M0**2));\n",
      "print (\"(ii) Stagnation temperature  = %.3f\")% (Ts), (\"K\")\n",
      "\n",
      "rho_s = ps*10**3/R/Ts;\n",
      "print (\"(iii) Stagnation density  = %.3f\")%(rho_s), (\"kg/m**3\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(i) Stagnation pressure  = 126.067 kN/m**2\n",
        "(ii) Stagnation temperature  = 303.407 K\n",
        "(iii) Stagnation density  = 1.448 kg/m**3\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 16.9 page no : 874"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "# Variables\n",
      "V0 = 1000.*1000./3600; \t\t\t#m/s\n",
      "T0 = 320.; \t\t\t#K\n",
      "p_atm = 98.1; \t\t\t#kN/m**2\n",
      "p = 9.81; \t\t\t#kN/m**2\n",
      "p0 = 98.1-p;\n",
      "R = 287.; \t\t\t#J/kg K\n",
      "y = 1.4;\n",
      "\n",
      "# Calculations and Results\n",
      "C0 = math.sqrt(y*R*T0);\n",
      "M0 = V0/C0;\n",
      "\n",
      "ps = p0*(1+((y-1)/2*M0**2))**(y/(y-1));\n",
      "print (\"Stagnation pressure  = %.3f\")% (ps), (\"kN/m**2\")\n",
      "\n",
      "Ts = T0*(1+((y-1)/2*M0**2));\n",
      "print (\"Stagnation temperature  = %.1f\")% (Ts), (\"K\")\n",
      "\n",
      "rho_s = ps*10**3/R/Ts;\n",
      "print (\"Stagnation density  = %.3f\")% (rho_s), (\"kg/m**3\")\n",
      "\n",
      "M = 0.8;\n",
      "\n",
      "CF = 1+(M0**2./4)+((2-y)/24.*M0**4);\n",
      "print (\"Compressibility factor %.2f\")% (CF)\n",
      "\n",
      "#Note : Answers are slightly different because of rounding error."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Stagnation pressure  = 131.282 kN/m**2\n",
        "Stagnation temperature  = 358.4 K\n",
        "Stagnation density  = 1.276 kg/m**3\n",
        "Compressibility factor 1.16\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 16.10 page no : 875"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "# Variables\n",
      "R = 287.; \t\t\t#J/kg K\n",
      "y = 1.4;\n",
      "p0 = 220.*10**3; \t#N/m**2\n",
      "T0 = 300.; \t\t\t#K\n",
      "V0 = 200.; \t\t\t#m/s\n",
      "\n",
      "# Calculations and Results\n",
      "C0 = math.sqrt(y*R*T0);\n",
      "rho_0 = p0/R/T0;\n",
      "print (\"Stagnation pressure  = \")\n",
      "\n",
      "print (\"(i) Compressibility is neglected\")\n",
      "ps = (p0+rho_0*V0**2/2)/10**3;\n",
      "print (\"ps = %.3f\")% (ps), (\"kN/m**2\")\n",
      "\n",
      "print (\"(ii) Compressibility is accounted for\")\n",
      "M0 = V0/C0;\n",
      "\n",
      "ps = (p0+rho_0*V0**2/2*(1+M0**2./4+(2-y)/24*M0**4))/10**3;\n",
      "print (\"ps = %.3f\")% (ps), (\"kN/m**2\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Stagnation pressure  = \n",
        "(i) Compressibility is neglected\n",
        "ps = 271.103 kN/m**2\n",
        "(ii) Compressibility is accounted for\n",
        "ps = 275.484 kN/m**2\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 16.11 page no : 875"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "# Variables\n",
      "p0 = 35.*10**3; \t\t\t#Pa\n",
      "T0 = 235.; \t\t\t#K\n",
      "ps = 65.4*10**3; \t\t\t#N/m**2\n",
      "R0 = 8314.; \t\t\t#Nm/mole K\n",
      "M = 28.;\n",
      "\n",
      "# Calculations\n",
      "R = R0/M;\n",
      "rho_0 = p0/R/T0;\n",
      "Va = math.sqrt(2*(ps-p0)/rho_0);\n",
      "\n",
      "# Results\n",
      "print (\"Speed of the aircraft  = %.3f\")% (Va), (\"m/s\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Speed of the aircraft  = 348.159 m/s\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 16.12 page no : 885"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "# Variables\n",
      "p0 = 30.*10**3; \t\t\t#N/m**2\n",
      "V0 = 152.; \t\t\t#m/s\n",
      "y = 1.4;\n",
      "rho_0 = 1.224; \t\t\t#kg/m**3\n",
      "ps = p0+rho_0*V0**2/2;\n",
      "\n",
      "# Calculations\n",
      "rho_0 = 0.454; \t\t\t#kg/m**3\n",
      "V0 = math.sqrt(2*(ps-p0)/rho_0);\n",
      "C0 = math.sqrt(y*p0/rho_0);\n",
      "M = V0/C0;\n",
      "ccf = (1+M**2/4); \t\t\t#Compressibility correction factor\n",
      "V = V0/math.sqrt(ccf); \t\t\t#True speed of aircraft\n",
      "\n",
      "# Results\n",
      "print (\"True speed of aircraft  = %.3f\")% (V), (\"m/s\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "True speed of aircraft  = 230.900 m/s\n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 16.13 page no : 886"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "# Variables\n",
      "M = 3.; \t\t\t#Mach number\n",
      "d = 0.2; \t\t\t#m\n",
      "p_nozzle = 7.85; \t\t\t#kN/m**2\n",
      "T_nozzle = 200.; \t\t\t#K\n",
      "y = 1.4;\n",
      "\n",
      "# Calculations and Results\n",
      "A = math.pi/4*d**2;\n",
      "p_res = p_nozzle*(1+((y-1)/2*M**2))**(y/(y-1));\n",
      "print (\"Reservoir pressure  = %.3f\")% (p_res), (\"kN/m**2\")\n",
      "\n",
      "T_res = T_nozzle*(1+((y-1)/2*M**2));\n",
      "print (\"Reservoir temperature  = %.3f\")% (T_res), (\"K\")\n",
      "\n",
      "Ac = A*M/((2+(y-1)*M**2)/(y+1))**((y+1)/2/(y-1));\n",
      "print (\"Throat area (critical)  = %.5f\")% (Ac), (\"m**2\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Reservoir pressure  = 288.352 kN/m**2\n",
        "Reservoir temperature  = 560.000 K\n",
        "Throat area (critical)  = 0.00742 m**2\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 16.14 page no : 887"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "# Variables\n",
      "R = 287.;   \t\t\t#J/kg K\n",
      "y = 1.4;\n",
      "p_atm = 100.; \t\t\t#kN/m**2\n",
      "p1 = 284. + p_atm; \t\t\t#kN/m**2\n",
      "T1 = 297.; \t    \t\t#K\n",
      "D = 0.02; \t\t    \t#m\n",
      "\n",
      "# Calculations\n",
      "A2 = math.pi/4*D**2;\n",
      "rho_1 = p1*10**3/R/T1;\n",
      "m_max = 0.685*A2*math.sqrt(p1*10**3*rho_1);\n",
      "\n",
      "# Results\n",
      "print (\"Maximum flow rate  = %.3f\")% (m_max), (\"kg/s\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Maximum flow rate  = 0.283 kg/s\n"
       ]
      }
     ],
     "prompt_number": 16
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 16.15 page no : 888"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Variables\n",
      "R = 287.; \t\t\t#J/kg K\n",
      "y = 1.4;\n",
      "p1 = 2500.*10**3; \t#N/m**2\n",
      "T1 = 293.; \t\t\t#K\n",
      "p2 = 1750.*10**3; \t#N/m**2\n",
      "\n",
      "# Calculations\n",
      "rho_1 = p1/R/T1;\n",
      "V2 = math.sqrt(2*y/(y-1)*p1/rho_1*(1-(p2/p1)**((y-1)/y)));\n",
      "\n",
      "# Results\n",
      "print (\"Velocity of air  = %.3f\")% (V2),(\"m/s\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Velocity of air  = 238.812 m/s\n"
       ]
      }
     ],
     "prompt_number": 17
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 16.16 page no : 889"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "# Variables\n",
      "R = 287.; \t    \t\t#J/kg K\n",
      "y = 1.4;\n",
      "p_atm = 10.**5; \t\t#N/m**2\n",
      "T1 = 293.    \t\t\t#K\n",
      "D2 = 0.025; \t\t\t#m\n",
      "p1 = 140.*10**3; \t\t#N/m**2\n",
      "\n",
      "# Calculations and Results\n",
      "A2 = math.pi/4*D2**2;\n",
      "\n",
      "print (\"(i) Mass rate of flow of air when pressure in the math.tank is 140 kN/m2 (abs.)\")\n",
      "rho_1 = p1/R/T1;\n",
      "p2 = 10**5; \t\t\t#N/m**2\n",
      "\n",
      "m = A2*math.sqrt(2*y/(y-1)*p1*rho_1*((p2/p1)**(2/y) - (p2/p1)**((y+1)/y)));\n",
      "print (\"m = %.3f\")% (m), (\"kg/s\")\n",
      "\n",
      "print (\"(ii) Mass rate of flow of air when pressure in the math.tank is 300 kN/m2 (abs.)\")\n",
      "p1 = 300.*10**3; \t\t\t#N/m**2\n",
      "p2 = 10.**5; \t\t\t#N/m**2\n",
      "rho_1 = p1/R/T1;\n",
      "\n",
      "print (\"The pressure ratio p2/p1 being less than the critical ratio 0.528, the flow in the nozzle will be sonic\");\n",
      "\n",
      "m_max = 0.685*A2*math.sqrt(p1*rho_1);\n",
      "print (\"m_max = %.3f\")% (m_max), (\"kg/s\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(i) Mass rate of flow of air when pressure in the math.tank is 140 kN/m2 (abs.)\n",
        "m = 0.149 kg/s\n",
        "(ii) Mass rate of flow of air when pressure in the math.tank is 300 kN/m2 (abs.)\n",
        "The pressure ratio p2/p1 being less than the critical ratio 0.528, the flow in the nozzle will be sonic\n",
        "m_max = 0.348 kg/s\n"
       ]
      }
     ],
     "prompt_number": 18
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 16.17 page no : 890"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "# Variables\n",
      "p1 = 200.; \t\t\t#kN/m**2\n",
      "V1 = 170.; \t\t\t#m/s\n",
      "T1 = 473.; \t\t\t#K\n",
      "A1 = 0.001; \t\t#m**2\n",
      "R = 287.; \t\t\t#J/kg K\n",
      "cp = 1000.; \t\t#J/kg K\n",
      "y = 1.4;\n",
      "\n",
      "# Calculations and Results\n",
      "print (\"(i) Stagnation temperature (Ts) and stagnation pressure (ps)\")\n",
      "\n",
      "Ts = T1+V1**2/2/cp;\n",
      "print (\"Ts = %.3f\")% (Ts), (\"K\")\n",
      "\n",
      "ps = p1*(Ts/T1)**(y/(y-1));\n",
      "print (\"ps = %.3f\")% (ps), (\"kN/m**2\")\n",
      "\n",
      "print (\"(ii) Sonic velocity and Mach number at this section\")\n",
      "\n",
      "C1 = math.sqrt(y*R*T1);\n",
      "print (\"Sonic velocity  = %.3f\")% (C1), (\"m/s\")\n",
      "\n",
      "M1 = V1/C1;\n",
      "print (\"Mach number  =  %.3f\")% (M1)\n",
      "\n",
      "print (\"(iii) Velocity, Mach number and flow area at outlet section where pressure is 110 kN/m2\")\n",
      "p2 = 110.; \t\t\t#kN/m**2\n",
      "M2 = math.sqrt(2/(y-1)*((ps/p2)**((y-1)/y) - 1));\n",
      "print (\"M2 = %.3f\")% (M2)\n",
      "\n",
      "T2 = Ts*(p2/ps)**((y-1)/y);\n",
      "C2 = math.sqrt(y*R*T2);\n",
      "V2 = M2*C2;\n",
      "print (\"V2 = %.3f\")% (V2), (\"m/s\")\n",
      "\n",
      "A2 = (p1*A1*V1*T2/T1/p2/V2)*10**6;\n",
      "print (\"A2 = %.3f\")% (A2), (\"mm**2\")\n",
      "\n",
      "\n",
      "print (\"(iv) Pressure (pt), temperature (Tt), velocity (Vt), and flow area (At) at throat of the nozzle\")\n",
      "Mt = 1.;\n",
      "Tt = Ts/(1+(y-1)/2*Mt**2);\n",
      "print (\"Tt  = %.3f\")% (Tt), (\"K\")\n",
      "\n",
      "pt = ps*(Tt/Ts)**(y/(y-1));\n",
      "print (\"pt = %.3f\")% (pt), (\"kN/m**2\")\n",
      "\n",
      "Ct = math.sqrt(y*R*Tt);\n",
      "Vt = Mt*Ct;\n",
      "\n",
      "At = (p1*A1*V1*Tt/T1/pt/Vt)*10**6;\n",
      "print (\"At = %.3f\")% (At), (\"mm**2\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(i) Stagnation temperature (Ts) and stagnation pressure (ps)\n",
        "Ts = 487.450 K\n",
        "ps = 222.214 kN/m**2\n",
        "(ii) Sonic velocity and Mach number at this section\n",
        "Sonic velocity  = 435.949 m/s\n",
        "Mach number  =  0.390\n",
        "(iii) Velocity, Mach number and flow area at outlet section where pressure is 110 kN/m2\n",
        "M2 = 1.055\n",
        "V2 = 422.183 m/s\n",
        "A2 = 617.168 mm**2\n",
        "(iv) Pressure (pt), temperature (Tt), velocity (Vt), and flow area (At) at throat of the nozzle\n",
        "Tt  = 406.208 K\n",
        "pt = 117.392 kN/m**2\n",
        "At = 615.673 mm**2\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 16.18 page no : 893"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "# Variables\n",
      "y = 1.4;\n",
      "p1 = 26.5; \t\t\t#kN/m**2\n",
      "rho_1 = 0.413; \t\t\t#kg/m**3\n",
      "M1 = 2.;\n",
      "R = 287.;\n",
      "\n",
      "# Calculations and Results\n",
      "M2 = math.sqrt(((y-1)*M1**2 + 2)/(2*y*M1**2 - (y-1)));\n",
      "print (\"Mach number M2 = %.3f\")% (M2)\n",
      "\n",
      "p2 = p1*(2*y*M1**2 - (y-1))/(y+1);\n",
      "print (\"p2 = %.3f\")% (p2), (\"kN/m**2\")\n",
      "\n",
      "rho_2 = rho_1*((y+1)*M1**2)/((y-1)*M1**2 + 2);\n",
      "print (\"density, rho_2  = %.3f\")% (rho_2), (\"kg/m**3\")\n",
      "\n",
      "T1 = p1*10**3/rho_1/R;\n",
      "print (\"T1 = %.3f\")% (T1), (\"K\")\n",
      "\n",
      "T2 = T1*((y-1)*M1**2 + 2)*(2*y*M1**2 - (y-1))/((y+1)**2*M1**2);\n",
      "print (\"T2 = %.3f\")% (T2), (\"K\")\n",
      "\n",
      "C1 = math.sqrt(y*R*T1);\n",
      "V1 = M1*C1;\n",
      "print (\"V1 = %.3f\")% (V1), (\"m/s\")\n",
      "\n",
      "C2 = math.sqrt(y*R*T2);\n",
      "V2 = M2*C2;\n",
      "print (\"V2  = %.3f\")% (V2), (\"m/s\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Mach number M2 = 0.577\n",
        "p2 = 119.250 kN/m**2\n",
        "density, rho_2  = 1.101 kg/m**3\n",
        "T1 = 223.570 K\n",
        "T2 = 377.275 K\n",
        "V1 = 599.435 m/s\n",
        "V2  = 224.788 m/s\n"
       ]
      }
     ],
     "prompt_number": 20
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 16.19 page no : 895"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "# Variables\n",
      "M1 = 1.5;\n",
      "p1 = 170.; \t\t\t#kN/m**2\n",
      "T1 = 296.; \t\t\t#K\n",
      "y = 1.4;\n",
      "\n",
      "# Calculations and Results\n",
      "print (\"(i) Pressure, temperature and Mach number downstream of the shock\")\n",
      "p2 = p1*(2*y*M1**2 - (y-1))/(y+1);\n",
      "print (\"p2 = %.3f\")% (p2), (\"kN/m**2\")\n",
      "\n",
      "T2 = T1*((y-1)*M1**2 + 2)*(2*y*M1**2 - (y-1))/(y+1)**2/M1**2;\n",
      "print (\"T2 = %.3f\")% (T2), (\"K\")\n",
      "\n",
      "M2 = math.sqrt(((y-1)*M1**2 + 2)/(2*y*M1**2 - (y-1)));\n",
      "print (\"M2 = %.3f\")% (M2)\n",
      "\n",
      "strength = p2/p1 - 1;\n",
      "print (\"Strength of stock  = %.3f\")% (strength)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(i) Pressure, temperature and Mach number downstream of the shock\n",
        "p2 = 417.917 kN/m**2\n",
        "T2 = 390.784 K\n",
        "M2 = 0.701\n",
        "Strength of stock  = 1.458\n"
       ]
      }
     ],
     "prompt_number": 21
    }
   ],
   "metadata": {}
  }
 ]
}