{
 "metadata": {
  "name": "",
  "signature": "sha256:0abcc423492072a54fb770a61520bf727ac4ace788fa5f2dbb0a6db0caff8ec2"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter10-Flow with free surfaces"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex1-pg436"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#calculate The depth of the water under the brigde and the depth of water upstream\n",
      "Q=400.; ## m^3/s\n",
      "b2=20.; ## m\n",
      "g=9.81; ## m/s^2\n",
      "b1=25.; ## m\n",
      "\n",
      "h2=(Q/b2/math.sqrt(g))**(2./3.);\n",
      "## Since energy is conserved\n",
      "## h1 + u1^2/2g = h2 +u2^2/2g = h2 + h2/2 = 3h2/2\n",
      "\n",
      "## h1 + 1/2*g*(Q/(b1h1))^2 = 3*h2/2;\n",
      "\n",
      "## h1^3-5.16*h1^2+13.05 = 0;\n",
      "\n",
      "## By solving this cubic equation\n",
      "\n",
      "h1=4.52; ## m\n",
      "\n",
      "print'%s %.1f %s'%(\" The depth of the water under the brigde =\",h2,\"m\")\n",
      "\n",
      "\n",
      "print'%s %.2f %s'%(\" the depth of water upstream =\",h1,\"m\")\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " The depth of the water under the brigde = 3.4 m\n",
        " the depth of water upstream = 4.52 m\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex2-pg447"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#calculate Rate of flow \n",
      "w=0.04; ## thickness of block in m\n",
      "d=0.07; ## depth of liquid in m\n",
      "b=0.4; ## m\n",
      "g=9.81; ## m/s^2\n",
      "\n",
      "H=d-w; \n",
      "\n",
      "Q=1.705*b*H**(3/2.);\n",
      "\n",
      "u1=Q/d/b;\n",
      "h=u1**2/(2.*g);\n",
      "\n",
      "H1=H+h;\n",
      "\n",
      "Q1=1.705*b*H1**(3/2.);\n",
      "\n",
      "print'%s %.4f %s'%(\"Rate of flow =\",Q1,\" m^3/s\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Rate of flow = 0.0037  m^3/s\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex3-pg455"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#calculate depth of water at the throat and the new flow rate and the Froude number at the throat and flow rate\n",
      "h1=0.45; ## m\n",
      "g=9.81; ## m/s^2\n",
      "b1=0.8; ## m\n",
      "h2=0.35; ## m\n",
      "b2=0.3; ## m\n",
      "print(\"the flow rate\")\n",
      "Q=math.sqrt((h1-h2)*2*g/(-(1./(h1*b1)**2)+(1./(h2*b2)**2)));\n",
      "print'%s %.3f %s'%(\"Flow rate =\",Q,\"m^3/s\")\n",
      "\n",
      "\n",
      "print(\" the Froude number at the throat\")\n",
      "Fr2=Q/(math.sqrt(g)*b2*h2**(3/2.));\n",
      "print'%s %.3f %s'%(\"The Froude number at the throat =\",Fr2,\"\")\n",
      "\n",
      "\n",
      "print(\"the depth of water at the throat\")\n",
      "\n",
      "## (h1/h2)^(3) + 1/2*(b2/b1)^2 = 3/2*(h1/h2)^2\n",
      "\n",
      "## The solution for the above eqn is as follows\n",
      "## (h1/h2) = 0.5 + cos(2arcsin(b2/b1)/3)\n",
      "\n",
      "## h1/h2=1.467\n",
      "\n",
      "h2_new=h1/1.467;\n",
      "print'%s %.3f %s'%(\"Depth of water at the throat =\",h2_new,\"m\")\n",
      "\n",
      "print(\"the new flow rate\")\n",
      "w=math.sqrt(g)*b2*h2_new**(3/2.);\n",
      "print'%s %.3f %s'%(\"New flow rate =\",Q,\"m^3/s\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "the flow rate\n",
        "Flow rate = 0.154 m^3/s\n",
        " the Froude number at the throat\n",
        "The Froude number at the throat = 0.790 \n",
        "the depth of water at the throat\n",
        "Depth of water at the throat = 0.307 m\n",
        "the new flow rate\n",
        "New flow rate = 0.154 m^3/s\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex4-pg460"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#calculate depth\n",
      "Q=8.75; ## m^3/s\n",
      "w=5.; ## m\n",
      "n=0.0015; \n",
      "s=1./5000.;\n",
      "\n",
      "## Q/(w*h0) = u = m^(2/3)*i^(1/2)/n = 1/0.015*(w*h0/(w+2*h0))^(2/3)*sqrt(s);\n",
      "## Solution by trial gives h0\n",
      "h0=1.8; ## m\n",
      "\n",
      "q=1.75;\n",
      "g=9.81;\n",
      "hc=(q**2/g)**(1/3); ## critical depth\n",
      "\n",
      "print'%s %.1f %s'%(\"Depth =\",h0,\"m\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Depth = 1.8 m\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex5-pg469"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#calculate wave length\n",
      "g=9.81; ## m/s^2\n",
      "T=5.; ## s\n",
      "h=4.; ## m\n",
      "\n",
      "## lambda=g*T^2/(2*%pi)*tanh(2*%pi*h/lambda1);\n",
      "## by trial method , we get \n",
      "lambda1=28.04;\n",
      "\n",
      "D=g*T**2/(2*math.pi)*math.tanh(2*math.pi*h/lambda1);\n",
      "print'%s %.1f %s'%(\"Wavelength =\",D,\"m\")"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Wavelength = 27.9 m\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "EX6-pg470"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#calculate phase velocity and wave length\n",
      "g=9.81; ## m/s^2\n",
      "T=12; ## s\n",
      "\n",
      "c=g*T/(2*math.pi);\n",
      "\n",
      "D=c*T;\n",
      "\n",
      "print\"%s %.1f %s\"%(\"Phase velocity =\",c,\"m/s\")\n",
      "\n",
      "\n",
      "print\"%s %.1f %s\"%(\"Wavelength =\",D,\"m\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Phase velocity = 18.7 m/s\n",
        "Wavelength = 224.8 m\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex7-pg476"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#Estimate the time elapsed since the waves were generated in a storm occurring 800 km out to sea and Estimate the depth at which the waves begin to be significantly influenced by the sea bed as they approach the shore\n",
      "c=18.74; ## m/s\n",
      "lambd=225.; ## m\n",
      "\n",
      "print(\"Estimate the time elapsed since the waves were generated in a storm occurring 800 km out to sea. \")\n",
      "\n",
      "x=800.*10**3.; ## m\n",
      "cg=c/2.;\n",
      "\n",
      "t=x/cg;\n",
      "\n",
      "print\"%s %.1f %s\"%(\"time elapsed =\",t/3600.,\"hours\")\n",
      "\n",
      "\n",
      "print(\"Estimate the depth at which the waves begin to be significantly influenced by the sea bed as they approach the shore.\")\n",
      "\n",
      "h1=lambd/2.;\n",
      "\n",
      "h2=lambd/(2.*math.pi)*math.atanh(0.99);\n",
      "\n",
      "print\"%s %.1f %s %.1f %s\"%(\"The answers show that h lies in the range between about\",h2,\"m , \",h1, \"m\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Estimate the time elapsed since the waves were generated in a storm occurring 800 km out to sea. \n",
        "time elapsed = 23.7 hours\n",
        "Estimate the depth at which the waves begin to be significantly influenced by the sea bed as they approach the shore.\n",
        "The answers show that h lies in the range between about 94.8 m ,  112.5 m\n"
       ]
      }
     ],
     "prompt_number": 7
    }
   ],
   "metadata": {}
  }
 ]
}