{
 "metadata": {
  "name": "",
  "signature": "sha256:df3153eb902c7efba51ed445ceefd3e3c02fa6ed938e4ef53fe06333d531bf11"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 6: The Energy Equation and its Applications"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.1, Page 170"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "import math\n",
      "\n",
      "\n",
      " #Initializing  the  variables  \n",
      "Pc  =  0;                                                                  #  Atmospheric  Pressure\n",
      "Z3  =  30+2;                                                            #height  of  nozzle\n",
      "Ep  =  50  ;                                                              #Energy  per  unit  weight  supplied  by  pump\n",
      "d1  =  0.150;                                                          #Diameter  of  sump\n",
      "d2  =  0.100;                                                          #Diameter  of  delivery  pipe\n",
      "d3  =  0.075  ;                                                        #Diameter  of  nozzle\n",
      "g  =  9.81;                                                              #  Acceleration  due  to  gravity\n",
      "Z2  =  2;                                                                  #Height  of  pump\n",
      "rho  =  1000;                                                          #  Density  of  water\n",
      "\n",
      " #Calculations\n",
      "U3  = (2*g*(Ep-Z3)/(1+5*(d3/d1)**4  +  12*(d3/d2)**4))**0.5;\n",
      "U1  =  U3/4;\n",
      "Pb  =  rho*g*Z2  +  3*rho*U1**2;\n",
      "print \"Velocity of Jet through nozzle (m/s) :\",round(U3,3)\n",
      "print \"Pressure in the suction pipe at the inlet to the pump at B (kN/m^2) :\",round(Pb/1000,3)     "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Velocity of Jet through nozzle (m/s) : 8.314\n",
        "Pressure in the suction pipe at the inlet to the pump at B (kN/m^2) : 32.58\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.2, Page 183"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "import math\n",
      "\n",
      " #Initializing  the  variables  \n",
      "x  =  45;                                                                  #  Inclination  of  pipe\n",
      "l  =  2;                                                                    #Length  of  pipe  under  consideration\n",
      "Ep  =  50  ;                                                              #Energy  per  unit  weight  supplied  by  pump\n",
      "d1  =  0.2;                                                              #Diameter  of  sump\n",
      "d2  =  0.1;                                                              #Diameter  of  delivery  pipe\n",
      "g  =  9.81;                                                              #  Acceleration  due  to  gravity\n",
      "rho  =  1000;                                                          #  Density  of  water\n",
      "V1  =  2;\n",
      "RD_oil  =  0.9;                                                      #  relative  density  of  oil\n",
      "RD_Merc  =  13.6;                                                  #  Relative  density  of  Mercury\n",
      "\n",
      " #Calculations\n",
      "V2  =  V1*(d1/d2)**2;\n",
      "dZ  =  round(l*math.sin(math.radians(x)),3);       # it is used in book as 1.414,by rounding so here also\n",
      "rho_Oil  =  RD_oil*rho;\n",
      "rho_Man  =  RD_Merc*rho;\n",
      "dP  =  0.5*rho_Oil*(V2**2-V1**2)  +  rho_Oil*g*dZ;\n",
      "h  =  rho_Oil  *(  dP/(rho_Oil*g)-  dZ)/(rho_Man  -  rho_Oil);\n",
      "\n",
      "print \"Pressure Difference(N/m2) : \",round(dP,0)\n",
      "print \"Difference in the level of mercury (m):\",round(h,3)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Pressure Difference(N/m2) :  39484.0\n",
        "Difference in the level of mercury (m): 0.217\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.3, Page 187"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "import math\n",
      "\n",
      "\n",
      " #Initializing  the  variables  \n",
      "d1  =  0.25;                                                            #Pipeline  diameter\n",
      "d2  =  0.10;                                                            #Throat  diameter\n",
      "h  =0.63;                                                                #Difference  in  height\n",
      "rho  =  1000;                                                          #Density  of  water\n",
      "g  =  9.81                                                                #Acceleration  due  to  gravity\n",
      "\n",
      " #Calculations\n",
      "rho_Hg  =  13.6*rho;\n",
      "rho_Oil  =  0.9*rho;\n",
      "A1  =  (math.pi*d1**2)/4;                                            #  Area  at  entry\n",
      "m  =  (d1/d2)**2;                                                    #Area  ratio\n",
      "Q  =  (A1/(m**2-1)**0.5)*(2*g*h*(rho_Hg/rho_Oil  -1))**0.5;\n",
      "\n",
      "print \"Thepretical Volume flow rate (m3/s ):\",round(Q,3)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Thepretical Volume flow rate (m3/s ): 0.105\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.4, Page 190"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "import math\n",
      "\n",
      "\n",
      " #Initializing  the  variables  \n",
      "\n",
      "x  =  1.5;\n",
      "y  =0.5;\n",
      "H  =  1.2;\n",
      "A  =  650*10**-6;\n",
      "Q  =0.117;\n",
      "g  =  9.81;\n",
      "\n",
      " #Calculations\n",
      "Cv  =(x**2/(4*y*H))**0.5;\n",
      "Cd  =  Q  /  (60*A*(2*g*H)**0.5);\n",
      "Cc  =  Cd/Cv;\n",
      "\n",
      "\n",
      "print \"Coefficient of velocity :\",round(Cv,3)\n",
      "print \"Coefficient of Discharge :\",round(Cd,3)\n",
      "print \"Coefficient of contraction :\",round(Cc,3)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Coefficient of velocity : 0.968\n",
        "Coefficient of Discharge : 0.618\n",
        "Coefficient of contraction : 0.639\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.5, Page 192"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "import math\n",
      "\n",
      "\n",
      " #Initializing  the  variables  \n",
      "B  =  0.7;\n",
      "H1  =  0.4;\n",
      "H2  =  1.9;\n",
      "g  =9.81;\n",
      "z  =  1.5  ;                                                              #  height  of  opening\n",
      "\n",
      " #Calculations\n",
      "Q_Th  =  2/3  *B*(2*g)**0.5*(H2**1.5  -  H1**1.5);\n",
      "A  =  z*B;\n",
      "h  =  0.5*(H1+H2);\n",
      "Q  =  A*(2*g*h)**0.5;\n",
      "\n",
      "print \"Percentage error in discharge (%):\",round((Q-Q_Th)*100/Q_Th,2)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Percentage error in discharge (%): 1.98\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.6, Page 195"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "import math\n",
      "\n",
      "\n",
      " #Initializing  the  variables  \n",
      "Cd  =  0.6;                                                              #Coefficient  of  discharge\n",
      "Q  =  0.28;\n",
      "x  =  90;                                                                  #Theta\n",
      "g  =  9.81;\n",
      "dH  =  0.0015;\n",
      "\n",
      " #Calculations\n",
      "H  =  (Q*(15/8)/(Cd*(2*g)**0.5*math.tan(math.radians(x/2))))**(2/5)\n",
      "Frac_Q  =  5/2  *(  dH/H);\n",
      "\n",
      "print \"Percentage error in discharge(%)\",round(Frac_Q*100,2)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Percentage error in discharge(%) 0.72\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.7, Page 196"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "import math\n",
      "\n",
      "\n",
      " #Initializing  the  variables  \n",
      "B  =  0.9;\n",
      "H  =  0.25;\n",
      "alpha  =  1.1;\n",
      "g  =  9.81;  \n",
      "\n",
      " #Calculations\n",
      "Q  =  1.84  *  B  *  H**(3/2);\n",
      "print \"Q(m3/s) :\",Q\n",
      "\n",
      "i  =  1;\n",
      "while(i  <= 3):\n",
      "    v  =  Q  /(1.2*  (H+0.2));\n",
      "    print \"V(m/s) :\",round(v,4)\n",
      "    k  =    ((1  +  alpha*v**2/(2*g*H))**1.5  -(alpha*v**2/(2*g*H))**1.5  );\n",
      "    Q  =  k*  1.84  *  B  *  H**(3/2);\n",
      "    print \"Q(m3/s) :\",round(Q,4)\n",
      "    i  =  i+1;\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Q(m3/s) : 0.207\n",
        "V(m/s) : 0.3833\n",
        "Q(m3/s) : 0.2161\n",
        "V(m/s) : 0.4001\n",
        "Q(m3/s) : 0.2168\n",
        "V(m/s) : 0.4016\n",
        "Q(m3/s) : 0.2169\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.8, Page 197"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "import math\n",
      "\n",
      "\n",
      " #Initializing  the  variables  \n",
      "rho  =  1000;\n",
      "v  =  66  ;\n",
      "Q  =  0.13;\n",
      "g  =  9.81;  \n",
      "z  =240;\n",
      "\n",
      " #Calculations\n",
      "P_Jet  =    0.5*rho*v**2*Q;\n",
      "P_Supp  =  rho*g*Q*z;\n",
      "P_Lost  =    P_Supp  -P_Jet;\n",
      "h  =  P_Lost/(rho*g*Q);\n",
      "eff  =  P_Jet/P_Supp;\n",
      "\n",
      "print \"Part(a) - power of the jet(kW):                  \",round(P_Jet/1000,2)\n",
      "print \"Part(b) - power supplied from the reservoir (kW):\",round(P_Supp/1000,2) \n",
      "print \"Part(C) - head used to overcome losses (m):      \",round(h,2)\n",
      "print \"Part(d) - Efficiency(%) :                        \",round(eff*100,1)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Part(a) - power of the jet(kW):                   283.14\n",
        "Part(b) - power supplied from the reservoir (kW): 306.07\n",
        "Part(C) - head used to overcome losses (m):       17.98\n",
        "Part(d) - Efficiency(%) :                         92.5\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.9, Page 203"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "import math\n",
      "from scipy import integrate\n",
      "\n",
      " #Initializing  the  variables  \n",
      "r1  =  0.2;\n",
      "Z1  =  0.500;\n",
      "Z2  =  0.340;\n",
      "g  =  9.81;\n",
      "rho  =  0.9*1000  ;\n",
      "\n",
      " #Calculations\n",
      "r0  =  r1*((2-2*Z2/Z1)**0.5);\n",
      "omega  =   round((2*g*Z1/r0**2)**0.5,1)\n",
      "\n",
      "def G(r):\n",
      "    out  =r**3  -  r*r0**2;\n",
      "    return out\n",
      "    \n",
      "results = integrate.quad(G, r0, r1)\n",
      "\n",
      "F  =  rho*omega**2*math.pi*results[0];\n",
      "\n",
      "print r0,r1\n",
      "print \"Part(a) Speed of rotation (rad/s ):\",round(omega,1)\n",
      "print \"Part(b) Upward force on the cover (N): \",round(F,1)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "0.16 0.2\n",
        "Part(a) Speed of rotation (rad/s ): 19.6\n",
        "Part(b) Upward force on the cover (N):  56.3\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.10, Page 206"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "import math\n",
      "\n",
      "\n",
      " #Initializing  the  variables  \n",
      "Ra  =  0.2;\n",
      "Rb  =  0.1;\n",
      "H  =  0.18;\n",
      "Za  =  0.125;\n",
      "\n",
      " #Calculations\n",
      "Y  =    Ra**2*(H-Za);\n",
      "Zb  =  H  -  Y/Rb**2;\n",
      "\n",
      "print \"Height above datum of a point B on the free surface at a radius of 100 mm (mm):\",Zb*1000"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Height above datum of a point B on the free surface at a radius of 100 mm (mm): -40.0\n"
       ]
      }
     ],
     "prompt_number": 10
    }
   ],
   "metadata": {}
  }
 ]
}