{
 "metadata": {
  "name": "",
  "signature": "sha256:11a32dcbb7adff422edff329d33e29629cd83e2f8ab7cf7ac7803e8cbd9385ca"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 08:Internal Flow"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.8-1, Page No:349"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable Decleration\n",
      "u_max=6 #Maximum Velocity in m/s\n",
      "R=0.02 #Radius of the Pipe in m\n",
      "L=70 #Length of the pipe in m\n",
      "rho=1252 #Density of glycerin in kg/m^3\n",
      "u=0.3073 #Viscosity of glycerin in kg/m.s\n",
      "g=9.81 #Acceleration due to gravity in m/s^2\n",
      "C=10**-3 #Conversion factor\n",
      "\n",
      "#Calculations\n",
      "D=R*2 #Diameter of the pipe in m\n",
      "V=u_max/2 #Average Velocity in m/s\n",
      "V_dot=V*(pi*R**2) #Volumertic Flow rate in m^3/s\n",
      "Re=(rho*V*D)/u #Reynolds Number \n",
      "f=64/Re #Friction Factor\n",
      "h_L=(f*L*V**2)/(2*g*D) #Head loss in m\n",
      "theta=(pi*15)/180 #Angle in radians\n",
      "\n",
      "#Applying the energy balance equation\n",
      "#As z2=z1 z2-z1=0 hence we do not consider it in the computation\n",
      "delta_P=rho*g*(h_L)*C #Pressure difference in kPa\n",
      "W_dot=V_dot*delta_P #Useful pumping Power in kW\n",
      "\n",
      "#Inclined Case\n",
      "delta_z=L*sin(theta) #elevation difference in m\n",
      "delta_P_up=(rho*g*delta_z*C)+(rho*g*h_L*C) #Pressure difference up in kPa\n",
      "V_dot_upward=W_dot/delta_P_up #Flow rate through the upward pipe in m^3/s\n",
      "\n",
      "#Percentage Calculations\n",
      "per_V=((V_dot-V_dot_upward)/V_dot)*100 #Percentage change in the flow rate\n",
      "\n",
      "#Result\n",
      "print \"The velocity of the flow is\",round(V),\"m/s\"\n",
      "print \"The pressure difference across 70m long pipe is\",round(delta_P),\"kPa\"\n",
      "print \"The power required to maintain the flow is\",round(W_dot,2),\"kW\"\n",
      "print \"The percentage change in the flow rate is\",round(per_V,1),\"%\"\n",
      "#Answer for percentage change and flow rate through the pipe upward direction are incorrect"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The velocity of the flow is 3.0 m/s\n",
        "The pressure difference across 70m long pipe is 1291.0 kPa\n",
        "The power required to maintain the flow is 4.87 kW\n",
        "The percentage change in the flow rate is 14.7 %\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.8-2, Page No:350"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable Decleration\n",
      "rho=1000 #Density of water in kg/m^3\n",
      "u=1.519*10**-3 #Viscosity of water in kg/m.s\n",
      "L=9 #Length of the pipe in m\n",
      "D=0.003 #Diameter of the pipe in m\n",
      "V=0.9 #Average velocity inside the pipe of water in m/s\n",
      "g=9.81 #Acceleration due to gravity in m/s^2\n",
      "\n",
      "#Calculations\n",
      "#Part(a)\n",
      "\n",
      "Re=(rho*V*D)/u #Reynolds Number\n",
      "f=64/Re #Friction Factor\n",
      "h_L=(f*L*V**2)/(2*g*D) #Head Loss in m\n",
      "\n",
      "#Part(b)\n",
      "delta_P=(f*L*V**2)/(2*D) #Pressure difference in kPa\n",
      "\n",
      "#Part(c)\n",
      "V_dot=(V*pi*D**2)/4 #Volumetric Flow rate in m^3/s\n",
      "W_dot=V_dot*delta_P*1000 #Pumping power required in W\n",
      "\n",
      "#Result\n",
      "print \"The Head Loss is\",round(h_L,2),\"m\"\n",
      "print \"The pressure drop is\",round(delta_P,1),\"kPa\"\n",
      "print \"The pumping power required is\",round(W_dot,2),\"W\"\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The Head Loss is 4.46 m\n",
        "The pressure drop is 43.7 kPa\n",
        "The pumping power required is 0.28 W\n"
       ]
      }
     ],
     "prompt_number": 17
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.8-3, Page No:360"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable Decleration\n",
      "rho=999 #Density of water in kg/m^3\n",
      "u=1.138*10**-3 #Viscosity in kg/m.s\n",
      "D=0.05 #Diameter of the pipe in m\n",
      "V_dot= 0.006 #Volumetric Flow rate in m^3/s\n",
      "L=60 #Length of the pipe in m\n",
      "e=0.002 #Relative roughness value from table\n",
      "f=0.0172 #Value from Moody Chart\n",
      "g=9.81 #Acceleration due to gravity in m/s^2\n",
      "\n",
      "#Calculations\n",
      "V=round((V_dot*4)/(pi*D**2),2) #Velocity of the flow in the pipe in m/s\n",
      "Re=(rho*V*D)/u #Reynolds Number\n",
      "e_D=e/(D*1000) #Relative roughness\n",
      "\n",
      "#Taking the value for root f from Moody Chart as f=0.0172\n",
      "delta_P=(f*L*rho*V**2)/(D*2) #Pressure Drop in N/m^2\n",
      "h_L=delta_P/(rho*g) #Head Loss in m\n",
      "W_pump=V_dot*delta_P #Required Power in W\n",
      "\n",
      "#Result\n",
      "print \"The Pressure Drop is\",round(delta_P),\"N/m^2\"\n",
      "print \"The head loss is\",round(h_L,2),\"m\"\n",
      "print \"The Power required is\",round(W_pump),\"W\" \n",
      "\n",
      "#The answer for delta_P is off by 4 due to decimal accuracy in the formula\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The Pressure Drop is 96536.0 N/m^2\n",
        "The head loss is 9.85 m\n",
        "The Power required is 579.0 W\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.8-4, Page No:361"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable Decleration\n",
      "V_dot=0.35 #Volumertic flow rate in m^3/s\n",
      "L=150 #Length of the pipe in m\n",
      "rho=1.145 #Density of the fluid in kg/m^3\n",
      "u=1.895*10**-5 #Dynamic viscosity of the fluid in kg/m.s\n",
      "v=1.655*10**-5 #Kinematic Viscosity of the fluid in m^2/s\n",
      "h_l=20 #Allowable head loss in m\n",
      "g= 9.81 #Acceleration due to gravity in m/s^2\n",
      "\n",
      "#The following three equations are solved using EES hence we will be taking the values directly here\n",
      "D=0.267 #Diameter of the pipe in m\n",
      "f=0.0180\n",
      "V=6.24 #Velocity of low in m/s\n",
      "Re=100800 #Reynolds Number\n",
      "\n",
      "#Calculations\n",
      "#Simplfying the calculations\n",
      "c=V_dot**9.4\n",
      "d=L/(g*h_l)\n",
      "f=d**5.2\n",
      "#Using Swamee-Jain Formula\n",
      "D=0.66*((v*c*f)**0.04) #Diameter of the pipe in m\n",
      "\n",
      "#Result\n",
      "print \"The diameter of the pipe is\",round(D,3),\"m\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The diameter of the pipe is 0.271 m\n"
       ]
      }
     ],
     "prompt_number": 18
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.8-5, Page No:362"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable Deceleration\n",
      "#Using the computationally simple method given in the discussion\n",
      "\n",
      "g=9.81 #Acceleration due to gravity in m/s^2\n",
      "D=0.267 #Diameter in m\n",
      "h_l=20 #Head loss in m\n",
      "L=300 #Length of the pipe in m\n",
      "v=1.655*10**-5 #Kinematic Voscosity in m^2/s\n",
      "V_dot_old=0.35 #Volumetric Flow rate in m^3/s\n",
      "\n",
      "#Calculations\n",
      "a=((3.17*v**2*L)/(g*D**3*h_l))**0.5\n",
      "b=log(a)\n",
      "c=((g*D**5*h_l)/L)**0.5\n",
      "\n",
      "V_dot_new=-0.965*b*c #Volumetric Flow rate in m^3/s\n",
      "V_dot=V_dot_old-V_dot_new #Drop in the flow rate in m^/s\n",
      "\n",
      "print \"The drop in the flow rate is\",round(V_dot,2),\"m^3/s\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The drop in the flow rate is 0.11 m^3/s\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.8-6, Page No:370"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable Decleration\n",
      "D1=0.06 #Diameter of the pipe at section 1 in m\n",
      "D2=0.09 #Diameter of the pipe at section 2 in m\n",
      "V1=7 #Average Velocity at section 1 in m/s\n",
      "K_l=0.133 # interpolating from table\n",
      "g=9.81 #Acceleration due to gravity in m/s^2\n",
      "P1=150 #Pressure head at section one in kPa\n",
      "rho=1000 #Density of the fluid in kg/m^3\n",
      "alpha1=1.06 #momentum correction factor\n",
      "alpha2=alpha1 #momentum correction factor\n",
      "C=10**-3 #Conversion factor\n",
      "\n",
      "#Calculations\n",
      "#Applying the one dimensional continuity equation\n",
      "V2=(D1**2/D2**2)*V1 #Velocity of the fluid at section 2 in m/s\n",
      "\n",
      "#Irreversible head loss\n",
      "h_l=K_l*(V1**2/(2*g)) #Irreversible head loss in m\n",
      "\n",
      "#Using the energy equation\n",
      "P2=P1+rho*(((alpha1*V1**2-alpha2*V2**2)*0.5)-g*h_l)*C #Pressure head at section 2 in kPa\n",
      "\n",
      "#Result\n",
      "print \"The head loss is\",round(h_l,4),\"m\"\n",
      "print \"The pressure head at section two is\",round(P2),\"kPa\"\n",
      "#The answer differs due to decimal point accuracy\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The head loss is 0.3322 m\n",
        "The pressure head at section two is 168.0 kPa\n"
       ]
      }
     ],
     "prompt_number": 21
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.8-8, Page No:377"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable decleration\n",
      "rho=999.7 #Density of the fluid in kg/m^3\n",
      "u=1.307*10**-3 # Dynamic Viscosity in kg/m.s \n",
      "e=0.00026 #Roughness of cast iron in m\n",
      "V_dot=0.006 #Volumetric Flow rate in m^3/s\n",
      "z2=4 #static head at section 2 in m\n",
      "D=0.05 #Diameter of the pipe in m\n",
      "#Kl declerations\n",
      "Kl_entrance=0.5\n",
      "Kl_elbow=0.3\n",
      "Kl_valve=0.2\n",
      "Kl_exit=1.06\n",
      "f=0.0315 #Using Moody Chart and Colebrook Equation friction factor\n",
      "L=89 #Length of the pipe in m                                \n",
      "g=9.81 #Acceleration due to gravity in m/s^2\n",
      "\n",
      "#Calculations\n",
      "V=(V_dot*4)/(pi*D**2)  #Average Velocity in the pipe in m/s\n",
      "Re=(rho*V*D)/u #Reynolds Number\n",
      "e_D=e/D\n",
      "sum_Kl=Kl_entrance+2*Kl_elbow+Kl_valve+Kl_exit #Summation of all Kl\n",
      "#Total Head Loss\n",
      "h_l=(((f*L)/D)+sum_Kl)*(V**2/(2*g)) #Total head loss in m\n",
      "\n",
      "#Using Energy equation\n",
      "z1=z2+h_l #Free surface of the first reservoir in m\n",
      "\n",
      "#Result\n",
      "print \"The elevation of the free surface of the first reservoir is\",round(z1,1),\"m\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The elevation of the free surface of the first reservoir is 31.8 m\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.8-10, Page No:385"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable Decleration\n",
      "rho_met=788.4 #Density of the fluid in kg/m^3\n",
      "u=5.857*10**-4 #Dynamic Viscosity in kg/m.s\n",
      "rho_hg=13600 #Density of mercury in kg/m^3\n",
      "d=0.03 #diameter of the orifice meter in m\n",
      "D=0.04 #Diameter of the pipe in m\n",
      "h=0.11 #differential height of the manometer in m\n",
      "g=9.81 #Acceleration due to gravity in m/s^2\n",
      "Cd=0.61 #Coefficient of discharge\n",
      "\n",
      "#Calculations\n",
      "beta=d/D #Diameter ratio\n",
      "Ao=(pi*d**2)/4 #Area of throat in m^2\n",
      "\n",
      "#Pressure Drop\n",
      "delta_P=(rho_hg-rho_met)*g*h #Pressure drop in m\n",
      "\n",
      "#Flow rate\n",
      "V_dot=Ao*Cd*(((2*delta_P)/(rho_met*(1-beta**4)))**0.5) #Volumetric Flow rate in m^3/s\n",
      "V=(V_dot*4)/(pi*D**2) #Average Velocity in m/s\n",
      "\n",
      "#Reynolds Number\n",
      "Re=(rho_met*V*D)/u #Reynolds Number\n",
      "\n",
      "#Coefficient of Discharge\n",
      "Cd_calculations=0.5959+0.0312*beta**2.1-0.184*beta**8+((91.71*beta**2.50)/Re**0.75)\n",
      "\n",
      "#Result\n",
      "print \"The flow rate of methanol in the pipe is\",round(V_dot,5),\"m^3/s\"\n",
      "print \"The average velocity of low in the pipe is\",round(V,2),\"m/s\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The flow rate of methanol in the pipe is 0.00309 m^3/s\n",
        "The average velocity of low in the pipe is 2.46 m/s\n"
       ]
      }
     ],
     "prompt_number": 5
    }
   ],
   "metadata": {}
  }
 ]
}