{
 "metadata": {
  "name": "",
  "signature": "sha256:50b271f93e8a365fc7786fed67e8c1b9727566cca589daf5682afce2ce0beb0c"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "CHAPTER10:COMPRESSIBLE FLOW THROUGH NOZZLES DIFFUSERS AND WIND TUNNELS"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E01 : Pg 345"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# All the quantities are expressed in Si units\n",
      "area_ratio = 10.25;                        # exit to throat area ratio\n",
      "p0 = 5;                                    # reservoir pressure in atm\n",
      "T0 = 333.3;                                # reservoir temperature\n",
      "\n",
      "# from appendix A, for an area ratio of 10.25\n",
      "Me = 3.95;                                 # exit mach number\n",
      "pe = 0.007*p0;                             # exit pressure\n",
      "Te = 0.2427*T0;                            # exit temperature\n",
      "\n",
      "print\"Me =\",Me\n",
      "print\"pe =\",pe,\"atm\"\n",
      "print\"Te =\",Te,\"K\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Me = 3.95\n",
        "pe = 0.035 atm\n",
        "Te = 80.89191 K\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E02 : Pg 346"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# All the quantities are expressed in Si units\n",
      "\n",
      "area_ratio = 2.;                            # exit to throat area ratio\n",
      "p0 = 1.;                                    # reservoir pressure in atm\n",
      "T0 = 288.;                                  # reservoir temperature\n",
      "\n",
      "# (a)\n",
      "# since M = 1 at the throat\n",
      "Mt = 1.;\n",
      "pt = 0.528*p0;                             # pressure at throat\n",
      "Tt = 0.833*T0;                             # temperature at throat\n",
      "\n",
      "# from appendix A for supersonic flow, for an area ratio of 2\n",
      "Me = 2.2;                                  # exit mach number\n",
      "pe = 1./10.69*p0;                           # exit pressure\n",
      "Te = 1./1.968*T0;                           # exit temperature\n",
      "\n",
      "print\"At throat: Mt =\",Mt\n",
      "print\"\\nAt throat: pt =\",pt,\"atm\"\n",
      "print\"\\nAt throat: Tt = \",Tt,\"K\"\n",
      "print\"\\nAt throat: For supersonic exit:\",Me\n",
      "print\"\\nAt throat: pe =\",pe,\"atm\"\n",
      "print\"\\nAt throat: Te = \",Te,\"K\"\n",
      "\n",
      "# (b)\n",
      "# from appendix A for subonic flow, for an area ratio of 2\n",
      "Me = 0.3;                                  # exit mach number\n",
      "pe = 1/1.064*p0;                           # exit pressure\n",
      "Te = 1/1.018*T0;                           # exit temperature\n",
      "\n",
      "print\"\\nFor subrsonic exit:\",Me\n",
      "print\"\\npe=\",pe,\"atm\"\n",
      "print\"\\nTe=\",Te,\"K\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "At throat: Mt = 1.0\n",
        "\n",
        "At throat: pt = 0.528 atm\n",
        "\n",
        "At throat: Tt =  239.904 K\n",
        "\n",
        "At throat: For supersonic exit: 2.2\n",
        "\n",
        "At throat: pe = 0.0935453695042 atm\n",
        "\n",
        "At throat: Te =  146.341463415 K\n",
        "\n",
        "For subrsonic exit: 0.3\n",
        "\n",
        "pe= 0.93984962406 atm\n",
        "\n",
        "Te= 282.907662083 K\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E03 : Pg 346"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# All the quantities are expressed in Si units\n",
      "\n",
      "area_ratio = 2.;                            # exit to throat area ratio\n",
      "p0 = 1.;                                    # reservoir pressure in atm\n",
      "T0 = 288.;                                  # reservoir temperature\n",
      "pe = 0.973;                                # exit pressure in atm\n",
      "\n",
      "p_ratio = p0/pe;                           # ratio of reservoir to exit pressure\n",
      "\n",
      "# from appendix A for subsonic flow, for an pressure ratio of 1.028\n",
      "Me = 0.2;                                  # exit mach number\n",
      "area_ratio_exit_to_star = 2.964;           # A_exit/A_star\n",
      "\n",
      "# thus\n",
      "area_ratio_throat_to_star = area_ratio_exit_to_star/area_ratio;           # A_exit/A_star\n",
      "\n",
      "# from appendix A for subsonic flow, for an area ratio of 1.482\n",
      "Mt = 0.44;                                 # throat mach number\n",
      "\n",
      "print\"Me =\",Me\n",
      "print\"Mt =\",Mt"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Me = 0.2\n",
        "Mt = 0.44\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E04 : Pg 352"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# All the quantities are expressed in SI units\n",
      "import math \n",
      "p0 = 30.*101000.;                            # reservoir pressure\n",
      "T0 = 3500.;                                 # reservoir temperature\n",
      "R = 520.;                                   # specific gas constant\n",
      "gam = 1.22;                                # ratio of specific heats\n",
      "A_star = 0.4;                              # rocket nozzle throat area\n",
      "pe = 5529.;                                 # rocket nozzle exit pressure equal to ambient pressure at 20 km altitude\n",
      "\n",
      "# (a)\n",
      "# the density of air in the reservoir can be calculated as\n",
      "rho0 = p0/R/T0;\n",
      "\n",
      "# from eq.(8.46)\n",
      "rho_star = rho0*(2/(gam+1))**(1/(gam-1));\n",
      "\n",
      "# from eq.(8.44)\n",
      "T_star = T0*2/(gam+1);\n",
      "a_star = math.sqrt(gam*R*T_star);\n",
      "u_star = a_star;\n",
      "m_dot = rho_star*u_star*A_star;\n",
      "\n",
      "# rearranging eq.(8.42)\n",
      "Me = math.sqrt(2/(gam-1)*(((p0/pe)**((gam-1)/gam)) - 1));\n",
      "Te = T0/(1+(gam-1)/2*Me*Me);\n",
      "ae = math.sqrt(gam*R*Te);\n",
      "ue = Me*ae;\n",
      "\n",
      "# thus the thrust can be calculated as\n",
      "T = m_dot*ue;\n",
      "T_lb = T*0.2247;\n",
      "\n",
      "# (b)\n",
      "# rearranging eq.(10.32)\n",
      "Ae = A_star/Me*((2/(gam+1)*(1+(gam-1)/2*Me*Me))**((gam+1)/(gam-1)/2));\n",
      "\n",
      "print\"(a)The thrust of the rocket is:T =\" ,T/1e6, \"N\"\n",
      "print\"\\n(b)The nozzle exit area is\",T_lb   \n",
      "\n",
      "print\"\\nAe =\",Ae, \"m2\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a)The thrust of the rocket is:T = 2.1702872295 N\n",
        "\n",
        "(b)The nozzle exit area is 487663.540469\n",
        "\n",
        "Ae = 16.7097500627 m2\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E05 : Pg 353"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# All the quantities are expressed in SI units\n",
      "import math \n",
      "p0 = 30.*101000.;                            # reservoir pressure\n",
      "T0 = 3500.;                                 # reservoir temperature\n",
      "R = 520.;                                   # specific gas constant\n",
      "gam = 1.22;                                # ratio of specific heats\n",
      "A_star = 0.4;                              # rocket nozzle throat area\n",
      "\n",
      "# the mass flow rate using the closed form analytical expression\n",
      "# from problem 10.5 can be given as\n",
      "m_dot = p0*A_star*math.sqrt(gam/R/T0*((2/(gam+1))**((gam+1)/(gam-1))));\n",
      "\n",
      "print\"The mass flow rate is: m_dot =\",m_dot, \"kg/s\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The mass flow rate is: m_dot = 586.100122081 kg/s\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example E06 : Pg 356"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# All the quantities are expressed in SI units\n",
      "M = 2.;                        # Mach number\n",
      "# for this value M, for a normal shock, from Appendix B\n",
      "p0_ratio = 0.7209;\n",
      "# thus\n",
      "area_ratio = 1./p0_ratio;\n",
      "print\"The diffuser throat to nozzle throat area ratio is: =\",area_ratio"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The diffuser throat to nozzle throat area ratio is: = 1.38715494521\n"
       ]
      }
     ],
     "prompt_number": 6
    }
   ],
   "metadata": {}
  }
 ]
}