{
 "metadata": {
  "name": "",
  "signature": "sha256:99b4244f7dba40fbe6b1f9647ffae37a043c932f7cb3e888c2ad7aac3ff9563e"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 5 : Flow in Channels"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.1 Page No : 67"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "\n",
      "#initialisation of variables\n",
      "h= 2.5 \t#ft  depth of water\n",
      "a= 45. \t#degrees  side slope\n",
      "x= 5. \t#ft\n",
      "Q= 45. \t#cuses\n",
      "v= 2.6 \t#ft/sec velocity\n",
      "w= 6.92 \t#ft \n",
      "C= 120.\n",
      "\n",
      "#CALCULATIONS\n",
      "b= (Q/(v*h))-h\n",
      "p= b+2*(h+math.sqrt(2))\n",
      "A= h*w\n",
      "m= A/p\n",
      "i= (v/(C*math.sqrt(m)))**2\n",
      "\n",
      "#RESULTS\n",
      "print  'Width = %.2f ft'%(b) \n",
      "print  ' Slope = %.6f '%(i) \n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Width = 4.42 ft\n",
        " Slope = 0.000332 \n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.2 Page No : 69"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "\n",
      "#initialisation of variables\n",
      "a= 60.   \t#degrees sides inclined\n",
      "i= 1./1600\n",
      "Q= 8.*10**6 \t#gal/hr discharge\n",
      "M= 110.\n",
      "w= 6.24 \t#lb/ft**3\n",
      "\n",
      "#CALCULATIOS\n",
      "d= ((Q*2**(2./3)*math.sqrt(1./i))/(w*3600*math.sqrt(3)*M))**(3./8)\n",
      "b=6.93   \t#ft\n",
      "\n",
      "#RESULTS\n",
      "print  'Diameter = %.f ft'%(d) \n",
      "print ' breadth = %.2f ft'%(b)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Diameter = 6 ft\n",
        " breadth = 6.93 ft\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.3 Page No : 71"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "#initialisation of variables\n",
      "g= 32.2 \t#ft/swc**2\n",
      "Q= 40. \t#cuses rate\n",
      "w= 5.5 \t#ft\n",
      "h= 9. \t#in  depth\n",
      "d= 0.75 \t#ft\n",
      "V= 3. \t#ft/sec\n",
      "\n",
      "#CALCULATIONS\n",
      "D= ((Q*2)**2/(g*(w*2)**2))**(1./3)\n",
      "v= Q*d/w\n",
      "D1= math.sqrt((2*v**2*d/g)+h/64)-(d/2)\n",
      "dD= D1-d\n",
      "El= -dD+((v**2*(1-(V/v)**2))/(2*g))\n",
      "Els= Q*El*62.4/550\n",
      "\n",
      "#RESULTS\n",
      "print 'Critical depth = %.2f ft'%(D)\n",
      "print ' Rise in level = %.f ft'%(D1)\n",
      "print  ' Horse-power lost = %.3f hp'%(Els) \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": [
        "Critical depth = 1.18 ft\n",
        " Rise in level = 1 ft\n",
        " Horse-power lost = 0.961 hp\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.6 Page No : 77"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "\n",
      "#initialisation of variables\n",
      "b= 3.5 \t#ft\n",
      "H= 2.5 \t#ft\n",
      "w= 3. \t#ft depth\n",
      "h= 6. \t#ft  wide\n",
      "g= 32.2 \t#ft/sec**2\n",
      "\n",
      "#CALCULATIONS\n",
      "Q= 3.09*b*H**1.5\n",
      "v= Q/(w*h)\n",
      "H1= H+(v**2/(2*g))\n",
      "Q1= 3.09*b*H1**1.5\n",
      "hc= (Q1**2/(b**2*g))**(1./3)\n",
      "h2= 0.5*(math.sqrt(hc**2+8*hc**2)-hc)\n",
      "dh= h2+b-w\n",
      "\n",
      "#RESULTS\n",
      "print \"Flow rate  = %.1f cusecs\"%(Q)\n",
      "print \" Flow rate  = %d cusecs\"%(Q1)\n",
      "print  ' maximum depth of water downstream = %.3f ft'%(dh) \n",
      "print  ' Shooting flow depth at hump = %.3f ft'%(h2) \n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Flow rate  = 42.8 cusecs\n",
        " Flow rate  = 45 cusecs\n",
        " maximum depth of water downstream = 2.226 ft\n",
        " Shooting flow depth at hump = 1.726 ft\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.7 Page No : 79"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "#initialisation of variables\n",
      "m= 60./26\n",
      "i= 1./2000\n",
      "h1= 3. \t#ft depth\n",
      "h2= 5. \t#ft depth\n",
      "m1= 10./3\n",
      "C= 90.      # constant\n",
      "l= 500. \t#ft depth\n",
      "H= 20. \t#ft broad\n",
      "H1= 29.62 \t#ft\n",
      "g= 32.2 \t#ft/s**2\n",
      "\n",
      "#CALCULATIONS\n",
      "v= 90*math.sqrt(m*i)\n",
      "v1= v*h1/h2\n",
      "dh= (i-(v1**2/(C**2*m1)))*l/(1-v1**2/(g*h2))\n",
      "h3= h2-dh\n",
      "V= h1*v/h3\n",
      "\n",
      "#RESULTS\n",
      "print  'Height of water 1000 ft upstream = %.3f ft'%(h3) \n",
      "print  ' Height of water upstream = %.3f ft'%(h3) \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": [
        "Height of water 1000 ft upstream = 4.808 ft\n",
        " Height of water upstream = 4.808 ft\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.8 Page No : 80"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "#initialisation of variables\n",
      "v= 5. \t    #ft/sec\n",
      "m= 60./26\n",
      "i= 1./2000\n",
      "h= 5.5   \t#ft\n",
      "m1= 110./31\n",
      "d= 3. \t    #ft\n",
      "g= 32.2 \t#ft/sec**2\n",
      "\n",
      "#CALCULATIONS\n",
      "C= v/(math.sqrt(m*i))\n",
      "v1= v*d/h\n",
      "r= (i-(v1**2/(C**2*m1)))/(1-(v1**2/(g*h)))\n",
      "x= 1/r\n",
      "\n",
      "#RESULTS\n",
      "print  'Distance upstream = %.f ft'%(round(x,-1)) \n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Distance upstream = 2380 ft\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.9 Page No : 81"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "from numpy import *\n",
      "from numpy.linalg import *\n",
      "\n",
      "#initialisation of variables\n",
      "g= 32.2 \t#ft/sec**2\n",
      "Q= 12 \t#cuses\n",
      "\n",
      "#CALCULATIONS\n",
      "hc= (Q/(3*math.sqrt(g)))**(2./3)\n",
      "vec=roots([1,6,12,8,0,-8.95,-8.95])\n",
      "H=vec[2]\n",
      "\n",
      "#RESULTS\n",
      "print  'Critical depth = %.2f ft'%(hc) \n",
      "print  ' Critical depth = %.2f ft'%(H) \n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Critical depth = 0.79 ft\n",
        " Critical depth = 0.89 ft\n"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stderr",
       "text": [
        "-c:17: ComplexWarning: Casting complex values to real discards the imaginary part\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5.11 Page No : 85"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "\n",
      "#initialisation of variables\n",
      "Cd= 0.64    # coefficient\n",
      "g= 32.2 \t#ft/sec**2\n",
      "A= 12.5 \t#ft**2\n",
      "H= 24.8 \t#ft\n",
      "Q= 3200. \t#cuses\n",
      "b= 150. \t#ft  wide\n",
      "A1= 5.*10**6  # avg surface area\n",
      "h= 9.   \t#ft\n",
      "h1= 6. \t    #in\n",
      "\n",
      "#CALCULATIONS\n",
      "N= Q/(Cd*A*math.sqrt(2*g*H))\n",
      "H1= (Q/(3.2*b))**(2./3)\n",
      "ES= (H1-(h1/12))*A1*h\n",
      "\n",
      "#RESULTS\n",
      "print  'number of siphons = %.f '%(N) \n",
      "print  ' Extra Storage = %.2e ft**3'%(ES) \n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "number of siphons = 10 \n",
        " Extra Storage = 1.37e+08 ft**3\n"
       ]
      }
     ],
     "prompt_number": 3
    }
   ],
   "metadata": {}
  }
 ]
}