{
 "metadata": {
  "name": "",
  "signature": "sha256:93240c9461961fb318dd0bfb1fd759f5d83f741dfd8a4a76ea2b51b81a776bec"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 1 :  Fundamentals"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.1 Page No : 8"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# variables\n",
      "T = 80.;\t\t#temperature of chlorine gas in degree F\n",
      "p = 100.;\t\t#pressure in psia\n",
      "W = 2*35.45;\t\t#molecular weight of chlorine \n",
      "\n",
      "# calculations \n",
      "R = 1545/W;\t\t#specific gas constant in ft-lb/lb-degreeR\n",
      "gam = p*(144/R)*(1/(460+T));\t\t#specific weight of chlorine in lb/cuft\n",
      "Spec_vol = 1/gam;\t\t#specific volume in cuft/lb\n",
      "rho = gam/32.2;\t\t#density of chlorine in slug/cuft\n",
      "\n",
      "# results \n",
      "print 'Specific weight = %.3f lb/cuft \\nSpecific volume = %.3f cuft/lb \\ndensity = %.4f slug/cuft'%(gam,Spec_vol,rho);"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Specific weight = 1.224 lb/cuft \n",
        "Specific volume = 0.817 cuft/lb \n",
        "density = 0.0380 slug/cuft\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.2 Page No : 12"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "\n",
      "# variables\n",
      "gamma = 1.4;\n",
      "T1 = 60.;\t\t#temperature of air in degree F\n",
      "p1 = 14.7;\t\t#pressure in psia\n",
      "k = 0.5;\t\t#(final volume/initial volume) = k\n",
      "R = 53.3;\t\t#Engineering gas constant\n",
      "\n",
      "# calculations \n",
      "gam1 = p1*(144/R)*(1/(460+T1));\t\t#lb/cuft\n",
      "gam2 = gam1/k;\t\t#lb/cuft\n",
      "p2 = (p1/(gam1**(gamma)))*(gam2**(gamma));\t\t# in psia\n",
      "T2 = p2*(144/R)*(1/gam2);\t\t#in degree F\n",
      "a1 = math.sqrt(gamma*32.2*R*(460+T1));\t\t# in fps\n",
      "a2 = math.sqrt(gamma*32.2*R*(T2));\t\t# in fps\n",
      "\n",
      "# results \n",
      "print 'Final pressure = %.1f psia \\\n",
      "\\nFinal temperature = %d degreeR  \\\n",
      "\\nSonic velocity before compression = %d fps \\\n",
      "\\nSonic velocity after compression = %.f fps'%(p2,T2,a1,a2);\n",
      "\n",
      "#the answers differ due to rounding-off errors"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "0.152749314475\n",
        "Final pressure = 38.8 psia \n",
        "Final temperature = 686 degreeR  \n",
        "Sonic velocity before compression = 1117 fps \n",
        "Sonic velocity after compression = 1284 fps\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.3 Page No : 17"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "from scipy.integrate import quad \n",
      "\n",
      "# variables\n",
      "r1 = 0.25;\t\t# radius of cylinder in feet\n",
      "l = 2.;\t    \t#length of cylnider in feet\n",
      "r2 = 0.30;\t\t# radius of co-axial cylinder in feet\n",
      "mu = 0.018;\t\t#lb-sec/ft**2\n",
      "torque = 0.25;\t\t# in ft-lb\n",
      "dv_dy1 = torque/(4*math.pi*mu*r1**2);\t\t#velocity gradient at radius = 0.25 in fps/ft\n",
      "dv_dy2 = torque/(4*math.pi*mu*r2**2);\t\t#velocity gradient at radius = 0.30 in fps/ft\n",
      "\n",
      "# calculations \n",
      "def f4(r): \n",
      "\t return -torque/(4*math.pi*mu*r**2)\n",
      "\n",
      "V1 =  quad(f4,r2,r1)[0]\n",
      "\n",
      "rpm1 = V1*60/(2*math.pi*r1);\n",
      "V2 = torque*(r2-r1)/(4*math.pi*mu*r1**2);\t\t#in fps\n",
      "rpm2 = V2*60/(2*math.pi*r1);\n",
      "hp = 2*math.pi*r1*(rpm1/(550*60));\n",
      "\n",
      "# results \n",
      "print 'Velocity gradient at the inner cylinder wall is %.1f fps/ft and at the outer cylinder wall is %.1f fps/ft'%(dv_dy1,dv_dy2);\n",
      "print 'rpm = %.1f  and approximate rpm = %.1f,  hp = %.5f '%(rpm1,rpm2,hp);"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Velocity gradient at the inner cylinder wall is 17.7 fps/ft and at the outer cylinder wall is 12.3 fps/ft\n",
        "rpm = 28.1  and approximate rpm = 33.8,  hp = 0.00134 \n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.4 Page No : 20"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# variables\n",
      "T = 70.     \t\t#degreeF\n",
      "del_p = 0.1;\t\t# in psi\n",
      "sigma = 0.00498;\t\t# lb/ft\n",
      "\n",
      "# calculations \n",
      "R = (sigma*2)/(del_p*144);\t\t#in ft\n",
      "d = 12*2*R;\t\t# in inches\n",
      "\n",
      "# results \n",
      "print 'Diameter of the droplet of water = %.4f in'%(d);"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Diameter of the droplet of water = 0.0166 in\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.5 Page No : 20"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "\n",
      "# variables\n",
      "l = 12.;\t\t# length of the cylinder\n",
      "T = 150.;\t\t#temperature of water in degreeF\n",
      "p1 = 14.52;\t\t#atmospheric pressure in psia\n",
      "p2 = 3.72;\t\t#the pressure on the inside of the piston in psia\n",
      "\n",
      "# calculations \n",
      "F = 0.25*(p1-p2)*math.pi*l**2;\t\t#Force on the piston in lb\n",
      "\n",
      "# results \n",
      "print 'Minimum force on the piston to be applied is, F = %d lb'%(F);\n",
      "\n",
      "#incorrect answer given in textbook"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Minimum force on the piston to be applied is, F = 1221 lb\n"
       ]
      }
     ],
     "prompt_number": 12
    }
   ],
   "metadata": {}
  }
 ]
}