{
 "metadata": {
  "name": "",
  "signature": "sha256:53c88693c5ad5193ad81179b96376eeb7bad9150fdb2bbf705d611fc5268083f"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter7-Flow and Losses in Pipes and Fittings"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex1-pg255"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#calculate Head lost to friction\n",
      "Q=50*10**-3; ## m^3/s\n",
      "d=0.15; ## m\n",
      "l=300.; ## m\n",
      "v=1.14*10**-6; ## m^2/s\n",
      "g=9.81; ## m/s^2\n",
      "\n",
      "## For galvanised steel\n",
      "k=0.00015; ## m\n",
      "t=0.001; ## ratio of k to d ; (k/d)\n",
      "f=0.00515;\n",
      "\n",
      "A1=math.pi/4.*d**2;\n",
      "\n",
      "u=Q/A1; \n",
      "Re=u*d/v;\n",
      "\n",
      "h_f=4*f*l*u**2/d/(2*g);\n",
      "print'%s %.3f %s'%(\"Head lost to friction =\",h_f,\"m\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Head lost to friction = 16.811 m\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex2-pg255"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\t\t\t\n",
      "#calculate rate of discharge\n",
      "k=0.00025; ## m\n",
      "d=0.1; ## m\n",
      "l=120.; ## m\n",
      "h_f=5.; ## m\n",
      "g=9.81; ## m/s^2\n",
      "v=10**-5; ## m^2/s\n",
      "\n",
      "f=0.0079042;\n",
      "\n",
      "u=math.sqrt(h_f*d*(2.*g)/(4.*f*l));\n",
      "Re=u*d/v;\n",
      "\n",
      "Q=u*math.pi/4*d**2;\n",
      "print'%s %.4f %s'%(\"Rate =\",Q,\"m^3/s\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Rate = 0.0126 m^3/s\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex3-pg256"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#calculate The size of galvanized steel pipe \n",
      "h_f=9.; ## m\n",
      "l=180.; ## m\n",
      "Q=85.*10**-3; ## m^3/s\n",
      "f=0.00475; \n",
      "k=0.00015; ## m\n",
      "v=1.14*10**-6; ## m^2/s\n",
      "g=9.81; ## m/s^2\n",
      "\n",
      "d=(4.*f*l*Q**2./h_f/(math.pi/4.)**2/(2.*g))**(1/5.);\n",
      "Re=(Q/(math.pi*d**2/4))*d/v;\n",
      "\n",
      "print'%s %.3f %s'%(\"The size of galvanized steel pipe =\",d,\"m \")"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The size of galvanized steel pipe = 0.187 m \n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex4-pg275"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#calculate Revised estimate of the optimum pipe diameter\n",
      "## D1=(5*b1/3/a)^(1/8)\n",
      "## D2=(5*b1/3/a)^(1/8)\n",
      "\n",
      "## But b2=2.5*b1\n",
      "## Therefore D2=(2.5)^(1/8)*D1\n",
      "\n",
      "D1=600.; ## mm\n",
      "\n",
      "D2=(2.5)**(1/8.)*D1;\n",
      "\n",
      "print'%s %.1f %s'%(\"Revised estimate of the optimum pipe diameter =\",D2,\"mm\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Revised estimate of the optimum pipe diameter = 672.8 mm\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex5-pg282"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#calculate Pressure difference  and Feed is at the centre of the main and Pressure difference \n",
      "Q0=4.5*10**-3; ## m**3/s\n",
      "d=0.1; ## m\n",
      "l=4.5*10**3; ## m\n",
      "g=9.81; ## m/s**2\n",
      "f=0.006; \n",
      "rho=1000.; ## kg/m**3\n",
      "\n",
      "u0=Q0/(math.pi/4.*d**2);\n",
      "h_f=4.*f*u0**2*l/3./(d*2*g);\n",
      "\n",
      "dp=h_f*rho*g;\n",
      "print'%s %.1f %s'%(\"Pressure difference =\",dp,\"N/m**2\")\n",
      "\n",
      "\n",
      "print(\"Feed is at the centre of the main\")\n",
      "\n",
      "Q0_b=Q0/2.;\n",
      "u0_b=u0/2.;\n",
      "l_b=l/2.;\n",
      "\n",
      "dp_b=(u0_b/u0)**2*(l_b/l)*dp;\n",
      "print'%s %.1f %s'%(\"Pressure difference =\",dp_b,\"N/m**2\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Pressure difference = 59090.5 N/m**2\n",
        "Feed is at the centre of the main\n",
        "Pressure difference = 7386.3 N/m**2\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex6-pg286"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#calculate The change in the level in larger tank \n",
      "d1=3.; ## m\n",
      "d2=2.; ## m\n",
      "f=0.007;\n",
      "l=75.; ## m\n",
      "d=0.05; ## m\n",
      "g=9.81; ## m/s**2\n",
      "h1=1.8; ## m\n",
      "\n",
      "A1=math.pi/4.*d1**2;\n",
      "A2=math.pi/4.*d2**2;\n",
      "\n",
      "## dh/dt=dz1/dr*(1+A1/A2)\n",
      "## Q=-A1*dz1/dt = -4/13*A1*dh/dt\n",
      "\n",
      "## u=(Q/2)**2/(%pi/4*d**2)\n",
      "## h=(4*f*l/d + 1.5)*u**2/2g = 1.438*10**5*Q**2\n",
      "\n",
      "## t=integrate('-1/(1+A1/A2)*A1*(1.438*10**5/h)**(1/2)','h',h1,H)\n",
      "\n",
      "## By integrating, we get\n",
      "H=(h1**(1/2.)-(900./2./824.7))**2;\n",
      "h=h1-H;\n",
      "dz1=1./(1+A1/A2)*h;\n",
      "\n",
      "print'%s %.3f %s'%(\"The change in the level in larger tank =\",dz1,\"m\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The change in the level in larger tank = 0.359 m\n"
       ]
      }
     ],
     "prompt_number": 7
    }
   ],
   "metadata": {}
  }
 ]
}