{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h1>Chapter 12: THE MOMENTUM AND MECHANICAL ENERGY EQUATIONS</h1>"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h2>Example 12.01, page: 273</h2>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "import math\n",
      "\n",
      "#Initialization  of  Variable\n",
      "V = 10 #ft/s\n",
      "A = 0.06 #ft2\n",
      "p = 1.94 #slug/ft3\n",
      "\n",
      "#calculations:\n",
      "Fax = -1*p*A*V**2\n",
      "Fay = p*A*V**2\n",
      "\n",
      "#Results\n",
      "print  \"resultant  force  in  x  direction  is\", round(Fax,2),\"(1-cos(theta)) lbf\"\n",
      "print  \"resultant  force  in  y  direction  is\", round(Fay,2),\"sin(theta) lbf\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "resultant  force  in  x  direction  is -11.64 (1-cos(theta)) lbf\n",
        "resultant  force  in  y  direction  is 11.64 sin(theta) lbf\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h2>Example 12.02, page: 275</h2>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "import math\n",
      "\n",
      "# Initialization  of  Variable\n",
      "p = 1.94 #slug/ft3\n",
      "P1 = 30 #psi\n",
      "V = 50 #ft/s\n",
      "P2 = 24 #psi\n",
      "A = 0.1 #ft2\n",
      "theta  = 180 #deg\n",
      "\n",
      "#calcualtions:\n",
      "#force in x dirn\n",
      "Fax = 0\n",
      "#mass flow rate\n",
      "mdot = p*A*V\n",
      "#force in y dirn\n",
      "Fay = -2*mdot*V - (P1 + P2)*144*A\n",
      "\n",
      "#Results\n",
      "print  \"resultant  force  in  x  direction is\", Fax,\"lbf\"\n",
      "print  \"resultant  force  in  y  direction is\", round(Fay,0),\"lbf\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "resultant  force  in  x  direction is 0 lbf\n",
        "resultant  force  in  y  direction is -1748.0 lbf\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h2>Example 12.03, page: 277</h2>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "import math\n",
      "\n",
      "# Initialization  of  Variable\n",
      "D1 = 16 #mm\n",
      "Q = 0.6 #lt/s\n",
      "Wn = 1 #N\n",
      "Ww = 0.03 #N\n",
      "D2 = 5 #mm\n",
      "P1 = 464 #kPa\n",
      "P2 = 0 #kPa\n",
      "p = 999 #kg/m3\n",
      "\n",
      "#calculations:\n",
      "#mass flow rate\n",
      "mdot = p*Q/1000\n",
      "#areas\n",
      "A1 = math.pi*1E-6*(D1**2)/4\n",
      "A2 = math.pi*1E-6*(D2**2)/4\n",
      "#volumetric flow rate\n",
      "V1 = Q*1E-3/A1\n",
      "V2 = Q*1E-3/A2\n",
      "Fa = mdot*(V1 - V2) + Wn + Ww + P1*1000*A1 - P2*A2\n",
      "\n",
      "#Results\n",
      "print  \"anchoring force is\",round(Fa,1),\"N\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "anchoring force is 77.8 N\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h2>Example 12.05, page: 284</h2>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "import math\n",
      "\n",
      "# Initialization  of  Variable\n",
      "l = 6 #m\n",
      "D = 0.1 #m\n",
      "P1_r = 3 #m\n",
      "P2_r = 0.5 #m\n",
      "z1 = 0 #m\n",
      "z2 = 2 #m\n",
      "\n",
      "#calculations:\n",
      "hL = P1_r - P2_r + z1 - z2\n",
      "\n",
      "#Results\n",
      "print  \"head  loss  in  terms  of  height  of  water is\", hL, \"m\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "head  loss  in  terms  of  height  of  water is 0.5 m\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h2>Example 12.06, page: 284</h2>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "import math\n",
      "\n",
      "# Initialization  of  Variable\n",
      "z1 = 100 #m\n",
      "V2 = 6 #m/s\n",
      "g = 9.81 #m/s2\n",
      "r = 9.8E3 #N/m3\n",
      "D = 1 #m\n",
      "\n",
      "#calculations:\n",
      "#Volumetric flow rate\n",
      "Q = math.pi*D**2*V2/4\n",
      "hL = 0 #no head loss\n",
      "#turbine head\n",
      "ht = z1 - (V2**2)/(2*g) - hL\n",
      "#power output\n",
      "Wtdot = r*Q*ht/1000\n",
      "\n",
      "#Results\n",
      "print  \"max power  output is\", round(Wtdot,0),\"kW\" \n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "max power  output is 4533.0 kW\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h2>Example 12.07, page: 285</h2>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "import math\n",
      "\n",
      "# Initialization  of  Variable\n",
      "Wpdot = 10 #hp\n",
      "r = 62.4 #lbf/ft3\n",
      "Q = 2 #ft3/s\n",
      "z2 = 30 #ft\n",
      "z1 = 0\n",
      "\n",
      "#calculations:\n",
      "#pump head\n",
      "hp = Wpdot*550/(r*Q)\n",
      "#head Loss\n",
      "hL = z1 - z2 + hp\n",
      "#on a power basis, the head loss\n",
      "hLp = r*Q*hL/550\n",
      "\n",
      "#Results\n",
      "print  \"head  loss is\", round(hL,1),\"ft or\", round(hLp,2),\"hp\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "head  loss is 14.1 ft or 3.19 hp\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h2>Example 12.08, page: 286</h2>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "import math\n",
      "\n",
      "# Initialization  of  Variable\n",
      "A2 = 0.001 #m2\n",
      "P1 = 1 #Mpa\n",
      "P0 = 1 #Mpa\n",
      "T1 = 360 #K\n",
      "T0 = 360 #K\n",
      "k = 1.4\n",
      "Pb1 = 500 #kPa\n",
      "Pb2 = 784 #kPa\n",
      "V1  = 0\n",
      "R = 8314/28.97 #J/kg-K\n",
      "\n",
      "#calculations:\n",
      "Pcr = 0.528*P0*1000\n",
      "if Pb1 < Pcr:\n",
      "    M1 = 1\n",
      "\n",
      "#exit Temp\n",
      "T2 = T0/(1 + (k - 1)*M1**2/2)\n",
      "#exit Velocity\n",
      "V2 = M1*(k*R*T2)**0.5\n",
      "#mass flow rate\n",
      "mdot1 = Pcr*1000*A2*V2/(R*T2)\n",
      "#Mach at 2\n",
      "M2 = (2/(k - 1)*((P0*1E6/(Pb2*1E3))**((k-1)/k) - 1))**0.5\n",
      "#exit Temp\n",
      "T2 = T0/(1 + (k - 1)*M2**2/2)\n",
      "#exit Velocity\n",
      "V2 = M2*(k*R*T2)**0.5\n",
      "#mass flow rate\n",
      "mdot2 = Pb2*1000*A2*V2/(R*T2)\n",
      "\n",
      "#Results\n",
      "print  \"the  mass flow rate and exit  mach  no at back pressure of 500 kPa are\",round(mdot1,2),\"kg/s and\", M1\n",
      "print  \"the  mass flow rate and exit  mach  no at back pressure of 784 kPa are\",round(mdot2,2),\"kg/s and\", round(M2,1)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "the  mass flow rate and exit  mach  no at back pressure of 500 kPa are 2.13 kg/s and 1\n",
        "the  mass flow rate and exit  mach  no at back pressure of 784 kPa are 1.79 kg/s and 0.6\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h2>Example 12.09, page: 286</h2>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "import math\n",
      "\n",
      "# Initialization  of  Variable\n",
      "A2 = 2.4 #in2\n",
      "P1 = 100 #lbf/in2\n",
      "P0 = 100 #lbf/in2\n",
      "T1 = 500 #degR\n",
      "T0 = 500 #degR\n",
      "At = 1 #in2\n",
      "k = 1.4\n",
      "V1  = 0\n",
      "R = 1548/28.97 #ft.lbf/lb-degR\n",
      "\n",
      "#calculations:\n",
      "#a)\n",
      "#mach at throat\n",
      "Mta = 0.7\n",
      "#From Table 12.2\n",
      "#At/A* = At_As\n",
      "At_Asa = 1.09437\n",
      "A2_Asa = A2*At_Asa/At\n",
      "#from Table 12.2\n",
      "M2a = 0.24\n",
      "T2_T0a = 0.988\n",
      "P2_P0a = 0.959\n",
      "T2a = T0*T2_T0a\n",
      "P2a = P0*P2_P0a\n",
      "#velocity at exit\n",
      "V2a = M2a*(k*R*T2a*32.2)**0.5\n",
      "#mass flow rate\n",
      "mdota = P2a*A2*V2a/(R*T2a)\n",
      "\n",
      "#b)\n",
      "#from Table 12.2\n",
      "M2b = 0.26\n",
      "T2_T0b = 0.986\n",
      "P2_P0b = 0.953\n",
      "T2b = T0*T2_T0b\n",
      "P2b = P0*P2_P0b\n",
      "#velocity at exit\n",
      "V2b = M2b*(k*R*T2b*32.2)**0.5\n",
      "#mass flow rate\n",
      "mdotb = P2b*A2*V2b/(R*T2b)\n",
      "\n",
      "#c)\n",
      "#from Table 12.2\n",
      "M2c = 2.4\n",
      "P2_P0c = 0.0684\n",
      "P2c = P0*P2_P0c\n",
      "#mass flow rate (nozzle is choked same as b)\n",
      "mdotc = mdotb\n",
      "\n",
      "#d)\n",
      "#from Table 12.2\n",
      "Mxd = 2.4\n",
      "Pxd = 6.84 #lbf/in2\n",
      "Myd = 0.52\n",
      "M2d = Myd\n",
      "Pyd = 6.5533*Pxd\n",
      "P2d = Pyd\n",
      "#mass flow rate (nozzle is choked same as b)\n",
      "mdotd = mdotb\n",
      "\n",
      "#e)\n",
      "Ax = 2 #in2\n",
      "Axs = At\n",
      "#from table 12.2\n",
      "Ax_Axs = 2 #Ax/Ax*\n",
      "Mxe = 2.2\n",
      "#Poy/Pox\n",
      "Poy_Pox = 0.62812\n",
      "#A2/Ay*\n",
      "A2_Ays = (A2/Axs)*Poy_Pox\n",
      "M2e = 0.43\n",
      "#P2/Poy\n",
      "P2_Poy = 0.88\n",
      "Pox = P0\n",
      "P2e = P2_Poy*Poy_Pox*Pox\n",
      "#mass flow rate (nozzle is choked same as b)\n",
      "mdote = mdotb\n",
      "\n",
      "#Results\n",
      "print  \"a)the  mass flow rate is\",round(mdota,2),\"lb/s or\", round(mdota/32.1740,4),\"slug/s, exit pressure is\",round(P2a,1),\"lbf/in2 and exit mach number is\",M2a\n",
      "print  \"b)the  mass flow rate is\",round(mdotb,2),\"lb/s or\", round(mdotb/32.1740,4),\"slug/s, exit pressure is\",round(P2b,1),\"lbf/in2 and exit mach number is\",M2b\n",
      "print  \"c)the  mass flow rate is\",round(mdotc,2),\"lb/s or\", round(mdotc/32.1740,4),\"slug/s, exit pressure is\",round(P2c,2),\"lbf/in2 and exit mach number is\",M2c\n",
      "print  \"d)the  mass flow rate is\",round(mdotd,2),\"lb/s or\", round(mdotd/32.1740,4),\"slug/s, exit pressure is\",round(P2d,2),\"lbf/in2 and exit mach number is\",M2d\n",
      "print  \"e)the  mass flow rate is\",round(mdote,2),\"lb/s or\", round(mdote/32.1740,4),\"slug/s, exit pressure is\",round(P2e,1),\"lbf/in2 and exit mach number is\",M2e\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "a)the  mass flow rate is 2.28 lb/s or 0.071 slug/s, exit pressure is 95.9 lbf/in2 and exit mach number is 0.24\n",
        "b)the  mass flow rate is 2.46 lb/s or 0.0765 slug/s, exit pressure is 95.3 lbf/in2 and exit mach number is 0.26\n",
        "c)the  mass flow rate is 2.46 lb/s or 0.0765 slug/s, exit pressure is 6.84 lbf/in2 and exit mach number is 2.4\n",
        "d)the  mass flow rate is 2.46 lb/s or 0.0765 slug/s, exit pressure is 44.82 lbf/in2 and exit mach number is 0.52\n",
        "e)the  mass flow rate is 2.46 lb/s or 0.0765 slug/s, exit pressure is 55.3 lbf/in2 and exit mach number is 0.43\n"
       ]
      }
     ],
     "prompt_number": 8
    }
   ],
   "metadata": {}
  }
 ]
}