{
 "metadata": {
  "name": "",
  "signature": "sha256:6875085981d30c40f21af9abe827ee04ccc837d7faa969a757e96f393b389713"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 2 : Flow Through Variable Area Ducts"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.1 page : 19"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "\t\t\t\t\n",
      "#Input data\n",
      "do1 = 1.12 \t\t\t\t#Density of air i reservoir in kg/m**3\n",
      "ao1 = 500 \t\t\t\t#Velocity of sound in reservoir in m/s\n",
      "d = 0.01 \t\t\t\t#Throat diameter in m \n",
      "k = 1.4 \t\t\t\t#Adiabatic Consmath.tant \n",
      "R = 287 \t\t\t\t#Specific gas consmath.tant in J/kg-K\n",
      "\n",
      "\t\t\t\t\n",
      "#Calculation\n",
      "To1 = ao1**2/(k*R) \t\t\t\t#Stagnation temperature in K\n",
      "Po1 = do1*R*To1 \t\t\t\t#Stagnation pressure in Pa\n",
      "p1 = 0.528 \t\t\t\t#Ratio of critical pressure to Stagnation pressure from gas tables @M = 1\n",
      "Pt = (Po1*p1)*10**-5 \t\t\t\t#Throat pressure in bar\n",
      "t1 = 0.834 \t\t\t\t#Ratio of critical temperature to Stagnation temperature from gas tables @M = 1\n",
      "Tt = To1*t1 \t\t\t\t#critical temperature in K\n",
      "d_t = (Pt*10**5)/(R*Tt) \t\t\t\t#Density of air at throat in kg/m**3\n",
      "a_t = math.sqrt(k*R*Tt) \t\t\t\t#Sound velocity at throat in m/s \n",
      "Ct = a_t \t\t\t\t#Air velocity t throat in m/s, Since M = 1\n",
      "A_t = math.pi*d**2/4 \t\t\t\t#Throat area in m**2 \n",
      "m = d_t*A_t*Ct \t\t\t\t#Maximum mass flow rate in kg/s\n",
      "\n",
      "\t\t\t\t\n",
      "#Output\n",
      "print 'A)Maximum mass flow rate is %3.5f kg/s \\\n",
      "\\nB)Pressure and temperarature at the throat are %3.3f bar and %3.4f K'%(m,Pt,Tt)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "A)Maximum mass flow rate is 0.02543 kg/s \n",
        "B)Pressure and temperarature at the throat are 1.056 bar and 518.9149 K\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.2 page : 20"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "\t\t\t\t\n",
      "#Input data\n",
      "P1 = 2. \t\t\t\t#Intial pressure in bar\n",
      "C1 = 170. \t\t\t\t#Initial velocity of air in m/s\n",
      "T1 = 473. \t\t\t\t#Intial temperature in K\n",
      "A1 = 1000. \t\t\t\t#Inlet area in mm**2\n",
      "P2 = 0.95 \t\t\t\t#Exit pressure in bar\n",
      "k = 1.4 \t\t\t\t#Adiabatic Consmath.tant \n",
      "R = 287. \t\t\t\t#Specific gas consmath.tant in J/kg-K\n",
      "\n",
      "\t\t\t\t\n",
      "#Calculation\n",
      "a_1 = math.sqrt(k*R*T1) \t\t\t\t#Velocity of sound at inlet in m/s\n",
      "M1 = C1/a_1 \t\t\t\t#Inlet mach number\n",
      "t1 = 0.970 \t\t\t\t#Ratio of inlet temperature to Stagnation temperature from gas tables @M = 1\n",
      "To1 = T1/t1 \t\t\t\t#Stagnation temperature in K\n",
      "p1 = 0.900 \t\t\t\t#Ratio of inlet pressure to Stagnation pressure from gas tables @M = 1\n",
      "Po1 = P1/p1 \t\t\t\t#Stagnation pressure in bar\n",
      "a1 = 1.623 \t\t\t\t#Ratio of inlet area to critical area from isentropic gas tables @M = 1\n",
      "At = A1/a1 \t\t\t\t#critical area in mm**2\n",
      "p2 = 0.528 \t\t\t\t#Pressure ratio at critical state from isentropic gas tables @M = 1\n",
      "Pt = Po1*p2 \t\t\t\t#Throat pressure in bar\n",
      "t2 = 0.834 \t\t\t\t#Temperature ratio at critical state from isentropic gas tables @M = 1\n",
      "Tt = To1*t2 \t\t\t\t#Throat temperature in K\n",
      "a_t = math.sqrt(k*R*Tt) \t\t\t\t#Velocity of sound at throat in m/s\n",
      "C_t = a_t \t\t\t\t#Critical velocity of air in m/s\n",
      "p3 = P2/Po1 \t\t\t\t#Pressure ratio at exit \n",
      "M2 = 1.17 \t\t\t\t#Mach number at exit from isentropic gas tables @p3\n",
      "t3 = 0.785 \t\t\t\t#Temperature ratio at exit from isentropic gas tables @M2\n",
      "T2 = To1*t3 \t\t\t\t#Exit temperature in K\n",
      "a3 = 1.022 \t\t\t\t#Area ratio at exit from isentropic gas tables @M2\n",
      "A2 = At*a3 \t\t\t\t#Exit area in mm**2,  wrong answer in textbook\n",
      "C2 = M2*math.sqrt(k*R*T2) \t\t\t\t#Exit velocity in m/s\n",
      "\n",
      "\t\t\t\t\n",
      "#Output\n",
      "print 'A)Stagnation temperature and pressure are %3.2f K and %3.3f bar \\\n",
      "\\nB)Sonic velocity and mach number at entry are %3.2f m/s and %3.2f \\\n",
      "\\nC)Velocity, Mach number and flow area at outlet section are %3.2f m/s, %3.2f and %3.2f mm**2 \\\n",
      "\\nD)Pressure, area at throat of the nozzle are %3.5f bar and %3.3f mm**2'%(To1,Po1,a_1,M1,C2,M2,A2,Pt,At)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "A)Stagnation temperature and pressure are 487.63 K and 2.222 bar \n",
        "B)Sonic velocity and mach number at entry are 435.95 m/s and 0.39 \n",
        "C)Velocity, Mach number and flow area at outlet section are 458.85 m/s, 1.17 and 629.70 mm**2 \n",
        "D)Pressure, area at throat of the nozzle are 1.17333 bar and 616.143 mm**2\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.3 page: 21"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "\t\t\t\t\n",
      "#Input data\n",
      "Po1 = 10. \t\t\t\t#Stagnation pressure in bar\n",
      "To1 = 798. \t\t\t\t#Stagnation temperature in K\n",
      "Pt = 7.6 \t\t\t\t#Throat pressure in bar \n",
      "m = 1.5 \t\t\t\t#Mass flow rate in kg/s\n",
      "k = 1.4 \t\t\t\t#Adiabatic Consmath.tant\n",
      "R = 287. \t\t\t\t#Specific gas consmath.tant in J/kg-K\n",
      "Cp = 1005. \t\t\t\t#Specific heat capacity at consmath.tant pressure in J/kg-K \n",
      " \n",
      "\t\t\t\t\n",
      "#Calculation\n",
      "p1 = 0.528 \t\t\t\t#Ratio of critical pressure to Stagnation pressure from isentropic gas tables @M = 1,k = 1.4\n",
      "Pc = p1*Po1 \t\t\t\t#Critical pressure in bar\n",
      "P2 = Pt \t\t\t\t#Exit pressure in bar, Since Pc<P2\n",
      "p2 = P2/Po1 \t\t\t\t#Pressure ratio\n",
      "M2 = 0.64 \t\t\t\t#Exit mach number from isentropic gas tables @p2\n",
      "t1 = 0.924 \t\t\t\t#Ratio of exit temperature to Stagnation temperature from isentropic gas tables @M2\n",
      "T2 = t1*To1 \t\t\t\t#exit temperature in K\n",
      "C2 = math.sqrt(k*R*T2)*M2 \t\t\t\t#Exit velocity in m/s\n",
      "C_max = math.sqrt(2*Cp*To1) \t\t\t\t#Maximum possible velocity in m/s\n",
      "d2 = (P2*10**5)/(R*T2) \t\t\t\t#Density at exit in kg/m**3\n",
      "At = (m/(d2*C2))*10**6 \t\t\t\t#Throat area in mm**2\n",
      "\n",
      "\t\t\t\t\n",
      "#Output\n",
      "print 'A)At the nozzle throat/exit:    \\\n",
      "\\nPressure is %3.2f bar    \\\n",
      "\\nTemperature is %3.2f K    \\\n",
      "\\nVelocity is %3.2f m/s \\\n",
      "\\nB)Maximum possible velocity is %3.2f m/s \\\n",
      "\\nC)Type of the nozzle is a convergent nozzle and its throat area is %3.3f mm**2'%(P2,T2,C2,C_max,At)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "A)At the nozzle throat/exit:    \n",
        "Pressure is 7.60 bar    \n",
        "Temperature is 737.35 K    \n",
        "Velocity is 348.36 m/s \n",
        "B)Maximum possible velocity is 1266.48 m/s \n",
        "C)Type of the nozzle is a convergent nozzle and its throat area is 1198.980 mm**2\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.4 page : 22"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "\t\t\t\t\n",
      "#Input data\n",
      "Po1 = 3.344 \t\t\t\t#Stagnation pressure in bar\n",
      "To1 = 900. \t\t\t\t#Stagnation temperature in K\n",
      "P2 = 1.05 \t\t\t\t#Exit pressure in bar\n",
      "k = 1.4 \t\t\t\t#Adiabatic Consmath.tant\n",
      "R = 287. \t\t\t\t#Specific gas consmath.tant in J/kg-K\n",
      "Cp = 1005. \t\t\t\t#Specific heat capacity at consmath.tant pressure in J/kg-K \n",
      "\n",
      "\t\t\t\t\n",
      "#Calculation\n",
      "p1 = P2/Po1 \t\t\t\t#Pressure ratio\n",
      "M2 = 1.40 \t\t\t\t#Exit mach number from gas tables @p1,k = 1.4\n",
      "t1 = 0.718 \t\t\t\t#Ratio of exit temperature to Stagnation temperature from isentropic gas tables @M2,k = 1.4\n",
      "T2 = To1*t1 \t\t\t\t#exit temperature in K\n",
      "C2 = math.sqrt(k*R*T2)*M2 \t\t\t\t#Exit velocity in m/s\n",
      "d2 = (P2*10**5)/(R*T2) \t\t\t\t#Density at exit in kg/m**3\n",
      "a1 = 1.115 \t\t\t\t#Ratio of exit area to critical area from isentropic gas tables @M2\n",
      "M_2 = 0.6733 \t\t\t\t#Exit mach number when it acts as diffuser \n",
      "t2 = 0.91633 \t\t\t\t#Ratio of exit temperature to Stagnation temperature from isentropic gas tables @M2\n",
      "T_2 = t2*To1 \t\t\t\t#exit temperature in K\n",
      "C_2 = math.sqrt(k*R*T_2)*M_2 \t\t\t\t#Exit velocity in m/s\n",
      "p2 = 0.738 \t\t\t\t#Ratio of exit pressure to Stagnation pressure from isentropic gas tables @M2\n",
      "P_2 = Po1*p2 \t\t\t\t#exit pressure in bar\n",
      "d_2 = (P_2*10**5)/(R*T_2) \t\t\t\t#Density at exit in kg/m**3\n",
      "\n",
      "\t\t\t\t\n",
      "#Output\n",
      "print 'A)At exit:    \\nTemperaure is %3i K    \\\n",
      "\\nVelocity is %3.2f m/s    \\\n",
      "\\nDensity is %3.3f kg/m**3 \\\n",
      "\\nB)At diffuser:    Temperaure is %3.3f K    \\\n",
      "\\nVelocity is %3.3f m/s    \\\n",
      "\\nDensity is %3.4f kg/m**3    \\\n",
      "\\nPressure is %3.4f bar'%(T2,C2,d2,T_2,C_2,d_2,P_2)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "A)At exit:    \n",
        "Temperaure is 646 K    \n",
        "Velocity is 713.37 m/s    \n",
        "Density is 0.566 kg/m**3 \n",
        "B)At diffuser:    Temperaure is 824.697 K    \n",
        "Velocity is 387.579 m/s    \n",
        "Density is 1.0427 kg/m**3    \n",
        "Pressure is 2.4679 bar\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.5 page : 23"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "\t\t\t\t\n",
      "#Input data\n",
      "Po1 = 8 \t\t\t\t#Stagnation pressure in bar\n",
      "To1 = 273+15 \t\t\t\t#Stagnation temperature in K\n",
      "At = 25 \t\t\t\t#Throat area in cm**2\n",
      "A2 = 100 \t\t\t\t#Exit area in cm**2\n",
      "k = 1.4 \t\t\t\t#Adiabatic Consmath.tant\n",
      "R = 287 \t\t\t\t#Specific gas consmath.tant in J/kg-K\n",
      "\n",
      "\t\t\t\t\n",
      "#Calculation\n",
      "a1 = A2/At \t\t\t\t#Area ratio\n",
      "M2 = 2.94 \t\t\t\t#Exit mach number from gas tables @a1,k = 1.4\n",
      "p1 = 0.0298 \t\t\t\t#Ratio of exit pressure to Stagnation pressure from isentropic gas tables @M2,k = 1.4\n",
      "P2 = Po1*p1 \t\t\t\t#exit pressure in bar\n",
      "M_2 = 0.146 \t\t\t\t#Exit mach number when it acts as diffuser\n",
      "p2 = 0.9847 \t\t\t\t#Ratio of exit pressure to Stagnation pressure from isentropic gas tables @M2\n",
      "P_2 = Po1*p2 \t\t\t\t#exit pressure in bar\n",
      "p3 = 0.528 \t\t\t\t#Ratio of critical pressure to Stagnation pressure from isentropic gas tables @M = 1,k = 1.4 \n",
      "Pc = (Po1*p3) \t\t\t\t#Critical pressure in bar\n",
      "t1 = 0.834 \t\t\t\t#Ratio of critical temperature to Stagnation temperature from isentropic gas tables @M = 1,k = 1.4 \n",
      "Tt = To1*t1 \t\t\t\t#critical temperature in K\n",
      "d_t = (Pc*10**5)/(R*Tt) \t\t\t\t#Density at critical state in kg/m**3\n",
      "a_t = math.sqrt(k*R*Tt) \t\t\t\t#Velocity of sound at critical state in m/s\n",
      "Ct = a_t \t\t\t\t#Velocity of air at critical state in m/s\n",
      "m = d_t*At*Ct*10**-4 \t\t\t\t#Mass flow rate in kg/s\n",
      "\n",
      "\t\t\t\t\n",
      "#Output\n",
      "print 'A)Maximum mass flow rate is %3.3f kg/s \\\n",
      "\\n\\\n",
      "\\nB)As nozzle:    \\\n",
      "\\nPressure is %3.4f bar    \\\n",
      "\\nMach number is %3.2f \\\n",
      "\\nAs diffuser:    \\\n",
      "\\nPressure is %3.4f bar    \\\n",
      "\\nMach number is %3.3f'%(m,P2,M2,P_2,M_2)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "A)Maximum mass flow rate is 4.759 kg/s \n",
        "\n",
        "B)As nozzle:    \n",
        "Pressure is 0.2384 bar    \n",
        "Mach number is 2.94 \n",
        "As diffuser:    \n",
        "Pressure is 7.8776 bar    \n",
        "Mach number is 0.146\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.6 page : 24"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "\t\t\t\t\n",
      "#Input data\n",
      "D1 = 15 \t\t\t\t#Entry diameter in cm\n",
      "D2 = 30 \t\t\t\t#Exit diamater in cm \n",
      "P1 = 0.96 \t\t\t\t#Inlet pressure in bar\n",
      "T1 = 340 \t\t\t\t#Inlet temperature in K\n",
      "C1 = 185 \t\t\t\t#INlet velocity in m/s\n",
      "k = 1.4 \t\t\t\t#Adiabatic Consmath.tant\n",
      "R = 287 \t\t\t\t#Specific gas consmath.tant in J/kg-K\n",
      "\n",
      "\t\t\t\t\n",
      "#Calculation\n",
      "A1 = math.pi*D1**2/4 \t\t\t\t#Entry area in cm**2\n",
      "A2 = math.pi*D2**2/4 \t\t\t\t#Exit area in cm**2\n",
      "a_1 = math.sqrt(k*R*T1) \t\t\t\t#Sound velocity in m/s\n",
      "M1 = C1/a_1 \t\t\t\t#Inlet mach number \n",
      "p1 = 0.843 \t\t\t\t#Ratio of inlet pressure to Stagnation pressure from gas tables @M1,k = 1.4\n",
      "Po1 = P1/p1 \t\t\t\t#Stagnation pressure in bar\n",
      "t1 = 0.952 \t\t\t\t#Ratio of inlet temperature to Stagnation temperature from gas tables @M1,k = 1.4\n",
      "To1 = T1/t1 \t\t\t\t#Stagnation temperature in K\n",
      "a1 = 1.34 \t\t\t\t#Ratio of inlet area to critical area from isentropic gas tables @M1,k = 1.4\n",
      "At = A1/a1 \t\t\t\t#critical area in cm**2\n",
      "a2 = A2/At \t\t\t\t#Area ratio\n",
      "M2 = 0.1088  \t\t\t\t#Exit mach number from gas tables @a2,k = 1.4\n",
      "p2 = 0.992 \t\t\t\t#Ratio of exit pressure to Stagnation pressure from isentropic gas tables @M2,k = 1.4\n",
      "P2 = Po1*p2 \t\t\t\t#exit pressure in bar\n",
      "t2 = 0.9976 \t\t\t\t#Ratio of exit temperature to Stagnation temperature from isentropic gas tables @M2,k = 1.4\n",
      "T2 = To1*t2 \t\t\t\t#exit temperature in K\n",
      "C2 = math.sqrt(k*R*T2)*M2 \t\t\t\t#Exit velocity in m/s\n",
      "F1 = P1*10**5*A1*10**-4*(1+(k*(M1**2))) \t\t\t\t#Force exerted at entry in kN\n",
      "F2 = P2*10**5*A2*10**-4*(1+(k*(M2**2))) \t\t\t\t#Force exerted at exit in kN\n",
      "F = (F2-F1)*10**-3 \t\t\t\t#Force exerted on the diffuser walls in kN, wrong answer in textbook \n",
      "\n",
      "\t\t\t\t\n",
      "#Output\n",
      "print 'A)Exit pressure is %3.3f bar \\\n",
      "\\n\\\n",
      "\\nB)Exit velocity is %3.2f m/s \\\n",
      "\\n\\\n",
      "\\nC)Force exerted on the diffuser walls is %3.3f kN'%(P2,C2,F)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "A)Exit pressure is 1.130 bar \n",
        "\n",
        "B)Exit velocity is 41.17 m/s \n",
        "\n",
        "C)Force exerted on the diffuser walls is 5.826 kN\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.7 page : 25"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "\t\t\t\t\n",
      "#Input data\n",
      "M1 = 3.6 \t\t\t\t#Inlet mach number \n",
      "M2 = 2 \t\t\t\t#Exit mach number\n",
      "m = 15 \t\t\t\t#Mass flow rate in kg/s\n",
      "P1 = 1.05 \t\t\t\t#Inlet pressure in bar\n",
      "T1 = 313 \t\t\t\t#Inlet temperature in K\n",
      "k = 1.4 \t\t\t\t#Adiabatic Consmath.tant\n",
      "R = 287 \t\t\t\t#Specific gas consmath.tant in J/kg-K\n",
      "\n",
      "\t\t\t\t\n",
      "#Calculation\n",
      "p1 = 11.38*10**-3 \t\t\t\t#Ratio of inlet pressure to Stagnation pressure from gas tables @M1,k = 1.4\n",
      "Po = P1/p1 \t\t\t\t#Stagnation pressure in bar\n",
      "t1 = 0.278 \t\t\t\t#Ratio of inlet temperature to Stagnation temperature from gas tables @M1,k = 1.4\n",
      "To = T1/t1 \t\t\t\t#Stagnation temperature in K\n",
      "C1 = math.sqrt(k*R*T1)*M1 \t\t\t\t#Inlet velocity in m/s\n",
      "d1 = (P1*10**5)/(R*T1) \t\t\t\t#Density at inlet in kg/s, P1 in Pa\n",
      "A1 = (m/(d1*C1))*10**4 \t\t\t\t#Inlet area in cm**2\n",
      "p2 = 0.128 \t\t\t\t#Ratio of exit pressure to Stagnation pressure from isentropic gas tables @M2,k = 1.4\n",
      "P2 = Po*p2 \t\t\t\t#exit pressure in bar\n",
      "t2 = 0.555 \t\t\t\t#Ratio of exit temperature to Stagnation temperature from isentropic gas tables @M2,k = 1.4\n",
      "T2 = To*t2 \t\t\t\t#exit temperature in K\n",
      "C2 = math.sqrt(k*R*T2)*M2 \t\t\t\t#Exit velocity in m/s\n",
      "d2 = (P2*10**5)/(R*T2) \t\t\t\t#Density at exit in kg/s\n",
      "A2 = (m/(d2*C2))*10**4 \t\t\t\t#Exit area in cm**2\n",
      "\n",
      "\t\t\t\t\n",
      "#Output \n",
      "print 'A)At Inlet:    \\\n",
      "\\nArea is %3.1f cm**2    \\\n",
      "\\nTotal pressure %3.2f bar    \\\n",
      "\\nTotal temperature is %3.1f K \\\n",
      "\\nB)At Exit:    \\\n",
      "\\nArea is %3.1f cm**2    \\\n",
      "\\nTotal pressure %3.2f bar    \\\n",
      "\\nTotal temperature is %3.2f K    \\\n",
      "\\nStatic temperature is %3.2f K    \\\n",
      "\\nStatic pressure is %3.2f bar'%(A1,Po,To,A2,Po,To,T2,P2)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "A)At Inlet:    \n",
        "Area is 100.5 cm**2    \n",
        "Total pressure 92.27 bar    \n",
        "Total temperature is 1125.9 K \n",
        "B)At Exit:    \n",
        "Area is 22.7 cm**2    \n",
        "Total pressure 92.27 bar    \n",
        "Total temperature is 1125.90 K    \n",
        "Static temperature is 624.87 K    \n",
        "Static pressure is 11.81 bar\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.8 page  :26"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "\t\t\t\t\n",
      "#Input data\n",
      "Po = 6.91 \t\t\t\t#Stagnation pressure in bar\n",
      "To = 325+273 \t\t\t\t#Stagnation temperature in K\n",
      "P2 = 0.98 \t\t\t\t#exit pressure in bar\n",
      "m = 3600/3600 \t\t\t\t#Mass flow rate in kg/s\n",
      "k = 1.4 \t\t\t\t#Adiabatic Consmath.tant\n",
      "R = 287 \t\t\t\t#Specific gas consmath.tant in J/kg-K\n",
      "Cp = 1005 \t\t\t\t#Specific heat capacity at consmath.tant pressure in J/kg-K \n",
      "\n",
      "\t\t\t\t\n",
      "#Calculation\n",
      "p1 = 0.528 \t\t\t\t#Ratio of critical pressure to Stagnation pressure from gas tables @M = 1\n",
      "Pt = Po*p1 \t\t\t\t#critical pressure in bar\n",
      "t1 = 0.834 \t\t\t\t#Ratio of critical temperature to Stagnation temperature from gas tables @M = 1\n",
      "Tt = To*t1 \t\t\t\t#critical temperature in K\n",
      "at = math.sqrt(k*R*Tt) \t\t\t\t#Sound velocity at throat in m/s \n",
      "Ct = at \t\t\t\t#Air velocity t throat in m/s, Since M = 1\n",
      "dt = (Pt*10**5)/(R*Tt) \t\t\t\t#Density of air at throat in kg/m**3, Pt in Pa\n",
      "At = (m/(dt*Ct))*10**4 \t\t\t\t#Throat area in m**2 x10**-4 \n",
      "p2 = P2/Po \t\t\t\t#Pressure ratio \n",
      "M2 = 1.93 \t\t\t\t#Exit mach number from gas tables @p2,k = 1.4\n",
      "t2 = 0.573 \t\t\t\t#Ratio of exit temperature to Stagnation temperature from isentropic gas tables @M2,k = 1.4\n",
      "T2 = To*t2 \t\t\t\t#exit temperature in K\n",
      "a2 = 1.593 \t\t\t\t#Ratio of exit area to critical area from isentropic gas tables @M2,k = 1.4\n",
      "A2 = a2*At \t\t\t\t#Exit area in m**2, At in m**2 x10**-4\n",
      "C_max = math.sqrt(2*Cp*To) \t\t\t\t#Maximum possible velocity in m/s\n",
      "\n",
      "\t\t\t\t\n",
      "#Output\n",
      "print 'A)At throat:    \\\n",
      "\\nArea is %3.2fx10**-4 m**2    \\\n",
      "\\nPressure is %3.2f bar    \\\n",
      "\\nVelocity is %3.1f m/s \\\n",
      "\\nB)At Exit:    \\\n",
      "\\nArea is %3.3fx10**-4 m**2    \\\n",
      "\\nMach number is %3.2f \\\n",
      "\\nC)Maximum possible velocity is %3.2f m/s'%(At,Pt,Ct,A2,M2,C_max)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "A)At throat:    \n",
        "Area is 8.76x10**-4 m**2    \n",
        "Pressure is 3.65 bar    \n",
        "Velocity is 447.6 m/s \n",
        "B)At Exit:    \n",
        "Area is 13.961x10**-4 m**2    \n",
        "Mach number is 1.93 \n",
        "C)Maximum possible velocity is 1096.35 m/s\n"
       ]
      }
     ],
     "prompt_number": 15
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.9 page : 27"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "\t\t\t\t\n",
      "#Input data\n",
      "P1 = 2.45 \t\t\t\t#Inlet pressure in bar\n",
      "T1 = 26.5+273 \t\t\t\t#Inlet temperature in K\n",
      "M1 = 1.4 \t\t\t\t#Inlet mach number \n",
      "M2 = 2.5 \t\t\t\t#Exit mach number\n",
      "k = 1.3 \t\t\t\t#Adiabatic Consmath.tant\n",
      "R = 469 \t\t\t\t#Specific gas consmath.tant in J/kg-K\n",
      "\n",
      "\t\t\t\t\n",
      "#Calculation\n",
      "t1 = 0.773 \t\t\t\t#Ratio of inlet temperature to Stagnation temperature from gas tables @M1,k = 1.3\n",
      "To = T1/t1 \t\t\t\t#Stagnation temperature in K\n",
      "t2 = 0.516 \t\t\t\t#Ratio of exit temperature to Stagnation temperature from isentropic gas tables @M2,k = 1.3\n",
      "T2 = To*t2 \t\t\t\t#exit temperature in K\n",
      "C2 = math.sqrt(k*R*T2)*M2 \t\t\t\t#Exit velocity in m/s\n",
      "a1 = math.sqrt(k*R*T1) \t\t\t\t#Sound velocity at inlet in m/s\n",
      "G = (P1*10**5*a1*M1)/(R*T1) \t\t\t\t#)Flow rate per square meter of the inlet cross section in kg/s-m**2\n",
      "\n",
      "\t\t\t\t\n",
      "#Output\n",
      "print 'A)Stagnation temperature is %3.2f K \\\n",
      "\\nB)At Exit:    \\\n",
      "\\nTemperature is %3.3f K    \\\n",
      "\\nVelocity is %3.2f m/s \\\n",
      "\\nC)Flow rate per square meter of the inlet cross section is %3.2f kg/s-m**2'%(To,T2,C2,G)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "A)Stagnation temperature is 387.45 K \n",
        "B)At Exit:    \n",
        "Temperature is 199.925 K    \n",
        "Velocity is 872.83 m/s \n",
        "C)Flow rate per square meter of the inlet cross section is 1043.47 kg/s-m**2\n"
       ]
      }
     ],
     "prompt_number": 17
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.10 page : 27"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "\t\t\t\t\n",
      "#Input data\n",
      "Po = 1000 \t\t\t\t#Stagnation pressure in kPa\n",
      "To = 800 \t\t\t\t#Stagnation temperature in K\n",
      "k = 1.4 \t\t\t\t#Adiabatic Consmath.tant \n",
      "M2 = 2 \t\t\t\t#Exit mach number\n",
      "At = 20 \t\t\t\t#Throat area in cm**2 \n",
      "R = 287 \t\t\t\t#Specific gas consmath.tant in J/kg-K\n",
      "\n",
      "\t\t\t\t\n",
      "#Calculation\n",
      "t1 = 0.834 \t\t\t\t#Ratio of critical temperature to Stagnation temperature from isentropic gas tables @M = 1,k = 1.4 \n",
      "Tt = To*t1 \t\t\t\t#critical temperature in K\n",
      "at = math.sqrt(k*R*Tt) \t\t\t\t#Velocity of sound at critical state in m/s\n",
      "Ct = at \t\t\t\t#Velocity of air at critical state in m/s, Since M = 1\n",
      "p1 = 0.528 \t\t\t\t#Ratio of critical pressure to Stagnation pressure from isentropic gas tables @M = 1,k = 1.4 \n",
      "Pt = Po*p1 \t\t\t\t#Critical pressure in bar\n",
      "dt = (Pt*10**3)/(R*Tt) \t\t\t\t#Density at critical state in kg/m**3, Pt in Pa\n",
      "m = dt*At*10**-4*Ct \t\t\t\t#Mass flow rate in kg/s, At in m**2\n",
      "p2 = 0.128 \t\t\t\t#Ratio of exit pressure to Stagnation pressure from isentropic gas tables @M2,k = 1.4\n",
      "P2 = Po*p2 \t\t\t\t#exit pressure in kPa\n",
      "t2 = 0.555 \t\t\t\t#Ratio of exit temperature to Stagnation temperature from isentropic gas tables @M2,k = 1.4\n",
      "T2 = To*t2 \t\t\t\t#exit temperature in K\n",
      "a2 = 1.687 \t\t\t\t#Ratio of exit area to critical area from isentropic gas tables @M2,k = 1.4\n",
      "A2 = At*a2 \t\t\t\t#Exit area in cm**2\n",
      "C2 = math.sqrt(k*R*T2)*M2 \t\t\t\t#Exit velocity in m/s\n",
      "d2 = P2*10**3/(R*T2) \t\t\t\t#Density at exit in kg/m**3, P2 in Pa\n",
      "\n",
      "\t\t\t\t\n",
      "#Output\n",
      "print 'A)At throat:    \\\n",
      "\\nTemperature is %3.1f K    \\\n",
      "\\nVelocity is %3.2f m/s    \\\n",
      "\\nPressure is %3i kPa \\\n",
      "\\nB)At Exit:    \\\n",
      "\\nTemperature is %3i K    \\\n",
      "\\nPressure is %3i kPa    \\\n",
      "\\nArea is %3.2f m**2    \\\n",
      "\\nMass flow rate is %3.4f kg/s'%(Tt,Ct,Pt,T2,P2,A2,m)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "A)At throat:    \n",
        "Temperature is 667.2 K    \n",
        "Velocity is 517.77 m/s    \n",
        "Pressure is 528 kPa \n",
        "B)At Exit:    \n",
        "Temperature is 444 K    \n",
        "Pressure is 128 kPa    \n",
        "Area is 33.74 m**2    \n",
        "Mass flow rate is 2.8553 kg/s\n"
       ]
      }
     ],
     "prompt_number": 19
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.11 page : 28"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "\t\t\t\t\n",
      "#Input data\n",
      "M2 = 2 \t\t\t\t#Exit mach number\n",
      "At = 1000 \t\t\t\t#Throat area in cm**2 \n",
      "Po = 0.69 \t\t\t\t#Stagnation pressure in bar \n",
      "To = 310 \t\t\t\t#Stagnation temperature in K\n",
      "k = 1.4 \t\t\t\t#Adiabatic Consmath.tant \n",
      "R = 287 \t\t\t\t#Specific gas consmath.tant in J/kg-K\n",
      "Cp = 1.005 \t\t\t\t#Specific heat capacity at consmath.tant pressure in kJ/kg-K \n",
      "\n",
      "\t\t\t\t\n",
      "#Calculation\n",
      "t1 = 0.834 \t\t\t\t#Ratio of critical temperature to Stagnation temperature from isentropic gas tables @M = 1,k = 1.4\n",
      "Tt = To*t1 \t\t\t\t#critical temperature in K\n",
      "at = math.sqrt(k*R*Tt) \t\t\t\t#Velocity of sound at critical state in m/s\n",
      "Ct = at \t\t\t\t#Velocity of air at critical state in m/s, Since M = 1\n",
      "p1 = 0.528 \t\t\t\t#Ratio of critical pressure to Stagnation pressure from isentropic gas tables @M = 1,k = 1.4 \n",
      "Pt = Po*p1 \t\t\t\t#Critical pressure in bar\n",
      "dt = (Pt*10**5)/(R*Tt) \t\t\t\t#Density at critical state in kg/m**3, Pt in Pa\n",
      "m = dt*At*10**-4*Ct \t\t\t\t#Mass flow rate in kg/s, At in m**2\n",
      "p2 = 0.128 \t\t\t\t#Ratio of exit pressure to Stagnation pressure from isentropic gas tables @M2,k = 1.4\n",
      "P2 = Po*p2 \t\t\t\t#exit pressure in bar\n",
      "t2 = 0.555 \t\t\t\t#Ratio of exit temperature to Stagnation temperature from isentropic gas tables @M2,k = 1.4\n",
      "T2 = To*t2 \t\t\t\t#exit temperature in K\n",
      "C2 = math.sqrt(k*R*T2)*M2 \t\t\t\t#Exit velocity in m/s\n",
      "d2 = (P2*10**5)/(R*T2) \t\t\t\t#Density at exit in kg/m**3, P2 in Pa\n",
      "A2 = (m/(d2*C2))*10**4 \t\t\t\t#Exit area in cm**2\n",
      "P = m*Cp*(To-T2) \t\t\t\t#Power required to drive the compressor in kW\n",
      "\n",
      "\t\t\t\t\n",
      "#Output\n",
      "print 'A)At throat:    \\\n",
      "\\nTemperature is %3.2f K    \\\n",
      "\\nVelocity is %3.2f m/s    \\\n",
      "\\nPressure is %3.3f bar    \\\n",
      "\\nAt Test section:    Temperature is %3.2f K    \\\n",
      "\\nVelocity is %3.3f m/s    \\\n",
      "\\nPressure is %3.3f bar \\\n",
      "\\nB)Area of cross section at test section is %3i cm**2 \\\n",
      "\\nC)Mass flow rate is %3.3f kg/s \\\n",
      "\\nD)Power required to drive the compressor is %3.2f kW'%(Tt,Ct,Pt,T2,C2,P2,A2,m,P)\n",
      "\n",
      "# note :  rounding off error."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "A)At throat:    \n",
        "Temperature is 258.54 K    \n",
        "Velocity is 322.31 m/s    \n",
        "Pressure is 0.364 bar    \n",
        "At Test section:    Temperature is 172.05 K    \n",
        "Velocity is 525.851 m/s    \n",
        "Pressure is 0.088 bar \n",
        "B)Area of cross section at test section is 1682 cm**2 \n",
        "C)Mass flow rate is 15.825 kg/s \n",
        "D)Power required to drive the compressor is 2193.97 kW\n"
       ]
      }
     ],
     "prompt_number": 22
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.12 page : 30"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "\n",
      "#Input data\n",
      "Po = 10. \t\t\t\t#Stagnation pressure in bar \n",
      "To = 100.+273 \t\t\t\t#Stagnation temperature in K\n",
      "m = 15. \t\t\t\t#mass flow rate in kg/s\n",
      "P2s = 1. \t\t\t\t#Back pressure in isentropic state in bar\n",
      "eff = 0.95 \t\t\t\t#efficiency of diverging nozzle\n",
      "k = 1.4 \t\t\t\t#Adiabatic Consmath.tant \n",
      "R = 287. \t\t\t\t#Specific gas consmath.tant in J/kg-K\n",
      "Cp = 1005. \t\t\t\t#Specific heat capacity at consmath.tant pressure in J/kg-K \n",
      "\n",
      "\n",
      "#Calculation\n",
      "#case I: isentropic\n",
      "t1 = 0.834 \t\t\t\t#Ratio of critical temperature to Stagnation temperature from isentropic gas tables @M = 1,k = 1.4\n",
      "Tt = To*t1 \t\t\t\t#critical temperature in K\n",
      "at = math.sqrt(k*R*Tt) \t\t\t\t#Velocity of sound at critical state in m/s\n",
      "Ct = at \t\t\t\t#Velocity of air at critical state in m/s, Since M = 1\n",
      "p1 = 0.528 \t\t\t\t#Ratio of critical pressure to Stagnation pressure from isentropic gas tables @M = 1,k = 1.4 \n",
      "Pt = Po*p1 \t\t\t\t#Critical pressure in bar\n",
      "dt = (Pt*10**5)/(R*Tt) \t\t\t\t#Density at critical state in kg/m**3, Pt in Pa\n",
      "At = (m/(dt*Ct))*10**4 \t\t\t\t#Throat area in cm**2 \n",
      "p2 = P2s/Po \t\t\t\t#Pressure ratio\n",
      "M2s = 2.15 \t\t\t\t#Exit mach number from gas tables (isentropic state) @p2,k = 1.4\n",
      "t2 = 0.519 \t\t\t\t#Ratio of exit temperature to Stagnation temperature from isentropic gas tables @M2s,k = 1.4\n",
      "T2s = t2*To \t\t\t\t#exit temperature in K\n",
      "a2s = math.sqrt(k*R*T2s) \t\t\t\t#Velocity of sound at exit in m/s\n",
      "C2s = M2s*a2s \t\t\t\t#Exit air velocity in m/s\n",
      "d2s = (P2s*10**5)/(R*T2s) \t\t\t\t#Density at exit in kg/m**3, P2 in Pa\n",
      "A2s = (m/(d2s*C2s))*10**4 \t\t\t\t#Exit area in cm**2\n",
      "#case II: isentropic upto throat\n",
      "T2 = To-(eff*(To-T2s)) \t\t\t\t#Exit tempareture in K\n",
      "C2 = math.sqrt(2*Cp*(To-T2)) \t\t\t\t#Exit air velocity in m/s\n",
      "P2 = P2s \t\t\t\t#Exit pressure in bar, Since it is diffuser\n",
      "d2 = (P2*10**5)/(R*T2) \t\t\t\t#Density at exit in kg/m**3, P2 in Pa\n",
      "A2 = (m/(d2*C2))*10**4 \t\t\t\t#Exit area in cm**2\n",
      "\n",
      "\n",
      "#Output\n",
      "print 'A)The nozzle cross section at throat in both cases is %3.2f cm**2 \\\n",
      "\\nB)The nozzle cross section at exit in case I is %3.3f cm**2 and in case II is %3.2f cm**2'%(At,A2s,A2)\n",
      "\n",
      "# note : rounding off error."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "A)The nozzle cross section at throat in both cases is 71.74 cm**2 \n",
        "B)The nozzle cross section at exit in case I is 138.985 cm**2 and in case II is 148.98 cm**2\n"
       ]
      }
     ],
     "prompt_number": 25
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.13 page  : 31"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "\t\t\t\t\n",
      "#Input data\n",
      "Po = 600. \t\t\t\t#Stagnation pressure in kPa\n",
      "To = 40.+273 \t\t\t\t#Stagnation temperature in K\n",
      "P2 = 100. \t\t\t\t#exit pressure in kPa\n",
      "k = 1.4 \t\t\t\t#Adiabatic Consmath.tant \n",
      "R = 287. \t\t\t\t#Specific gas consmath.tant in J/kg-K\n",
      "\n",
      "\t\t\t\t\n",
      "#Calculation\n",
      "p1 = P2/Po \t\t\t\t#pressure ratio \n",
      "M2 = 1.82 \t\t\t\t#Exit mach number from gas tables @p2,k = 1.4\n",
      "ar = 1.461 \t\t\t\t#Ratio of nozzle exit area to nozzle throat area from gas tables @M2\n",
      "t1 = 0.602 \t\t\t\t#Ratio of exit temperature to Stagnation temperature from isentropic gas tables @M2,k = 1.4\n",
      "T2 = To*t1 \t\t\t\t#exit temperature in K\n",
      "C2 = math.sqrt(k*R*T2)*M2 \t\t\t\t#Exit air velocity in m/s\n",
      "p2 = 3.698 \t\t\t\t#Ratio of static pressures after shock to before shock from normal shock gas tables @M2 \n",
      "Py = p2*P2 \t\t\t\t#The back pressure at which normal shock acts at the exit plane of the nozzle in kPa\n",
      "\n",
      "\t\t\t\t\n",
      "#Output\n",
      "print 'A)Ratio of nozzle exit area to nozzle throat area is %3.3f \\\n",
      "\\nB)The discharge velocity from nozzle is %3.2f m/s \\\n",
      "\\nC)The back pressure at which normal shock acts at the exit plane of the nozzle is %3.1f kPa'%(ar,C2,Py)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "A)Ratio of nozzle exit area to nozzle throat area is 1.461 \n",
        "B)The discharge velocity from nozzle is 500.78 m/s \n",
        "C)The back pressure at which normal shock acts at the exit plane of the nozzle is 369.8 kPa\n"
       ]
      }
     ],
     "prompt_number": 27
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.14 page : 32"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "\t\t\t\t\n",
      "#Input data\n",
      "ar = 2. \t\t\t\t#Ratio of nozzle exit area to nozzle throat area\n",
      "Po = 700. \t\t\t\t#Stagnation pressure in kPa\n",
      "P2 = 400. \t\t\t\t#exit pressure in kPa\n",
      "\n",
      "\t\t\t\t\n",
      "#Calculation\n",
      "p1 = 0.528 \t\t\t\t#Ratio of critical pressure to Stagnation pressure from gas tables @M = 1\n",
      "Pt = Po*p1 \t\t\t\t#critical pressure in bar\n",
      "p2 = P2/Po \t\t\t\t#Pressure ratio\n",
      "M2 = 0.93 \t\t\t\t#Exit mach number from gas tables @p2,k = 1.4\n",
      "\n",
      "\t\t\t\t\n",
      "#Output\n",
      "print 'Since pressure decreases from %3i kPa to %3.1f kPa from inlet to throat, \\\n",
      "\\nit acts as nozzle Since exit pressure %3i kPa is above critical pressure %3.1f kPa, \\\n",
      "\\nit acts as diffuser with M = %3.2f Hence the duct acts as Venturi'%(Po,Pt,P2,Pt,M2)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Since pressure decreases from 700 kPa to 369.6 kPa from inlet to throat, \n",
        "it acts as nozzle Since exit pressure 400 kPa is above critical pressure 369.6 kPa, \n",
        "it acts as diffuser with M = 0.93 Hence the duct acts as Venturi\n"
       ]
      }
     ],
     "prompt_number": 29
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.15 page : 33"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "\t\t\t\t\n",
      "#Input data\n",
      "A1 = 0.15 \t\t\t\t#Inlet area in m**2\n",
      "C1 = 240 \t\t\t\t#Inlet velocity in m/s \n",
      "T1 = 300 \t\t\t\t#Inlet temperature in K\n",
      "P1 = 0.7 \t\t\t\t#Inlet pressure in bar\n",
      "C2 = 120 \t\t\t\t#Exit velocity in m/s\n",
      "k = 1.4 \t\t\t\t#Adiabatic Consmath.tant\n",
      "R = 287 \t\t\t\t#Specific gas consmath.tant in J/kg-K\n",
      "Cp = 1005 \t\t\t\t#Specific heat capacity at consmath.tant pressure in J/kg-K \n",
      "\n",
      "\t\t\t\t\n",
      "#Calculations\n",
      "a1 = math.sqrt(k*R*T1) \t\t\t\t#Velocity of sound at inlet in m/s\n",
      "M1 = C1/a1 \t\t\t\t#Inlet mach number \n",
      "d1 = (P1*10**5)/(R*T1) \t\t\t\t#Density at inlet in kg/s, P1 in Pa\n",
      "m = d1*A1*C1 \t\t\t\t#Mass flow rate in kg/s\n",
      "t1 = 0.913 \t\t\t\t#Ratio of inlet temperature to Stagnation temperature from gas tables @M1,k = 1.4\n",
      "To = T1/t1 \t\t\t\t#Stagnation temperature in K\n",
      "p1 = 0.727 \t\t\t\t#Ratio of inlet pressure to Stagnation pressure from gas tables @M1,k = 1.4\n",
      "Po = P1/p1 \t\t\t\t#Stagnation pressure in bar\n",
      "T2 = To-(C2**2/(2*Cp)) \t\t\t\t#Exit temperature in K\n",
      "t2 = T2/To \t\t\t\t#Temperature ratio \n",
      "M2 = 0.33 \t\t\t\t#Exit mach number from gas tables @t2,k = 1.4\n",
      "p2 = 0.927 \t\t\t\t#Ratio of exit pressure to Stagnation pressure from isentropic gas tables @M2,k = 1.4\n",
      "P2 = Po*p2 \t\t\t\t#exit pressure in bar\n",
      "d2 = (P2*10**5)/(R*T2) \t\t\t\t#Density at exit in kg/s, P2 in Pa\n",
      "A2 = (m/(d2*C2)) \t\t\t\t#Exit area in m**2\n",
      "ds = 0 \t\t\t\t#Entropy change in kJ/kg-K, math.since process is isentropic\n",
      "\n",
      "\t\t\t\t\n",
      "#Output\n",
      "print 'A)Mass flow rate is %3.3f kg/s \\\n",
      "\\nB)Stagnation pressure at exit is %3.4f bar \\\n",
      "\\nC)Stagnation Temperature at exit is %3.3f K \\\n",
      "\\nD)Static exit pressure is %3.3f bar \\\n",
      "\\nE)Entropy change is %3i kJ/kg-K \\\n",
      "\\nF)Exit area is %3.3f m**2'%(m,Po,To,P2,ds,A2)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "A)Mass flow rate is 29.268 kg/s \n",
        "B)Stagnation pressure at exit is 0.9629 bar \n",
        "C)Stagnation Temperature at exit is 328.587 K \n",
        "D)Static exit pressure is 0.893 bar \n",
        "E)Entropy change is   0 kJ/kg-K \n",
        "F)Exit area is 0.252 m**2\n"
       ]
      }
     ],
     "prompt_number": 33
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.16 page :  34"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "\t\t\t\t\n",
      "#Input data\n",
      "A2 = 645. \t\t\t\t#Exit area in mm**2\n",
      "M2 = 2. \t\t\t\t#Exit mach number\n",
      "P2 = 1. \t\t\t\t#exit pressure in bar\n",
      "T2 = 185. \t\t\t\t#Exit temperature in K\n",
      "k = 1.4 \t\t\t\t#Adiabatic Consmath.tant\n",
      "R = 287. \t\t\t\t#Specific gas consmath.tant in J/kg-K\n",
      "\n",
      "\t\t\t\t\n",
      "#Calculation\n",
      "t1 = 0.555 \t\t\t\t#Ratio of exit temperature to Stagnation temperature from gas tables @M2,k = 1.4\n",
      "To = T2/t1 \t\t\t\t#Stagnation temperature in K\n",
      "p1 = 0.128 \t\t\t\t#Ratio of exit pressure to Stagnation pressure from isentropic gas tables @M2,k = 1.4\n",
      "Po = P2/p1 \t\t\t\t#Stagnation pressure in bar\n",
      "a1 = 1.687 \t\t\t\t#Ratio of exit area to critical area from isentropic gas tables @M2,k = 1.4\n",
      "At = A2/a1 \t\t\t\t#Critical area in mm**2\n",
      "d2 = (P2*10**5)/(R*T2) \t\t\t\t#Density at exit in kg/s, P2 in Pa\n",
      "C2 = math.sqrt(k*R*T2)*M2 \t\t\t\t#Exit air velocity in m/s\n",
      "m = d2*A2*C2*10**-6 \t\t\t\t#Mass flow rate in kg/s, A2 in m**2\n",
      "\n",
      "\t\t\t\t\n",
      "#Output\n",
      "print 'A)Throat area is %3.2f mm**2 \\\n",
      "\\nB)Reservoir pressure is %3.4f bar \\\n",
      "\\nC)Reservoir temperature is %3.2f K \\\n",
      "\\nD)Mass flow rate is %3.4f kg/s'%(At,Po,To,m)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "A)Throat area is 382.34 mm**2 \n",
        "B)Reservoir pressure is 7.8125 bar \n",
        "C)Reservoir temperature is 333.33 K \n",
        "D)Mass flow rate is 0.6624 kg/s\n"
       ]
      }
     ],
     "prompt_number": 35
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.17 page : 34"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "\t\t\t\t\n",
      "#Input data\n",
      "Po = 20. \t\t\t\t#Stagnation pressure in kPa\n",
      "To = 1000. \t\t\t\t#Stagnation temperature in K\n",
      "P2 = 3. \t\t\t\t#exit pressure in bar\n",
      "A2 = 100. \t\t\t\t#Exit area in cm**2\n",
      "k = 1.4 \t\t\t\t#Adiabatic Consmath.tant\n",
      "R = 287. \t\t\t\t#Specific gas consmath.tant in J/kg-K\n",
      "Cp = 1005. \t\t\t\t#Specific heat capacity at consmath.tant pressure in J/kg-K \n",
      "\n",
      "\t\t\t\t\n",
      "#Calculations\n",
      "p1 = P2/Po \t\t\t\t#Pressure ratio\n",
      "M2 = 1.9 \t\t\t\t#Exit mach number from gas tables @p1,k = 1.4\n",
      "t1 = 0.581 \t\t\t\t#Ratio of exit temperature to Stagnation temperature from isentropic gas tables @M2,k = 1.4 \n",
      "T2 = To*t1 \t\t\t\t#exit temperature in K\n",
      "C2 = M2*math.sqrt(k*R*T2) \t\t\t\t#Exit velocity in m/s\n",
      "a1 = 1.555 \t\t\t\t#Ratio of exit area to critical area from isentropic gas tables @M2,k = 1.4\n",
      "At = A2/a1 \t\t\t\t#critical area in cm**2\n",
      "p1 = 0.528 \t\t\t\t#Ratio of critical pressure to Stagnation pressure from gas tables @M = 1\n",
      "Pt = Po*p1 \t\t\t\t#critical pressure in bar\n",
      "t1 = 0.834 \t\t\t\t#Ratio of critical temperature to Stagnation temperature from gas tables @M = 1\n",
      "Tt = To*t1 \t\t\t\t#critical temperature in K\n",
      "at = math.sqrt(k*R*Tt) \t\t\t\t#Sound velocity at throat in m/s \n",
      "Ct = at \t\t\t\t#Air velocity t throat in m/s, Since M = 1\n",
      "dt = (Pt*10**5)/(R*Tt) \t\t\t\t#Density of air at throat in kg/m**3, Pt in Pa\n",
      "m = dt*At*10**-4*Ct \t\t\t\t#Mass flow rate in kg/s, At in m**2\n",
      "C_max = math.sqrt(2*Cp*To) \t\t\t\t#Maximum possible velocity in m/s\n",
      "cr = C2/C_max \t\t\t\t#Ratio of velocities\n",
      "\n",
      "\t\t\t\t\n",
      "#Output\n",
      "print 'A)At Throat:    \\\n",
      "\\nArea is %3.2f cm**2    \\\n",
      "\\nPressure is %3.2f bar    \\\n",
      "\\nTemperature is %3i K \\\n",
      "\\nB)Exit velocity is %3.4f times C_max in m/s \\\n",
      "\\nC)Mass flow rate is %3.2f kg/s'%(At,Pt,Tt,cr,m)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "A)At Throat:    \n",
        "Area is 64.31 cm**2    \n",
        "Pressure is 10.56 bar    \n",
        "Temperature is 834 K \n",
        "B)Exit velocity is 0.6475 times C_max in m/s \n",
        "C)Mass flow rate is 16.42 kg/s\n"
       ]
      }
     ],
     "prompt_number": 37
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.18 page : 35"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "\t\t\t\t\n",
      "#Input data\n",
      "Po = 7. \t\t\t\t#Stagnation pressure in bar\n",
      "To = 100.+273 \t\t\t\t#Stagnation temperature in K\n",
      "At = 12. \t\t\t\t#Critical area in cm**2\n",
      "A2 = 25.166 \t\t\t\t#Exit area in cm**2\n",
      "k = 1.4 \t\t\t\t#Adiabatic Consmath.tant\n",
      "R = 287. \t\t\t\t#Specific gas consmath.tant in J/kg-K\n",
      "\n",
      "\t\t\t\t\n",
      "#Calculation\n",
      "a1 = A2/At \t\t\t\t#Ratio of areas\n",
      "\t\t\t\t#subsonic\n",
      "M2 = 0.29 \t\t\t\t#Exit mach number from gas tables @a1,k = 1.4\n",
      "p1 = 0.943 \t\t\t\t#Ratio of exit pressure to Stagnation pressure from isentropic gas tables @M2,k = 1.4\n",
      "P2 = Po*p1 \t\t\t\t#exit pressure in bar\n",
      "t1 = 0.983 \t\t\t\t#Ratio of exit temperature to Stagnation temperature from gas tables @M2,k = 1.4\n",
      "T2 = To*t1 \t\t\t\t#Exit temperature in K\n",
      "C2 = M2*math.sqrt(k*R*T2) \t\t\t\t#Exit air velocity in m/s\n",
      "\t\t\t\t#supersonic\n",
      "M_2 = 2.25 \t\t\t\t#Exit mach number from gas tables @a1,k = 1.4\n",
      "p2 = 0.0865 \t\t\t\t#Ratio of exit pressure to Stagnation pressure from isentropic gas tables @M2,k = 1.4\n",
      "P_2 = Po*p2 \t\t\t\t#exit pressure in bar\n",
      "t2 = 0.497 \t\t\t\t#Ratio of exit temperature to Stagnation temperature from gas tables @M2,k = 1.4\n",
      "T_2 = To*t2 \t\t\t\t#Exit temperature in K\n",
      "C_2 = M_2*math.sqrt(k*R*T_2) \t\t\t\t#Exit air velocity in m/s\n",
      "d2 = (P2*10**5)/(R*T2) \t\t\t\t#Density at exit in kg/s, P2 in Pa\n",
      "m = d2*A2*10**-4*C2 \t\t\t\t#Mass flow rate in kg/s, A2 in m**2\n",
      "\n",
      "\t\t\t\t\n",
      "#Output\n",
      "print 'A)Maximum mass flow rate is %3.3f kg/s \\\n",
      "\\nB)Subsonic exit condition:    \\\n",
      "\\nTemperature is %3.3f K    \\\n",
      "\\nVelocity is %3.2f m/s    \\\n",
      "\\nPressure is %3.3f bar    \\\n",
      "\\nMach number is %3.2f    \\\n",
      "\\nSupersonic exit condition:    \\\n",
      "\\nTemperature is %3.3f K    \\\n",
      "\\nVelocity is %3.2f m/s    \\\n",
      "\\nPressure is %3.4f bar    \\\n",
      "\\nMach number is %3.2f'%(m,T2,C2,P2,M2,T_2,C_2,P_2,M_2)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "A)Maximum mass flow rate is 1.757 kg/s \n",
        "B)Subsonic exit condition:    \n",
        "Temperature is 366.659 K    \n",
        "Velocity is 111.31 m/s    \n",
        "Pressure is 6.601 bar    \n",
        "Mach number is 0.29    \n",
        "Supersonic exit condition:    \n",
        "Temperature is 185.381 K    \n",
        "Velocity is 614.07 m/s    \n",
        "Pressure is 0.6055 bar    \n",
        "Mach number is 2.25\n"
       ]
      }
     ],
     "prompt_number": 39
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.19 page : 36"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "\t\t\t\t\n",
      "#Input data\n",
      "T1 = 335. \t\t\t\t#Inlet temperature in K\n",
      "P1 = 655. \t\t\t\t#Inlet pressure in kPa\n",
      "C1 = 150. \t\t\t\t#Inlet velocity in m/s\n",
      "P2 = 138. \t\t\t\t#Exit pressure in kPa\n",
      "T2 = 222. \t\t\t\t#Exit temperature in K\n",
      "m = 9. \t\t\t\t#Mass flow rate in kg/s\n",
      "Mol = 32. \t\t\t\t#Molar mass of oxygen in kg/mol\n",
      "Ri = 8314. \t\t\t\t#Ideal gas consmath.tant in J/kg-k\n",
      "k = 1.4 \t\t\t\t#Adiabatic Consmath.tant\n",
      "Cp = 915. \t\t\t\t#Specific heat capacity at consmath.tant pressure in J/kg-K \n",
      "\n",
      "\t\t\t\t\n",
      "#Calculation\n",
      "R = Ri/Mol \t\t\t\t#Specific gas consmath.tant in J/kg-K\n",
      "a1 = math.sqrt(k*R*T1) \t\t\t\t#Sound velocity at inlet in m/s \n",
      "M1 = C1/a1 \t\t\t\t#Inlet mach number\n",
      "t1 = 0.964 \t\t\t\t#Ratio of inlet temperature to Stagnation temperature from gas tables @M1,k = 1.4\n",
      "To1 = T1/t1 \t\t\t\t#Stagnation temperature at inlet in K\n",
      "p1 = 0.881 \t\t\t\t#Ratio of inlet pressure to Stagnation pressure at entry from gas tables @M1,k = 1.4 \n",
      "Po1 = P1/p1 \t\t\t\t#Stagnation pressure at entry in kPa\n",
      "t2 = 0.834 \t\t\t\t#Ratio of critical temperature to Stagnation temperature from gas tables @M = 1\n",
      "Tt = To1*t2 \t\t\t\t#critical temperature in K\n",
      "C2 = math.sqrt(C1**2+(2*Cp*(T1-T2))) \t\t\t\t#Exit velocity in m/s, \n",
      "a2 = math.sqrt(k*R*T2) \t\t\t\t#Sound velocity at exit in m/s \n",
      "M2 = C2/a2 \t\t\t\t#Exit mach number \n",
      "p2 = 0.208 \t\t\t\t#Ratio of exit pressure to Stagnation pressure at exit from isentropic gas tables @M2,k = 1.4\n",
      "Po2 = P2/p2 \t\t\t\t#Stagnation pressure at exit in kPa\n",
      "SPC = (Po1-Po2) \t\t\t\t#Change in the stagnation pressure between inlet and exit in kPa\n",
      "ds = R*math.log(Po1/Po2) \t\t\t\t#Change in entropy in J/kg-K\n",
      "T2s = T1*((P2/P1)**((k-1)/k)) \t\t\t\t#Exit temperature at isentropic state in K\n",
      "eff = ((T1-T2)/(T1-T2s))*100 \t\t\t\t#Nozzle efficiency in percent\n",
      "\n",
      "\t\t\t\t\n",
      "#Output\n",
      "print 'A)Exit mach number is %3.2f \\\n",
      "\\nB)Change in the stagnation pressure between inlet and exit is %3.2f kPa \\\n",
      "\\nC)Change in entropy is %3.3f J/kg-K \\\n",
      "\\nD)Static temperature at throat is %3.1f K \\\n",
      "\\nE)Nozzle efficiency is %3.2f percent'%(M2,SPC,ds,Tt,eff)\n",
      "\n",
      "# note : rounding off error."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "A)Exit mach number is 1.69 \n",
        "B)Change in the stagnation pressure between inlet and exit is 80.01 kPa \n",
        "C)Change in entropy is 29.583 J/kg-K \n",
        "D)Static temperature at throat is 289.8 K \n",
        "E)Nozzle efficiency is 93.92 percent\n"
       ]
      }
     ],
     "prompt_number": 42
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.20 page : 37"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "\t\t\t\t\n",
      "#Input data\n",
      "C1 = 200. \t\t\t\t#Inlet velocity in m/s\n",
      "Po1 = 400. \t\t\t\t#Stagnation pressure at entry in kPa\n",
      "To1 = 500. \t\t\t\t#Stagnation temperature at inlet in K\n",
      "C2 = 100. \t\t\t\t#Exit velocity in m/s\n",
      "eff = 0.9 \t\t\t\t#Nozzle efficiency \n",
      "k = 1.4 \t\t\t\t#Adiabatic Consmath.tant\n",
      "Cp = 1005. \t\t\t\t#Specific heat capacity at consmath.tant pressure in J/kg-K \n",
      "\n",
      "\t\t\t\t\n",
      "#Calculation\n",
      "T1 = To1-(C1**2/(2*Cp)) \t\t\t\t#Inlet temperature in K\n",
      "t1 = T1/To1 \t\t\t\t#Temperature ratio \n",
      "P1 = Po1*t1**(k/(k-1)) \t\t\t\t#Inlet pressure in kPa\n",
      "To2s = (eff*(To1-T1))+T1 \t\t\t\t#Exit Stagnation temperature at isentropic state in K\n",
      "To2 = To2s \t\t\t\t#Exit Stagnation temperature in K, Since adiabatic \n",
      "T2 = To2-(C2**2/(2*Cp)) \t\t\t\t#Exit temperature in K\n",
      "t2 = To2s/T1 \t\t\t\t#Temperature ratio \n",
      "Po2 = P1*t2**(k/(k-1)) \t\t\t\t#Stagnation pressure at exit in kPa\n",
      "t3 = T2/To2 \t\t\t\t#Temperature ratio \n",
      "P2 = Po2*t3**(k/(k-1)) \t\t\t\t#Exit pressure in kPa\n",
      "Cpr = (P2-P1)/(Po1-P1) \t\t\t\t#Pressure raise coefficient\n",
      "ar = (P1*T2*C1)/(P2*T1*C2) \t\t\t\t#Ratio of exit to inlet area\n",
      "\n",
      "\t\t\t\t\n",
      "#Output\n",
      "print 'A)Pressure raise coefficient is %3.3f \\\n",
      "\\nB)Ratio of exit to inlet area is %3.3f'%(Cpr,ar)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "A)Pressure raise coefficient is 0.638 \n",
        "B)Ratio of exit to inlet area is 1.871\n"
       ]
      }
     ],
     "prompt_number": 44
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.21 page : 38"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "\t\t\t\t\n",
      "#Input data\n",
      "Po1 = 4.9 \t\t\t\t#Stagnation pressure at entry in bar\n",
      "P2 = 1.4 \t\t\t\t#Exit pressure in bar\n",
      "To = 810 \t\t\t\t#Stagnation temperature in K\n",
      "m = 1 \t\t\t\t#Mass flow rate in kg/s\n",
      "eff = 0.9 \t\t\t\t#Nozzle efficiency \n",
      "k = 1.4 \t\t\t\t#Adiabatic Consmath.tant\n",
      "R = 287 \t\t\t\t#Specific gas consmath.tant in J/kg-K\n",
      "Cp = 1005 \t\t\t\t#Specific heat capacity at consmath.tant pressure in J/kg-K \n",
      "\n",
      "\t\t\t\t\n",
      "#Calculations\n",
      "t1 = 0.834 \t\t\t\t#Ratio of critical temperature to Stagnation temperature from gas tables @M = 1\n",
      "Tt = To*t1 \t\t\t\t#critical temperature in K\n",
      "at = math.sqrt(k*R*Tt) \t\t\t\t#Sound velocity at critical state in m/s \n",
      "Ct = at \t\t\t\t#Air velocity t throat in m/s, Since M = 1\n",
      "p1 = 0.528 \t\t\t\t#Ratio of critical pressure to Stagnation pressure from gas tables @M = 1\n",
      "Pt = Po1*p1 \t\t\t\t#critical pressure in bar\n",
      "dt = (Pt*10**5)/(R*Tt) \t\t\t\t#Density of air at throat in kg/m**3, Pt in Pa\n",
      "At = (m/(dt*Ct))*10**4 \t\t\t\t#Throat area in cm**2 \n",
      "p2 = P2/Po1 \t\t\t\t#Pressure ratio\n",
      "T2s = To*p2**((k-1)/k) \t\t\t\t#Exit temperature in K (at isentropic state)\n",
      "T2 = To-(eff*(To-T2s)) \t\t\t\t#Exit temperature in K\n",
      "d2 = (P2*10**5)/(R*T2) \t\t\t\t#Density at exit in kg/m**3, P2 in Pa\n",
      "C2 = math.sqrt(2*Cp*(To-T2)) \t\t\t\t#Exit air velocity in m/s\n",
      "A2 = (m/(d2*C2))*10**4 \t\t\t\t#Exit area in cm**2\n",
      "a2 = math.sqrt(k*R*T2) \t\t\t\t#Sound velocity at exit in m/s \n",
      "M2 = C2/a2 \t\t\t\t#Exit mach number\n",
      "p3 = 0.332 \t\t\t\t#Static to stagnation pressure ratio at exit from isentropic gas tables @M2,k = 1.4 \n",
      "Po2 = P2/p3 \t\t\t\t#stagnation pressure in bar\n",
      "TPL = Po1-Po2 \t\t\t\t#Loss in total pressure is %3.3f bar\n",
      "ds = R*math.log(Po1/Po2) \t\t\t\t#Increase in entropy in kJ/kg-K\n",
      "\n",
      "\t\t\t\t\n",
      "#Output\n",
      "print 'A)Throat and exit area are %3.2f cm**2 and %3.3f cm**2 \\\n",
      "\\nB)Exit mach number is %3.2f \\\n",
      "\\nC)Loss in total pressure is %3.3f bar \\\n",
      "\\nD)Increase in entropy is %3.2f kJ/kg-K'%(At,A2,M2,TPL,ds)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "A)Throat and exit area are 14.38 cm**2 and 18.236 cm**2 \n",
        "B)Exit mach number is 1.36 \n",
        "C)Loss in total pressure is 0.683 bar \n",
        "D)Increase in entropy is 43.09 kJ/kg-K\n"
       ]
      }
     ],
     "prompt_number": 46
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.22 page : 40"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "\t\t\t\t\n",
      "#Input data\n",
      "Po = 3.5 \t\t\t\t#Stagnation pressure in bar\n",
      "To = 425.+273 \t\t\t\t#Stagnation temperature in K\n",
      "P2 = 0.97 \t\t\t\t#Exit pressure in bar\n",
      "m = 18. \t\t\t\t#Mass flow rate in kg/s\n",
      "Kd = 0.99 \t\t\t\t#Coefficient of discharge\n",
      "eff = 0.94 \t\t\t\t#Nozzle efficiency \n",
      "k = 1.33 \t\t\t\t#Adiabatic Consmath.tant\n",
      "Cp = 1110. \t\t\t\t#Specific heat capacity at consmath.tant pressure in J/kg-K \n",
      "\n",
      "\t\t\t\t\n",
      "#Calculations \n",
      "Pt = Po*(2/(k+1))**(k/(k-1)) \t\t\t\t#critical pressure in bar\n",
      "Tt = To*(2/(k+1)) \t\t\t\t#critical temperature in K\n",
      "R = Cp/(k/(k-1)) \t\t\t\t#Specific gas consmath.tant in J/kg-K\n",
      "m_s = m/Kd \t\t\t\t#Isentropic mass\n",
      "at = math.sqrt(k*R*Tt) \t\t\t\t#Sound velocity at throat in m/s\n",
      "Ct = at \t\t\t\t#Air velocity t throat in m/s, Since M = 1\n",
      "dt = (Pt*10**5)/(R*Tt) \t\t\t\t#Density of air at throat in kg/m**3, Pt in Pa\n",
      "At = (m_s/(dt*Ct))*10**4 \t\t\t\t#Throat area in cm**2 \n",
      "p2 = P2/Po \t\t\t\t#Pressure ratio\n",
      "T2s = To*p2**(1/(k/(k-1))) \t\t\t\t#Exit temperature in K (at isentropic state)\n",
      "T2 = To-(eff*(To-T2s)) \t\t\t\t#Exit temperature in K\n",
      "d2 = (P2*10**5)/(R*T2) \t\t\t\t#Density at exit in kg/m**3, P2 in Pa\n",
      "C2 = math.sqrt(2*Cp*(To-T2)) \t\t\t\t#Exit air velocity in m/s\n",
      "A2 = (m_s/(d2*C2))*10**4 \t\t\t\t#Exit area in cm**2\n",
      "\n",
      "\t\t\t\t\n",
      "#Output\n",
      "print 'Throat area and Exit area of nozzle are %3.1f cm**2 and %3.1f cm**2'%(At,A2)\n",
      "\n",
      "# note : rounding off error."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Throat area and Exit area of nozzle are 338.6 cm**2 and 425.2 cm**2\n"
       ]
      }
     ],
     "prompt_number": 49
    }
   ],
   "metadata": {}
  }
 ]
}