{
 "metadata": {
  "name": "",
  "signature": "sha256:fe74dcaff3035e39890b266fafcf015d3afee121cbb7baf09e89820b75888c5a"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 5 : Flow Through Pipes"
     ]
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.1 pageno : 131"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math\n",
      "import numpy \n",
      "#initialisation of variables\n",
      "h = 4. \t\t\t#ft\n",
      "h1 = 3. \t\t\t#ft\n",
      "r = 3. \t\t\t#ft\n",
      "h2 = 1.5 \t\t\t#ft\n",
      "#CALCULATIONS\n",
      "m = (h*h1+(h1**2/2))/(h+(h/2)*math.sqrt(h1**2+(h1/2)**2))\n",
      "a = 2*numpy.degrees(numpy.arccos(h2/r))\n",
      "P = 2*math.pi*r*a/360.\n",
      "A = r**2*((2*math.pi/3.)-math.sin(math.radians(a)))/2.\n",
      "H = A/(2*math.pi)\n",
      "#RESULTS\n",
      "print 'Hydraulic mean depth m = %.2f ft'%m\n",
      "print  'hydraulic mean depth  = %.2f ft '%(H)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Hydraulic mean depth m = 1.54 ft\n",
        "hydraulic mean depth  = 0.88 ft \n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.2 pageno : 133"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "\n",
      "#initialisation of variables\n",
      "d = 3. \t\t\t#ft\n",
      "l = 5280. \t\t\t#ft\n",
      "v = 3. \t\t\t#ft/sec\n",
      "f = 0.005\n",
      "g = 32.2 \t\t\t#ft/sec**2\n",
      "C = 115.\n",
      "#CALCULATIONS\n",
      "hf = 4*f*l*v**2/(2*g*v)\n",
      "m = d/4\n",
      "hf1 = (v/C)**2*4*l/3\n",
      "#RESULTS\n",
      "print  'hf  = %.2f ft '%(hf)\n",
      "print  'hf  = %.1f ft '%(hf1)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "hf  = 4.92 ft \n",
        "hf  = 4.8 ft \n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.3 page no : 134"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "import math \n",
      "#initialisation of variables\n",
      "d = 6. \t\t\t#in\n",
      "Q = 2. \t\t\t#cfs\n",
      "l = 1000. \t\t\t#ft\n",
      "f = 0.0055\n",
      "w = 62.4 \t\t\t#lb/ft**3\n",
      "g = 32.2 \t\t\t#ft/sec**2\n",
      "h = 70. \t\t\t#ft\n",
      "#CALCULATIONS\n",
      "v = Q/(math.pi*(d/12)**2/4)\n",
      "hf = 4*f*l*w*(Q/(math.pi*(d/12)**2/4))**2/((d/12)*2*144*g)\n",
      "ft_water = round(hf*144/w + 70)\n",
      "P = ft_water*w/144\n",
      "\n",
      "#RESULTS\n",
      "print  'pressure  = %.1f lb/in**2 '%(hf)\n",
      "print  'presure difference  = %.0f lb/in**2 '%(P)\n",
      "\n",
      "# Answers are slightly different because of rounding error."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "pressure  = 30.7 lb/in**2 \n",
        "presure difference  = 61 lb/in**2 \n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.4 pageno : 135"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "#initialisation of variables\n",
      "d = 6. \t\t\t#in\n",
      "hf = 7.7 \t\t\t#ft\n",
      "f = 0.005\n",
      "l = 1000. \t\t\t#ft\n",
      "g = 32.2 \t\t\t#ft/sec**2\n",
      "#CALCULATIONS\n",
      "C = math.sqrt(2*g/f)\n",
      "Q = math.pi*C*(d/12)**2.5*(hf/1000)**0.5 /8\n",
      "#RESULTS\n",
      "print  'Discharge  = %.2f cfs '%(Q)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Discharge  = 0.69 cfs \n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.5 page no : 136"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "import math \n",
      "#initialisation of variables\n",
      "Q = 400000.\n",
      "d = 4. \t\t\t#miles\n",
      "h = 50. \t\t\t#ft\n",
      "q = 40. \t\t\t#gallons of water\n",
      "t = 8. \t\t\t#hr\n",
      "f = 0.0075\n",
      "w = 6.24 \t\t\t#lb/ft**3\n",
      "g = 32.2 \t\t\t#ft/sec**2\n",
      "#CALCULATIONS\n",
      "Q1 = round(Q*q*0.5/(t*60*60*w),1)\n",
      "d = (4*f*(d*5280)*Q1**2*16/(math.pi**2*h*2*g))**0.2*12\n",
      "\n",
      "#RESULTS\n",
      "print  'size of the supply  = %.3f in '%(d)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "size of the supply  = 43.579 in \n"
       ]
      }
     ],
     "prompt_number": 18
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.6 pageno : 138"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "import math \n",
      "\n",
      "#initialisation of variables\n",
      "Q = 0.7 \t\t\t#cfs\n",
      "d = 6. \t\t\t#in\n",
      "v1 = 1.084*10**-5 \t\t\t#ft**2/sec\n",
      "v2 = 0.394*10**-5 \t\t\t#ft**2/sec\n",
      "R = 2320.\n",
      "#CALCULATIONS\n",
      "Re = (4*Q)/(math.pi*.5*v2)\n",
      "v3 = R*v1/(d/12.)\n",
      "v4 =R*v2/(d/12.) \n",
      "v = Q*4/(math.pi*(d/12.)**2)\n",
      "\n",
      "#RESULTS\n",
      "print 'Re at 80 C %.0f'%Re\n",
      "print  'crititcal velocity  = %.4f ft/sec '%(v4)\n",
      "print  'actual velocity  = %.2f ft/sec '%(v)\n",
      "\n",
      "# Note : answer is correct. Please calculate it manually."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Re at 80 C 452420\n",
        "crititcal velocity  = 0.0183 ft/sec \n",
        "actual velocity  = 3.57 ft/sec \n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.7 pageno : 140"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "#initialisation of variables\n",
      "p = 0.91 \t\t\t#units\n",
      "u = 0.21 \t\t\t#poise\n",
      "q = 200. \t\t\t#gallons\n",
      "h = 40. \t\t\t#ft\n",
      "l = 200. \t\t\t#ft\n",
      "w = 62.4 \t\t\t#lb/ft**3\n",
      "d = 3./4 \t\t\t#in\n",
      "g =32.2 \t\t\t#ft/s**2\n",
      "#CALCULATIONS\n",
      "v = u/(p*(30.5)**2)\n",
      "Q = q*10/(w*3600*p)\n",
      "V = Q/(math.pi*(d/12)**2/4)\n",
      "Re = V*(d/12)/v\n",
      "F = 64/Re\n",
      "Hf = F*l*V**2/(2*g*(d/12))\n",
      "Ht = Hf+h\n",
      "P = w*p*Ht/144\n",
      "#RESULTS\n",
      "print  'Pressure head   = %.1f lb/sq in '%(P)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Pressure head   = 31.6 lb/sq in \n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.8 page no : 142"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from math import log10\n",
      "#initialisation of variables\n",
      "h = 1.5         # H\n",
      "v = 2.          # V\n",
      "\n",
      "#CALCULATIONS\n",
      "logh = round(log10(h),4)\n",
      "logk = -0.415            # from fig.\n",
      "logv = round(log10(v),4)\n",
      "n = (logh-logk)/logv\n",
      "\n",
      "#RESULTS\n",
      "print  'n  = %.3f  '%(n)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "n  = 1.964  \n"
       ]
      }
     ],
     "prompt_number": 21
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.10 page no : 146"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "#initialisation of variables\n",
      "pb = 20. \t\t\t#lb/in**2\n",
      "w = 62.4 \t\t\t#lb/ft**3\n",
      "Q = 1.96 \t\t\t#cfs\n",
      "d1 = 0.5 \t\t\t#ft\n",
      "d2 = 1. \t\t\t#ft\n",
      "f = 0.005\n",
      "g = 32.2 \t\t\t#ft/sec**2\n",
      "l1 = 300. \t\t\t#ft\n",
      "H = 14.015 \t\t\t#ft of water\n",
      "#CALCULATIONS\n",
      "v1 = Q/(math.pi*d1**2/4.)\n",
      "v2 = Q/(math.pi*d2**2./4.)\n",
      "hf1 = 4*f*l1*v1**2./(2.*g*d1)\n",
      "hf2 = 4*f*l1*v2**2/(2*g*d2)\n",
      "h = (v1-v2)**2/(2*g)\n",
      "h1 = v1**2/(2*g)\n",
      "h2 = v2**2/(2*g)\n",
      "P = H*w/144\n",
      "#RESULTS\n",
      "print  'Loss of head at C  = %.2f ft '%(h1)\n",
      "print  'Loss of head at C  = %.3f ft '%(h2)\n",
      "print  'Pressure differnece at discharge end  = %.2f lb/in**2 '%(P)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Loss of head at C  = 1.55 ft \n",
        "Loss of head at C  = 0.097 ft \n",
        "Pressure differnece at discharge end  = 6.07 lb/in**2 \n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.11 page no : 148"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "#initialisation of variables\n",
      "d = 8. \t\t\t#in\n",
      "l = 6000. \t\t\t#ft\n",
      "H = 100. \t\t\t#ft\n",
      "H1 = 1000. \t\t\t#ft\n",
      "f = 0.008\n",
      "g = 32.2 \t\t\t#ft/sec**2\n",
      "h1 = 24. \t\t\t#ft\n",
      "h2 = 34. \t\t\t#ft \n",
      "h3 = 25. \t\t\t#ft\n",
      "w = 6.24 \t\t\t#lb/ft**3\n",
      "#CALCULATIONS\n",
      "v = math.sqrt(H*d*2*g/(4*f*l*12))\n",
      "h = -h1+(v**2/(2*g))+h3+(4*f*H1*v**2/(2*g*(d/12)))\n",
      "Q = round(math.pi*(d/12)**2*v*3600*w/4,-2)\n",
      "#RESULTS\n",
      "print  'minimum depth  = %.f ft '%(h)\n",
      "print  'Discharge  = %.f gpm'%(Q)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "minimum depth  = 18 ft \n",
        "Discharge  = 37100 gpm\n"
       ]
      }
     ],
     "prompt_number": 31
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.12 page no : 151"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "#initialisation of variables\n",
      "h = 25. \t\t\t#ft\n",
      "l = 2000. \t\t\t#ft\n",
      "d = 12. \t\t\t#in\n",
      "g = 32.2 \t\t\t#ft/sec**2\n",
      "f = 0.005\n",
      "dz = 16. \t\t\t#ft\n",
      "zb = 25. \t\t\t#ft\n",
      "zc = -16. \t\t\t#ft\n",
      "#CALCULATIONS\n",
      "v = math.sqrt(2*g*h/(1.5+(4*f*l/(d/12))))\n",
      "Q = math.pi*(d/12)**2*v/4\n",
      "l1 = (34-dz)*l/(zb-zc-dz)\n",
      "#RESULTS\n",
      "print  'Discharge  = %.1f cfs '%(Q)\n",
      "print  'length of the inlet  = %.f ft of water '%(l1)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Discharge  = 4.9 cfs \n",
        "length of the inlet  = 1440 ft of water \n"
       ]
      }
     ],
     "prompt_number": 33
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.13 page no : 153"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "import math \n",
      "\n",
      "#initialisation of variables\n",
      "d1 = 2 \t\t\t#in\n",
      "l1 = 25 \t\t\t#ft\n",
      "d2 = 4 \t\t\t#in\n",
      "l2 = 140 \t\t\t#ft\n",
      "v = 4 \t\t\t#ft/sec\n",
      "g = 32.2 \t\t\t#ft/sec**2\n",
      "f = 0.0065\n",
      "#CALCULATIONS\n",
      "v1 = v*(d2/d1)**2\n",
      "H = (0.5*v1**2/(2*g))+(4*f*l1*12*v1**2/(d1*2*g))+((v1-v)**2/(2*g))+(4*f*l2*12*v**2/(d2*2*g))+(v**2/(2*g))\n",
      "#RESULTS\n",
      "print  'necessaey height of water  = %.3f ft '%(H)\n",
      "\n",
      "# Note : answer is slightly different because of rounding error."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "necessaey height of water  = 22.688 ft \n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.14 page no : 155"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "#initialisation of variables\n",
      "l1 = 3000. \t\t\t#ft\n",
      "d1 = 18. \t\t\t#in\n",
      "l2 = 1500. \t\t\t#ft\n",
      "d2 = 15. \t\t\t#ft\n",
      "l3 = 1000. \t\t\t#ft\n",
      "d3 = 12. \t\t\t#in\n",
      "#CALCULATIONS\n",
      "d = ((l1+l2+l3)/((l1/d1**5)+(l2/d2**5)+(l3/d3**5)))**(1./5)\n",
      "#RESULTS\n",
      "print  'Diameter  = %.2f in '%(d)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Diameter  = 14.86 in \n"
       ]
      }
     ],
     "prompt_number": 35
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.15 page no : 156"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "import math \n",
      "#initialisation of variables\n",
      "g = 32.2 \t\t\t#ft/sec**2\n",
      "D = 9. \t\t\t#in\n",
      "#CALCULATIONS\n",
      "d = D/(2**0.4)\n",
      "#RESULTS\n",
      "print  'diameter of paralle mains  = %.2f in '%(d)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "diameter of paralle mains  = 6.82 in \n"
       ]
      }
     ],
     "prompt_number": 36
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.16 page no : 157"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "import math \n",
      "#initialisation of variables\n",
      "d = 2. \t\t\t#ft\n",
      "l = 5280. \t\t\t#ft\n",
      "f = 0.01\n",
      "H = 100. \t\t\t#ft\n",
      "g = 32.2 \t\t\t#ft/sec**2\n",
      "#CALCLATIONS\n",
      "v = math.sqrt(H*2*d*g/(4*f*l))\n",
      "Q = math.pi*d**2*v/4.\n",
      "r = d\n",
      "v2 = math.sqrt(H/((r**2+1)*(4*f*l/(2*2*2*g))))\n",
      "Q1 = 2*math.pi*d**2*v2/4.\n",
      "dQ = Q1-Q\n",
      "p = dQ*100./Q\n",
      "#RESULTS\n",
      "print  'percentage increase in discharge  = %.1f %% '%(p)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "percentage increase in discharge  = 26.5 % \n"
       ]
      }
     ],
     "prompt_number": 38
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.17 Page no : 160"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " import math\n",
      "\n",
      "# Variables\n",
      "d1 = 2          # ft\n",
      "d2 = 1.5        # ft\n",
      "d3 = 1          # ft\n",
      "l1 = 2000       # ft\n",
      "l2 = 3000       # ft\n",
      "l3 = 1500       # ft\n",
      "za = 100        # ft\n",
      "zb = 70         # ft\n",
      "zc = 50         # ft\n",
      "zd = 80         # ft\n",
      "f = 0.007       # ft\n",
      "v3 = 7.93\n",
      "\n",
      "# Calculations\n",
      "\n",
      "v1 = round(math.sqrt(111-1.412*(v3**2)),1)\n",
      "v2 = round(math.sqrt(-23.4+.745*(v3**2)),2)\n",
      "pd_w = round((za - zd) - ( 29 * v1**2/64.4),2)\n",
      "Q1 = (math.pi/4)*d1**2*v1\n",
      "Q2 = (math.pi/4)*d2**2*v2\n",
      "Q3 = Q1 - Q2\n",
      "\n",
      "# Results\n",
      "print \"V1 = %.1f ft/sec\"%v1\n",
      "print \"V2 = %.2f ft/sec\"%v2\n",
      "print \"V3 = %.2f ft/sec\"%v3\n",
      "print \"Pressure at the junction point : %.2f ft of water\"%pd_w\n",
      "print \"Discharge in section : %.2f cfs\"%Q3\n",
      "\n",
      "# Note : Answers may vary because of rounding error. Please check it manually."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "V1 = 4.7 ft/sec\n",
        "V2 = 4.84 ft/sec\n",
        "V3 = 7.93 ft/sec\n",
        "Pressure at the junction point : 10.05 ft of water\n",
        "Discharge in section : 6.21 cfs\n"
       ]
      }
     ],
     "prompt_number": 19
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.18 page no : 164"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "import math \n",
      "#initialisation of variables\n",
      "A = 10000. \t\t\t#ft**2\n",
      "H1 = 50. \t\t\t#ft\n",
      "H2 = 40. \t\t\t#ft\n",
      "l = 1500. \t\t\t#ft\n",
      "d = 6. \t\t\t#in\n",
      "f = 0.0075\n",
      "g = 32.2 \t\t\t#f/sec**2\n",
      "#CALCULATIONS\n",
      "t = 2.*A*math.sqrt((1.5+(4*f*l/(d/12)))/(2*g))*(math.sqrt(H1)-math.sqrt(H2))/(math.pi*(d/12)**2/4)\n",
      "#RESULTS\n",
      "print  'Time taken to lower the level of water  = %.f hours '%(t/3600)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Time taken to lower the level of water  = 25 hours \n"
       ]
      }
     ],
     "prompt_number": 43
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.19 page no : 164"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "#initialisation of variables\n",
      "l = 24. \t\t\t#ft\n",
      "b = 12. \t\t\t#ft\n",
      "f = 0.006\n",
      "d = 4. \t\t\t#in\n",
      "l1 = 25. \t\t\t#ft\n",
      "H1 = 6. \t\t\t#ft\n",
      "H = 20. \t\t\t#ft\n",
      "g = 32.2 \t\t\t#ft/sec**2\n",
      "Cd = 0.6\n",
      "#CALCULATIONS\n",
      "a = math.pi*(d/12)**2/4\n",
      "A = l*b\n",
      "H2 = H1+H\n",
      "t = round(2*A*math.sqrt((1.5+(4*f*l1/(d/12)))/(2*g))*(math.sqrt(H2)-math.sqrt(H))/a,-1)\n",
      "t1 = 2*A*math.sqrt((1.5+(4*f*l1/(d/12)))/(2*g))*math.sqrt(H1)/a\n",
      "t2 = 2*A*math.sqrt(H1)/(Cd*a*math.sqrt(2*g))\n",
      "#RESULTS\n",
      "print  'Time taken to lower the pipe  = %.f sec '%(t)\n",
      "print  'Time taken to lower the pipe  = %.f sec '%(t1)\n",
      "print  'Time taken to lower the pipe  = %.f sec '%(t2)\n",
      "\n",
      "# note : answers may vary becasue of ronding error. "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Time taken to lower the pipe  = 940 sec \n",
        "Time taken to lower the pipe  = 3660 sec \n",
        "Time taken to lower the pipe  = 3358 sec \n"
       ]
      }
     ],
     "prompt_number": 49
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.20 page no : 165\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "import math \n",
      "#initialisation of variables\n",
      "d = 2 \t\t\t#ft\n",
      "l = 1000 \t\t\t#ft\n",
      "f = 0.0075\n",
      "H1 = 20 \t\t\t#ft\n",
      "A1 = 100000 \t\t\t#ft**2\n",
      "A2 = 50000 \t\t\t#ft**2\n",
      "g = 32.2 \t\t\t#ft/sec**2\n",
      "#CALCULATIONS\n",
      "h = 2*A1/A2\n",
      "H2 = H1-h\n",
      "t = 2*A1*A2*math.sqrt(1.5+(4*f*l/2))*0.47/((A1+A2)*(math.pi*d**2/4)*math.sqrt(2*g))/60\n",
      "#RESULTS\n",
      "print  'Time taken to lower the level of water  = %.f min '%(t)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Time taken to lower the level of water  = 84 min \n"
       ]
      }
     ],
     "prompt_number": 50
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.21 page no : 167"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "import math \n",
      "#initialisation of variables\n",
      "H = 1000. \t\t\t#lb/in**2\n",
      "Hf = 100. \t\t\t#lb/in**2\n",
      "l = 10. \t\t\t#miles\n",
      "HP = 100.\n",
      "g = 32.2 \t\t\t#ft/sec**2\n",
      "w = 64.4 \t\t\t#lb/ft**3\n",
      "f = 0.006\n",
      "#CALCULATIONS\n",
      "n = (H-Hf)*100/H\n",
      "v = Hf*550/((math.pi/4)*n*10*144)\n",
      "r = Hf*144*2*g/(w*4*f*l*5280)\n",
      "d = (v**2/r)**(1./5)\n",
      "#RESULTS\n",
      "print  'Diameter  = %.4f ft '%(d)\n",
      "\n",
      "# answer may vary because of rounding error."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Diameter  = 0.4808 ft \n"
       ]
      }
     ],
     "prompt_number": 52
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.22 page no : 170"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "import math \n",
      "#initialisation of variables\n",
      "h1 = 1640. \t\t\t#ft\n",
      "h2 = 40. \t\t\t#ft\n",
      "d = 8. \t\t\t#in\n",
      "l = 2. \t\t\t#miles\n",
      "D = 3. \t\t\t#ft\n",
      "f = 0.006\n",
      "Cv = 0.98\n",
      "g = 32.2 \t\t\t#ft/sec**2\n",
      "w = 62.4 \t\t\t#lb/ft**3\n",
      "#CALCULATIONS\n",
      "r = (d/12)/D\n",
      "vact = Cv*math.sqrt(2*g*(h1-h2)/(1+(4*f*l*5280*r**4/D)))\n",
      "HP = round(round(w*vact**3*(math.pi*(d/12)**2/4)/(550*2*g),-2),-3)\n",
      "#RESULTS\n",
      "print  'Horse Power of Jet  = %.f HP '%(HP)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Horse Power of Jet  = 15000 HP \n"
       ]
      }
     ],
     "prompt_number": 58
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.23 page no : 171"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "import math \n",
      "#initialisation of variables\n",
      "p = 60. \t\t\t#lb/in**2\n",
      "l = 300. \t\t\t#ft\n",
      "D = 2.5 \t\t\t#in\n",
      "d = 7./8 \t\t\t#in\n",
      "f = 0.018\n",
      "g = 32.2 \t\t\t#ft/sec**2\n",
      "w = 62.4 \t\t\t#lb/ft**3\n",
      "#CALCULATIONS\n",
      "r = (D/d)**4\n",
      "V = math.sqrt(2*g*144*p/(w*(r+0.5+(4*f*l/(D/12)))))\n",
      "Q = V*(math.pi*(D/12)**2)/4\n",
      "#RESULTS\n",
      "print  'Volume of flow  = %.3f cu ft/sec '%(Q)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Volume of flow  = 0.246 cu ft/sec \n"
       ]
      }
     ],
     "prompt_number": 59
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.24 page no : 171"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "import math \n",
      "#initialisation of variables\n",
      "D = 3. \t\t\t#in\n",
      "l = 800. \t\t\t#ft\n",
      "H = 120. \t\t\t#ft\n",
      "f = 0.01\n",
      "g = 32.2 \t\t\t#ft/sec**2\n",
      "w = 62.4 \t\t\t#lb/ft**3\n",
      "#CALCULATIONS\n",
      "d = ((D/12)**5/(8*f*l))**0.25\n",
      "hf = H/3\n",
      "dh = H-hf\n",
      "v = math.sqrt(hf*(D/12)*2*g/(4*f*l))\n",
      "HPmax = w*math.pi*((D/48)**2/4)*v*dh/550\n",
      "#RESULTS\n",
      "print  'HPmax  = %.3f HP '%(HPmax)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "HPmax  = 0.125 HP \n"
       ]
      }
     ],
     "prompt_number": 60
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.25 page no : 177"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "import math \n",
      "#initialisation of variables\n",
      "l = 2. \t\t\t#miles\n",
      "Q = 2.*10**6 \t\t\t#gal/day\n",
      "d = 12. \t\t\t#in\n",
      "t = 16. \t\t\t#sec\n",
      "w = 62.4 \t\t\t#lb/ft**3\n",
      "g = 32.2 \t\t\t#ft/sec**2\n",
      "#CALCULATIO\n",
      "Q1 =Q*10/(w*24*60*60)\n",
      "hi = l*5280*Q1/((math.pi*(d/12)**2./4)*(g*t))\n",
      "#RESULTS\n",
      "print  'height  = %.1f ft '%(hi)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "height  = 96.8 ft \n"
       ]
      }
     ],
     "prompt_number": 61
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.26 pageno : 178"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "#initialisation of variables\n",
      "d = 6. \t\t\t#in\n",
      "Q = 0.7854 \t\t\t#cfs\n",
      "E = 30*10**6 \t\t\t#lb/in**2\n",
      "t = 0.25 \t\t\t#in\n",
      "g = 32.2 \t\t\t#ft/sec**2\n",
      "w = 62.4 \t\t\t#lb/ft**3\n",
      "K = 300000. \t\t\t#lb/in**2\n",
      "#CALCULATIONS\n",
      "v = Q/(math.pi*(d/12)**2/4)\n",
      "p = v/(math.sqrt(144*(g/w)*((1/K)+(d/(t*E)))))\n",
      "#RESULTS\n",
      "print  'rise of presure in the pipe  = %.f lb/in**2 '%(p)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "rise of presure in the pipe  = 228 lb/in**2 \n"
       ]
      }
     ],
     "prompt_number": 62
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.27 page no : 183"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "import math \n",
      "#initialisation of variables\n",
      "w = 62.4 \t\t\t#lb/ft**3\n",
      "f = 0.005\n",
      "Q = 100. \t\t\t#cuses\n",
      "m = 40. \t\t\t#Rs\n",
      "n = 0.75\n",
      "n1 = 0.065\n",
      "K = 15. \t\t\t#Rs\n",
      "#CALCULATIONS\n",
      "d = ((5*w/(1.5*550*10))*n*f*Q**3*m/(K*n1))**(1/6.5)\n",
      "#RESULTS\n",
      "print  'economical diameter of pipe line  = %.3f ft '%(d)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "economical diameter of pipe line  = 3.795 ft \n"
       ]
      }
     ],
     "prompt_number": 63
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [],
     "language": "python",
     "metadata": {},
     "outputs": []
    }
   ],
   "metadata": {}
  }
 ]
}