{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 6 : Fluid friction in steady on dimentional flow"
     ]
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 6.1 page no : 180\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the drop in pressure per unit length in a pipe\n",
      "import math\n",
      "\n",
      "# Variables  \n",
      "q=50.0                        #gal/min flow rate\n",
      "d=3.068                       #in inner diameter\n",
      "\n",
      "# Calculation  \n",
      "a=(math.pi)*(3.068/12.0)**2/4.0            #ft^2\n",
      "#1 ft^3 = 7.48 gal\n",
      "#1 min = 60 sec\n",
      "v_avg=q/a/60.0/7.48                        #ft/s\n",
      "mew=50.0                                   #cP\n",
      "#1 cP = 0.000672 lbm/ft/s\n",
      "rho=62.3                                   #lbm/ft^3\n",
      "\n",
      "# Result\n",
      "R=(d/12)*v_avg*rho/(mew*0.000672)           #dimentionless reynold's no.\n",
      "if (R<2000):\n",
      "    print \"Laminar flow\"\n",
      "else:\n",
      "    print \"Turbulent flow\"\n",
      "\n",
      "dx=3000.0                                #ft length of pipe\n",
      "#1 gal = 231 in^3\n",
      "#1 cP.ft^3 = 0.0000209 lbf.s\n",
      "dp=(q/60)*(128/math.pi)*(mew/d**4)*dx*231*0.0000209/12         #lbf/in^2 or psi\n",
      "#let D represent d/dx\n",
      "Dp=(dp/dx)*100                          #psi/ft\n",
      "print \"The pressure gradient in the pipe is %f psi/100ft\"%Dp"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Laminar flow\n",
        "The pressure gradient in the pipe is 0.770911 psi/100ft\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 6.2 page no : 182\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate viscosity of fluid using a viscometer\n",
      "import math\n",
      "\n",
      "# Variables  \n",
      "rho=1050.                         #Kg/m^3\n",
      "g=9.81                            #m/s^2\n",
      "dz=0.12                           #m change in height\n",
      "d=0.001                           #m inner diameter of capillary of viscometer\n",
      "q=10**(-8)                        #m^3/s\n",
      "dx=0.1                            #m length of capillary\n",
      "\n",
      "# Calculation  \n",
      "mew=(rho*g*dz*(math.pi)*d**4)*1000/128./(q*dx)           #cP\n",
      "\n",
      "# Result\n",
      "print \"The viscosity of the fluid is %f cP\"%mew"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The viscosity of the fluid is 30.337477 cP\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 6.3 page no : 187\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Calculate the fanning friction factor\n",
      "\n",
      "# Variables  \n",
      "R=10**5.                          #dimentionless reynold's no.\n",
      "ratio_ED=0.0002                   #dimentionless\n",
      "\n",
      "# Calculation  \n",
      "f=0.001375*(1+(20000*ratio_ED+10**6/R)**(1./3))            #dimentionless\n",
      "\n",
      "# Result\n",
      "print \"The fanning friction factor is %f\"%f"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The fanning friction factor is 0.004689\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 6.4 page no : 188\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Calculate the gauge pressure in the tank\n",
      "import math\n",
      "\n",
      "# Variables  \n",
      "q=300.                             #gal/min flow rate\n",
      "d=3.068                            #in inner diameter\n",
      "\n",
      "# Calculation  \n",
      "a=(math.pi)*(3.068/12.0)**2/4.0    #ft^2\n",
      "\n",
      "#1 ft^3 = 7.48 gal\n",
      "#1 min = 60 sec\n",
      "v_avg=13.                          #q/a/60.0/7.48#ft/s\n",
      "f=0.0091                           #dimentionless fanning friction factor\n",
      "dx=3000.                           #ft\n",
      "rho=62.3                           #lbm/ft^3\n",
      "dp=4*f*(dx/(d/12.0))*rho*(v_avg**2/2.0)/32.2/144.0   #lbf/in^2 or psi\n",
      "\n",
      "# Result\n",
      "print \"The gauge pressure in the tank is %d psi\"%dp"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The gauge pressure in the tank is 484 psi\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 6.5 page no : 190\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Calculate volumetric flow rate of gasoline through a pipe\n",
      "import math\n",
      "\n",
      "# Variables  \n",
      "d=0.1                            #m internal diameter of pipe\n",
      "A=math.pi*d**2/4.0               #m^2\n",
      "dx=100.0                         #m length of pipe\n",
      "f=0.005                          #dimentionless fanning friction factor\n",
      "dz=10.0                          #m difference in water level\n",
      "g=9.81                           #m/s^2\n",
      "\n",
      "# Calculation  \n",
      "v=((2*g*dz/4/f)*(0.1/100))**0.5       #4.0/f)*d/dx)**0.5#m/s\n",
      "\n",
      "# Result\n",
      "print \"The velocity of gasoline through pipe is %f m/s\"%v\n",
      "q=A*v#m^3/s\n",
      "print \"The volumteric flow arte od gasoline through the pipe is %f m^3/s\"%q"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The velocity of gasoline through pipe is 3.132092 m/s\n",
        "The volumteric flow arte od gasoline through the pipe is 0.024599 m^3/s\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 6.6 page no : 192\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Calculate pressure difference across the duct\n",
      "import math\n",
      "\n",
      "# Variables  \n",
      "p=14.75                  #lbf/in^2\n",
      "M=29.                    #lbm/lbmol\n",
      "R=10.73                  #lbf.ft^3/(in^2.lbmol.R)\n",
      "T=500.                   #R Rankine temperature scale\n",
      "rho=p*M/(R*T)            #lbm/ft^3\n",
      "q=500.                   #ft^3/min\n",
      "d=1.                     #ft\n",
      "A=(math.pi)*d**2/4       #ft^2\n",
      "v=(q/60.0)/A             #ft/s\n",
      "mew=0.017                #cP\n",
      "\n",
      "#1cP = 0.000672 lbm/ft/s\n",
      "R=d*v*rho/(mew*0.000672)               #dimentionless reynold's no.\n",
      "f=0.00465                              #fanning friction factor\n",
      "dx=800.                                #ft lenght of duct\n",
      "#1 ft = 12 in\n",
      "#1 lbf.s^2 = 32.2 lbm.ft\n",
      "\n",
      "# Calculation  \n",
      "dP=rho*(4*f*(dx/d)*(v**2/2))/32.2/144.                #lbf/in^2\n",
      "\n",
      "# Result\n",
      "print \"The pressure drop across the duct is %f lbf/in^2\"%dP"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The pressure drop across the duct is 0.014402 lbf/in^2\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 6.8 page no : 197\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Calculate the pump power required\n",
      "\n",
      "# Variables  \n",
      "q=200.                         #gal/min\n",
      "rho=62.3                       #lbm/ft^3\n",
      "#1 ft^3 = 7.48 gal\n",
      "\n",
      "# Calculation  \n",
      "m=(q/60)*rho/7.48              #lbm/s\n",
      "dx=2000.                       #ft\n",
      "dp=3.87                        #psi/100ft\n",
      "F=(dp/100)*dx/rho*32.2*144     #ft\n",
      "#1 hp = 550 lbf.ft/s\n",
      "Po=F*m/550.                    #hp\n",
      "\n",
      "# Result\n",
      "print \"The pump power required is %f hp\"%Po"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The pump power required is 290.786193 hp\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 6.9 page no : 198\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Calculate the drop in pressure per unit length in a pipe\n",
      "\n",
      "# Variables  \n",
      "dp=0.1                 #psi\n",
      "dx=800.                #ft\n",
      "\n",
      "#let D represent d/dx\n",
      "#1 psi = 6895 Pa\n",
      "#1 m = 3.28 ft\n",
      "\n",
      "# Calculation  \n",
      "Dp=(dp/dx)*6895*3.28    #Pa/m\n",
      "\n",
      "# Result\n",
      "print \"The drop in pressure per unit length in the pipe is %f Pa/m\"%Dp\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The drop in pressure per unit length in the pipe is 2.826950 Pa/m\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 6.10 page no : 201\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Calculate the pressure difference created due to expansion and contraction\n",
      "\n",
      "# Variables  \n",
      "rho=62.3               #lbm/ft^3\n",
      "K=1.5                  #dimentionless\n",
      "v=13.                  #ft/s\n",
      "\n",
      "#1 ft = 12 in\n",
      "#1 lbf.s^2 = 32.2 lbm.ft\n",
      "\n",
      "# Calculation  \n",
      "dp=rho*K*(v**2/2)/32.2/144                #lbf/in^2\n",
      "\n",
      "# Result\n",
      "print \"The pressure drop due to expansion and contraction is %f lbf/in^2\"%dp"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The pressure drop due to expansion and contraction is 1.703012 lbf/in^2\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 6.11 page no : 203\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Calculate the pressure drop in the pipe due to fittings\n",
      "\n",
      "# Variables  \n",
      "dx=3000.0                 #ft actual length of pipe\n",
      "dx1=281.                  #ft equivalent length of fittings\n",
      "p=484.                    #psi\n",
      "\n",
      "# Calculation  \n",
      "dx_total=dx+dx1           #ft\n",
      "dp_total=p*(dx_total/dx)  #psi\n",
      "dp_vnf=dp_total-p         #psi pressure drop fue to valves and fittings\n",
      "\n",
      "# Result\n",
      "print \"The pressure drop due to valves and fittings is %d psi\"%dp_vnf"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The pressure drop due to valves and fittings is 45 psi\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 6.12 page no : 203\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Calculate pressure drop due to valves and fittings\n",
      "\n",
      "# Variables  \n",
      "K=27.56               #deimentionless\n",
      "rho=62.3              #lbm/ft^3\n",
      "v=13.                 #ft/s\n",
      "\n",
      "# Calculation  \n",
      "#1 ft = 12 in\n",
      "#1 lbf.s^2 = 32.2 lbm.ft\n",
      "dp=rho*K*(v**2/2)/32.2/144.            #psi\n",
      "\n",
      "# Result\n",
      "print \"THe pressure drop due to valves and fittings is %d psi\"%dp"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "THe pressure drop due to valves and fittings is 31 psi\n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 6.13 page no : 207\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Calculate the gasoline leakage rate through a seal\n",
      "import math\n",
      "\n",
      "# Variables  \n",
      "p=100.0                #lbf/in^2\n",
      "l=1.                   #in length od seal in direction of leak\n",
      "mew=0.6                #cP\n",
      "d=0.25                 #in diameter of valve stem\n",
      "t=0.0001               #in thickness of valva stem\n",
      "\n",
      "# Calculation  \n",
      "#1 cP = 0.0000209 lbf.s/ft^2\n",
      "#1 ft = 12 in\n",
      "q=(p/l)*(1/12.0/mew)*(math.pi)*d*t**3/0.0000209*144*3600.     #in^3/hr\n",
      "\n",
      "# Result\n",
      "print \"The volumetric leakage rate of gasoline is %f in^3/hr\"%q\n",
      "rho=0.026              #lbm/in^3\n",
      "m=q*rho                #lbm/hr\n",
      "print \"The mass leakage rate of gasoline is %f lbm/hr\"%m"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The volumetric leakage rate of gasoline is 0.270568 in^3/hr\n",
        "The mass leakage rate of gasoline is 0.007035 lbm/hr\n"
       ]
      }
     ],
     "prompt_number": 16
    }
   ],
   "metadata": {}
  }
 ]
}