{
 "metadata": {
  "name": "",
  "signature": "sha256:a67e8661ab863efba6ffe8486e33132e755624949690c50df8ae76d2d928ed8b"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 7 - Flow of incompressible fluids in closed conduits"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1a - Pg 241"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the reynolds number of the flow\n",
      "#Initialization of variables\n",
      "import math\n",
      "z1=2. #ft\n",
      "Q=0.1 #gal/min\n",
      "alpha=2.\n",
      "g=32.2 #ft/s^2\n",
      "L=4. #ft\n",
      "D=1./96. #ft\n",
      "#calculations\n",
      "v2=Q/(7.48*60* math.pi/4. *D*D)\n",
      "hl=z1-alpha*v2*v2 /(2*g)\n",
      "Nr=64./hl *L/D *v2*v2 /(2*g)\n",
      "#results\n",
      "print '%s %d %s' %(\"Reynolds number is\",Nr,\".Hence the flow is laminar\")\n",
      "print '%s' %(\"The answers are a bit different from textbook due to rounding off error\")"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Reynolds number is 1459 .Hence the flow is laminar\n",
        "The answers are a bit different from textbook due to rounding off error\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1b - Pg 242"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the kinematic viscosity\n",
      "#Initialization of variables\n",
      "import math\n",
      "z1=2 #ft\n",
      "Q=0.1 #gal/min\n",
      "alpha=2.\n",
      "g=32.2 #ft/s^2\n",
      "L=4. #ft\n",
      "D=1./96. #ft\n",
      "#calculations\n",
      "v2=Q/(7.48*60* math.pi/4. *D*D)\n",
      "hl=z1-alpha*v2*v2/(2*g)\n",
      "Nr=64./hl *L/D *v2*v2 /(2*g)\n",
      "mu=v2*D/Nr\n",
      "#results\n",
      "print '%s %.2e %s' %(\"Kinematic viscosity =\",mu,\"ft^2/s\")\n",
      "print '%s' %(\"The answers are a bit different from textbook due to rounding off error\")"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Kinematic viscosity = 1.87e-05 ft^2/s\n",
        "The answers are a bit different from textbook due to rounding off error\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Exaple 1c - Pg 242"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the theoretical entrance transistion length\n",
      "#Initialization of variables\n",
      "import math\n",
      "z1=2. #ft\n",
      "Q=0.1 #gal/min\n",
      "alpha=2.\n",
      "g=32.2 #ft/s^2\n",
      "L=4. #ft\n",
      "D=1./96. #ft\n",
      "#calculations\n",
      "v2=Q/(7.48*60* math.pi/4. *D*D)\n",
      "hl=z1-alpha*v2*v2 /(2*g)\n",
      "Nr=64./hl *L/D *v2*v2 /(2*g)\n",
      "Ld=0.058*Nr*D\n",
      "#results\n",
      "print '%s %.3f %s' %(\"Theoretical entrance transistion length =\",Ld,\"ft\")\n",
      "print '%s' %(\"The answers are a bit different from textbook due to rounding off error\")"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Theoretical entrance transistion length = 0.882 ft\n",
        "The answers are a bit different from textbook due to rounding off error\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2 - Pg 246"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the horsepower required for the motor\n",
      "#Initialization of variables\n",
      "import math\n",
      "Q=350. #gal/min\n",
      "D=6. #in\n",
      "rho=0.84\n",
      "gam=62.4\n",
      "g=32.2 #ft/s^2\n",
      "mu=9.2e-5 #lb-sec/ft^2\n",
      "L=5280. #ft\n",
      "#calculations\n",
      "V=Q/(7.48*60*math.pi/4. *math.pow((D/12),2))\n",
      "Nr=V*D/12 *rho*gam/g /mu\n",
      "f=0.3164/math.pow((Nr),0.25)\n",
      "hl=f*L*12/D *V*V /(2*g)\n",
      "hp=hl*gam*Q*rho/(550*7.48*60.)\n",
      "#results\n",
      "print '%s %.2f %s' %(\"Horsepower required =\",hp,\"hp/mile\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Horsepower required = 4.44 hp/mile\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3 - Pg 250"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the values of the coefficients alpha and beta\n",
      "#Initialization of variables\n",
      "n=7.\n",
      "import math\n",
      "#calculations\n",
      "alpha= math.pow((n+1),3) *math.pow((2*n+1),3) /(4*math.pow(n,4) *(n+3)*(2*n+3))\n",
      "bet=math.pow((n+1),2) *math.pow((2*n+1),2) /(2*n*n *(n+2)*(2*n+2))\n",
      "#results\n",
      "print '%s %.2f' %(\"alpha = \",alpha)\n",
      "print '%s %.2f' %(\"\\n beta = \",bet)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "alpha =  1.06\n",
        "\n",
        " beta =  1.02\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5 - Pg 252"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the mass flow rate and horsepower input of the fan\n",
      "#Initialization of variables\n",
      "import math\n",
      "spg=0.84\n",
      "z=1. #in\n",
      "gam=62.4\n",
      "patm=14.7 #psia\n",
      "T=459.6+85 #R\n",
      "R=53.3\n",
      "g=32.2 #ft/s^2\n",
      "D=3. #ft\n",
      "mu=3.88e-7 #lb-sec/ft^2\n",
      "#calculations\n",
      "dp=spg*z/12. *gam\n",
      "rho=patm*144. /(R*T*g)\n",
      "umax=math.sqrt(2*dp/rho)\n",
      "V=0.8*umax\n",
      "Nr=V*D*rho/mu\n",
      "V2=0.875*umax\n",
      "mass=rho*math.pi/4. *D*D *V2\n",
      "emf=V2*V2 /(2*g)\n",
      "hp=emf*mass*g/550.\n",
      "#results\n",
      "print '%s %.2f %s' %(\"Mass flow rate =\",mass,\"slug/sec\")\n",
      "print '%s %.2f %s' %(\"\\n Horsepower input of the fan =\",hp,\"hp\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Mass flow rate = 0.87 slug/sec\n",
        "\n",
        " Horsepower input of the fan = 2.34 hp\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7a - Pg 266"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the velocity using several equations listed above\n",
      "#Initialization of variables\n",
      "import math\n",
      "D=36. #in\n",
      "rho=0.00226  #slug/ft^3\n",
      "mu=3.88e-7 #lb-sec/ft^2\n",
      "umax=62.2 #ft/s\n",
      "V=54.5 #ft/s\n",
      "Nr=9.5e5\n",
      "r0=18. #in\n",
      "r=12. #in\n",
      "n=8.8\n",
      "k=0.4\n",
      "#calculations\n",
      "f=0.0032 + 0.221/(math.pow(Nr,0.237))\n",
      "Vs=math.sqrt(f/8) *V\n",
      "y=r0-r\n",
      "u1=umax*math.pow((y/r0),(1/n))\n",
      "u2=umax+ 2.5*Vs*math.log(y/r0)\n",
      "u3=umax+ Vs/k *(math.sqrt(1-y/r0) + math.log(1-math.sqrt(1-y/r0)))\n",
      "u4=Vs*(5.5+ 5.75*math.log10(Vs*y/12 *rho/mu))\n",
      "#results\n",
      "print '%s %.1f %s' %(\"Using equation 7-13, velocity =\",u1,\" ft/s\")\n",
      "print '%s %.1f %s' %(\"\\n Using equation 7-18, velocity =\",u2,\" ft/s\")\n",
      "print '%s %.1f %s' %(\"\\n Using equation 7-25, velocity =\",u3,\" ft/s\")\n",
      "print '%s %.1f %s' %(\"\\n Using equation 7-34a, velocity =\",u4,\" ft/s\")"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Using equation 7-13, velocity = 54.9  ft/s\n",
        "\n",
        " Using equation 7-18, velocity = 56.5  ft/s\n",
        "\n",
        " Using equation 7-25, velocity = 57.6  ft/s\n",
        "\n",
        " Using equation 7-34a, velocity = 56.7  ft/s\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7b - Pg 266"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the outer edge buffer zone distance and also its thickness\n",
      "#Initialization of variables\n",
      "import math\n",
      "D=36. #in\n",
      "rho=0.00226  #slug/ft^3\n",
      "mu=3.88e-7 #lb-sec/ft^2\n",
      "umax=62.2 #ft/s\n",
      "V=54.5 #ft/s\n",
      "Nr=9.5e5\n",
      "r0=18. #in\n",
      "r=12. #in\n",
      "n=8.8\n",
      "k=0.4\n",
      "#calculations\n",
      "f=0.0032 + 0.221/(math.pow(Nr,0.237))\n",
      "Vs=math.sqrt(f/8.) *V\n",
      "y=r0-r\n",
      "delta1=D*5*math.sqrt(8) /(Nr*math.sqrt(f))\n",
      "vss=70.\n",
      "thick=13*delta1\n",
      "#results\n",
      "print '%s %d' %(\"Outer edge of buffer zone is at \",vss)\n",
      "print '%s %.4f %s' %(\"\\n Thickness of buffer zone =\",thick,\"in\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Outer edge of buffer zone is at  70\n",
        "\n",
        " Thickness of buffer zone = 0.0645 in\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7c - Pg 266"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the velocity using the given equations\n",
      "#Initialization of variables\n",
      "import math\n",
      "D=36. #in\n",
      "rho=0.00226  #slug/ft^3\n",
      "mu=3.88e-7 #lb-sec/ft^2\n",
      "umax=62.2 #ft/s\n",
      "V=54.5 #ft/s\n",
      "Nr=9.5e5\n",
      "r0=18. #in\n",
      "r=12. #in\n",
      "n=8.8\n",
      "k=0.4\n",
      "#calculations\n",
      "f=0.0032 + 0.221/(math.pow(Nr,0.237))\n",
      "Vs=math.sqrt(f/8) *V\n",
      "delta1=D*5*math.sqrt(8.) /(Nr*math.sqrt(f))\n",
      "y=delta1\n",
      "u2=Vs*Vs *delta1/12. *rho/mu\n",
      "u1=62.2 *math.pow((delta1/18.),(1/n))\n",
      "#results\n",
      "print '%s %.1f %s' %(\"using equation 7-13, velocity =\",u1,\"ft/s\")\n",
      "print '%s %.1f %s' %(\"\\n using equation 7-30, velocity =\",u2,\"ft/s\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "using equation 7-13, velocity = 24.5 ft/s\n",
        "\n",
        " using equation 7-30, velocity = 10.4 ft/s\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7d - Pg 266"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the velocity using the listed equations\n",
      "#Initialization of variables\n",
      "import math\n",
      "D=36. #in\n",
      "rho=0.00226  #slug/ft^3\n",
      "mu=3.88e-7 #lb-sec/ft^2\n",
      "umax=62.2 #ft/s\n",
      "V=54.5 #ft/s\n",
      "Nr=9.5e5\n",
      "r0=18. #in\n",
      "r=12. #in\n",
      "n=8.8\n",
      "k=0.4\n",
      "#calculations\n",
      "f=0.0032 + 0.221/(math.pow(Nr,0.237))\n",
      "Vs=math.sqrt(f/8.) *V\n",
      "delta1=D*5*math.sqrt(8.) /(Nr*math.sqrt(f))\n",
      "y=14*delta1\n",
      "u2=62.2*math.pow((y/18.),(1/n))\n",
      "u3=Vs*(5.50 + 5.75*math.log10(Vs*y/12 *rho/mu))\n",
      "#results\n",
      "print '%s %.1f %s' %(\"Using equation 7-13, velocity =\",u2,\"ft/s\")\n",
      "print '%s %.1f %s' %(\"\\n using equation 7-34a, velocity =\",u3,\"ft/s\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Using equation 7-13, velocity = 33.1 ft/s\n",
        "\n",
        " using equation 7-34a, velocity = 33.5 ft/s\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7e - Pg 266"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the shearing stress using both the equations\n",
      "#Initialization of variables\n",
      "import math\n",
      "D=36. #in\n",
      "rho=0.00226  #slug/ft^3\n",
      "mu=3.88e-7 #lb-sec/ft^2\n",
      "umax=62.2 #ft/s\n",
      "V=54.5 #ft/s\n",
      "Nr=9.5e+5\n",
      "r0=18. #in\n",
      "r=12. #in\n",
      "n=8.8\n",
      "k=0.4\n",
      "#calculations\n",
      "f=0.0032 + 0.221/(math.pow(Nr,0.237))\n",
      "Vs=math.sqrt(f/8.) *V\n",
      "delta1=D*5*math.sqrt(8.) /(Nr*math.sqrt(f))\n",
      "u2=Vs*Vs *delta1/12. *rho/mu\n",
      "T0=rho*Vs*Vs\n",
      "T02=mu*u2/delta1 *12.\n",
      "#results\n",
      "print '%s %.5f %s' %(\"Using equation 7-9a, shearing stress =\",T0,\"lb/ft^2\")\n",
      "print '%s %.5f %s' %(\"\\n Using equation 7-28, shearing stress =\",T02,\"lb/ft^2\")\n",
      "print '%s' %(\"The answers are a bit different due to rounding off error in textbook\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Using equation 7-9a, shearing stress = 0.00979 lb/ft^2\n",
        "\n",
        " Using equation 7-28, shearing stress = 0.00979 lb/ft^2\n",
        "The answers are a bit different due to rounding off error in textbook\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8 - Pg 273"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the required velocity\n",
      "#Initialization of variables\n",
      "import math\n",
      "umax=62.2 #ft/s\n",
      "r0=18. #in\n",
      "e=0.0696 #in\n",
      "r=6. #in\n",
      "#calculations\n",
      "Vs=umax/(8.5 + 5.75*math.log10(r0/e))\n",
      "u=Vs*(8.5 + 5.75*math.log10(r/e))\n",
      "#results\n",
      "print '%s %.1f %s' %(\"Velocity =\",u,\"ft/s\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Velocity = 54.6 ft/s\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 9 - Pg 277"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the flow rate and roughness factor\n",
      "#Initialization of variables\n",
      "import math\n",
      "d=8. #in\n",
      "V=3.65 #ft/s\n",
      "u1=4.75 #ft/s\n",
      "r0=4. #in\n",
      "#calculations\n",
      "f=0.0449\n",
      "Q=V*math.pi/4. *math.pow((d/12),2)\n",
      "Vs=(u1-V)/3.75\n",
      "r0e=math.pow(10,((u1/Vs - 8.5)/5.75))\n",
      "e=r0/r0e\n",
      "#results\n",
      "print '%s %.2f %s' %(\"Flow rate =\",Q,\"ft^3/s\")\n",
      "print '%s %.3f %s' %(\"\\n roughness factor =\",e,\"in\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Flow rate = 1.27 ft^3/s\n",
        "\n",
        " roughness factor = 0.184 in\n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 10 - Pg 285"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the pressure difference per foot of horizontal pipe\n",
      "#Initialization of variables\n",
      "import math\n",
      "e0=0.00085 #ft\n",
      "alpha=0.25 #/year\n",
      "t=15. #years\n",
      "r0=3. #in\n",
      "Q=500. #gal/min\n",
      "d=6. #in\n",
      "mu=2.04e-5 #lb-sec/ft^2\n",
      "rho=1.94 #slugs/ft^3\n",
      "g=32.2 #ft/s^2\n",
      "L=1. #ft\n",
      "gam=62.4\n",
      "#calculations\n",
      "e15=e0*(1+ alpha*t)\n",
      "ratio=r0/(12.*e15)\n",
      "V=Q/(7.48*60*math.pi/4. *math.pow((d/12),2))\n",
      "Nr=V*d*rho/(mu*12)\n",
      "f=0.036\n",
      "hl=f*L/(d/12.) *V*V /(2*g)\n",
      "dp=gam*hl\n",
      "#results\n",
      "print '%s %.2f %s' %(\"Pressure difference =\",dp,\"lb/ft^2 per foot of horizontal pipe\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Pressure difference = 2.25 lb/ft^2 per foot of horizontal pipe\n"
       ]
      }
     ],
     "prompt_number": 15
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 11 - Pg 289"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the horsepower required\n",
      "#Initialization of variables\n",
      "import math\n",
      "d2=4. #in\n",
      "d1=3. #in\n",
      "e=0.0005 #ft\n",
      "mu=3.75e-5 #lb-sec/ft^2\n",
      "rho=1.94 #slugs/ft^3\n",
      "Q=100. #gal/min\n",
      "L=100. #ft\n",
      "g=32.2 #ft/s^2\n",
      "gam=62.4\n",
      "#calculations\n",
      "A=math.pi/4. *(math.pow((d2/12),2) -math.pow((d1/12),2))\n",
      "WP=math.pi*(d1+d2)/12.\n",
      "R=A/WP\n",
      "RR= 2*R/e\n",
      "V= Q/(7.48*60*A)\n",
      "Nr=V*4*R*rho/mu\n",
      "f=0.035\n",
      "hl=f*L/(4*R) *V*V /(2*g)\n",
      "hp=hl*Q/(7.48*60) *gam/550.\n",
      "#results\n",
      "print '%s %.2f %s' %(\"horsepower required =\",hp,\" hp/100 ft\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "horsepower required = 0.56  hp/100 ft\n"
       ]
      }
     ],
     "prompt_number": 16
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 12 - Pg 296"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the discharge flow\n",
      "#Initialization of variables\n",
      "import math\n",
      "p1=25. #psig\n",
      "p2=20. #psig\n",
      "d1=18. #in\n",
      "d2=12. #in\n",
      "Cl=0.25\n",
      "gam=62.4\n",
      "g=32.2 #ft/s^2\n",
      "#calculations\n",
      "Vr=(d2/d1)*(d2/d1)\n",
      "xv=(p2-p1)*144/gam\n",
      "V22=xv/(-1-Cl+Vr*Vr) *2*g\n",
      "V2=math.sqrt(V22)\n",
      "Q=V2*math.pi/4. *(d2/12.)*(d2/12.)\n",
      "#results\n",
      "print '%s %.1f %s' %(\"Discharge =\",Q,\"ft^3/s\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Discharge = 20.9 ft^3/s\n"
       ]
      }
     ],
     "prompt_number": 17
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 13 - Pg 300"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the discharge flow rate\n",
      "#Initialization of variables\n",
      "import math\n",
      "V61=10.8 #ft/s\n",
      "V81=6.05 #ft/s\n",
      "r0=3 #in\n",
      "e=0.00015\n",
      "d1=6. #in\n",
      "rho=1.94 #slugs/ft^3\n",
      "mu=2.34e-5 #ft-lb/s^2\n",
      "#calculations\n",
      "roe=r0/(12*e)\n",
      "Nr1=V61*(d1/12.)*rho/mu\n",
      "f6=0.0165\n",
      "V6=11.6 #ft/s\n",
      "V8=6.52 #ft/s\n",
      "Q=V6*math.pi/4 *(d1/12.)*(d1/12.)\n",
      "#results\n",
      "print '%s %.2f %s' %(\"Discharge =\",Q,\"ft^3/s\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Discharge = 2.28 ft^3/s\n"
       ]
      }
     ],
     "prompt_number": 18
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 14 - Pg 302"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the diameter of steel pipe\n",
      "#Initialization of variables\n",
      "import math\n",
      "L=1000. #ft\n",
      "Q=2000/(7.48*60) #ft63/s\n",
      "g=32.2 #ft/s^2\n",
      "p=5. #psi/1000 ft\n",
      "gam=62.4\n",
      "sp=0.7\n",
      "f=0.02\n",
      "r0=0.904/2.\n",
      "e=0.00015\n",
      "mu=7e-6 #lb-ft/s^2\n",
      "L=1000. #ft\n",
      "#calculations\n",
      "hl=p*144/(sp*gam)\n",
      "D5=f*8*L*Q*Q /(math.pi*math.pi *g*hl)\n",
      "D=math.pow(D5,(1./5.))\n",
      "Nr=4*Q*sp*gam/(g*(math.pi*D*mu))\n",
      "f2=0.0145\n",
      "D5=f2*8*L*Q*Q /(math.pi*math.pi *g*hl)\n",
      "D1=math.pow(D5,(1./5.))\n",
      "#results\n",
      "print '%s %.3f %s' %(\"Diameter of steel pipe =\",D1,\" ft\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Diameter of steel pipe = 0.848  ft\n"
       ]
      }
     ],
     "prompt_number": 19
    }
   ],
   "metadata": {}
  }
 ]
}