{
 "metadata": {
  "name": "",
  "signature": "sha256:0997b77d100b3345365d77881e9dcf23833d271e3f7741c8fb4ad6c260c5ffc6"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 24: Positive Displacement Machines"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 24.1, Page 860"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "import math\n",
      "\n",
      " #Initializing  the  variables\n",
      "H_at  =  10.3;\n",
      "Hs  =  1.5;\n",
      "Hd  =  4.5;\n",
      "Ls  =  2;\n",
      "Ld  =  15;\n",
      "g  =  9.81;\n",
      "Ds  =  0.4;                                                              #  Diameter  of  stroke\n",
      "Db  =  0.15;                                                            #  Diameter  of  bore\n",
      "Dd  =  0.05;                                                            #  Diameter  of  discharge  and  suction  pipe\n",
      "nu  =  0.2;\n",
      "f  =  0.01;\n",
      "abs_pump_pressure  =  2.4;\n",
      "\n",
      " #Calculations\n",
      "A  =  math.pi*(Db)**2/4;\n",
      "a  =  math.pi*(Dd)**2/4;\n",
      "r  =  Ds/2;\n",
      "W  =  2*math.pi*nu;\n",
      "Hsf  =  0;  \n",
      "def  H_suck(n):\n",
      "    y  =  H_at  -  Hs  +(-1)**n*(L/g)*(A/a)*W**2*r;  \n",
      "    return y\n",
      "\n",
      "def  H(n,DischargeOrSuction):\n",
      "    if(DischargeOrSuction  ==  1):\n",
      "        y  =  H_at  -  Hs  +(-1)**n*(Ls/g)*(A/a)*W**2*r;\n",
      "    elif(DischargeOrSuction  ==  2):\n",
      "        y  =  H_at  +  Hd  +(-1)**n*(Ld/g)*(A/a)*W**2*r;\n",
      "    else:\n",
      "        print \"There  is  something  wrong  :\"\n",
      "    return y\n",
      "\n",
      "def  H_mid(DischargeOrSuction,uA):\n",
      "    if(DischargeOrSuction  ==  1):\n",
      "        Hsf  =  4*f*Ls/(2*Dd*g)*(uA/a)**2;\n",
      "        y  =  H_at  -  Hs  -  Hsf;\n",
      "    elif(DischargeOrSuction  ==  2):\n",
      "        Hsf  =  4*f*Ld/(2*Dd*g)*(uA/a)**2;\n",
      "        y  =  H_at  +  Hd  +  Hsf;\n",
      "    else:\n",
      "        print \"There  is  something  wrong  :\"\n",
      "    return y\n",
      "\n",
      "Hs_start  =  H(1,1);                #  Inertia  head  negative  hence  n  =  1\n",
      "Hs_end    =  H(2,1);                #  Inertia  head  positive  hence  n  =  2\n",
      "Hd_start  =  H(1,2);\n",
      "Hd_end    =  H(2,2);\n",
      "u  =  W*r;\n",
      "Hs_mid  =  H_mid(1,u*A);\n",
      "slip  =  0.04;\n",
      "Hd_mid  =  H_mid(2,u*A);\n",
      "suction   = [Hs_start,  Hs_end,  Hs_mid];\n",
      "discharge = [Hd_start,  Hd_end,  Hd_mid];\n",
      "suction1=[0,0,0]\n",
      "discharge1=[0,0,0]\n",
      "for c in range(3):\n",
      "    suction1[c]   =round(suction[c],2)\n",
      "    discharge1[c] =round(discharge[c],2)\n",
      "W_max  =  (abs((abs_pump_pressure  -  H_at  +  Hs)*(g/Ls)*(a/A)*(1/r)))**0.5;\n",
      "W_max_rev  =  W_max/(2*math.pi)*60;                      #  maximum  rotation  speed  in  rev/min\n",
      "\n",
      "header  =  \"Start   End   Mid\";\n",
      "\n",
      "print \"\\n!----Part(a)----!  Head at \\n\",header\n",
      "print suction1\n",
      "print \"\\n!----Part(b)----!  Head at \\n\",header\n",
      "print discharge1\n",
      "print \"\\n!----Part(c)----1 \\nDrive speed for s eperation (rev/min) :\",round(W_max_rev)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "!----Part(a)----!  Head at \n",
        "Start   End   Mid\n",
        "[8.22, 9.38, 8.38]\n",
        "\n",
        "!----Part(b)----!  Head at \n",
        "Start   End   Mid\n",
        "[10.45, 19.15, 17.93]\n",
        "\n",
        "!----Part(c)----1 \n",
        "Drive speed for s eperation (rev/min) : 40.0\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 24.2, Page 863"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "import math\n",
      "\n",
      " #Example  24.2  \n",
      "\n",
      " #Initializing  the  variables\n",
      "H_friction  =  2.4;\n",
      "H_at  =  10.3;\n",
      "Hs  =  1.5;\n",
      "L  =2;\n",
      "f  =  0.01;\n",
      "d  =  0.05;\n",
      "g  =  9.81;                                 #  Diameter  of  stroke\n",
      "Db  =  0.15;                                #  Diameter  of  bore\n",
      "r  =  0.2;\n",
      "\n",
      " #Calculations\n",
      "A  =  math.pi*(Db)**2/4;\n",
      "a  =  math.pi*(d)**2/4;\n",
      "W=  (((H_at  -  Hs  -    H_friction  )*(2*d*g/(4*f*L)))**0.5)*(a/A)*(math.pi/r); # in rad/s\n",
      "W_rev  =  W/(2*math.pi)*60;                 #  maximum  rotation  speed  in  rev/min\n",
      "# IMPORTANT : In book conversion from rad/s to rev/min is wrong, so answer will be diffrent from book\n",
      " \n",
      "print \"speed in          (rad/s)  :\",round(W,2)\n",
      "print \"Increase in speed (rev/min):\",round(W_rev-40,2)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "speed in          (rad/s)  : 15.46\n",
        "Increase in speed (rev/min): 107.65\n"
       ]
      }
     ],
     "prompt_number": 2
    }
   ],
   "metadata": {}
  }
 ]
}