{
 "metadata": {
  "name": "",
  "signature": "sha256:994ba4703f91ead0a5ff4da6459451af8490fc9d0d26864c4973279092fd8132"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 8 : Uniform Open Channel Flow"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.1 Page No : 306"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\t\t\n",
      "#Initialization of variables\n",
      "b = 4. \t\t\t    #m\n",
      "y = 1.2 \t\t\t#m\n",
      "sf = 0.001\n",
      "n = 0.012\n",
      "gam = 9.81*1000\n",
      "\t\t\t\n",
      "#calculations\n",
      "A = b*y\n",
      "R = A/(b+ 2*y)\n",
      "Q = 1/n *A*R**(2./3) *sf**(1./2)\n",
      "T = gam*R*sf\n",
      "\t\t\t\n",
      "#results\n",
      "print \"Discharge  =  %.3f m**3/s\"%(Q)\n",
      "print \" bed shear  =  %.2f N/m**2\"%(T)\n",
      "#The answer in textbook is wrong for discharge. Please use a calculator."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Discharge  =  10.442 m**3/s\n",
        " bed shear  =  7.36 N/m**2\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.2 Page No : 306"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\t\t\n",
      "#Initialization of variables\n",
      "b = 6. \t\t    \t#m\n",
      "y = 2. \t\t\t    #m\n",
      "sf = 0.005\n",
      "slope  =  2.\n",
      "gam = 9.81*1000\n",
      "Q = 65. \t\t\t#m**3/s\n",
      "\t\t\t\n",
      "#calculations\n",
      "A = (b+ 2*y)*slope\n",
      "P = b+ 2*y*math.sqrt(slope**2 +1)\n",
      "R = A/P\n",
      "V = Q/A\n",
      "n = R**(2./3) *sf**(1./2) /V\n",
      "\t\t\t\n",
      "#results\n",
      "print \"Value of mannings coefficient  =  %.3f\"%(n)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Value of mannings coefficient  =  0.026\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.3 Page No : 307"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\t\t\n",
      "#Initialization of variables\n",
      "b = 3. \t\t\t#m\n",
      "y = 1. \t\t\t#m\n",
      "sf = 0.005      #slope\n",
      "n = 0.028       \n",
      "gam = 9.81*1000\n",
      "Q = 0.25 \t\t\t#discharge - m**3/s\n",
      "slope = 1.5\n",
      "\t\t\t\n",
      "#calculations\n",
      "A =  0.5 *b*y\n",
      "P = 2*math.sqrt(1 + (slope)**2)\n",
      "R = A/P\n",
      "yx =  Q*n/(slope * R**(2./3) *sf**(1./2))\n",
      "y =  yx**(3./8)\n",
      "\t\t\t\n",
      "#results\n",
      "print \"depth  =  %.2f m\"%(y)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "depth  =  0.45 m\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.4 Page No : 307"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\t\t\n",
      "#Initialization of variables\n",
      "sf = 0.0064         #slope\n",
      "n = 0.015\n",
      "Q = 6.   \t\t\t#discharge - m**3/s\n",
      "gam = 9.81*1000\n",
      "\t\t\t\n",
      "#calculations\n",
      "AR =  n*Q/math.sqrt(sf)\n",
      "print (\"On trial and error, \")\n",
      "y = 0.385 \t\t\t#m\n",
      "print \"normal depth  =  %.3f m\"%(y)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "On trial and error, \n",
        "normal depth  =  0.385 m\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.5 Page No : 308"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "from numpy import *\n",
      "\t\t\t\n",
      "#Initialization of variables\\\n",
      "sf = 0.00007\n",
      "n = 0.013\n",
      "gam = 9.81*1000\n",
      "V = 0.45 \t\t\t#velocity - m/s\n",
      "Q = 1.4 \t\t\t#m**3/s\n",
      "\t\t\t\n",
      "#calculations\n",
      "by = Q/V\n",
      "#x = poly(0,\"x\")\n",
      "#y = roots(x**2 -2.66*x +1.55)\n",
      "y = roots([1,-2.66,1.55])\n",
      "b = by/y\n",
      "\t\t\t\n",
      "#results\n",
      "print \"y  =  \", y \n",
      "print \"corresponding b = \" ,b"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "y  =   [ 1.7978675  0.8621325]"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "corresponding b =  [ 1.73044516  3.60862294]\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.6 Page No : 310"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\t\t\n",
      "#Initialization of variables\n",
      "sf = 0.0016         #slope\n",
      "n = 0.02\n",
      "Q = 0.84 \t\t\t#m**3/s\n",
      "gam = 9.81*1000\n",
      "\t\t\t\n",
      "#calculations\n",
      "y53 =  Q*n/math.sqrt(sf)\n",
      "y = y53**(3./5)\n",
      "\t\t\t\n",
      "#results\n",
      "print \"depth of flow  =  %.2f m\"%(y)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "depth of flow  =  0.59 m\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.7 Page No : 313"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\t\t\n",
      "#Initialization of variables\n",
      "n = 0.015\n",
      "Q = 1.3 \t\t\t#m**3/s\n",
      "V = 0.6 \t\t\t#m/s\n",
      "gam = 9.81*1000\n",
      "\t\t\t\n",
      "#calculations\n",
      "alpha = 60. \t\t\t#degrees\n",
      "A = 0.5 *(1./2)**2 *(180-alpha)/180 *math.pi -(1./4)**2 *math.radians(math.tan(alpha))\n",
      "A = 0.206\n",
      "P = 0.5*(180-alpha)/180 *math.pi\n",
      "R = A/P\n",
      "d2 = V*n/(R**(2./3))\n",
      "d8 =  Q*n*4*4**(2./3) /math.pi\n",
      "d = math.sqrt(d8/d2)\n",
      "sf =  (d2**2/d**(4./3))\n",
      "\t\n",
      "#results\n",
      "print \"Diameter  =  %.2f m\"%(d)\n",
      "print \" slope  =  %.5f \"%(sf)\n",
      "#The answer given in textbook is wrong. please check"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Diameter  =  1.53 m\n",
        " slope  =  0.00040 \n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.8 Page No : 315"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\t\t\n",
      "#Initialization of variables\n",
      "b = 0.5 \t\t\t#m\n",
      "y = 0.35 \t\t\t#m\n",
      "sf = 0.001          #slope\n",
      "nc = 0.016\n",
      "gam = 9.81*1000\n",
      "Q = 0.15 \t\t\t#m**3/s\n",
      "\t\t\t\n",
      "#calculations\n",
      "A = b*y\n",
      "P =  b+ 2*y\n",
      "R = A/P\n",
      "ng = 1/Q *A*R**(2./3) *sf**(1./2)\n",
      "n =  (b*nc**(3./2) + 2*y*ng**(3./2))**(2./3) /(P**(2./3))\n",
      "Q2 = 1/n *A*R**(2./3) *sf**(1./2)\n",
      "\t\t\t\n",
      "#results\n",
      "print \"flow in case 2  =  %.3f m**3/s\"%(Q2)\n",
      "\n",
      "# note : rounding off error"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "flow in case 2  =  0.120 m**3/s\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.9 Page No : 316"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\t\t\n",
      "#Initialization of variables\n",
      "b1 = 8. \t\t\t#m\n",
      "b2 = 5. \t\t\t#m\n",
      "y = 5.  \t\t\t#m\n",
      "b5 = 15. \t\t\t#m\n",
      "b3 = 3. \t\t\t#m\n",
      "b4 = 3. \t\t\t#m\n",
      "y2 = 2. \t\t\t#m\n",
      "y3 = 3. \t\t\t#m\n",
      "n1 = 0.025\n",
      "n2 = 0.035\n",
      "sf = 0.0008\n",
      "\t\t\t#calcuations\n",
      "A =  (b1+b2)*y\n",
      "P =  b1+ math.sqrt(b2**2 +y**2) + math.sqrt(b3**2 +b4**2)\n",
      "R = A/P\n",
      "Q1 = 1/n1 *A*R**(2./3) *sf**(1./2)\n",
      "A2  =  b5*y2 - 0.5*y2*y2 + 0.5*y3*y2\n",
      "P2 =  b5 + math.sqrt(b4**2 + y3**2)\n",
      "R2 = A2/P2\n",
      "Q2 =  1/n2 *A2*R2**(2./3) *sf**(1./2)\n",
      "Q = Q1+Q2\n",
      "\t\t\t\n",
      "#results\n",
      "print \"Total discharge  =  %.f m**3/s\"%(Q)\n",
      "\n",
      "# rounding off error"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Total discharge  =  200 m**3/s\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.10 Page No : 320"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\t\t\n",
      "#Initialization of variables\n",
      "Q = 12. \t\t\t#m**3/s\n",
      "n = 0.023\n",
      "A = 2.472\n",
      "b = 0.472\n",
      "sf = 1./8000\n",
      "\t\t\t\n",
      "#calculations\n",
      "y8 =  Q*n/A *2**(2./3) /sf**(1./2)\n",
      "y = y8**(3./8)\n",
      "b2 =  b*y\n",
      "\t\t\t\n",
      "#results\n",
      "print \"depth  =  %.3f m\"%(y)\n",
      "print \" width  =  %.2f m\"%(b2)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "depth  =  2.819 m\n",
        " width  =  1.33 m\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.11 Page No : 320"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\t\t\n",
      "#Initialization of variables\n",
      "Q = 30. \n",
      "V = 1.\n",
      "\t\t\t\n",
      "#calculations\n",
      "A = Q/V\n",
      "y  =  math.sqrt(A/(math.sqrt(2) + 0.5))\n",
      "b =  (A- 0.5*y**2)/y\n",
      "\t\t\t\n",
      "#results\n",
      "print \"width  =  %.2f m\"%(b)\n",
      "print \" depth  =  %.2f m\"%(y)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "width  =  5.60 m\n",
        " depth  =  3.96 m\n"
       ]
      }
     ],
     "prompt_number": 11
    }
   ],
   "metadata": {}
  }
 ]
}