{
 "metadata": {
  "name": "",
  "signature": "sha256:204da51ebf9aa715601d60f6e1aaa3c9734a35c1b9cad7274440a88878e8202c"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 4 : Energy Considerations in Steady Flow"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.1 Page No : 93"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\n",
      "#Initialization of variables\n",
      "d = 1.26    #specific gravity\n",
      "d = 24.  \t#in\n",
      "d2 = 60.    #cm\n",
      "Q = 25. \t#cfs\n",
      "Q2 = 700. \t#L/s\n",
      "dout = 12. \t#in\n",
      "dout2 = 30./100 \t#m\n",
      "z = 3. \t    #ft\n",
      "z2 = 1. \t#m\n",
      "P1 = 45. \t#psi\n",
      "P2 = 300. \t#kN/m**2\n",
      "gamma = 9.81 \t#kN/m**3\n",
      "\t\n",
      "#calculations\n",
      "V1 = d/math.pi\n",
      "V2 = d*4/math.pi\n",
      "pf = (P1*144/(1.26*62.4) + (V1**2)/64.4 - V2**2 /64.4 +z)*1.26*62.4/144\n",
      "V1 = Q2/1000/(math.pi*dout2**2)\n",
      "V2 = 4*V1\n",
      "p2f = ((P2/(1.26*gamma)) + V1**2 /(2*gamma) -V2**2 /(2*gamma) +z2)*1.26*gamma\n",
      "\n",
      "#Results\n",
      "print \" English units\"\n",
      "print \" Pressure at point 2  =  %.1f psi \"%(pf)\n",
      "print \" \\n SI Units\"\n",
      "print \" Pressure at point 2  =  %.d kN/m**2 \"%(p2f)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " English units\n",
        " Pressure at point 2  =  39.2 psi \n",
        " \n",
        " SI Units\n",
        " Pressure at point 2  =  254 kN/m**2 \n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.2 Page No : 94"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\n",
      "#Initialization of variables\n",
      "h = 20.    \t#m\n",
      "c = 4187. \t#N m /(kg K)\n",
      "g = 9.81\n",
      "\t\n",
      "#calculations\n",
      "dT = g*h/c\n",
      "\t\n",
      "#Results\n",
      "print \"Increase in temperature of water  =  %.3f K\"%(dT)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Increase in temperature of water  =  0.047 K\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.3 Page No : 96"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\t\n",
      "#Initialization of variables\n",
      "sg = 1.26  #specific gravity of liquid\n",
      "sg2 = 1.26 #\n",
      "HP = 22.\n",
      "HP2 = 16.\n",
      "\t\n",
      "#calculations\n",
      "hp = HP*550/(sg*62.4) \t#divide by Q\n",
      "Q = 14.2 \t#cfs\n",
      "print \"In English units, By trial Q =  %.1f cfs\"%(Q)\n",
      "hp2 = HP2*1000/(sg2*9.81)\n",
      "Q2 = 0.42 \t#m**3/s\n",
      "print \" In SI units, By trial Q =  %.2f m**3/s\"%(Q2)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "In English units, By trial Q =  14.2 cfs\n",
        " In SI units, By trial Q =  0.42 m**3/s\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.4 Page No : 96"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\t\n",
      "#Initialization of variables\n",
      "g = 9810. \t#N/m**3\n",
      "Q = 10 \t    #m**3/s\n",
      "H = 20 \t    #m\n",
      "\t\n",
      "#calculations\n",
      "Rate = g*Q*H/1000\n",
      "\t\n",
      "#Results\n",
      "print \"Rate of energy loss  =  %d kW\"%(Rate-2)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Rate of energy loss  =  1960 kW\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.5 Page No : 98"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\n",
      "#Initialization of variables\n",
      "s = 0.86\n",
      "P2 = 3.8 \t#pressure - psia\n",
      "Patm = 26.8 \t#atmospheric pressure - Hg\n",
      "SPatm = 29.9 \t#in of Hg\n",
      "psi = 14.7 \t#psia\n",
      "\t\n",
      "#calculations\n",
      "Pa = Patm*psi/SPatm\n",
      "Pcrit = -(Pa-P2)*144/(s*62.4)\n",
      "Q = math.sqrt((-Pcrit+ 10*144/(s*62.4))*64.4*math.pi**2 /(-1/2.25**2 + 1/0.25**2 ))\n",
      "\t\n",
      "#Results\n",
      "print \"Max. theoretical flow  =  %.1f cfs\"%(Q)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Max. theoretical flow  =  45.7 cfs\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.6 Page No : 104"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\n",
      "#Initialization of variables\n",
      "z = 3.       \t#ft\n",
      "s = 0.82\n",
      "\t\n",
      "#calculations\n",
      "ua = math.sqrt(z*2*32.2)\n",
      "ub = math.sqrt(2*32.2*(-2*(1-s) +ua**2 /(2*32.2)))\n",
      "\t\n",
      "#Results\n",
      "print \"Velocity at B =  %.1f fps\"%(ub)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Velocity at B =  13.0 fps\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.7 Page No : 108"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\n",
      "#Initialization of variables\n",
      "d = 3.   \t#in\n",
      "x1 = 0.5**2\n",
      "x2 = 0.75**2\n",
      "z = 80.  \t#ft\n",
      "z3 = 10. \t#ft\n",
      "\t\n",
      "#calculations\n",
      "print (\"Using Bernoullis theorem\")\n",
      "v3 = 29.7 \t#fps\n",
      "Q = math.pi /4 *(d/12)**2 *v3\n",
      "hls = 5*(x1*v3)**2 /(2*32.2)\n",
      "hld = 12*(x2*v3)**2 /(2*32.2)\n",
      "\t\n",
      "#Results\n",
      "print \"Head loss in suction pipe  =  %.1f ft\"%(hls)\n",
      "print \" Head loss in discharge pipe  =  %.1f ft\"%(hld)\n",
      "print \" Flow rate  =  %.2f cfs\"%(Q)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Using Bernoullis theorem\n",
        "Head loss in suction pipe  =  4.3 ft\n",
        " Head loss in discharge pipe  =  52.0 ft\n",
        " Flow rate  =  1.46 cfs\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.8 Page No : 109"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\n",
      "#Initialization of variables\n",
      "z1 = 2.\n",
      "z2 = 0.8\n",
      "\t\n",
      "#calculations\n",
      "print (\"From equation of continuity, z1*v1 = z2*v2\")\n",
      "V1 =  math.sqrt((z2-z1)*2*9.81/(1-z1**2 /z2**2))\n",
      "V2 = z1*V1/z2\n",
      "Q = z1*1*V1\n",
      "\t\n",
      "#Results\n",
      "print \"Flow rate  =  %.2f m**3/s\"%(Q)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "From equation of continuity, z1*v1 = z2*v2\n",
        "Flow rate  =  4.24 m**3/s\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.9 Page No : 113"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\n",
      "#Initialization of variables\n",
      "theta = 30. \t#degrees\n",
      "z = 10.     \t#ft\n",
      "x = 60.  \t    #ft\n",
      "\t\n",
      "#calculations\n",
      "V = math.sqrt((0.5*32.2*69.3**2)/((x-math.sin(math.radians(theta)) *69.3)))\n",
      "\t\n",
      "#Results\n",
      "print \"velocity  =  %.0f fps\"%(V)\n",
      "\n",
      "# rounding off error"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "velocity  =  55 fps\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.10 Page No : 119"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\n",
      "#Initialization of variables\n",
      "V = 60. \t#fps\n",
      "theta = 15. #degrees\n",
      "ra = 6/12. \t#ft\n",
      "rb = 8/12. \t#ft\n",
      "B = 1.5/12 \t#ft\n",
      "\t\n",
      "#calculations\n",
      "Vra = V*math.sin(math.radians(theta))\n",
      "Q = 2* math.pi*ra*B*Vra\n",
      "Vratio = ra/rb\n",
      "Vb = Vratio*V\n",
      "flow = (V**2 - Vb**2)/(2*32.2)\n",
      "\t\n",
      "#Results\n",
      "print \"Flow rate  =  %.2f cfs\"%(Q)\n",
      "print \" Velocity at b  =  %d fps\"%(Vb)\n",
      "print \" Pressure head  =  %.1f ft\"%(flow)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Flow rate  =  6.10 cfs\n",
        " Velocity at b  =  45 fps\n",
        " Pressure head  =  24.5 ft\n"
       ]
      }
     ],
     "prompt_number": 11
    }
   ],
   "metadata": {}
  }
 ]
}