{
 "metadata": {
  "name": "",
  "signature": "sha256:623ec7b54c6f867c29215af300ff18cf72a9c5c9473bc56f1a63e8f6d5b3f414"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 7 : Flow Through Pipes"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.1 Page No : 209"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "\n",
      "# Calculations and Results\n",
      "print (\"Part(i)\");\n",
      "print (\"Absolute unit of viscosity(in C.G.S) is Poise.\");\n",
      "print (\"Poise = 1 dyne-sec/cm**2\");\n",
      "print (\"Gravitational unit of viscosity is 1 gm-sec/cm**2.\");\n",
      "print (\"On equating we get, 1 gm  =  981 dyne\");\n",
      "#Let x = 1kg-sec/m**2\n",
      "x = 1*10.**3/10**4;\t\t\t#g-sec/cm**2\n",
      "x = x*981;\t\t\t#dyne-sec/cm**2 or Poise(Putting 1gm = 981 dyne)\n",
      "print \"1 kg-sec/m**2  =  \",(x),\" Poise\"\n",
      "one_Poise = 1./x;\t\t\t#kg-sec/m**2\n",
      "one_Poise = 1/x*9.81;\t\t\t#N-sec/m**2 or Pa-sec(as 1Pa = 1N/m**2)\n",
      "print \"1 Poise  =  \",(one_Poise),\" N-sec/m**2 or Pa-sec\"\n",
      "print (\"Part(ii)\");\n",
      "print (\"Kinematic viscosity  =  viscosity/specific_gravity\");\n",
      "print (\"Kinematic viscosity C.G.S unit is cm**2/sec. 1cm**2/sec = 1stoke\");\n",
      "print (\"Kinematic viscosity M.K.S unit is m**2/sec\");\n",
      "\t\t\t#let x = 1;\t\t\t#m**2/sec\n",
      "x = 1.;\t\t\t#m**2/sec\n",
      "x = x*10**4;\t\t\t#cm**2/sec or stokes\n",
      "print \"1 m**2/sec  =  \",(x),\" cm**2/sec or stoke\"\n",
      "one_stoke = 1/x;\t\t\t#m**2/sec\n",
      "print \"1 stoke  =  \",(one_stoke),\" m**2/sec\"\n",
      "print (\"1 stoke  =  100 centi-stokes\");\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Part(i)\n",
        "Absolute unit of viscosity(in C.G.S) is Poise.\n",
        "Poise = 1 dyne-sec/cm**2\n",
        "Gravitational unit of viscosity is 1 gm-sec/cm**2.\n",
        "On equating we get, 1 gm  =  981 dyne\n",
        "1 kg-sec/m**2  =   98.1  Poise\n",
        "1 Poise  =   0.1  N-sec/m**2 or Pa-sec\n",
        "Part(ii)\n",
        "Kinematic viscosity  =  viscosity/specific_gravity\n",
        "Kinematic viscosity C.G.S unit is cm**2/sec. 1cm**2/sec = 1stoke\n",
        "Kinematic viscosity M.K.S unit is m**2/sec\n",
        "1 m**2/sec  =   10000.0  cm**2/sec or stoke\n",
        "1 stoke  =   0.0001  m**2/sec\n",
        "1 stoke  =  100 centi-stokes\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.2 Page No : 210"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\t\t\n",
      "# Variables :\n",
      "mu = 0.009;\t\t\t#kg-sec/m**2\n",
      "rho = 0.89;\t\t\t#sp. gravity\n",
      "Q = 4.*10**-3;\t\t\t#m**3/sec\n",
      "d = 30./1000;\t\t\t#meter\n",
      "\n",
      "# Calculations and Results\n",
      "v = mu/rho;\t\t\t#m**2/s\n",
      "print \"Kinematic viscosity in m**2/sec : %.4f\"%v\n",
      "A = math.pi*d**2/4;\t\t\t#m**2\n",
      "vm = Q/A;\t\t\t#m/s\n",
      "Rn = vm*d/v;\t\t\t#Reynolds no.\n",
      "print \"Reynolds number for flow  : %.1f\"%Rn\n",
      "print (\"This is laminar flow because Rn no. is less than 2000.\");\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Kinematic viscosity in m**2/sec : 0.0101\n",
        "Reynolds number for flow  : 16.8\n",
        "This is laminar flow because Rn no. is less than 2000.\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.3 Page No : 211"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\t\t\n",
      "# Variables :\n",
      "d = 200./1000;\t\t\t#meter\n",
      "Q = 40.*10**-3;\t\t\t#m**3/sec\n",
      "A = math.pi*d**2/4;\t\t\t#m**2\n",
      "vm = Q/A;\t\t\t#m/s\n",
      "v = 0.25*10**-4;\t\t\t#m**2/s\n",
      "\n",
      "# Calculations and Results\n",
      "Rn = vm*d/v;\t\t\t#Reynolds no.\n",
      "print \"Reynolds number for flow  : %.f\"%Rn\n",
      "print (\"This is turbulent flow because Rn no. is greater than 4000.\");\n",
      "print \"New Reynolds number for flow  : %.f\"%(Rn/8)\n",
      "print (\"This is laminar flow because Rn no. is less than 2000.\");\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Reynolds number for flow  : 10186\n",
        "This is turbulent flow because Rn no. is greater than 4000.\n",
        "New Reynolds number for flow  : 1273\n",
        "This is laminar flow because Rn no. is less than 2000.\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.4 Page No : 218"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\t\t\n",
      "# Variables :\n",
      "D = 30./100;\t\t\t#meter\n",
      "L = 100.;\t\t\t#meter\n",
      "v = 0.01*10**-4;\t\t\t#m**2/s\n",
      "a = 3.;\t\t\t#m/s\n",
      "g = 9.81;\t\t\t#gravity consmath.tanty\n",
      "Rn = a*D/v;\t\t\t#Reynolds no.\n",
      "\n",
      "# Calculations\n",
      "f = 0.079/Rn**(1./4);\t\t\t#umath.sing blasius formula \n",
      "hf = 4*f*L/D*a**2/2/g;\t\t\t#meter\n",
      "\n",
      "# Results\n",
      "print \"Head lost in meter : %.2f\"%hf\n",
      "\n",
      "#Answer in the book is wrong.\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Head lost in meter : 1.57\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.5 Page No : 219"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\t\t\n",
      "# Variables :\n",
      "D = 30./100;\t\t\t#meter\n",
      "L = 500.;\t\t\t#meter\n",
      "Q = 300.*10**-3;\t\t\t#m**2/sec\n",
      "f = 0.0008;\t\t\t#coeff. of friction\n",
      "\n",
      "# Calculations\n",
      "v = Q/(math.pi/4*D**2);\t\t\t#m/s\n",
      "g = 9.81;\t\t\t#gravity consmath.tanty\n",
      "hf = 4*f*L*v**2/D/2/g;\t\t\t#meter\n",
      "\n",
      "# Results\n",
      "print \"Difference in elevation in meter : %.2f\"%hf\n",
      "\n",
      "#Answer in the book is wrong.\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Difference in elevation in meter : 4.90\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.6 Page No : 219"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\t\t\n",
      "# Variables :\n",
      "D = 20./100;\t\t\t#meter\n",
      "v = 3.;\t\t\t#m/s\n",
      "v1 = 0.01*10**-3;\t\t\t#m**2/sec\n",
      "Re = D*v/v1;\t\t\t#Reynolds number\n",
      "f = 0.002+0.09/Re**0.3;\t\t\t#coeff. of friction\n",
      "L = 5.;\t\t\t#meter\n",
      "g = 9.81;\t\t\t#gravity consmath.tanty\n",
      "\n",
      "# Calculations\n",
      "hf = 4*f*L*v**2/D/2/g;\t\t\t#meter\n",
      "\n",
      "# Results\n",
      "print \"Head lost due to friction in meter : %.3f\"%hf\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Head lost due to friction in meter : 0.244\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.7 Page No : 230"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\t\t\n",
      "# Variables :\n",
      "D = 80./1000;\t\t\t#meter\n",
      "Q = 600.*10**-3/60;\t\t\t#m**3/sec\n",
      "L = 1.*10**3;\t\t\t#meter\n",
      "f = 0.02;\t\t\t#coefficient of friction\n",
      "\n",
      "# Calculations\n",
      "v = Q/(math.pi/4*D**2);\t\t\t#m/s\n",
      "g = 9.81;\t\t\t#gravity consmath.tanty\n",
      "hf = 4*f*L*v**2/D/2/g;\t\t\t#meter\n",
      "\n",
      "# Results\n",
      "print \"Head lost due to friction in meter : %.3f\"%hf\n",
      "\n",
      "#Answer is wrong in the book.\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Head lost due to friction in meter : 201.726\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.8 Page No : 230"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\t\t\n",
      "# Variables :\n",
      "g = 9.81;\t\t\t#gravity consmath.tanty\n",
      "f = 0.02;\t\t\t#coefficient of friction\n",
      "Cc = 0.62;\t\t\t#coefficient of contraction\n",
      "\n",
      "# Calculations\n",
      "#Portion AB\n",
      "Q1 = 50.*10**-3;\t\t\t#m**3/sec\n",
      "D1 = 150./1000;\t\t\t#meter\n",
      "v1 = Q1/(math.pi/4*D1**2);\t\t\t#m/s\n",
      "hr = 0.5*v1**2/2/g;\t\t\t#meter\n",
      "L1 = 200.;\t\t\t#meter\n",
      "hf1 = 4*f*L1*v1**2/2/g/D1;\t\t\t#meter\n",
      "D2 = 200./1000;\t\t\t#meter\n",
      "v2 = Q1/(math.pi/4*D2**2);\t\t\t#m/s\n",
      "hc1 = (v1-v2)**2/2/g;\t\t\t#meter\n",
      "L2 = 500.;\t\t\t#meter\n",
      "hf2 = 4*f*L2*v2**2/2/g/D2;\t\t\t#meter\n",
      "d = 75./1000;\t\t\t#meter\n",
      "ho = ((math.pi/4*D2**2)/Cc/((math.pi/4*D2**2)-(math.pi/4*d**2))-1)**2*v2**2/2/g;\t\t\t#meter\n",
      "D3 = 120./1000;\t\t\t#meter\n",
      "v3 = Q1/(math.pi/4*D3**2);\t\t\t#m/s\n",
      "hc2 = v3**2/2/g*(1/Cc-1)**2;\t\t\t#meter\n",
      "L3 = 500.;\t\t\t#meter\n",
      "hf3 = 4*f*L3*v3**2/2/g/D3;\t\t\t#meter\n",
      "Kb = 0.25;\t\t\t#assumed\n",
      "hb1 = Kb*v3**2/2/g;\t\t\t#meter\n",
      "D4 = 120./1000;\t\t\t#meter\n",
      "v4 = Q1/(math.pi/4*D4**2);\t\t\t#m/s\n",
      "L4 = 500.;\t\t\t#meter\n",
      "hf4 = 4*f*L4*v4**2/2/g/D4;\t\t\t#meter\n",
      "hb2 = Kb*v3**2/2/g;\t\t\t#meter\n",
      "L5 = 500.;\t\t\t#meter\n",
      "hf5 = 4*f*L5*v4**2/2/g/D4;\t\t\t#meter\n",
      "h_outlet = v3**2/2/g;\t\t\t#meter\n",
      "h_total = hr+hf1+hc1+hf2+ho+hc2+hf3+hb1+hf4+hb2+hf5+h_outlet;\t\t\t#meter\n",
      "\n",
      "# Results\n",
      "print \"Total loss of head in meter : %.f\"%h_total\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Total loss of head in meter : 1068\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.9 Page No : 233"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\t\t\n",
      "# Variables :\n",
      "g = 9.81;\t\t\t#gravity consmath.tanty\n",
      "Cc = 0.62;\t\t\t#coefficient of contraction\n",
      "D1 = 150./1000;\t\t\t#meter\n",
      "D2 = 100./1000;\t\t\t#meter\n",
      "Q = 2.7/60;\t\t\t#m**3/sec\n",
      "p1 = 0.8*10**4;\t\t\t#kg/m**2\n",
      "\n",
      "# Calculations\n",
      "v1 = Q/(math.pi/4*D1**2);\t\t\t#m/s\n",
      "v2 = Q/(math.pi/4*D2**2);\t\t\t#m/s\n",
      "hc = v2**2/2/g*(1/Cc-1)**2;\t\t\t#meter\n",
      "w = 1000;\t\t\t#kg/m**3\n",
      "p2 = (v1**2/2/g+p1/w-v2**2/2/g-hc)*w;\t\t\t#kg/m**2(Z1 = Z2)\n",
      "p2 = p2*10**-4;\t\t\t#kg/cm**2\n",
      "\n",
      "# Results\n",
      "print \"Intensity of pressure in kg/cm**2 : %.4f\"%p2\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Intensity of pressure in kg/cm**2 : 0.6029\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.10 Page No : 238"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\t\t\n",
      "# Variables :\n",
      "g = 9.81;\t\t\t#gravity consmath.tanty\n",
      "L = 3.*1000;\t\t\t#meter\n",
      "hf = 20.;\t\t\t#meter\n",
      "Q = 1.;\t\t\t#m**3/sec\n",
      "f = 0.02;\t\t\t#coeff. of friction\n",
      "\n",
      "# Calculations\n",
      "#v = math.sqrt(hf*2*g/4/f/L/D);\t\t\t#it is v**2*D\n",
      "D2v = Q/(math.pi/4);\t\t\t#it is D**2*v\n",
      "D = (Q/(math.pi/4)/math.sqrt(hf*2*g/4/f/L))**(2./5);\t\t\t#meter\n",
      "D = D*1000;\t\t\t#mm\n",
      "\n",
      "# Results\n",
      "print \"Diameter of pipe in mm   : %.f\"%D\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Diameter of pipe in mm   : 998\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.11 Page No : 238"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "# Variables :\n",
      "g = 9.81;\t\t\t#gravity consmath.tanty\n",
      "D1 = 100./1000;\t\t\t#meter\n",
      "D2 = 200./1000;\t\t\t#meter\n",
      "PQ = 100.;\t\t\t#meter\n",
      "QR = 100.;\t\t\t#meter\n",
      "slope = 1./100;\t\t\t#upward slope\n",
      "Q = 0.02;\t\t\t#cumec\n",
      "p1 = 2.;\t\t\t#kg/cm**2(Pressure in 100 mm dia pipe)\n",
      "f = 0.02;\t\t\t#unitless\n",
      "Q_P = 100./100;\t\t\t#meter(Point Q hight respect to point P)\n",
      "Q_R = 200./100;\t\t\t#meter(Point Q hight respect to point R)\n",
      "\n",
      "# Calculations and Results\n",
      "v1 = Q/(math.pi/4*D1**2);\t\t\t#m/sec\n",
      "v2 = Q/(math.pi/4*D2**2);\t\t\t#m/sec\n",
      "hf1 = 4*f*PQ*v1**2/(2*g*D1);\t\t\t#meter\n",
      "hf2 = 4*f*QR*v2**2/(2*g*D2);\t\t\t#meter\n",
      "hse = (v1-v2)**2/2/g;\t\t\t#meter(loss due to sudden enlargement)\n",
      "#Section PQ\n",
      "Z1P = 0;\t\t\t#meter(Datum Head)\n",
      "H1P = v1**2/2/g;\t\t\t#meter(velocity Head)\n",
      "p1BYw = p1*10**4/1000;\t\t\t#meter(Pressure Head at P)\n",
      "Z1Q = 1;\t\t\t#meter(Datum Head)\n",
      "H1Q = v2**2/2/g;\t\t\t#meter(velocity Head)\n",
      "#Applying bernaullis theorem\n",
      "p2BYw = Z1P+p1BYw+H1P-Z1Q-H1Q-hf1;\t\t\t#meter(Pressure Head at Q)\n",
      "\n",
      "print \"Pressure Head at point P(m)\",p1BYw\n",
      "print \"Velocity Head at point P(m) %.3f\"%H1P\n",
      "print \"Pressure Head at point Q(m) : %.3f\"%p2BYw\n",
      "\n",
      "#Section QR\n",
      "#Applying bernaullis theorem\n",
      "p2dashBYw = p2BYw+H1P-H1Q-hse;\t\t\t#meter(Pressure Head at Q)\n",
      "Z2 = 1;\t\t\t#meter(Datum Head)\n",
      "H1Q = v2**2/2/g;\t\t\t#meter(velocity Head)\n",
      "Z3 = 2;\t\t\t#meter(Datum Head at R)\n",
      "H1R = v2**2/2/g;\t\t\t#meter(velocity Head at R)\n",
      "\n",
      "#Applying bernaullis theorem\n",
      "p3BYw = Z2+p2dashBYw+H1Q-Z3-H1R-hf2;\t\t\t#meter(Pressure Head at R)\n",
      "print \"Velocity Head at point Q after enlargemant(m) : %.2f\"%H1Q\n",
      "print \"Pressure Head at point Q after enlargemant(m) : %.3f\"%p2dashBYw\n",
      "print \"Pressure Head at point R(m) : %.3f\"%p3BYw\n",
      "print \"Velocity Head at point R(m) : %.3f\"%H1R\n",
      "\n",
      "\n",
      "#Answer in the book is wrong for some calculations.\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Pressure Head at point P(m) 20.0\n",
        "Velocity Head at point P(m) 0.331\n",
        "Pressure Head at point Q(m) : -7.131\n",
        "Velocity Head at point Q after enlargemant(m) : 0.02\n",
        "Pressure Head at point Q after enlargemant(m) : -7.007\n",
        "Pressure Head at point R(m) : -8.833\n",
        "Velocity Head at point R(m) : 0.021\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.12 Page No : 246"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\t\t\n",
      "# Variables :\n",
      "g = 9.81;\t\t\t#gravity consmath.tanty\n",
      "D1 = 400./1000;\t\t\t#meter\n",
      "D2 = 300./1000;\t\t\t#meter\n",
      "D3 = 200./1000;\t\t\t#meter\n",
      "v1 = 3;\t\t\t#m/s\n",
      "v2 = 2;\t\t\t#m/s\n",
      "\n",
      "# Calculations and Results\n",
      "A1 = math.pi/4*D1**2;\t\t\t#m**2\n",
      "A2 = math.pi/4*D2**2;\t\t\t#m**2\n",
      "A3 = math.pi/4*D3**2;\t\t\t#m**2\n",
      "Q1 = A1*v1;\t\t\t#cumec\n",
      "print \"Discharge in pipe 1 in cumec : %.4f\"%Q1\n",
      "\n",
      "Q2 = A2*v2;\t\t\t#cumec\n",
      "Q3 = Q1-Q2;\t\t\t#cumec\n",
      "v3 = Q3/A3;\t\t\t#m/s\n",
      "print \"Velocity of water in 200mm pipe in m/s : \",v3\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Discharge in pipe 1 in cumec : 0.3770\n",
        "Velocity of water in 200mm pipe in m/s :  7.5\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.13 Page No :  247"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\t\t\n",
      "# Variables :\n",
      "g = 9.81;\t\t\t#gravity consmath.tanty\n",
      "D1 = 100./1000;\t\t\t#meter\n",
      "D2 = 300./1000;\t\t\t#meter\n",
      "\n",
      "# Calculations\n",
      "Q1 = 0.01;\t\t\t#m**3/sec\n",
      "A1 = math.pi/4*D1**2;\t\t\t#m**2\n",
      "A2 = math.pi/4*D2**2;\t\t\t#m**2\n",
      "\t\t\t#hf1 = hf2\n",
      "Q2 = math.sqrt(D2/(D1)*(Q1/A1)**2*A2**2);\t\t\t#cumec\n",
      "\n",
      "# Results\n",
      "print \"Discharge throough 300mm pipe in cumec : %.3f\"%Q2\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Discharge throough 300mm pipe in cumec : 0.156\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.14 Page No : 248"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\t\t\n",
      "# Variables :\n",
      "g = 9.81;\t\t\t#gravity consmath.tanty\n",
      "f = 0.02;\t\t\t#coeff. of friction\n",
      "PQ = 500.;\t\t\t#meter\n",
      "QR = 1000.;\t\t\t#meter\n",
      "RS = 500.;\t\t\t#meter\n",
      "\n",
      "# Calculations\n",
      "hf = 10+PQ/62.5+QR/125-RS/100-2;\t\t\t#meter\n",
      "l = 500+1000+500;\t\t\t#/meter\n",
      "D = 250./1000;\t\t\t#meter\n",
      "v = math.sqrt(hf*2*g*D/4/f/l);\t\t\t#m/s\n",
      "Q = math.pi/4*D**2*v;\t\t\t#m**3/sec\n",
      "Q = Q*1000;\t\t\t#litres/sec\n",
      "\n",
      "# Results\n",
      "print \"Discharge in pipe line in litres/sec : %.f\"%Q\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Discharge in pipe line in litres/sec : 37\n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.15 Page No : 249"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\n",
      "# Variables :\n",
      "g = 9.81;\t\t\t#gravity consmath.tant\n",
      "slope = 1./125;\t\t\t#slope\n",
      "hA = 12.;\t\t\t#meter(level of water in reservoir A)\n",
      "hB = 1.5;\t\t\t#meter(level of water in reservoir B)\n",
      "L1 = 500.;\t\t\t#meter\n",
      "D1 = 250./1000;\t\t\t#meter\n",
      "L2 = 1000.;\t\t\t#meter\n",
      "D2 = 200./1000;\t\t\t#meter\n",
      "L3 = 500.;\t\t\t#meter\n",
      "D3 = 150./1000;\t\t\t#meter\n",
      "\n",
      "# Calculations\n",
      "f = 0.02;\t\t\t#coeff. of friction\n",
      "fall_level = (L1+L2+L3)*slope;\t\t\t#meter\n",
      "H = hA+fall_level-hB;\t\t\t#meter(Head available for flow)\n",
      "v2BYv1 = (D1/D2)**2;\n",
      "v3BYv1 = (D1/D3)**2;\n",
      "#H = hf = hf1+hf2+hf3\n",
      "#H = (4*f*L1*v1**2/(2*g*D1)+4*f*L2*v2**2/(2*g*D2)+4*f*L3*v3**2/(2*g*D3))\n",
      "v1 = math.sqrt(H/(4*f*L1/(2*g*D1)+4*f*L2*v2BYv1**2/(2*g*D2)+4*f*L3*v3BYv1**2/(2*g*D3)));\t\t\t#m/s\n",
      "Q = math.pi*D1**2/4*v1;\t\t\t#m**3/sec\n",
      "Q = Q*1000;\t\t\t#litres/sec\n",
      "\n",
      "# Results\n",
      "print \"Discharge in pipe line in litres/sec : %.1f\"%Q\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Discharge in pipe line in litres/sec : 19.8\n"
       ]
      }
     ],
     "prompt_number": 15
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.16 Page No : 250"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\t\t\n",
      "# Variables :\n",
      "g = 9.81;\t\t\t#gravity consmath.tant\n",
      "l = 4.;\t\t\t#km\n",
      "n = 5000.;\t\t\t#habimath.tants\n",
      "Ch = 200.;\t\t\t#litres/day(habimath.tant capacity)\n",
      "t = 10.;\t\t\t#hour(daiy supply time)\n",
      "hf = 20.;\t\t\t#meter(Head loss)\n",
      "f = 0.008;\t\t\t#coeff. of friction\n",
      "\n",
      "# Calculations\n",
      "Qty = n*Ch/2;\t\t\t#litres(Water supplied in 10 hours)\n",
      "Q = Qty/(t*60*60);\t\t\t#litres/sec\n",
      "Q = Q/1000;\t\t\t#m**3/sec\n",
      "d = (f*l*1000*Q**2/3.0257/hf)**(1./5);\t\t\t#meter\n",
      "\n",
      "# Results\n",
      "print \"Diameter of pipe(mm) : %.f\"%(d*1000)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Diameter of pipe(mm) : 159\n"
       ]
      }
     ],
     "prompt_number": 16
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.17 Page No : 251"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\t\t\n",
      "# Variables :\n",
      "g = 9.81;\t\t\t#gravity consmath.tant\n",
      "D1 = 50./1000;\t\t\t#meter\n",
      "D2 = 100./1000;\t\t\t#meter\n",
      "l1 = 100.\n",
      "l2 = 100.;\t\t\t#meter\n",
      "hf1 = 10.;\t\t\t#meter(level difference)\n",
      "f = 0.008;\t\t\t#coeff. of friction\n",
      "\n",
      "# Calculations and Results\n",
      "Q2BYQ1 = math.sqrt((l1/l2)*(D2/D1)**5);\t\t\t#as hf1 = hf2\n",
      "Q1 = math.sqrt(hf1/f/l1*(3.0257*D1**5));\t\t\t#m**3/sec\n",
      "Q2 = Q2BYQ1*Q1;\t\t\t#m**3/sec or cumec\n",
      "print \"Rate of flow of pipe 1(m**3/sec) : %.2e\"%Q1\n",
      "print \"Rate of flow of pipe 2(m**3/sec) : %.3f\"%Q2\n",
      "\n",
      "Q = Q1+Q2;\t\t\t#m**3/sec(Total Discharge)\n",
      "d = (f*l1*Q**2/3.0257/hf1)**(1./5);\t\t\t#meter\n",
      "print \"Diameter of math.single pipe(mm) : %.1f\"%(d*1000)\n",
      "\n",
      "\n",
      "#Answer in the book is not accurate.\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Rate of flow of pipe 1(m**3/sec) : 3.44e-03\n",
        "Rate of flow of pipe 2(m**3/sec) : 0.019\n",
        "Diameter of math.single pipe(mm) : 106.7\n"
       ]
      }
     ],
     "prompt_number": 17
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.18 Page No : 252"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\t\t\n",
      "# Variables :\n",
      "g = 9.81;\t\t\t#gravity consmath.tant\n",
      "D = 30./100;\t\t\t#meter\n",
      "l = 400.;\t\t\t#meter\n",
      "Q = 300.;\t\t\t#litres/sec\n",
      "f = 0.008;\t\t\t#coeff. of friction\n",
      "Q = Q*10**-3;\t\t\t#m**3/sec\n",
      "\n",
      "# Calculations\n",
      "A = math.pi*D**2/4;\t\t\t#m**2\n",
      "v = Q/A;\t\t\t#m/s(velocity of flow)\n",
      "h1 = 0.5*v**2/2/g;\t\t\t#meter(Head loss at entrance to a pipe)\n",
      "h2 = 4*f*l*v**2/(2*g*D);\t\t\t#meter(Head loss due to friction)\n",
      "h3 = v**2/2/g;\t\t\t#meter(Head loss at entrance of reservoir)\n",
      "H = h1+h2+h3;\t\t\t#meter(Difference of water level)\n",
      "\n",
      "# Results\n",
      "print \"Difference of water level between two reservoir(meter) : %.3f\"%H\n",
      "\n",
      "#Answer in the book is not accurate as h2 is calculated wrong.\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Difference of water level between two reservoir(meter) : 40.548\n"
       ]
      }
     ],
     "prompt_number": 18
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.19 Page No : 254"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\t\t\n",
      "# Variables :\n",
      "g = 9.81;\t\t\t#gravity consmath.tant\n",
      "D = 150./1000;\t\t\t#meter\n",
      "l = 70.;\t\t\t#meter\n",
      "H = 2.6;\t\t\t#meter(head of water)\n",
      "f = 0.01;\t\t\t#coeff. of friction\n",
      "\n",
      "# Calculations\n",
      "#Applyong Bernoullis theorem\n",
      "v = math.sqrt(H*(2/g*(1+0.5+4*f*l/D))/4);\t\t\t#m/s\n",
      "Q = math.pi*D**2/4*v;\t\t\t#m**3/sec\n",
      "Q = Q*1000;\t\t\t#litres/sec\n",
      "\n",
      "# Results\n",
      "print \"Discharge through the pipe(litres/sec) : %.1f\"%Q\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Discharge through the pipe(litres/sec) : 28.9\n"
       ]
      }
     ],
     "prompt_number": 19
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.20 Page No : 255"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\t\t\n",
      "# Variables :\n",
      "g = 9.81;\t\t\t#gravity consmath.tant\n",
      "Cv = 0.97;\t\t\t#coeffiecient of velocity\n",
      "Cc = 0.95;\t\t\t#coeffiecient\n",
      "Dn = 50./1000;\t\t\t#meter(Nozzle diameter)\n",
      "D = 100./1000;\t\t\t#meter(Pipe diameter)\n",
      "p = 6.867;\t\t\t#N/cm**2(Pressure at the base of nozzle)\n",
      "\n",
      "# Calculations and Results\n",
      "Hb = p*10**4/(g*1000)\t\t\t#meter(Head at the base of nozzle)\n",
      "v = Cv*math.sqrt(2*g*Hb);\t\t\t#m/s(velocty of jet)\n",
      "print \"Velocity in the jet(m/s) : %.2f\"%v\n",
      "A = math.pi/4*Dn**2;\t\t\t#m**2(Cross sction of jet)\n",
      "Q = Cc*A*v;\t\t\t#m**3/sec(Discharge)\n",
      "Q = Q*1000;\t\t\t#litres/sec\n",
      "print \"Rate of discharge(litres/second) : %.2f\"%Q\n",
      "E = g*1000*Q/1000*Hb/1000;\t\t\t#kW(Energy transmitted)\n",
      "print \"Energy per second n the jet(kW) : %.2f\"%E\n",
      "\n",
      "#Answer in the book is not accurate.\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Velocity in the jet(m/s) : 11.37\n",
        "Rate of discharge(litres/second) : 21.20\n",
        "Energy per second n the jet(kW) : 1.46\n"
       ]
      }
     ],
     "prompt_number": 20
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.21 Page No : 258"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\t\t\n",
      "# Variables :\n",
      "g = 9.81;\t\t\t#gravity consmath.tant\n",
      "D = 100./1000;\t\t\t#meter(Pipe diameter)\n",
      "L = 700.;\t\t\t#meter(Total length)\n",
      "Lin = 300.;\t\t\t#meter(inlet length)\n",
      "hf = 10.;\t\t\t#meter(Available head)\n",
      "h = 1.4;\t\t\t#meter(height)\n",
      "f = 0.02;\t\t\t#coefficient of friction\n",
      "\n",
      "# Calculations and Results\n",
      "v = math.sqrt(hf*2*g*D/4/f/L);\t\t\t#m/s\n",
      "Q = math.pi*D**2/4*v*1000;\t\t\t#litres/sec\n",
      "print \"Discharge in pipe(litres/second) : %.2f\"%Q\n",
      "\n",
      "#Applying Brnaullis theorem\n",
      "p1 = 0\n",
      "v1 = 0\n",
      "Z1 = 0;\t\t\t#(Neglecting minor losses)\n",
      "v2 = v;\t\t\t#m/s\n",
      "Z2 = h;\t\t\t#meter\n",
      "hf = 4*f*Lin*v**2/(2*g*D);\t\t\t#meter\n",
      "p2BYw = -v2**2/2/g-Z2-hf;\t\t\t#meter of water\n",
      "hatm = 10.3;\t\t\t#meter(Atmospheric pressure head)\n",
      "habs = p2BYw+hatm;\t\t\t#meter(Absolute pressure head)\n",
      "print \"Pressure at the summit of siphon(meter) : %.3f\"%habs\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Discharge in pipe(litres/second) : 4.65\n",
        "Pressure at the summit of siphon(meter) : 4.596\n"
       ]
      }
     ],
     "prompt_number": 22
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.22 Page No : 263"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\t\t\n",
      "# Variables :\n",
      "g = 9.81;\t\t\t#gravity consmath.tant\n",
      "D = 150./1000;\t\t\t#meter(Pipe diameter)\n",
      "Q = 40.;\t\t\t#litres/sec(rate of discharge)\n",
      "l = 500.;\t\t\t#meter(valve dismath.tance)\n",
      "T = 0.5;\t\t\t#second\n",
      "\n",
      "# Calculations\n",
      "v = Q/1000/(math.pi/4*D**2);\t\t\t#m/s(velocity of flow)\n",
      "pi = 1000/g*(l*v/T);\t\t\t#kg/m**2\n",
      "\n",
      "# Results\n",
      "print \"Increase in pressure intensity(kg/m**2) : %.3e\"%pi\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Increase in pressure intensity(kg/m**2) : 2.307e+05\n"
       ]
      }
     ],
     "prompt_number": 24
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.23 Page No : 266"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\t\t\n",
      "# Variables :\n",
      "g = 9.81;\t\t\t#gravity consmath.tant\n",
      "l = 10000.;\t\t\t#meter(length of pipe line)\n",
      "D = 0.2;\t\t\t#meter(Diameter of pipe)\n",
      "p = 60.*10**5;\t\t\t#N/m**2\n",
      "f = 0.007;\t\t\t#coefficient of friction\n",
      "w = g*1000.;\t\t\t#N/m**3\n",
      "\n",
      "# Calculations\n",
      "H = p/w;\t\t\t#meter\n",
      "hf = H/3;\t\t\t#meter(friction head loss is 1/3rd)\n",
      "v = math.sqrt(hf*2*g*D/4/f/l);\t\t\t#m/s\n",
      "P = w*math.pi*D**2/4*v*(H-hf)/1000;\t\t\t#kW\n",
      "\n",
      "# Results\n",
      "print \"Maximum power(kW) : %.3f\"%P\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Maximum power(kW) : 212.410\n"
       ]
      }
     ],
     "prompt_number": 25
    }
   ],
   "metadata": {}
  }
 ]
}