{
 "metadata": {
  "name": "",
  "signature": "sha256:cfc2d9c55b511981c268535b9b836c28d1aec92123c8d6e11efaae493bc2b6d5"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 6 : Flow in Pipes"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.1 Page No : 95"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "#initialisation of variables\n",
      "l= 5000.     #ft long\n",
      "l1= 2000.    #ft\n",
      "d= 12.       #in diameter\n",
      "f= 0.005     # coefficient\n",
      "d1= 24       #in diameter\n",
      "f1= 0.0045   \n",
      "l2= 3000.    #ft\n",
      "Q= 1800.     #gal/min flow\n",
      "w= 6.24      #lb/ft**3\n",
      "g=32.2       #ft/s**2\n",
      "\n",
      "#CALCULATIONS\n",
      "F= Q/(60*w)\n",
      "v1= F*4/(math.pi*(d/12)**2)\n",
      "v2= v1/(d1/d)**2\n",
      "H= (f*l1*F**2/(10*(d/12)**5))+(f1*l2*F**2/(10*(d1/12)**5))+(v1**2/(4*g))+((v1-v2)**2/(2*g))+(v2**2/(2*g))\n",
      "\n",
      "#RESULTS\n",
      "print  'Available Head = %.2f ft'%(H)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Available Head = 24.74 ft\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.2 Page No : 96"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "\n",
      "#initialisation of variables\n",
      "g= 32.2 \t#ft/sec**2\n",
      "f= 0.01\n",
      "h= 42.   \t#ft\n",
      "l= 3200. \t#ft length\n",
      "d= 14.   \t#in diameter\n",
      "h1= 8.   \t#ft\n",
      "l1= 1800. \t#ft point\n",
      "w= 6.24 \t#lb/ft**3\n",
      "\n",
      "#CALCULATIONS\n",
      "v= math.sqrt(2*g*h/(1+0.5+(4*f*l/(d/12.))))\n",
      "h2= h-h1-(v**2/(2*g))-h1-(0.5*v**2/(2*g))-(4*f*l1*v**2/(2*g*(d/12)))\n",
      "Q= math.pi*(d/12)**2*v*w*60/4\n",
      "\n",
      "#RESULTS\n",
      "print  'Height of siphon above A = %.2f ft'%(h2)\n",
      "print  ' Total Discharge = %.f gal/min'%(Q)\n",
      "\n",
      "# rounding off error"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Height of siphon above A = 2.13 ft\n",
        " Total Discharge = 1974 gal/min\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.3 Page No : 97"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "\n",
      "#initialisation of variables\n",
      "H= 950. \t#lb/in**2\n",
      "l= 5.    \t#miles distance\n",
      "d= 4.    \t#in\n",
      "f= 0.0075    # friction\n",
      "p= 92.   \t#per cent\n",
      "hp= 200. \t#h.p power\n",
      "g= 32.2 \t#ft/sec62\n",
      "w= 62.4 \t#lb/ft**3\n",
      "\n",
      "#CALCULATIONS\n",
      "H1= H*2.3\n",
      "H2= H1*100/p\n",
      "Hf= H2-H1\n",
      "v= math.sqrt(2*g*(d/12)*Hf/(4*f*l*5280))\n",
      "n= hp/(w*v*(H1/550)*math.pi*(d/12)**2/4)\n",
      "\n",
      "#RESULTS\n",
      "print  'number of pipes required = %.2f'%(n)\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "number of pipes required = 4.07\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.4 Page No : 98"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "#initialisation of variables\n",
      "l= 1.5 \t    #miles length\n",
      "d= 18. \t    #in diameter\n",
      "Q= 12.4 \t#/cusecs\n",
      "h= 130. \t#ft\n",
      "r= 169.\n",
      "r1= 338.\n",
      "w= 62.4 \t#lb/ft**3\n",
      "g= 32.2 \t#ft/sec**2\n",
      "\n",
      "#CALCULATIONS\n",
      "f= h*10*l**5/(l*5280*Q**2)\n",
      "R= math.sqrt(1.5*r1-r)\n",
      "d= math.sqrt(l**2/R*144)\n",
      "v= math.sqrt(h*g*2/(r/R**2+1))\n",
      "HP= w*0.25*math.pi*(d/12)**2*v**3/(550*2*g)\n",
      "\n",
      "#RESULTS\n",
      "print  'f = %.3f '%(f)\n",
      "print  ' Diameter of jet d = %.2f in'%(d)\n",
      "print  ' Water h.p = %.1f h.p'%(HP)\n",
      "\n",
      "\n",
      "#The answer is a bit different due to rounding off error in textbook\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "f = 0.008 \n",
        " Diameter of jet d = 4.20 in\n",
        " Water h.p = 70.6 h.p\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.5 Page No : 100"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "\n",
      "#initialisation of variables\n",
      "l= 5000. \t#ft long\n",
      "d= 24. \t    #in diameter\n",
      "Q= 18.  \t#cuses\n",
      "t= 10. \t    #sec \n",
      "P= 275000. \t#lb/in**2\n",
      "g= 32.2 \t#ft/sec**2\n",
      "w=62.4\n",
      "\n",
      "#CALCULATIONS\n",
      "v= Q/(math.pi*(d/24)**2)\n",
      "C= v/(t**2/2)\n",
      "Pr= ((l*C*t/g)+(v**2/(2*g)))/2.3\n",
      "Pr1= v*12*math.sqrt(w*P/(386.4*1728))\n",
      "\n",
      "#RESULTS\n",
      "print  'Pressure Rise = %.1f lb/in**2'%(Pr)\n",
      "print  ' Pressure Rise = %d lb/in**2'%(Pr1)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Pressure Rise = 77.6 lb/in**2\n",
        " Pressure Rise = 348 lb/in**2\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.6 Page No : 102"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "\n",
      "#initialisation of variables\n",
      "g= 32.2 \t#ft/sec**2\n",
      "v= 4.     \t#ft/sec velocity\n",
      "K= 300000. \t#lb/in**2 water\n",
      "d= 6. \t#in\n",
      "t= 0.25 \t#in\n",
      "E= 30*10**6 \t#lb/in**2\n",
      "w= 62.4 \t#lb/ft**3\n",
      "\n",
      "#CALCULATIONS\n",
      "P= math.sqrt((w*v**2/g)/((d/(E*144*t))+(1/(K*144))))/144\n",
      "Sm= P*d/(2*t)\n",
      "\n",
      "#RESULTS\n",
      "print  'Hoop stress = %.f lb/in**2'%(Sm)\n",
      "\n",
      "# rounding off error"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Hoop stress = 2739 lb/in**2\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.7 Page No : 104"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "\n",
      "#initialisation of variables\n",
      "l1= 19. \t#ft\n",
      "l2= 1.   \t#ft\n",
      "r1= 0.298\n",
      "r2= 0.238\n",
      "r3= 0.359\n",
      "r4= 0.242\n",
      "r5= 0.121\n",
      "d= 6 \t    #in diameter\n",
      "\n",
      "#CALCULATIONS\n",
      "m= -(-r4-math.sqrt(r4**2-4*(3*r1-r5)*(-(d/2)*r2-r3)))/(2*(3*r1-r5))\n",
      "v2= math.sqrt((l1+l2)/(r1*m**2-r2))\n",
      "v3= m*v2\n",
      "Q2= math.pi*v2/d**2\n",
      "Q3= math.pi*v3/d**2\n",
      "Q= Q2+Q3\n",
      "\n",
      "#RESULTS\n",
      "print  'Q2 = %.3f cusec'%(Q2)\n",
      "print  ' Q3 = %.2f cusec'%(Q3)\n",
      "print  ' Total Quantity = %.3f cusecs'%(Q)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Q2 = 0.711 cusec\n",
        " Q3 = 0.96 cusec\n",
        " Total Quantity = 1.668 cusecs\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.8 Page No : 106"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "#initialisation of variables\n",
      "h= 80.   \t#ft levels\n",
      "f= 0.008    # friction coefficient\n",
      "l= 3000. \t#ft long\n",
      "r1= 6.07\n",
      "r2= 377.5\n",
      "r3= 4733. \n",
      "r4= 0.0466\n",
      "r5= 3220.\n",
      "r6= 51.5\n",
      "\n",
      "#CALCULATIONS\n",
      "Q= math.sqrt(h*10/(f*l))\n",
      "Q1= math.sqrt(r2+math.sqrt(r2**2-4*r1*r3)/(2*r1))/3\n",
      "Q2= Q1-r4*math.sqrt(r5-r6*Q1**2)\n",
      "\n",
      "#RESULTS\n",
      "print  'rate discharge when valve B is closed= %.2f cusecs'%(Q)\n",
      "print  ' Flow in reservoir= %.2f cusecs'%(Q2)\n",
      "\n",
      "#The answer is a bit different due to rounding off error in textbook\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "rate discharge when valve B is closed= 5.77 cusecs\n",
        " Flow in reservoir= 5.13 cusecs\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.9 Page No : 108"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "\n",
      "#initialisation of variables\n",
      "Q= 450.  \t#gal/min\n",
      "w= 6.24 \t#lb/ft**3\n",
      "f= 0.005\n",
      "l1= 1000. \t#ft from reservoir A\n",
      "l2= 2000. \t#ft from reservoir D\n",
      "r1= 1.6\n",
      "r2= 4.4\n",
      "r3= 0.8\n",
      "r4 = 12.85\n",
      "h1= 59.1 \t#ft\n",
      "h2= 40.19 \t#ft\n",
      "v= 1.2 \t    #ft/sec\n",
      "f= 0.0056\n",
      "l= 10 \t    #ft  below reservoir A\n",
      "\n",
      "#CALCULATIONS\n",
      "Q1=  Q/(w*60)\n",
      "Q2= (r1+math.sqrt(r1**2+4*r2))/2\n",
      "Q3= Q2-Q1\n",
      "Q4= (-r3+math.sqrt(r3**2+4*r4))/2\n",
      "Q5= Q4+Q1\n",
      "d= (f*5500*v**2/(l*(h1-h2)))**0.2*12\n",
      "\n",
      "#RESULTS\n",
      "print  'flow in to reservoir B= %.2f cusecs'%(Q3)\n",
      "print  ' flow in to reservoir D= %.1f cusecs'%(Q5)\n",
      "print  ' diameter of MN= %.f in'%(d)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "flow in to reservoir B= 1.84 cusecs\n",
        " flow in to reservoir D= 4.4 cusecs\n",
        " diameter of MN= 9 in\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.10 Page No : 110"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "\n",
      "#initialisation of variables\n",
      "d= 2.5 \t#ft\n",
      "a= 45. \t#degrees\n",
      "Q= 69. \t#cuses\n",
      "l= 30. \t#ft\n",
      "w= 62.4 \t#lb/ft**3\n",
      "g= 32.2 \t#ft/sec**2\n",
      "\n",
      "#CALCULATIONS\n",
      "Ps= 0.25*math.pi*d**2*w*l/2240\n",
      "Rs= Ps*math.sqrt((1-math.cos(math.radians(a)))*2)\n",
      "W= Q*w/2240\n",
      "v= Q*4/(math.pi*d**2)\n",
      "Rd= W*v*math.sqrt(2*(1-math.cos(math.radians(a))))/g\n",
      "Rt= Rs+Rd\n",
      "\n",
      "#RESULTS\n",
      "print  'total resultant thrust = %.3f tons'%(Rt)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "total resulmath.tant thrust = 3.782 tons\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.11 Page No : 112"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "#initialisation of variables\n",
      "r1= 1./3\n",
      "r2= 7./12\n",
      "l= 5000. \t#ft\n",
      "l1= 10000. \t#ft\n",
      "d= 27. \t#in\n",
      "d1= 18. \t#in\n",
      "Q= 10. \t#cuses\n",
      "f= 0.006\n",
      "\n",
      "#CALCULATIONS\n",
      "Q2= Q/(math.sqrt(r2/r1)+1)\n",
      "Q1= Q-Q2\n",
      "H= (f*l*Q**2/(10*(d/12)**5))+(f*l1*Q1**2/(3*10**(d1/12)**5))\n",
      "\n",
      "#RESULTS\n",
      "print  'total difference in head = %.2f ft'%(H)\n",
      "\n",
      "\n",
      "#ANSWER GIVEN IN THE TEXTBOOK IS WRONG\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "total difference in head = 5.20 ft\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.12 Page No : 115"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "\n",
      "#initialisation of variables\n",
      "V= 4. \t    #ft/sec\n",
      "L= 1225. \t#ft\n",
      "l= 1200. \t#ft\n",
      "H= 50.   \t#ft\n",
      "d= 1./3 \t#ft\n",
      "f= 0.008\n",
      "g= 32.2 \t#ft/sec**2\n",
      "\n",
      "#CALCULATIONS\n",
      "a= 2*g*H\n",
      "b= (4*f*L/d)+1.5\n",
      "c= math.sqrt(a/b)\n",
      "d= math.sqrt(a*b)\n",
      "T= math.log(math.sqrt((c+V)/(c-V)))*l*2/d\n",
      "\n",
      "#RESULTS\n",
      "print  'time interval for elapse = %.2f sec'%(T)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "time interval for elapse = 3.95 sec\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.14 Page No : 119"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "\n",
      "#initialisation of variables\n",
      "L= 8000. \t#ft\n",
      "d= 5.    \t#ft\n",
      "g= 32.2 \t#ft/sec**2\n",
      "d= 5. \t    #ft\n",
      "l= 250. \t#ft\n",
      "b= 100.\n",
      "\n",
      "#CALCULATIONS\n",
      "A= math.pi*0.25*d**2*l-0.5*d**2*b\n",
      "V= A*g/L\n",
      "\n",
      "#RESULTS\n",
      "print  'Velocity = %.2f ft/sec'%(V)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Velocity = 14.73 ft/sec\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.15 Page No : 121"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "\n",
      "#initialisation of variables\n",
      "B= 3.    \t#ft\n",
      "Cd= 0.6\n",
      "g= 32.2 \t#ft/sec**2\n",
      "d1= 6. \t    #in\n",
      "d2= 4.   \t#in\n",
      "\n",
      "#CALCULATIONS\n",
      "Q2= 0.428 \t#cuses\n",
      "r= math.sqrt((((d1/12)**5)/((d2/12)**5)))\n",
      "Q1= r*Q2\n",
      "Q= Q1+Q2\n",
      "\n",
      "#RESULTS\n",
      "print  'Total inflow = %.3f cuses'%(Q)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Total inflow = 1.607 cuses\n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.17 Page No : 124"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "\n",
      "#initialisation of variables\n",
      "f= 0.007\n",
      "l= 30.        \t#miles\n",
      "Q1= 5.*10**6 \t#gal/day\n",
      "w= 6.24 \t    #lb/ft**3\n",
      "H= 500. \t    #ft\n",
      "Q2= 7*10**6 \t#gal/day\n",
      "\n",
      "#CALCULATIONS\n",
      "Qi= Q1/(w*24*3600)\n",
      "d= (f*l*5280*Qi**2/(10*H))**0.2\n",
      "Qe = Q2*Qi/Q1\n",
      "x= (30-(H*10*d**5/(f*Qe**2*5280)))*(4./3)\n",
      "\n",
      "#RESULTS\n",
      "print 'diameter of pipes = %.1f ft'%d\n",
      "print  'length of new pipe required = %.1f miles'%(x)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "diameter of pipes = 1.8 ft\n",
        "length of new pipe required = 19.6 miles\n"
       ]
      }
     ],
     "prompt_number": 1
    }
   ],
   "metadata": {}
  }
 ]
}