{
 "metadata": {
  "name": "",
  "signature": "sha256:de3cacdaf57dab2533c3d6a29cdb98f8a7442d8b301aac65e35672e8b8cf9017"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 7 : Incompressible Flow Through Conduits"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.1 Page No : 240"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\t\t\n",
      "#Initialization of variables\n",
      "g = 9.81 \t\t\t#m/s**2\n",
      "rho = 10.**3 \t\t#kg/m**3\n",
      "h1 = 4. \t\t\t#m\n",
      "muw = 0.001 \t\t#Ns/m**2\n",
      "l = 1.5 \t\t\t#m\n",
      "B = 0.15/1000 \t\t#m\n",
      "lenth = 11.2 \t\t\t#m\n",
      "\t\t\t\n",
      "#calculations\n",
      "P1 = g*rho*h1\n",
      "V = P1*B**2 /(12*muw*l)\n",
      "A = B*lenth\n",
      "Q = A*V\n",
      "Q = 7112.4\n",
      "tau =  B/2 *(P1)/l\n",
      "\t\t\t\n",
      "#results\n",
      "print \"Average velocity through the crack  =  %.3f m/s\"%(V)\n",
      "print \" rate of leakage  =  %.1f l/hr\"%(Q)\n",
      "print \" Shear stress  =  %.3f N/m**2\"%(tau)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Average velocity through the crack  =  0.049 m/s\n",
        " rate of leakage  =  7112.4 l/hr\n",
        " Shear stress  =  1.962 N/m**2\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.2 Page No : 242"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\t\t\n",
      "#Initialization of variables\n",
      "g = 9.81 \t\t\t#m/s**2\n",
      "rho = 1200. \t\t\t#kg/m**3\n",
      "mu = 0.005 \t\t\t#Ns/m**2\n",
      "d = 0.006 \t\t\t#m\n",
      "Re = 2000.\n",
      "V = 0.15 \t\t\t#m/s\n",
      "\t\t\t\n",
      "#calculations\n",
      "Vc = Re*mu/(d*rho)\n",
      "Vr = V/Vc\n",
      "T0 = 8*mu*V/d\n",
      "\t\n",
      "#results\n",
      "print \"Shear stress  =  %d N/m**2\"%(T0)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Shear stress  =  1 N/m**2\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.3 Page No : 243"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\t\t\n",
      "#Initialization of variables\n",
      "g = 9.81 \t\t\t#m/s**2\n",
      "rho = 10.**3 \t\t#kg/m**3\n",
      "Q = 0.45/(60*1000) \t#m**3/s\n",
      "d = 0.003 \t\t\t#m\n",
      "depth = 0.95 \t\t#m\n",
      "alpha = 2.\n",
      "lenth = 1.25 \t\t\t#m\n",
      "\t\t\t\n",
      "#calculations\n",
      "A = math.pi/4 *d**2\n",
      "V = Q/A\n",
      "nu =  (depth - alpha*V**2 /(2*g))*g*d**2 /(32*V*lenth)\n",
      "Re = V*d/nu\n",
      "\t\t\t\n",
      "#results\n",
      "if Re<2000:\n",
      "    print \"Flow is laminar\"\n",
      "else:\n",
      "    print \"Flow is not laminar\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Flow is laminar\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.4 Page No : 262"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\t\t\n",
      "#Initialization of variables\n",
      "g = 9.81 \t\t\t#m/s**2\n",
      "rho = 787. \t\t\t#specific gravity - kg/m**3\n",
      "Q = 90.*10**-3 \t\t#m**3/hr\n",
      "d = 0.015 \t\t\t#m\n",
      "k = 0.0045*10**-2 \t#m\n",
      "nu = 1.6e-6         #kinematic viscosity - m^2/s\n",
      "l = 5.   \t\t\t#m\n",
      "\t\t\t\n",
      "#calculations\n",
      "V = Q/(60*math.pi/4 *d**2)\n",
      "Rn = V*d/nu\n",
      "e = k/d\n",
      "print (\"From moody diagram, f = 0.028\")\n",
      "f = 0.028\n",
      "hl = f*l/d *V**2 /(2*g)\n",
      "Power = rho*g*Q/60 *hl\n",
      "\t\t\t#result\n",
      "print \"Head loss  =  %.2f m\"%(hl)\n",
      "print \" power required   = %.3f kW\"%(Power/1000)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "From moody diagram, f = 0.028\n",
        "Head loss  =  34.27 m\n",
        " power required   = 0.397 kW\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.5 Page No : 263"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\t\t\n",
      "#Initialization of variables\n",
      "g = 9.81 \t\t\t#m/s**2\n",
      "rho = 870. \t\t\t#density - kg/m**3\n",
      "Q = 2.*10**-3 \t\t#m**3/s\n",
      "d = 0.03 \t\t\t#diameter - m\n",
      "mu = 5.*10**-4      #dynamics viscosity(N-s/m^2)\n",
      "l = 50. \t\t\t#length - m\n",
      "\t\t\t\n",
      "#calculations\n",
      "V = Q/(math.pi/4 *d**2)\n",
      "RN = rho*V*d/mu\n",
      "f = 0.017\n",
      "hl = f*l/d *V**2/(2*g)\n",
      "Ploss = rho*g*hl\n",
      "\t\t\t\n",
      "#results\n",
      "print \"Loss of pressure  =  %.1f kN/m**2\"%(Ploss/1000)\n",
      "#The answers are a bit different due to rounding off error in textbook"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Loss of pressure  =  98.7 kN/m**2\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.6 Page No : 263"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\t\t\n",
      "#Initialization of variables\n",
      "g = 9.81 \t\t\t#m/s**2\n",
      "rho = 813. \t\t\t#density - kg/m**3\n",
      "Q = 0.007 \t\t\t#m**3/hr\n",
      "d = 0.01\t\t\t#m\n",
      "mu = 0.002 \t\t\t#Ns/m**2\n",
      "l = 30. \t\t\t#m\n",
      "\t\t\t\n",
      "#calculations\n",
      "V = Q/(60*math.pi/4*d**2)\n",
      "RN = V*d*rho/mu\n",
      "f = 0.316/RN**(0.25)\n",
      "h = (1+f*l/d)*V**2 /(2*g)\n",
      "\n",
      "#result\n",
      "print \"Height required  =  %.2f m\"%(h)\n",
      "\n",
      "# rounding off error."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Height required  =  12.21 m\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.7 Page No : 264"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\t\t\n",
      "#Initialization of variables\n",
      "g = 9.81 \t\t    \t#m/s**2\n",
      "rho = 10**3 \t\t\t#kg/m**3\n",
      "hl = 0.02\n",
      "d = 1.2     \t\t\t#diameter - m\n",
      "l = 1.   \t    \t\t#m\n",
      "k = 0.5 *10**-2 \t\t#m\n",
      "\t\t\t\n",
      "#calculations\n",
      "v2f = hl*(2*g*d)/l\n",
      "e = k/d\n",
      "f = 0.028\n",
      "V = math.sqrt(v2f/f)\n",
      "Q = math.pi/4 *d**2 *V\n",
      "\t\t\t\n",
      "#results\n",
      "print \"Rate of flow  =  %.2f m**3/s\"%(Q)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Rate of flow  =  4.64 m**3/s\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.8 Page No : 265"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\t\t\n",
      "#Initialization of variables\n",
      "g = 9.81 \t\t    \t#m/s**2\n",
      "rho = 10.**3 \t\t\t#kg/m**3\n",
      "e = 0.03*10**-2 \t\t#surface roughness - m\n",
      "l = 3000. \t    \t\t#distance - m\n",
      "Q = 300.*10**-3 \t\t#m**3/s\n",
      "nu = 10.**-5 \t\t\t#kinematic viscosity - m**2/s\n",
      "hl = 24.     \t\t\t#m\n",
      "\t\t\t\n",
      "#calculations\n",
      "d5f =  l*Q/(math.pi/4) * Q/(math.pi/4) /(hl*2*g)\n",
      "f = 0.022\n",
      "d = (d5f*f)**(1./5)\n",
      "\t\t\t\n",
      "#results\n",
      "print \"Size of the required pipe  =  %d cm\"%(d*100)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Size of the required pipe  =  45 cm\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.9 Page No : 266"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\t\t\n",
      "#Initialization of variables\n",
      "g = 9.81 \t\t\t#m/s**2\n",
      "rho = 10.**3 \t\t#kg/m**3\n",
      "d = 0.3 \t\t\t#m\n",
      "per = 25./100\n",
      "Q = 0.1 \t\t\t#m**3/s\n",
      "k0 = 0.025*10**-2 \t#m\n",
      "nu = 0.000001\n",
      "year = 10.\n",
      "\t\t\t\n",
      "#calculations\n",
      "V = Q/(math.pi/4 *d**2)\n",
      "RN = V*d/nu\n",
      "e1 = k0/d\n",
      "f1 = 0.019 \n",
      "f2 = (1+per)*f1\n",
      "e2 = 0.002\n",
      "k2 = e2*d\n",
      "rate  =  (k2-k0)*100/year\n",
      "\t\t\t\n",
      "#results\n",
      "print \"Rate of increase  = %.4f cm/year\"%(rate)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Rate of increase  = 0.0035 cm/year\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.10 Page No : 267"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\t\t\n",
      "#Initialization of variables\n",
      "g = 9.81 \t\t\t#m/s**2\n",
      "rho = 10.**3 \t\t#kg/m**3\n",
      "l = 1. \t\t\t    #m\n",
      "b = 0.3 \t\t\t#m\n",
      "Q = 4.2 \t\t\t#m**3/s\n",
      "\t\t\t\n",
      "#calculations\n",
      "A = l*b\n",
      "R = A/(2*(l+b))\n",
      "d5 = 1.62/24.15\n",
      "d = d5**(1./5)\n",
      "Pr = 2*(l+b)/(math.pi*d)\n",
      "\t\t\t\n",
      "#results\n",
      "print \"The rectangular cross section will cost %.2f times that of a circular cross section\"%(Pr)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The rectangular cross section will cost 1.42 times that of a circular cross section\n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.11 Page No : 270"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\t\t\n",
      "#Initialization of variables\n",
      "g = 9.81 \t\t\t#m/s**2\n",
      "rho = 10.**3 \t\t\t#kg/m**3\n",
      "d1 = 2.5*10**-2 \t\t\t#m\n",
      "d2 = 7.2*10**-2 \t\t\t#m\n",
      "Q = 100.*10**-3 \t\t\t#m**3/hr\n",
      "\t\t\t\n",
      "#calculations\n",
      "V1 = Q/(60*math.pi/4*d1**2)\n",
      "V2 = (d1/d2)**2 *V1\n",
      "dp =  -(V2**2 -V1**2 + (V1-V2)**2)/(2*g)\n",
      "Pdiff = dp*g*rho\n",
      "\t\t\t\n",
      "#results\n",
      "print \"pressure difference  =  %.2f kN/m**2\"%(Pdiff/1000)\n",
      "\n",
      "# note : The answers are a bit different due to rounding off error"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "pressure difference  =  1.22 kN/m**2\n"
       ]
      }
     ],
     "prompt_number": 16
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.12 Page No : 273"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\t\t\n",
      "#Initialization of variables\n",
      "g = 9.81 \t\t\t#m/s**2\n",
      "rho = 10.**3 \t\t\t#kg/m**3\n",
      "d2 = 30./100 \t\t\t#cm\n",
      "d1 = 60./100 \t\t\t#cm\n",
      "Pu = 105. \t\t\t#kN/m**2\n",
      "Pd = 75. \t\t\t#kN/m**2\n",
      "Cc = 0.65\n",
      "\t\t\t\n",
      "#calculations\n",
      "V22 = (2*g/(1 - (d2/d1)**4 + (1/Cc -1)**2)) *(Pu-Pd)*10**3 /(rho*g)\n",
      "V2 = math.sqrt(V22)\n",
      "Q = math.pi/4 *V2 *d2**2\n",
      "hl = (1/Cc -1)**2 *V2**2 /(2*g)\n",
      "\t\t\t\n",
      "#results\n",
      "print \"Flow rate  =  %.3f m**3/s\"%(Q)\n",
      "print \" Head loss  =  %.3f m\"%(hl)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Flow rate  =  0.494 m**3/s\n",
        " Head loss  =  0.722 m\n"
       ]
      }
     ],
     "prompt_number": 15
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.13 Page No : 277"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\t\t\n",
      "#Initialization of variables\n",
      "g = 9.81 \t\t\t#m/s**2\n",
      "rho = 10.**3 \t\t#kg/m**3\n",
      "d = 9.   \t\t\t#m\n",
      "dia = 0.3 \t\t\t#m\n",
      "\t\t\t\n",
      "#calculations\n",
      "V302 =  2*g*d/(0.5 + 20 + 2.53+101+0.66+41.47+2.07)\n",
      "V30 = math.sqrt(V302)\n",
      "Q = math.pi/4 *dia**2 *V30\n",
      "\t\t\t\n",
      "#results\n",
      "print \"Flow rate  =  %.3f m**3/s\"%(Q)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Flow rate  =  0.072 m**3/s\n"
       ]
      }
     ],
     "prompt_number": 16
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.14 Page No : 278"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\t\t\n",
      "#Initialization of variables\n",
      "h = 6. \t\t\t    #m\n",
      "rho = 930. \t\t\t#kg/m**3\n",
      "Q = 3./60 \t\t\t#m**3/s\n",
      "d = 0.15 \t\t\t#m\n",
      "L = 20. \t\t\t#m\n",
      "mu = 0.006          #viscosity\n",
      "g = 9.81 \t\t\t#m/s**2\n",
      "\t\t\t\n",
      "#calculations\n",
      "V = Q/(math.pi/4 *d**2)\n",
      "RN = V*d*rho/mu\n",
      "f = 0.316/RN**0.25\n",
      "hl = f*L/d *V**2 /(2*g)\n",
      "Hp = h+hl\n",
      "gam = rho*g\n",
      "W = gam*Q\n",
      "Power =  W*Hp\n",
      "\t\t\t\n",
      "#results\n",
      "print \"Power required   =  %.3f kW\"%(Power/1000)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Power required   =  3.227 kW\n"
       ]
      }
     ],
     "prompt_number": 17
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.15 Page No : 279"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "from scipy.integrate import quad\n",
      "\t\t\t\n",
      "#Initialization of variables\n",
      "d = 0.02 \t\t\t#m\n",
      "d2 = 1.2 \t\t\t#diameter - m\n",
      "f = 0.01\n",
      "L = 250.\n",
      "ken = 0.5\n",
      "g = 9.81\n",
      "h1 = 8. \t\t\t#m\n",
      "h2 = 4. \t\t\t#m\n",
      "\t\t\t\n",
      "#calculations\n",
      "V2 = 2*g/(1+ken+ f*L/d)\n",
      "V = math.sqrt(V2)\n",
      "Q = math.pi/4 *d**2 *V\n",
      "def time(h):\n",
      "    return  -math.pi/4 *d2**2 /Q /math.sqrt(h)\n",
      "\n",
      "ti = quad(time,h1,h2)[0]\n",
      "hours = ti/3600\n",
      "mins = ti%3600/60\n",
      "secs = ti%3600%60\n",
      "\n",
      "#results\n",
      "print \"Time required  =  %d hours %d mins %d seconds\"%(hours,mins,secs)\n",
      "\n",
      "# rounding off error."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Time required  =  4 hours 12 mins 25 seconds\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.16 Page No : 280"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\t\t\t\n",
      "#Initialization of variables\n",
      "d1 = 0.1 \t\t\t#m\n",
      "d2 = 0.05 \t\t\t#m\n",
      "l1 = 20. \t\t\t#m\n",
      "l2 = 20. \t\t\t#m\n",
      "f = 0.02\n",
      "\t\t\t\n",
      "#calculations\n",
      "Kl = (f*l2/d2 *(d1/d2)**4 - f*l1/d1)\n",
      "\t\t\t\n",
      "#results\n",
      "print \"Loss coefficient  =  %d \"%(Kl)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Loss coefficient  =  124 \n"
       ]
      }
     ],
     "prompt_number": 19
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.17 Page No : 281"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\t\t\t\n",
      "#Initialization of variables\n",
      "g = 9.81 \n",
      "ratio = 1.265\n",
      "\t\t\t\n",
      "#calculations\n",
      "percent  =  (ratio-1)*100\n",
      "\t\t\t\n",
      "#results\n",
      "print \"Increase in discharge  =  %.1f %%\"%(percent)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Increase in discharge  =  26.5 %\n"
       ]
      }
     ],
     "prompt_number": 17
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.18 Page No : 282"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\t\t\n",
      "#Initialization of variables\n",
      "Q = 0.6 \t\t\t#m**3/s\n",
      "l1 = 1200. \t\t\t#m\n",
      "l2 = 800. \t\t\t#m\n",
      "d1 = 0.3 \t\t\t#m\n",
      "\t\t\t\n",
      "#calculations\n",
      "V1 = 1.02 \t\t\t#m/s\n",
      "d5 =  d1*l2*4**2 *Q**2 /(l1*math.pi**2 *V1**2)\n",
      "d = d5**(1./5)\n",
      "\t\t\t\n",
      "#results\n",
      "print \"diameter of the single pipe  =  %.2f m\"%(d)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "diameter of the single pipe  =  0.65 m\n"
       ]
      }
     ],
     "prompt_number": 18
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.19 Page No : 284"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\t\t\n",
      "#Initialization of variables\n",
      "g = 9.81\n",
      "Q = 0.18 \t\t\t#m**3/s\n",
      "d3 = 0.3\t\t\t#m\n",
      "f = 0.032           #friction factor\n",
      "L3 = 360. \t\t\t#m\n",
      "z = 25.5 \t\t\t#m\n",
      "z2 = 30. \t\t\t#m\n",
      "L2 = 450. \t\t\t#m\n",
      "d2 = 0.45\t\t\t#m\n",
      "L1 = 950. \t\t\t#m\n",
      "d1 = 0.45 \t\t\t#m\n",
      "zn = 18. \t\t\t#m\n",
      "rho = 1000.\n",
      "\t\t\t\n",
      "#calculations\n",
      "V3 = Q/(math.pi/4 *d3**2)\n",
      "hl3 = f*L3/d3 *(V3**2 /(2*g))\n",
      "Z2 = z+hl3\n",
      "hl2 = Z2-z2\n",
      "V2 =  math.sqrt(2*g*d2*hl2/(f*L2))\n",
      "Q2 = math.pi/4 *d2**2 *V2\n",
      "V1 = V2+ (d3/d2)**2 *V3\n",
      "hl1 = f*L1/d1*V1**2 /(2*g)\n",
      "Hp =  hl1+ Z2-zn\n",
      "gam = rho*g\n",
      "P = gam*Hp\n",
      "\t\t\t\n",
      "#results\n",
      "print \"Discharge into the reservoir  =  %.3f m**3/s\"%(Q2)\n",
      "print \" Pressure maintained by the pump  =  %.2f kN/m**2\"%(P/1000)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Discharge into the reservoir  =  0.356 m**3/s\n",
        " Pressure maintained by the pump  =  582.34 kN/m**2\n"
       ]
      }
     ],
     "prompt_number": 23
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.20 Page No : 285"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "from numpy import *\n",
      "\t\t\t\n",
      "#Initialization of variables\n",
      "z1 = 10. \t\t\t#m\n",
      "z2 = 5. \t\t\t#m\n",
      "z3 = 7.5 \t\t\t#m\n",
      "f = 0.04 \n",
      "l1 = 100. \t\t\t#m\n",
      "l2 = 50. \t\t\t#m\n",
      "l3 = 70. \t\t\t#m\n",
      "d1 = 0.1 \t\t\t#m\n",
      "d2 = 0.075 \t\t\t#m\n",
      "d3 = 0.06 \t\t\t#m\n",
      "g = 9.81 \t\t\t#m/s**2\n",
      "h = array([1, 2, 1.9, 1.96])\n",
      "\n",
      "#calculations\n",
      "Q1 = sqrt(d1**5 *(math.pi/4)**2 *2*g/(f*l1)) *sqrt(z1-h)\n",
      "Q2 = sqrt(d2**5 *(math.pi/4)**2 *2*g/(f*l2)) *sqrt(h+z2)\n",
      "Q3 = sqrt(d3**5 *(math.pi/4)**2 *2*g/(f*l3)) *sqrt(h+z3)\n",
      "for i in range(4):\n",
      "    Q = Q2[i]+Q3[i]\n",
      "    if (Q1[i]  ==  Q):\n",
      "        break;\n",
      "    print \"height h  =  %.2f m\"%(h[i])\n",
      "    print \"Discharge in BC Q2  =  %.2f lps\"%((Q2[i])*1000)\n",
      "    print \"Discharge in BD Q3  =  %.2f lps\"%((Q3[i])*1000)\n",
      "    \n",
      "# note : rounding off error.    "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "height h  =  1.00 m\n",
        "Discharge in BC Q2  =  9.28 lps\n",
        "Discharge in BD Q3  =  5.35 lps\n",
        "height h  =  2.00 m\n",
        "Discharge in BC Q2  =  10.03 lps\n",
        "Discharge in BD Q3  =  5.65 lps\n",
        "height h  =  1.90 m\n",
        "Discharge in BC Q2  =  9.95 lps\n",
        "Discharge in BD Q3  =  5.62 lps\n",
        "height h  =  1.96 m\n",
        "Discharge in BC Q2  =  10.00 lps\n",
        "Discharge in BD Q3  =  5.64 lps\n"
       ]
      }
     ],
     "prompt_number": 16
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.21 Page No : 290"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\t\t\n",
      "#Initialization of variables\n",
      "e = 0.8\n",
      "output = 400. \t\t#kW\n",
      "H = 150. \t\t\t#m\n",
      "rho = 1000. \n",
      "g = 9.81\n",
      "f = 0.028\n",
      "l = 1250. \t\t\t#m\n",
      "\t\t\t\n",
      "#calculations\n",
      "gam = rho*g\n",
      "inpu = output/e\n",
      "Q = inpu*10**3 /(2./3 *gam*H)\n",
      "hl = 1./3 *H\n",
      "d5 =  f*l*Q**2 /(2*g* math.pi/4 * math.pi/4 *hl)\n",
      "d = d5**(1./5)\n",
      "\t\t\t\n",
      "#results\n",
      "print \"Smallest diameter of pen stock  =  %d cm\"%(d*100)\n",
      "    "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Smallest diameter of pen stock  =  43 cm\n"
       ]
      }
     ],
     "prompt_number": 25
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.22 Page No : 291"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\t\t\n",
      "#Initialization of variables\n",
      "f = 0.04\n",
      "H = 30. \t\t\t#m\n",
      "l = 200. \t\t\t#m\n",
      "d = 0.075 \t\t\t#m\n",
      "g = 9.81\n",
      "rho = 1000.\n",
      "gam = rho*g\n",
      "\t\t\t\n",
      "#calculations\n",
      "h = 2/3. *H\n",
      "vj = math.sqrt(2.*g*h)\n",
      "hl =  1/3. *H\n",
      "V =  math.sqrt(hl*d*2*g/(f*l))\n",
      "dj =  d*(math.sqrt(V/vj))\n",
      "Power =  2/3. *gam*math.pi/4. *d**2 *V*H\n",
      "\t\t\t\n",
      "#results\n",
      "print \"Size of nozzle  =  %.1f cm\"%(dj*100)\n",
      "print \" Max power  =  %.2f kW\"%(Power/1000)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Size of nozzle  =  2.0 cm\n",
        " Max power  =  1.18 kW\n"
       ]
      }
     ],
     "prompt_number": 29
    }
   ],
   "metadata": {}
  }
 ]
}