{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 5 : Bernoulli Equation"
     ]
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.1 page no : 134\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Calculate the increase in temperature due to falling water of waterfall\n",
      "\n",
      "# Variables    \n",
      "g=9.81;           #m/s^2 acc. due to gravity\n",
      "dz=100.;          #m Height of waterfall\n",
      "\n",
      "# Calculation\n",
      "du=g*dz;          #J/kg Change in internal energy\n",
      "Cv=4184.0;        #J/kg/K;\n",
      "dT=du/Cv          #K Change in temperature\n",
      "\n",
      "# Result\n",
      "print \"Change in temperature is %f K or degree centigrade\"%dT"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Change in temperature is 0.234465 K or degree centigrade\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.2 page no : 141\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate velocity of air coming out from the nozzle\n",
      "\n",
      "# Variables  \n",
      "T=528.                           #R Rankine scale\n",
      "R=10.73;                         #psi.ft^3/R/lbmol universal gas constant\n",
      "p=14.71                          #psi\n",
      "p_atm=14.7;                      #psi\n",
      "M=29.;                           #lbm/lbmol\n",
      "\n",
      "# Calculation  \n",
      "#considering the velocity at the start of the nozzle is negligible\n",
      "v=((2*R*T/p/M)*(p-p_atm)*(144*32.2))**0.5;              #ft/s\n",
      "\n",
      "# Result\n",
      "print \"Velocity of the air flowing out of the pipe %f ft/s\"%v"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Velocity of the air flowing out of the pipe 35.094226 ft/s\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.3 page no : 143\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Calculate the velocity of water flowing out of a nozzle at the bottom of a tank\n",
      "\n",
      "# Variables  \n",
      "g=32.2;                             #ft/s^2\n",
      "h=30.;                              #ft height tank\n",
      "\n",
      "# Calculation  \n",
      "#considering the velocityof water at the top of the tank is negligible\n",
      "v=(2*g*h)**0.5;                     #ft/s\n",
      "\n",
      "# Result\n",
      "print \"The velocity of the water flowing out through the nozzle is %f ft/s\"%v"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The velocity of the water flowing out through the nozzle is 43.954522 ft/s\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.4 page no : 144\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate velocity of water flowing out of nozzle\n",
      "\n",
      "# Variables  \n",
      "A_nozzle=1.0                          #ft^2\n",
      "A_tank=4.0                            #ft^2\n",
      "g=32.2                                #ft/s^2\n",
      "h=30.                                 #ft\n",
      "\n",
      "# Calculation  \n",
      "v=(2*g*h/(1-(A_nozzle/A_tank)**2))**0.5           #ft/s\n",
      "\n",
      "# Result\n",
      "print \"The velocity of water flowing out of nozzle is %f ft/s\"%v"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The velocity of water flowing out of nozzle is 45.396035 ft/s\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.5 page no : 145\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the velocity of water flowing out of a nozzle\n",
      "\n",
      "# Variables  \n",
      "g=32.2                   #ft/s^2\n",
      "h=30.                    #ft\n",
      "M_air=29.                #dimentionless (molecular weight)\n",
      "M_CO2=44.                #dimentionless (molecular weight)\n",
      "\n",
      "# Calculation  \n",
      "v=(2*g*h*(1-(M_air/M_CO2)))**0.5            #ft/s\n",
      "\n",
      "# Result\n",
      "print \"The velocity of water flowing out of nozzle is %f ft/s\"%v"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The velocity of water flowing out of nozzle is 25.663912 ft/s\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.6 page no : 147\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate velocity of sailboat using pitot tube\n",
      "\n",
      "# Variables  \n",
      "h=1.                      #m height of water above the water level\n",
      "g=9.81                    #m/s^2\n",
      "\n",
      "# Calculation  \n",
      "v=(2*g*h)**0.5            #m/s\n",
      "\n",
      "# Result\n",
      "print \"The velocity of sailboat is %f m/s\"%v"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The velocity of sailboat is 4.429447 m/s\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.7 page no : 148\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Calculate velocity of air flowing through an air duct\n",
      "\n",
      "# Variables  \n",
      "dP=0.05                        #psi or lbf/in^2\n",
      "rho_air=0.075                  #lbm/ft^3\n",
      "\n",
      "#1ft = 12in\n",
      "#1 lbf.s^2 = 32.2 lbm.ft\n",
      "\n",
      "# Calculation  \n",
      "v=(2*dP*144*32.2/rho_air)**0.5        #ft/s\n",
      "\n",
      "# Result\n",
      "print \"The velocity of air in the air duct is %f ft/s\"%v"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The velocity of air in the air duct is 78.628239 ft/s\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.8 page no : 149\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate volumetric flow rate using a venturi-meter\n",
      "import math\n",
      "\n",
      "# Variables  \n",
      "dP=1.                                #psi\n",
      "rho_water=62.3                       #lbm/ft^3\n",
      "d1=1.                                #ft area at pt 1 in venturimeter\n",
      "A1=(math.pi)*d1**2/4.0               #ft^2\n",
      "d2=0.5                               #ft\n",
      "A2=(math.pi)*d2**2/4.0               #ft^2\n",
      "\n",
      "#1ft = 12in\n",
      "\n",
      "# Calculation  \n",
      "#1 lbf.s^2 = 32.2 lbm.ft\n",
      "v=((2*dP*144*32.2/rho_water)/(1-(A2/A1)**2))**0.5            #ft/s\n",
      "q=v*A2                                                       #ft^3/s\n",
      "\n",
      "# Result\n",
      "print \"The velocity of the water flowing through venturimeter is %f ft/s\"%v\n",
      "print \"The volumetric flow rate of water is %f ft^3/s\"%q"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The velocity of the water flowing through venturimeter is 12.600696 ft/s\n",
        "The volumetric flow rate of water is 2.474141 ft^3/s\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.9 page no : 149\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate actual volumetric flow rate using a venturi-meter\n",
      "import math\n",
      "\n",
      "# Variables  \n",
      "dP=1.                                #psi\n",
      "rho_water=62.3                       #lbm/ft^3\n",
      "d1=1.                                #ft area at pt 1 in venturimeter\n",
      "A1=(math.pi)*d1**2/4                 #ft^2\n",
      "d2=0.5                               #ft\n",
      "A2=(math.pi)*d2**2/4                 #ft^2\n",
      "#1ft = 12in\n",
      "\n",
      "# Calculation  \n",
      "#1 lbf.s^2 = 32.2 lbm.ft\n",
      "v_th=((2*dP*144*32.2/rho_water)/(1-(A2/A1)**2))**0.5           #ft/s\n",
      "Cv=0.984                            #dimentionless\n",
      "v_act=Cv*v_th                       #ft/s actual velocity\n",
      "q=v_act*A2                          #ft^3/s\n",
      "\n",
      "# Result\n",
      "print \"The velocity of the water flowing through venturimeter is %f ft/s\"%v_act\n",
      "print \"The volumetric flow rate of water is %f ft^3/s\"%q"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The velocity of the water flowing through venturimeter is 12.399084 ft/s\n",
        "The volumetric flow rate of water is 2.434555 ft^3/s\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.10 page no : 152\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Calculate the pressure difference in a pipe\n",
      "import math\n",
      "\n",
      "# Variables  \n",
      "v1=1.                    #m/s\n",
      "d1=0.4                   #m\n",
      "A1=(math.pi)*d1**2/4     #m^2\n",
      "d2=0.2                   #m\n",
      "A2=(math.pi)*d2**2/4     #m^2\n",
      "v2=A1*v1/A2              #m/s\n",
      "Cv=0.62                  #dimentionless\n",
      "rho_water=998.2          #kg/m^3\n",
      "\n",
      "# Calculation  \n",
      "dP=(rho_water*v2**2/2/Cv**2)*(1-(A2/A1)**2)/1000.             #KPa\n",
      "\n",
      "# Result\n",
      "print \"The pressure difference in the pipe is %f KPa\"%dP"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The pressure difference in the pipe is 19.475806 KPa\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.11 page no : 155\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Calculate the flow rate of helium with rotameter caliberated with nitogen\n",
      "\n",
      "# Variables  \n",
      "M_N2=28.                            #dimentionless\n",
      "M_He=4.                             #dimentionless\n",
      "\n",
      "#Density is proportional to molecular weight\n",
      "q_N2=100.                           #cm^3/min\n",
      "\n",
      "# Calculation  \n",
      "q_He=q_N2*(M_N2/M_He)**0.5          #cm^3/min\n",
      "\n",
      "# Result\n",
      "print \"The flow rate of Helium is %f cm^3/min\"%q_He"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The flow rate of Helium is 264.575131 cm^3/min\n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.12 page no : 156\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Calculate the absolute pressure at the top of a inverted manometer tube\n",
      "\n",
      "# Variables  \n",
      "p_atm=14.7                        #lbf/in^2\n",
      "g=32.2                            #ft/s^2\n",
      "\n",
      "#one end of the inverted manometer is immersed in a tank and the other end is open to atmosphere 10 ft below tank level\n",
      "#pt 1 is at tank water level, pt 2 is at top of inverted manometer and pt3 is at the other end of manometer\n",
      "dh=10.                            #ft\n",
      "v3=(2*g*dh)**0.5                  #ft/s\n",
      "p1=p_atm                          #lbf/in^2\n",
      "rho_water=62.3                    #lbm/ft^3\n",
      "\n",
      "#Difference of height between pt 1 and pt 2 is 40 ft\n",
      "dh1=40.                           #dft\n",
      "\n",
      "# Calculation  \n",
      "p2=p1-(rho_water*v3**2/2/32.2/144)-(rho_water*g*dh1)/32.2/144          #lbf/in^2\n",
      "\n",
      "# Result\n",
      "print \"The absolute pressure at the top of the inverted manometer is %f lbf/in^2\"%p2"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The absolute pressure at the top of the inverted manometer is -6.931944 lbf/in^2\n"
       ]
      }
     ],
     "prompt_number": 15
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5.13 page no : 156\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Calculate pressure at the throat in a venturimeter\n",
      "\n",
      "# Variables  \n",
      "dP=10.                             #psi or lbf/in^2\n",
      "rho_water=62.3                     #lbm/ft^3\n",
      "#1ft = 12in\n",
      "\n",
      "# Calculation  and  Result\n",
      "#1 lbf.s^2 = 32.2 lbm.ft\n",
      "v3=(2*dP*144*32.2/rho_water)**0.5         #ft/s\n",
      "print \"The velocity of water after the throat is %f ft/s\"%v3\n",
      "\n",
      "ratio_A=0.5                               #dimentionless (ratio of throat area to pipe area)\n",
      "v2=v3/ratio_A                             #ft/s\n",
      "print \"The velocity of water at the throat is %f ft/s\"%v2\n",
      "\n",
      "P1=24.7                                   #psia\n",
      "rho_water=62.3                            #lbm/ft^3\n",
      "P2=P1-(rho_water)*v2**2/32.2/144/2        #psia\n",
      "print \"The pressure of water at the throat is %f psia\"%P2"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The velocity of water after the throat is 38.581593 ft/s\n",
        "The velocity of water at the throat is 77.163186 ft/s\n",
        "The pressure of water at the throat is -15.300000 psia\n"
       ]
      }
     ],
     "prompt_number": 16
    }
   ],
   "metadata": {}
  }
 ]
}