{
 "metadata": {
  "name": "",
  "signature": "sha256:d3fc279744b60850d5797d14855414b40de2e09f4541a34684deba85c06170cf"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 3 : The First Law of Thermodynamics"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.1  Page No : 91"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#For a constant volume process, 10 Btu/lbm heat is added to the system\n",
      "#We can consider thet a math.tank having a fixed volume has heat added to it\n",
      "#Under these conditions,the mechanical work done on or by the system must be 0\n",
      "#u2-u1 = q\n",
      "print \"Heat has been converted to internal energy of the working fluid\";\n",
      "#So,\n",
      "print \" So,Change in internal energy u2-u1 = 10 Btu/Lbm\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Heat has been converted to internal energy of the working fluid\n",
        " So,Change in internal energy u2-u1 = 10 Btu/Lbm\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.4  Page No : 91"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "print \"Solution For a\";\n",
      "m = 10; \t\t\t#Unit:lbm \t\t\t#mass of water\n",
      "#delataU = U2-U1\n",
      "Heat = 100.; \t\t\t#Unit:Btu \t\t\t#heat added\n",
      "deltaU = Heat/m; \t\t\t#Change in internal energy  \t\t\t#unit:Btu/lbm\n",
      "print \"Change in internal energy per pound of water is %.2f Btu/lbm\"%(deltaU);\n",
      "\n",
      "print \"Solution For b\";\n",
      "print \"In this process,energy crosses the boundary of the system by means of fractional work\"\n",
      "print \"The contents of the math.tank will not distinguish between the energy if it is added as\\\n",
      " heat or the energy added as fraction work\";\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Solution For a\n",
        "Change in internal energy per pound of water is 10.00 Btu/lbm\n",
        "Solution For b\n",
        "In this process,energy crosses the boundary of the system by means of fractional work\n",
        "The contents of the math.tank will not distinguish between the energy if it is added as heat or the energy added as fraction work\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.5  Page No : 96"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given value\n",
      "P1 = 100 \t\t\t#Unit:psia \t\t\t#Pressure at the entrance to a steady-flow device\n",
      "Rho1 = 62.4 \t\t\t#Unit:lbm/ft**3 \t\t\t#the density of the fluid\n",
      "A1V1 = 10000 \t\t\t#Unit:ft**3/min \t\t\t#Entering fluid\n",
      "A2 = 2 \t\t\t#Unit:ft**2 \t\t\t#Exit area\n",
      "\n",
      "# Calculations and Results\n",
      "m = Rho1*A1V1; \t\t\t#Unit:lbm/min \t\t\t#mass rate of flow per unit time\n",
      "print \"Mass flow rate is %.2f LBm/min\"%(m);\n",
      "\n",
      "Rho2 = Rho1; \t\t\t#Unit:lbm/ft**3 \t\t\t#the density of the fluid\n",
      "#m = Rho2*A2*V2\n",
      "#So,\n",
      "V2 = m/(Rho2*A2); \t\t\t#velocity at exit \t\t\t#Unit:ft/min\n",
      "print \"The exit velocity is %.2f ft/min\"%(V2);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Mass flow rate is 624000.00 LBm/min\n",
        "The exit velocity is 5000.00 ft/min\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.6  Page No : 97"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given value\n",
      "Rho1 = 1000. \t\t\t#Unit:kg/m**3 \t\t\t#the density of the fluid at entrance\n",
      "A1V1 = 2000 \t\t\t#Unit:m**3/min \t\t\t#Entering fluid\n",
      "A2 = 0.5 \t\t\t#Unit:ft**2 \t\t\t#Exit area\n",
      "\n",
      "# Calculations and Results\n",
      "m = Rho1*A1V1; \t\t\t#Unit:kg/min \t\t\t#mass rate of flow per unit time\n",
      "print \"Mass flow rate is %.2f kg/min\"%(m);\n",
      "\n",
      "Rho2 = Rho1; \t\t\t#Unit:kg/m**3 \t\t\t#the density of the fluid at exit\n",
      "#m = Rho2*A2*V2\n",
      "#So,\n",
      "V2 = m/(Rho2*A2); \t\t\t#The exit velocity \t\t\t#Unit:m/min\n",
      "print \"The exit velocity is %.2f m/min\"%(V2);"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Mass flow rate is 2000000.00 kg/min\n",
        "The exit velocity is 4000.00 m/min\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.7  Page No : 97"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "# Given value\n",
      "Rho = 62.4 \t\t\t#Unit:lbm/ft**3 \t\t\t#the density of the fluid\n",
      "V = 100 \t\t\t#Unit:ft/s \t\t\t#Velocity of fluid\n",
      "d = 1 \t\t\t#Unit:in \t\t\t#Diameter\n",
      "\n",
      "# Calculations\n",
      "#1 ft**2 = 144 in**2 \t\t\t#A = (math.pi/4)*d**2\n",
      "A = (math.pi*d**2)/(4*144) \t\t\t#Unit:ft**2 \t\t\t#area \n",
      "m = Rho*A*V; \t\t\t#Unit:lbm/s \t\t\t#mass rate of flow per unit time\n",
      "\n",
      "# Results\n",
      "print \"Mass flow rate is %.2f lbm/s\"%(m);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Mass flow rate is 34.03 lbm/s\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.8  Page No : 98"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "# Given value\n",
      "m1 = 50000.; \t\t\t#Unit:LBm/hr \t\t\t#An inlet steam flow\n",
      "v1 = 0.831 \t\t\t#Unit:ft**3/LBm \t\t\t#Specific volume of inlet steam\n",
      "d1 = 6.  \t\t\t#Unit:in \t\t\t#Inlet diameter\n",
      "\n",
      "# Calculations and Results\n",
      "A1 = (math.pi*d1**2)/(4*144) \t\t\t#1 ft**2 = 144 in**2 \t\t\t#Entering area\n",
      "V1 = (m1*v1)/(A1*60*60) \t\t\t#(60 min/hr * 60 s/min) \t\t\t#To convert hours into seconds \t\t\t#velocity at inlet\n",
      "print \"The velocity at inlet is %.2f ft/s\"%(V1);\n",
      "\n",
      "\n",
      "m2 = m1; \t\t\t#Unit:LBm/hr \t\t\t#m2 = An outlet steam flow\n",
      "v2 = 1.825 \t\t\t#Unit:ft**3/LBm \t\t\t#Specific volume of outlet steam\n",
      "d2 = 8  \t\t\t#Unit:in \t\t\t#Outlet diameter\n",
      "A2 = (math.pi*d2**2)/(4*144) \t\t\t#1 ft**2 = 144 in**2 \t\t\t#Exit area\n",
      "V2 = (m1*v2)/(A2*60*60) \t\t\t#(60 min/hr * 60 s/min) \t\t\t#To convert hours into seconds \t\t\t#velocity at outlet\n",
      "print \"The velocity at outlet is %.2f ft/s\"%(V2);"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The velocity at inlet is 58.78 ft/s\n",
        "The velocity at outlet is 72.61 ft/s\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.9  Page No : 99"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "# Given value\n",
      "m1 = 10000; \t\t\t#Unit:kg/hr \t\t\t#An inlet steam flow\n",
      "v1 = 0.05 \t\t\t#Unit:m**3/kg \t\t\t#Specific volume of inlet steam\n",
      "d1 = 0.1  \t\t\t#Unit:m \t\t\t#Inlet diameter \t\t\t#100 mm  = 0.1 m\n",
      "\n",
      "# Calculations and Results\n",
      "A1 = (math.pi/4)*d1**2 \t\t\t#Unit:m**2 \t\t\t#Entering area\n",
      "V1 = (m1*v1)/(A1*60*60) \t\t\t#(60 min/hr * 60 s/min) \t\t\t#To convert hours into seconds \t\t\t#velocity at inlet \t\t\t#Unit:m/s\n",
      "print \"The velocity at inlet is %.2f m/s\"%(V1);\n",
      "\n",
      "\n",
      "m2 = m1; \t\t\t#Unit:kg/hr \t\t\t#m2 = An outlet steam flow\n",
      "v2 = 0.10 \t\t\t#Unit:m**3/kg \t\t\t#Specific volume of outlet steam\n",
      "d2 = 0.2  \t\t\t#Unit:m \t\t\t#Outlet diameter \t\t\t#200 mm  =  0.2 m\n",
      "A2 = (math.pi/4)*(d2**2) \t\t\t#Unit:m**2 \t\t\t#Exit area\n",
      "V2 = (m1*v2)/(A2*60*60) \t\t\t#(60 min/hr * 60 s/min) \t\t\t#To convert hours into seconds \t\t\t#velocity at outlet \t\t\t#Unit:m/s\n",
      "print \"The velocity at outlet is %.2f m/s\"%(V2);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The velocity at inlet is 17.68 m/s\n",
        "The velocity at outlet is 8.84 m/s\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.10  Page No : 105"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given value\n",
      "Cp = 0.22; \t\t\t#Unit:Btu/(LBm*R) \t\t\t#Specific heat for constant pressure process\n",
      "Cv = 0.17; \t\t\t#Unit:Btu/(LBm*R) \t\t\t#Specific heat for constant volume process\n",
      "q = 800./10; \t\t\t#data given:800 Btu as heat is added to 10 LBm \t\t\t#Unit:Btu/LBm\n",
      "T1 = 100; \t\t\t#Unit:Fahrenheit \t\t\t#Initial temperature \t\t\t#T2 = Final temperature\n",
      "\n",
      "# Calculations\n",
      "#For a non-flow,constant pressure process\n",
      "#q = deltah = h2-h1 = Cp(T2-T1) \t\t\t#deltah = change in enthalpy\n",
      "#deltaT = T2-T1;\n",
      "deltaT = q/Cp; \t\t\t#Fahrenheit  \t\t\t#change in temperature\n",
      "T2 = deltaT+T1; \t\t\t#Fahrenheit  \t\t\t#final temperature\n",
      "#For a constant volume pressure\n",
      "#u2-u1 = Change in internal energy \t\t\t#w = workdone\n",
      "#q-w = u2-u1\n",
      "#-w = (u2-u1)-q  =  Cv*(T2-T1)-q\n",
      "w = -(Cv*(T2-T1)-q); \t\t\t#Unit:Btu/lbm \t\t\t#workdone\n",
      "\n",
      "# Results\n",
      "print \"%.2f Btu/lbm work is taken out of the system due to workdone by gas\"%(w);\n",
      "print \"As there is 10 lbm in the system\"\n",
      "print \"%.2f Btu work is taken out of the system due to workdone by gas\"%(w*10);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "18.18 Btu/lbm work is taken out of the system due to workdone by gas\n",
        "As there is 10 lbm in the system\n",
        "181.82 Btu work is taken out of the system due to workdone by gas\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.11  Page No : 111"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "#Given data\n",
      "#                    Inlet     Outlet\n",
      "#Pressure(psia)      1000      1\n",
      "#Temperature(F)      1000      101.74\n",
      "#Velocity(ft/s)      125       430\n",
      "#Inlet position(ft)  +10       0\n",
      "#Enthalpy(Btu/LBm)   1505.4    940.0\n",
      "#Steam flow rate of 150000 LBm/hr\n",
      "\n",
      "#From the table,\n",
      "Z1 = 10; \n",
      "V1 = 125; \n",
      "h1 = 1505.4; \n",
      "Z2 = 0; \n",
      "V2 = 430; \n",
      "h2 = 940.0;\n",
      "\n",
      "#Energy equation is given by\n",
      "#((Z1/J)*(g/gc)) + (V1**2/(2*gc*J)) + h1 + q  =  ((Z2/J)*(g/gc)) + (V2**2/(2*gc*J)) + h2 + w/J\n",
      "print \"Solution for a \";\n",
      "q = 0; \t\t\t#net heat\n",
      "J = 778.; \t\t\t#Conversion factor\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",
      "#W1 = w/J;\n",
      "#Energy equation is given by\n",
      "W1 = ((Z1/J)*(g/gc)) + (V1**2/(2*gc*J)) + h1 + q - ((Z2/J)*(g/gc)) - (V2**2/(2*gc*J)) - h2; \t\t\t#Unit:Btu/LBm\n",
      "print \"If heat losses are negligible\"\n",
      "print \"Total work of the turbine is %.2f Btu/LBm\"%(W1);\n",
      "print \"Total work of the turbine is %.2f Btu/hr\"%(W1*150000); \n",
      "#(W*150000*778)/(60*33000) \t\t\t#in terms of horsepower  \t\t\t#1 hr = 60 min \t\t\t#1 hp = 33000 (ft*LBf)\n",
      "print \"Total work of the turbine is %.2f hp \"%(((W1*150000*778)/60*33000)); \n",
      "#1 hp  = 0.746 kW\n",
      "print \"Total work of the turbine is %.2f kW \"%((((W1*150000*778)/60*33000))*0.746);\n",
      "\n",
      "\n",
      "print \"Solution for b \";\n",
      "#Heat losses equal 50,000 Btu/hr\n",
      "q = 50000./150000; \t\t\t#Unit:Btu/LBm \t\t\t#Heat loss\n",
      "W2 = ((Z1/J)*(g/gc)) + (V1**2/(2*gc*J)) + h1 - q - ((Z2/J)*(g/gc)) - (V2**2/(2*gc*J)) - h2; \t\t\t#Unit:Btu/LBm\n",
      "print \"If heat losses equal 50,000 Btu/hr , Total work of the turbine is %.2f Btu/LBm\"%(W2);\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Solution for a \n",
        "If heat losses are negligible\n",
        "Total work of the turbine is 562.03 Btu/LBm\n",
        "Total work of the turbine is 84304739.48 Btu/hr\n",
        "Total work of the turbine is 36073998024056.70 hp \n",
        "Total work of the turbine is 26911202525946.29 kW \n",
        "Solution for b \n",
        "If heat losses equal 50,000 Btu/hr , Total work of the turbine is 561.70 Btu/LBm\n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.12  Page No : 112"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "Z1 = 2; \t\t\t#Unit:m \t\t\t#Inlet position\n",
      "g = 9.81 \t\t\t#Unit:m/s**2 \t\t\t#g = The local gravity\n",
      "V1 = 40; \t\t\t#Unit:m/s \t\t\t#Inlet velocity\n",
      "h1 = 3433.8; \t\t\t#Unit:kJ/kg \t\t\t#Inlet enthalpy\n",
      "q = 1 \t\t\t#Unit:kJ/kg \t\t\t#Heat losses\n",
      "Z2 = 0; \t\t\t#Outlet position \t\t\t#unit:m\n",
      "V2 = 162; \t\t\t#Unit:m/s \t\t\t#Outlet velocity\n",
      "h2 = 2675.5; \t\t\t#Unit:kJ/kg \t\t\t#Outlet enthalpy\n",
      "\n",
      "#Energy equation is given by\n",
      "#((Z1*g)) + (V1**2/2) + h1 + q  =  ((Z2*g) + (V2**2/2) + h2 + w\n",
      "\n",
      "w =  ((Z1*g)/1000) + ((V1**2/2)/1000) + h1 - q - ((Z2*g)/1000) - ((V2**2/2)/1000) - h2 ; \t\t\t#Unit:kJ/kg \t\t\t#Conersation: 1 kJ = 1000 J\n",
      "print \"The work output per kimath.logram is %.2f kJ/kg\"%(w);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The work output per kimath.logram is 744.32 kJ/kg\n"
       ]
      }
     ],
     "prompt_number": 15
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.13  Page No : 113"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "p1 = 150; \t\t\t#Unit:psia \t\t\t#Initial pressure\n",
      "T1 = 1000; \t\t\t#Unit:R \t\t\t#Temperature at pressure p1\n",
      "p2 = 15; \t\t\t#Unit:psia \t\t\t#Final pressure\n",
      "T2 = 600; \t\t\t#Unit:R \t\t\t#Temperature at pressure p2\n",
      "Cp = 0.24; \t\t\t#Unit:Btu/(LBm*R) \t\t\t#Specific heat for constant pressure process\n",
      "v1 = 2.47; \t\t\t#Unit:ft**3/LBm \t\t\t#Specific volume at inlet conditions\n",
      "v2 = 14.8; \t\t\t#Unit:ft**3/LBm \t\t\t#Specific volume at outlet conditions\n",
      "\n",
      "#For a non-flow,constant pressure process\n",
      "#w/J = deltah = h2-h1 = Cp(T2-T1) \t\t\t#deltah = change in enthalpy\n",
      "#W = w/J\n",
      "W = Cp*(T1-T2); \t\t\t#W = Work output \t\t\t#Unit:Btu/LBm\n",
      "\n",
      "# Results\n",
      "print \"The work output of the turbine per pound of working fluid is %.2f Btu/LBm\"%(W);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The work output of the turbine per pound of working fluid is 96.00 Btu/LBm\n"
       ]
      }
     ],
     "prompt_number": 16
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.14  Page No : 114"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#In problem 3.13 ,\n",
      "p1 = 150.; \t\t\t#Unit:psia \t\t\t#Initial pressure\n",
      "T1 = 1000.; \t\t\t#Unit:R \t\t\t#Temperature at pressure p1\n",
      "p2 = 15.; \t\t\t#Unit:psia \t\t\t#Final pressure\n",
      "T2 = 600.; \t\t\t#Unit:R \t\t\t#Temperature at pressure p2\n",
      "Cp = 0.24; \t\t\t#Unit:Btu/(LBm*R) \t\t\t#Specific heat for constant pressure process\n",
      "v1 = 2.47; \t\t\t#Unit:ft**3/LBm \t\t\t#Specific volume at inlet conditions\n",
      "v2 = 14.8; \t\t\t#Unit:ft**3/LBm \t\t\t#Specific volume at outlet conditions\n",
      "\n",
      "#For a non-flow,constant pressure process\n",
      "#w/J = deltah = h2-h1 = Cp(T2-T1) \t\t\t#deltah = change in enthalpy\n",
      "#W = w/J\n",
      "W = Cp*(T1-T2); \t\t\t#W = Work output \t\t\t#Unit:Btu/LBm \t\t\t#h2-h1\n",
      "print \"In problem 3.13, The work output of the turbine per pound of working fluid is %.2f Btu/LBm  \"%(W);\n",
      "\n",
      "#Now,In problem 3.14 , \n",
      "q = 1.1; \t\t\t#Unit:Btu/LBm \t\t\t#Heat losses\n",
      "#For a non-flow,constant pressure process\n",
      "#q-w/J = deltah = h2-h1 = Cp(T2-T1) \t\t\t#deltah = change in enthalpy\n",
      "#W1 = w/J\n",
      "W1 = -q+W; \t\t\t#W = Work output \t\t\t#Unit:Btu/LBm \t\t\t#W = h2-h1 \t\t\t#Because q  is out of the system,it is a negative quantity\n",
      "print \"In problem 3.14%(heat loss equal to 1.1 Btu/LBm\"\n",
      "print \"The work output of the turbine per pound of working fluid is %.2f Btu/LBm \"%(W1);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "In problem 3.13, The work output of the turbine per pound of working fluid is 96.00 Btu/LBm  \n",
        "In problem 3.14%(heat loss equal to 1.1 Btu/LBm\n",
        "The work output of the turbine per pound of working fluid is 94.90 Btu/LBm \n"
       ]
      }
     ],
     "prompt_number": 17
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.15  Page No : 115"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "p1 = 100.; \t\t\t#Unit:psia \t\t\t#Initial pressure\n",
      "t1 = 950.; \t\t\t#Unit:Fahrenheit \t\t\t#Temperature at pressure p1\n",
      "p2 = 76.; \t\t\t#Unit:psia \t\t\t#Final pressure\n",
      "t2 = 580.; \t\t\t#Unit:Fahrenheit \t\t\t#Temperature at pressure p2\n",
      "v1 = 4.; \t\t\t#Unit:ft**3/LBm \t\t\t#Specific volume at inlet conditions\n",
      "v2 = 3.86; \t\t\t#Unit:ft**3/LBm \t\t\t#Specific volume at outlet conditions\n",
      "Cv = 0.32; \t\t\t#Unit:Btu/(LBm*R) \t\t\t#Specific heat for constant volume process\n",
      "\n",
      "T1 = t1+460; \t\t\t#Unit:R \t\t\t#Temperature at pressure p1\n",
      "T2 = t2+460; \t\t\t#Unit:R \t\t\t#Temperature at pressure p2\n",
      "J = 778.; \t\t\t#J = Conversion factor\n",
      "\n",
      "#Z1 = Inlet position \t\t\t#Unit:m \n",
      "#V1 = Inlet velocity \t\t\t#Unit:m/s\n",
      "#Z2 = Outlet position \t\t\t#Unit:m \n",
      "#V2 = Outlet velocity Unit:m/s \n",
      "#u1 = internal energy \t\t\t#energy in\n",
      "#u2 = internal energy \t\t\t#energy out\n",
      "\n",
      "#Energy equation is given by\n",
      "#((Z1/J)*(g/gc)) + (V1**2/(2*gc*J)) + u1 + ((p1*v1)/J) + q  =  ((Z2/J)*(g/gc)) + (V2**2/(2*gc*J)) + u2 + ((p2*v2)/J) + w/J; \t\t\t#Unit:Btu/LBm\n",
      "#Because pipe is horizontal and velocity terms are to be neglected, \n",
      "# Also no work crosses the boundaries of the system, the energy equation is reduced to\n",
      "#u1 + ((p1*v1)/J) + q  =  u2 + ((p2*v2)/J)\n",
      "#u2-u1 = Cv*(T2-T1) \t\t\t#For a constant volume process \t\t\t#u2-u1 = Chnage in internal energy\n",
      "#So,\n",
      "q = Cv*(T2-T1) + (p2*v2*144)/J - (p1*v1*144)/J;  \t\t\t#q = heat transfer \t\t\t#1 ft**2 = 144 in**2 \t\t\t#Unit:Btu/LBm\n",
      "\n",
      "# Results\n",
      "print \"%.2f Btu/LBm heat is transferred from the gas \"%(q);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "-138.14 Btu/LBm heat is transferred from the gas \n"
       ]
      }
     ],
     "prompt_number": 18
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.16  Page No : 116"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#In problem 3.15,\n",
      "p1 = 100; \t\t\t#Unit:psia \t\t\t#Initial pressure\n",
      "t1 = 950; \t\t\t#Unit:Fahrenheit \t\t\t#Temperature at pressure p1\n",
      "p2 = 76; \t\t\t#Unit:psia \t\t\t#Final pressure\n",
      "t2 = 580; \t\t\t#Unit:Fahrenheit \t\t\t#Temperature at pressure p2\n",
      "v1 = 4; \t\t\t#Unit:ft**3/LBm \t\t\t#Specific volume at inlet conditions\n",
      "v2 = 3.86; \t\t\t#Unit:ft**3/LBm \t\t\t#Specific volume at outlet conditions\n",
      "Cv = 0.32; \t\t\t#Unit:Btu/(LBm*R) \t\t\t#Specific heat for constant volume process\n",
      "\n",
      "T1 = t1+460; \t\t\t#Unit:R \t\t\t#Temperature at pressure p1\n",
      "T2 = t2+460; \t\t\t#Unit:R \t\t\t#Temperature at pressure p2\n",
      "J = 778.; \t\t\t#J = Conversion factor\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",
      "\n",
      "#Z1 = Inlet position \t\t\t#Unit:m \n",
      "#V1 = Inlet velocity \t\t\t#Unit:m/s\n",
      "#Z2 = Outlet position \t\t\t#Unit:m \n",
      "#V2 = Outlet velocity Unit:m/s \n",
      "#u1 = internal energy \t\t\t#energy in\n",
      "#u2 = internal energy \t\t\t#energy out\n",
      "\n",
      "#Energy equation is given by\n",
      "#((Z1/J)*(g/gc)) + (V1**2/(2*gc*J)) + u1 + ((p1*v1)/J) + q  =  ((Z2/J)*(g/gc)) + (V2**2/(2*gc*J)) + u2 + ((p2*v2)/J) + w/J; \t\t\t#Unit:Btu/LBm\n",
      "#In 3.15, the elevation of the pipe at section 1 makes Z1  =  0\n",
      "# Also no work crosses the boundaries of the system, the energy equation is reduced to\n",
      "#u1 + ((p1*v1)/J) + q  =  u2 + ((p2*v2)/J) + ((Z2/J)*(g/gc))\n",
      "#In problrm 3.16,\n",
      "Z2 = 100; \t\t\t#Given \t\t\t#Unit:ft \t\t\t#Outlet position\n",
      "#u2-u1 = Cv*(T2-T1) \t\t\t#For a constant volume process \t\t\t#u2-u1 = Chnage in internal energy\n",
      "#So,\n",
      "q = Cv*(T2-T1) + (p2*v2*144)/J - (p1*v1*144)/J + ((Z2/J)*(g/gc)) ;  \t\t\t#q = heat transfer \t\t\t#1 ft**2 = 144 in**2 \t\t\t#Unit:Btu/LBm\n",
      "\n",
      "# Results\n",
      "print \"%.2f Btu/LBm heat is transferred from the gas \"%(q);\n",
      "#For this problem , neglecting the elevation term leads to an insignificant error\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "-138.01 Btu/LBm heat is transferred from the gas \n"
       ]
      }
     ],
     "prompt_number": 19
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.17  Page No : 117"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "p1 = 1000; \t\t\t#Unit:psia \t\t\t#Initial pressure\n",
      "t1 = 100;  \t\t\t#Unit:Fahrenheit \t\t\t#Temperature at pressure p1\n",
      "p2 = 1000; \t\t\t#Unit:psia \t\t\t#Final pressure\n",
      "t2 = 1000; \t\t\t#Unit:Fahrenheit \t\t\t#Temperature at pressure p2\n",
      "# feed in 10,000 LBm/hr \n",
      "h1 = 70.68  \t\t\t#Unit:Btu/LBm \t\t\t#Inlet enthalpy\n",
      "h2 = 1505.9 \t\t\t#Unit:Btu/LBm \t\t\t#Outlet enthalpy\n",
      "\n",
      "T1 = t1+460; \t\t\t#Unit:R \t\t\t#Temperature at pressure p1\n",
      "T2 = t2+460; \t\t\t#Unit:R \t\t\t#Temperature at pressure p2\n",
      "#Energy equation is given by\n",
      "J = 778; \t\t\t#J = Conversion factor\n",
      "\n",
      "#Z1 = Inlet position \t\t\t#Unit:m \n",
      "#V1 = Inlet velocity \t\t\t#Unit:m/s\n",
      "#Z2 = Outlet position \t\t\t#Unit:m \n",
      "#V2 = Outlet velocity Unit:m/s \n",
      "#u1 = internal energy \t\t\t#energy in\n",
      "#u2 = internal energy \t\t\t#energy out\n",
      "#h = enthalpy\n",
      "\n",
      "#Energy equation is given by\n",
      "#((Z1/J)*(g/gc)) + (V1**2/(2*gc*J)) + u1 + ((p1*v1)/J) + q  =  ((Z2/J)*(g/gc)) + (V2**2/(2*gc*J)) + u2 + ((p2*v2)/J) + w/J; \t\t\t#Unit:Btu/LBm\n",
      "\n",
      "#we can consider this system as a math.single unit with feed water entering ans steam leaving. \n",
      "#It well designed,this unit will be thoroughly insulated,and heat losse will be reduced to a negligible amount\n",
      "#Alos,no work will be added to the fluid during the time it is pasmath.sing through the unit, and kinetic energy differences will be assumed to be negligibly small\n",
      "#Differennces in elevation also be considered negligible\n",
      "#So,the energy equation is reduced to \n",
      "#u1 + ((p1*v1)/J) + q  =  u2 + ((p2*v2)/J)\n",
      "#Because h = u+(p*v/J)\n",
      "q = h2-h1; \t\t\t#q = net heat losses \t\t\t#Unit:Btu/LBm\n",
      "\n",
      "# Results\n",
      "print \"Net heat losses is %.2f Btu/LBm \"%(q);\n",
      "print \"For 10000 LBm/hr\"\n",
      "print \"%.2f Btu/hr energy has been added to the water to convert it to steam\"%(q*10000)\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Net heat losses is 1435.22 Btu/LBm \n",
        "For 10000 LBm/hr\n",
        "14352200.00 Btu/hr energy has been added to the water to convert it to steam\n"
       ]
      }
     ],
     "prompt_number": 20
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.18  Page No : 119"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "h1 = 1220  \t\t\t#Unit:Btu/LBm \t\t\t#Inlet enthalpy\n",
      "h2 = 1100 \t\t\t#Unit:Btu/LBm \t\t\t#Outlet enthalpy\n",
      "\n",
      "#Z1 = Inlet position \t\t\t#Unit:m \n",
      "#V1 = Inlet velocity \t\t\t#Unit:m/s\n",
      "#Z2 = Outlet position \t\t\t#Unit:m \n",
      "#V2 = Outlet velocity Unit:m/s \n",
      "#u1 = internal energy \t\t\t#energy in\n",
      "#u2 = internal energy \t\t\t#energy out\n",
      "J = 778; \t\t\t#J = Conversion factor\n",
      "gc = 32.174; \t\t\t#Unit: (LBm*ft)/(LBf*s**2) \t\t\t#gc is constant of proportionality\n",
      "\n",
      "#Energy equation is given by\n",
      "#((Z1/J)*(g/gc)) + (V1**2/(2*gc*J)) + u1 + ((p1*v1)/J) + q  =  ((Z2/J)*(g/gc)) + (V2**2/(2*gc*J)) + u2 + ((p2*v2)/J) + w/J; \t\t\t#Unit:Btu/LBm\n",
      "\n",
      "#For this device,differences in elevation are negligible.No work is done on or by the fluid,friction is negligible\n",
      "#And due to the speed of the fluid flowing and the short length of the nozzle,heat transfer to or from the surroundings is also negligible.\n",
      "#So,the energy equation is reduced to \n",
      "#u1 + ((p1*v1)/J) +(V1**2/(2*gc*J)   =  u2 + ((p2*v2)/J) + (V2**2/(2*gc*J)\n",
      "# h1-h2  =  ((V2**2-V1**2)/(2*gc*J))\n",
      "\n",
      "print \"Solution for a\";\n",
      "#For neglegible entering velocity, V1 = 0\n",
      "#So,\n",
      "V2 = math.sqrt((2*gc*J)*(h1-h2)); \t\t\t#the final velocity  \t\t\t#ft/s\n",
      "print \"It the initial velocity of the system is negligible, the final velocity is %.2f ft/s  \"%(V2);\n",
      "\n",
      "print \"Solution for b\";\n",
      "#If the initial velocity is appreciable,\n",
      "V1 = 1000; \t\t\t#Unit:ft/s \t\t\t#the initial velocity \n",
      "V2 = math.sqrt(((h1-h2)*(2*gc*J)) + V1**2 ) ;\n",
      "print \"It the initial velocity of the system is appreciable, the final velocity is %.2f ft/s  \"%(V2);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Solution for a\n",
        "It the initial velocity of the system is negligible, the final velocity is 2451.03 ft/s  \n",
        "Solution for b\n",
        "It the initial velocity of the system is appreciable, the final velocity is 2647.17 ft/s  \n"
       ]
      }
     ],
     "prompt_number": 21
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.19  Page No : 120"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given value\n",
      "h1 = 3450*1000 \t\t\t#Unit:J/kg \t\t\t#Enthalpy of steam when it enters a nozzle\n",
      "h2 = 2800*1000 \t\t\t#Unit:J/kg \t\t\t#Enthalpy of steam when it leaves a nozzle\n",
      "\n",
      "# Calculations\n",
      "#V2**2/2 = h1-h2;\n",
      "V2 = math.sqrt(2*(h1-h2)); \t\t\t#V2 = Final velocity \t\t\t#Unit:m/s\n",
      "\n",
      "# Results\n",
      "print \"Final velocity  =  %.2f m/s\"%(V2);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Final velocity  =  1140.18 m/s\n"
       ]
      }
     ],
     "prompt_number": 22
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.21  Page No : 125"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given value\n",
      "m = 400; \t\t\t#Unit:LBm/min \t\t\t#mass of lubricating oil\n",
      "Cp = 0.85; \t\t\t#Unit:Btu/LBm*R \t\t\t#Specific heat of the oil\n",
      "T1 = 215; \t\t\t#Temperature when hot oil is entering \t\t\t#Unit:Fahrenheit\n",
      "T2 = 125; \t\t\t#Temperature when hot oil is leaving \t\t\t#Unit:Fahrenheit\n",
      "\n",
      "# Calculations and Results\n",
      "DeltaT = T2-T1; \t\t\t#Unit:Fahrenheit  \t\t\t#change in temperature\n",
      "Qoil = m*Cp*DeltaT; \t\t\t#Heat out of oil \t\t\t#Btu/min\n",
      "print \"Heat out of oil is %.2f Btu/min Out of oil\"%(Qoil);\n",
      "#Heat out of oil is the heat into the water\n",
      "#Mw = Water flow rate\n",
      "#M*Cpw*DeltaTw = Qoil\n",
      "Cpw = 1.0; \t\t\t#Unit:Btu/LBm*R \t\t\t#Specific heat of the water\n",
      "T3 = 60.; \t\t\t#Temperature when water is entering \t\t\t#Unit:Fahrenheit\n",
      "T4 = 90; \t\t\t#Temperature when water is leaving \t\t\t#Unit:Fahrenheit\n",
      "DeltaTw = T4-T3; \t\t\t#Unit:Fahrenheit \t\t\t#change in temperature\n",
      "Mw = Qoil/(Cpw*DeltaTw); \t\t\t#The Required water flow rate  \t\t\t#Unit;lbm/Min\n",
      "print \"The Required water flow rate is %.2f lbm/Min\"%(abs(Mw));\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Heat out of oil is -30600.00 Btu/min Out of oil\n",
        "The Required water flow rate is 1020.00 lbm/Min\n"
       ]
      }
     ],
     "prompt_number": 24
    }
   ],
   "metadata": {}
  }
 ]
}