{
 "metadata": {
  "name": "",
  "signature": "sha256:086f4825fb4b8e83d4ca795bc6e4859da294b353e111bb33a89148489ab4ef6c"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 2 : Work, Energy and Heat"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.2  Page No : 62"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given\n",
      "k = 100; \t\t\t# Unit:lbf/in. \t\t\t#k = spring constant\n",
      "l = 2; \t\t\t#Unit:inch \t\t\t#l =  length of compression of string\n",
      "\n",
      "# Calculations\n",
      "work = (1./2)*k*l**2; \t\t\t#force-print lacement relation \t\t\t#Unit:in*lbf\n",
      "\n",
      "# Results\n",
      "print \"Workdone is %.2f inch*lbf\"%(work);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Workdone is 200.00 inch*lbf\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.3  Page No : 62"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given\n",
      "k = 20*1000; \t\t\t# Unit:N/m  \t\t\t#k = 20kN \t\t\t#k = spring constant\n",
      "l = 0.075; \t\t\t#Unit:meter  \t\t\t#l = 75 mm \t\t\t#l =  length of compression of string\n",
      "\n",
      "# Calculations\n",
      "work = (1./2)*k*l**2; \t\t\t#force-print lacement relation \t\t\t#Unit:N*m\n",
      "\n",
      "# Results\n",
      "print \"Workdone is %.2f Jule\"%(work);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Workdone is 56.25 Jule\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.4  Page No : 66"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Given\n",
      "Z = 600; \t\t\t#Unit:ft \t\t\t#Z = The dismath.tance,the body is raised from its initial position when the force is applied\n",
      "gc = 32.174; \t\t\t#Unit: (lbm*ft)/(lbf*s**2) \t\t\t#gc is constant of proportionality\n",
      "g = gc; \t\t\t#Unit:ft/s**2 \t\t\t#g = The local gravity\n",
      "m = 1.; \t\t\t#Unit:lbm \t\t\t#m = mass\n",
      "\n",
      "# Calculations\n",
      "PE = (m*g*Z)/gc; \t\t\t#potential energy \t\t\t#Unit:ft*lbf\n",
      "\n",
      "# Results\n",
      "print \"%.2f ft*lbf work is done lifting the water to elevation \"%(PE)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "600.00 ft*lbf work is done lifting the water to elevation \n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.5  Page No : 66"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given value\n",
      "m = 1; \t\t\t#Unit:kg \t\t\t#m = mass\n",
      "g =  9.81 \t\t\t#Unit:m/s**2 \t\t\t#g = The local gravity\n",
      "Z = 50 \t\t\t#Unit:m \t\t\t#\t\t\t#Z = The dismath.tance,the body is raised from its initial position when the force is applied \t\t\t#In this case Z = delivered water from well to pump\n",
      "\n",
      "# Calculations\n",
      "PE = m*g*Z; \t\t\t#PE = Potential Energy \t\t\t#Unit:Joule\n",
      "\n",
      "# Results\n",
      "print \"Change in potential energy per kg of water is %.2f J \"%(PE); \t\t\t#J = Joule = N*m = kg*m**2/s**2\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Change in potential energy per kg of water is 490.50 J \n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.6  Page No : 66"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given value\n",
      "Rho = 62.4; \t\t\t#Unit:lbm/ft**3 \t\t\t#Rho = The density of water\n",
      "A = 10000; \t\t\t#Flow = 10000; gal/min\n",
      "V = (231./1728); \t\t\t# 12 inch = 1 ft \t\t\t#So,1 ft**3 = 1728 in**3  \t\t\t# One Gallon is a volumetric measure equal to 231 in**3\n",
      "#A*V \t\t\t#Unit:ft**3/min\n",
      "\n",
      "#In example, 2.4:\n",
      "#  From example 2.4\n",
      "Z = 600; \t\t\t#Unit:ft \t\t\t#Z = The dismath.tance,the body is raised from its initial position when the force is applied\n",
      "gc = 32.174; \t\t\t#Unit: (lbm*ft)/(lbf*s**2) \t\t\t#gc is constant of proportionality\n",
      "g = gc; \t\t\t#Unit:ft/s**2 \t\t\t#g = The local gravity\n",
      "m = 1; \t\t\t#Unit:lbm \t\t\t#m = mass\n",
      "\n",
      "# Calculations and Results\n",
      "PE = (m*g*Z)/gc; \t\t\t#potential energy \t\t\t#Unit:ft*lbf\n",
      "print \"%.2f ft*lbf work is done lifting the water to elevation \"%(PE);\n",
      "\n",
      "#So,\n",
      "# In example 2.5\n",
      "M = Rho*A*V; \t\t\t#M = the mass flow\n",
      "Power = M*PE; \t\t\t#Unit:ft*lbf/lbm\n",
      "print \"Generated Power is %.2f ft*lbf/lbm \"%(Power);\n",
      "# 1 horsepower  =  33,000 ft*lbf/min\n",
      "print \"Power  =  %.2f hp\"%(Power/33000);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "600.00 ft*lbf work is done lifting the water to elevation \n",
        "Generated Power is 50050000.00 ft*lbf/lbm \n",
        "Power  =  1516.67 hp\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.7  Page No : 67"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "print \"In problem 2.5\";\n",
      "m = 1; \t\t\t#Unit:kg \t\t\t#m = mass\n",
      "g =  9.81 \t\t\t#Unit:m/s**2 \t\t\t#g = The local gravity\n",
      "Z = 50 \t\t\t#Unit:m \t\t\t#\t\t\t#Z = The dismath.tance,the body is raised from its initial position when the force is applied \t\t\t#In this case Z = delivered water from well to pump\n",
      "\n",
      "# Calculations and Results\n",
      "PE = m*g*Z; \t\t\t#PE = Potential Energy \t\t\t#Unit:Joule\n",
      "print \"Change in potential energy per kg of water is %.2f J \"%(PE); \t\t\t#J = Joule = N*m = kg*m**2/s**2\n",
      "#Given data in problem 2.7 is\n",
      "M = 1000; \t\t\t#Unit;kg/min\t\t\t#M = Water density \n",
      "Power = PE*M*(1./60); \t\t\t#1 min = 60 seconds \t\t\t#power \t\t\t#unit:Joule/s = W\n",
      "print \"Power is %.2f Watt\"%(Power); \t\t\t#Watt = N*m/s  =  Joule/s  = Watt\n",
      "#1 Hp = 746 Watt\n",
      "print \"Power is %.2f Horsepower\"%(Power/745);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "In problem 2.5\n",
        "Change in potential energy per kg of water is 490.50 J \n",
        "Power is 8175.00 Watt\n",
        "Power is 10.97 Horsepower\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.8  Page No : 69"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "m = 10.; \t\t\t#Unit:lb \t\t\t#m = Mass\n",
      "V1 = 88.; \t\t\t#Unit:\t\t\t#ft/s V1 = Velocity before it is slowed down\n",
      "V2 = 10.; \t\t\t#Unit;ft/s \t\t\t#V2 = Velocity after it is slowed down\n",
      "gc = 32.174; \t\t\t#Unit: (lbm*ft)/(lbf*s**2) \t\t\t#gc is constant of proportionality\n",
      "\n",
      "# Calculations and Results\n",
      "KE1 = m*V1**2/(2*gc); \t\t\t#The kinetic energy of the body before it is slowed down \t\t\t#Unit:ft*lbf\n",
      "print \"The kinetic energy of the body before it is slowed down is %.2f ft*lbf\"%(KE1);\n",
      "\n",
      "KE2 = m*V2**2/(2*gc); \t\t\t#The kinetic energy of the body before it is slowed down \t\t\t#Unit:ft*lbf\n",
      "print \"The kinetic energy of the body before it is slowed down is %.2f ft*lbf\"%(KE2);\n",
      "\n",
      "KE = KE1-KE2; \t\t\t#KE = Change in kinetic energy \t\t\t#Unit:ft*lbf\n",
      "print \"Change in kinetic energy is %.2f ft*lbf\"%(KE);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The kinetic energy of the body before it is slowed down is 1203.46 ft*lbf\n",
        "The kinetic energy of the body before it is slowed down is 15.54 ft*lbf\n",
        "Change in kinetic energy is 1187.92 ft*lbf\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.9  Page No : 70"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given value\n",
      "m = 1500.; \t\t\t#Unit:kg \t\t\t#m = mass\n",
      "V1 = 50.; \t\t\t#Km/hour V1 = Velocity before it is slowed down\n",
      "#V1 = (50*1000 m/hour)**2/(3600 s/hour)**2 \n",
      "\n",
      "# Calculations\n",
      "KE1 = (m*(V1*1000)**2/3600**2)/2; \t\t\t#KE1 = Initial kinetic energy \t\t\t#Unit:Joule\n",
      "\n",
      "#After slowing down\n",
      "V2 = 30; \t\t\t#Unit:KM/hour \t\t\t#V2 = Velocity after it is slowed down\n",
      "#V2 = (30*1000 m/hour)**2/(3600 s/hour)**2 \n",
      "KE2 = (m*(V2*1000)**2/3600**2)/2; \t\t\t#KE2 = After slowing down, the kinetic energy \t\t\t#Unit:Joule\n",
      "\n",
      "KE = KE1-KE2; \t\t\t#KE = Change in kinetic energy \t\t\t#Unit:Joule\n",
      "\n",
      "# Results\n",
      "print \"Change in kinetic energy is %.2f kJ\"%(KE/1000);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Change in kinetic energy is 92.59 kJ\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.10  Page No : 70"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "m = 10 \t\t\t#Unit:kg \t\t\t#m = mass\n",
      "Z = 10 \t\t\t#Unit:m \t\t\t#Z = The dismath.tance,the body is raised from its initial position when the force is applied\n",
      "g =  9.81 \t\t\t#Unit:m/s**2 \t\t\t#g = The local gravity\n",
      "#There are no losses in the system\n",
      "#So,initial potential energy plus initial kinetic energy equal to sum of final potential energy plus final kinetic energy\n",
      "#So, PE1+KE1 = PE2+KE2\n",
      "#From the figure,KE1 = 0; PE2 = 0;\n",
      "#So,PE1 = KE2;\n",
      "\n",
      "# Calculations and Results\n",
      "PE1 = m*g*Z; \t\t\t#PE = Potential Energy \t\t\t#Unit:Joule\n",
      "#KE2 = (m*v**2)/2\n",
      "v = (PE1*2)/m; \n",
      "V = math.sqrt(v); \t\t\t#Unit:m/s \t\t\t#velocity \n",
      "print \"Velocity  =  %.2f m/s\"%(V);\n",
      "KE2 = PE1; \t\t\t#kinetic energy \t\t\t#Unit:Joule\n",
      "print \"Kinetic energy is %.2f N*m\"%(PE1);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Velocity  =  14.01 m/s\n",
        "Kinetic energy is 981.00 N*m\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.11  Page No : 74"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "p1 = 100.; \t\t\t#pressure at the enmath.tance \t\t\t#Unit:psia,lbf/in**2\n",
      "Rho1 = 62.4; \t\t\t#Unit:lbm/ft**3  \t\t\t#Rho = The density\n",
      "v1 = 144.*(1/Rho1) \t\t\t#Specific Volume at entrance or reciprocal of fluid density \t\t\t# 144 in**2 = 1 ft**2\n",
      "#1 Btu  =  778 ft*lbf \n",
      "J = 778.; \t\t\t#Unit:ft*lbf/Btu \t\t\t#conversion factor\n",
      "\n",
      "# Calculations and Results\n",
      "FW1 = (p1*v1)/J; \t\t\t#Flow work  \t\t\t#Btu/lbm\n",
      "print \"Flow work  =  %.2f Btu/lbm\"%(FW1);\n",
      "\n",
      "print \"At the exit of device\"\n",
      "p2 = 50.; \t\t\t#pressure at the exit \t\t\t#Unit:psia,lbf/in**2\n",
      "Rho2 = 30.; \t\t\t#Unit:lbm/ft**3 \t\t\t#Rho = The density\n",
      "v2 = 144.*(1./Rho2) \t\t\t#Specific Volume at exit or reciprocal of fluid density \t\t\t# 144 in**2 = 1 ft**2\n",
      "#1 Btu  =  778 ft*lbf \n",
      "J = 778.; \t\t\t#Unit:ft*lbf/Btu \t\t\t#conversion factor\n",
      "FW2 = (p2*v2)/J; \t\t\t#Flow work \t\t\t#Btu/lbm\n",
      "print \"Flow work  =  %.2f Btu/lbm\"%(FW2);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Flow work  =  0.30 Btu/lbm\n",
        "At the exit of device\n",
        "Flow work  =  0.31 Btu/lbm\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.12  Page No : 75"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "print \"At the entrance of device\"\n",
      "p1 = 200*1000; \t\t\t#200kPa*1000 Pa/kPa  \t\t\t#pressure at the entrance \t\t\t#Unit:N/m**2\n",
      "Rho1 = 1000; \t\t\t#kg/m**3 \t\t\t#Fluid density at entrance\n",
      "v1 = 1./Rho1; \t\t\t#Specific Volume at entrance or reciprocal of fluid density\n",
      "FW1 = p1*v1; \t\t\t#Flow work at entrance \t\t\t#Unit:N*m/kg\n",
      "print \"Flow work  =  %.2fN*m/kg\"%(FW1);\n",
      "\n",
      "print \"At the exit of device\"\n",
      "p2 = 100*1000; \t\t\t#200kPa*1000 Pa/kPa  \t\t\t#pressure at the exit \t\t\t#Unit:N/m**2\n",
      "Rho2 = 250; \t\t\t#kg/m**3 \t\t\t#Fluid density at exit\n",
      "v2 = 1./Rho2; \t\t\t#Specific Volume at entrance or reciprocal of fluid density\n",
      "FW2 = p2*v2; \t\t\t#Flow work at exit\t\t\t#Unit:N*m/kg\n",
      "print \"Flow work  =  %.2f N*m/kg\"%(FW2);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "At the entrance of device\n",
        "Flow work  =  200.00N*m/kg\n",
        "At the exit of device\n",
        "Flow work  =  400.00 N*m/kg\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.14  Page No : 78"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#It is necessary that pressure be expressed as psfa when the volume is in cubic feet\n",
      "#100 psia  =  100*144 psfa\n",
      "p1 = 100*144; \t\t\t#Unit:psfa  \t\t\t#initial pressure\n",
      "v1 = 2; \t\t\t#Unit:ft**3/lb \t\t\t#Initial Specific Volume\n",
      "v2 = 1.; \t\t\t#Unit:ft**3/lb \t\t\t#Final Specific Volume\n",
      "\n",
      "# Calculations\n",
      "w = p1*v1*math.log(v2/v1); \t\t\t#work done on fluid \t\t\t#Unit:ft*lbf/lbm\n",
      "\n",
      "# Results\n",
      "print \"Work done on fluid  =  %.2f ft*lbf/lb\"%(w);\n",
      "#1 Btu  =  778 ft*lbf \n",
      "print \"Work done on the fluid per pound of fluid is %.2f Btu/lbm\"%(w/778);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Work done on fluid  =  -19962.64 ft*lbf/lb\n",
        "Work done on the fluid per pound of fluid is -25.66 Btu/lbm\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.15  Page No : 79"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "# Given value\n",
      "#p1*v1 = p2*v2\n",
      "p1 = 200.*1000; \t\t\t#p1 = Initial Pressure \t\t\t#Unit:Pa\n",
      "p2 = 800*1000; \t\t\t#p2 = Final Pressure \t\t\t#Unit:Pa\n",
      "v1 = 0.1; \t\t\t#v1 = Initial Special Volume \t\t\t#Unit:m**3/kg\n",
      "\n",
      "# Calculations\n",
      "v2 = (p1/p2)*v1; \t\t\t#v1 = final Special Volume \t\t\t#Unit:m**3/kg\n",
      "w = p1*v1*math.log(v2/v1); \t\t\t#workdone \t\t\t#Unit:kJ/kg\n",
      "\n",
      "# Results\n",
      "print \"Work done per kilogram of gas is %.2f kJ/kg into the system)\"%(w/1000);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Work done per kilogram of gas is -27.73 kJ/kg into the system)\n"
       ]
      }
     ],
     "prompt_number": 15
    }
   ],
   "metadata": {}
  }
 ]
}