{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 9 - Properties of the pure substance"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1 - Pg 194"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the internal energy of the system.\n",
      "#Initialization of variables\n",
      "T=32. #F\n",
      "m=1 #lbm\n",
      "J=778.16\n",
      "#calculations\n",
      "print '%s' %(\"From steam tables,\")\n",
      "hf=0 \n",
      "p=0.08854 #psia\n",
      "vf=0.01602 #ft^3/lbm\n",
      "u=hf-p*144*vf/J\n",
      "#results\n",
      "print '%s %.7f %s' %(\"Internal energy =\",u,\"Btu/lbm\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "From steam tables,\n",
        "Internal energy = -0.0002625 Btu/lbm\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2 - Pg 194"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the change in entropy of the process\n",
      "#Initialization of variables\n",
      "P=40. #psia\n",
      "#calculations\n",
      "print '%s' %(\"from steam tables,\")\n",
      "hf=200.8 #Btu/lbm\n",
      "hg=27 #Btu/lbm\n",
      "T=495.  #R\n",
      "ds=(hf-hg)/T\n",
      "#results\n",
      "print '%s %.3f %s' %(\"Change in entropy =\",ds,\"Btu/lbm R\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "from steam tables,\n",
        "Change in entropy = 0.351 Btu/lbm R\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3 - Pg 194"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the specific enthalpy of the mixture\n",
      "#Initialization of variables\n",
      "x=0.35\n",
      "T=18. #F\n",
      "#calculations\n",
      "print '%s' %(\"From table B-14,\")\n",
      "hf=12.12 #Btu/lbm\n",
      "hg=80.27 #Btu.lbm\n",
      "hfg=-hf+hg\n",
      "h=hf+x*hfg\n",
      "#results\n",
      "print '%s %.1f %s' %(\"specific enthalpy =\",h,\"Btu/lbm\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "From table B-14,\n",
        "specific enthalpy = 36.0 Btu/lbm\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4 - Pg 194"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the heat required for the process\n",
      "#Initialization of variables\n",
      "x=0.35\n",
      "T=18. #F\n",
      "T2=55.5 #F\n",
      "#calculations\n",
      "print '%s' %(\"From table B-14,\")\n",
      "hf=12.12 #Btu/lbm\n",
      "hg=80.27 #Btu.lbm\n",
      "hfg=-hf+hg\n",
      "h=hf+x*hfg\n",
      "h2=85.68 #Btu/lbm\n",
      "dh=h2-h\n",
      "#results\n",
      "print '%s %.2f %s' %(\"Heat required =\",dh,\"Btu/lbm\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "From table B-14,\n",
        "Heat required = 49.71 Btu/lbm\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5 - Pg 194"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the enthalpy given out and the quality of the gas\n",
      "#Initialization of variables\n",
      "P=1460. #psia\n",
      "T=135. #F\n",
      "P2=700. #psia\n",
      "#calculations\n",
      "print '%s' %(\"From mollier chart,\")\n",
      "h=120 #Btu/lbm\n",
      "x=0.83\n",
      "#results\n",
      "print '%s %d %s' %(\"enthalpy =\",h,\" Btu/lbm\")\n",
      "print '%s %.2f' %(\"\\n Qulaity = \",x)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "From mollier chart,\n",
        "enthalpy = 120  Btu/lbm\n",
        "\n",
        " Qulaity =  0.83\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6 - Pg 195"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the heat transferred in the process\n",
      "#Initialization of variables\n",
      "m=1 #lbm\n",
      "P1=144. #psia\n",
      "P2=150. #psia\n",
      "T1=360. #F\n",
      "J=778.16\n",
      "#calculations\n",
      "print '%s' %(\"From table 3,\")\n",
      "v1=3.160 #ft^3/lbm\n",
      "h1=1196.5 #Btu/lbm\n",
      "u1=h1-P1*144*v1/J\n",
      "h2=1211.4 #Btu/lbm\n",
      "u2=h2-P2*144*v1/J\n",
      "dq=u2-u1\n",
      "#results\n",
      "print '%s %.1f %s' %(\"Heat transferred =\",dq,\" Btu/lbm\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "From table 3,\n",
        "Heat transferred = 11.4  Btu/lbm\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7 - Pg 195"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the work required, reversible work and the work done in compression \n",
      "#Initialization of variables\n",
      "T1=100 #F\n",
      "P2=1000. #psia\n",
      "x=0.6\n",
      "J=778.16\n",
      "tir=2 \n",
      "P1=0.9 #psia\n",
      "#calculations\n",
      "print '%s' %(\"From table 3,\")\n",
      "hf=67.97\n",
      "htc=2.7\n",
      "hpc=0.32\n",
      "h1=67.97\n",
      "dv=0.000051\n",
      "v=0.01613\n",
      "h2=hf+htc+hpc\n",
      "wrev=h1-h2\n",
      "wact=wrev/x\n",
      "dt=hpc+tir\n",
      "t2act=T1+dt\n",
      "wrev2=-v*144*(P2-P1)/J\n",
      "dw=(P1+P2)/2. *dv *144/J\n",
      "#results\n",
      "print '%s %.2f %s' %(\"Work required =\",wact,\" Btu/lbm\")\n",
      "print '%s %.2f %s' %(\"\\n reversible work done =\",wrev2,\" Btu/lbm\")\n",
      "print '%s %.4f %s' %(\"\\n Work done in compression =\",dw,\"Btu/lbm\")\n",
      "print '%s' %(\"The answers are a bit different due to rounding off error in textbook\")"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "From table 3,\n",
        "Work required = -5.03  Btu/lbm\n",
        "\n",
        " reversible work done = -2.98  Btu/lbm\n",
        "\n",
        " Work done in compression = 0.0047 Btu/lbm\n",
        "The answers are a bit different due to rounding off error in textbook\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8 - Pg 196"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the heat transferred in the process\n",
      "#Initialization of variables\n",
      "pa=1000. #atm\n",
      "ta=100. #F\n",
      "#calculations\n",
      "hf=67.97 #Btu/lbm\n",
      "w=3 #Btu/lbm\n",
      "ha=hf+w\n",
      "print '%s' %(\"from steam table 2,\")\n",
      "hc=1191.8 #Btu/lbm\n",
      "qrev=hc-ha\n",
      "#results\n",
      "print '%s %.1f %s' %(\"Heat transferred =\",qrev,\"Btu/lbm\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "from steam table 2,\n",
        "Heat transferred = 1120.8 Btu/lbm\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 10 - Pg 197"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the work done and final pressure\n",
      "#Initialization of variables\n",
      "P1=144 #psia\n",
      "T1=400 #F\n",
      "y=0.7\n",
      "#calculations\n",
      "print '%s' %(\"From steam tables,\")\n",
      "h1=1220.4 #Btu/lbm\n",
      "s1=1.6050 #Btu/lbm R\n",
      "s2=1.6050 #Btu/lbm R\n",
      "P2=3 #psia\n",
      "sf=0.2008 #Btu/lbm R\n",
      "sfg=1.6855 #Btu/lbm R\n",
      "x=(s1-sf)/sfg\n",
      "hf=109.37 #Btu/lbm\n",
      "hfg=1013.2 #Btu/;bm\n",
      "h2=hf+x*hfg\n",
      "work=h1-h2\n",
      "dw=y*work\n",
      "h2d=h1-dw\n",
      "#results\n",
      "print '%s %d %s' %(\"Work done =\",work,\"Btu/lbm\")\n",
      "print '%s %.1f %s' %(\"\\n work done in case 2 =\",dw,\"Btu/lbm\")\n",
      "print '%s %d %s' %(\"\\n Final state pressure =\",P2,\"psia\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "From steam tables,\n",
        "Work done = 266 Btu/lbm\n",
        "\n",
        " work done in case 2 = 186.8 Btu/lbm\n",
        "\n",
        " Final state pressure = 3 psia\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 11 - Pg 200"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the quality of wet steam\n",
      "#Initialization of variables\n",
      "pb=14.696 #psia\n",
      "pa=150 #psia\n",
      "tb=300 #F\n",
      "#calculations\n",
      "print '%s' %(\"From steam tables,\")\n",
      "hb=1192.8 #Btu/lbm\n",
      "ha=hb\n",
      "hf=330.51 #Btu/lbm\n",
      "hfg=863.6 #Btu/lbm\n",
      "x=(ha-hf)/hfg*100\n",
      "#results\n",
      "print '%s %.1f %s' %(\"Quality of wet steam =\",x,\"percent\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "From steam tables,\n",
        "Quality of wet steam = 99.8 percent\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 12 - Pg 204"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the thermal and furnace efficiencies\n",
      "#Initialization of variables\n",
      "p1=600 #psia\n",
      "p2=0.2563 #psia\n",
      "t1=486.21 #F\n",
      "t2=60 #F\n",
      "fur=0.75\n",
      "#calculations\n",
      "print '%s' %(\"from steam tables,\")\n",
      "h1=1203.2\n",
      "hf1=471.6\n",
      "hfg1=731.6\n",
      "h2=1088\n",
      "hf2=28.06\n",
      "hfg2=1059.9\n",
      "s1=1.4454\n",
      "sf1=0.6720\n",
      "sfg1=0.7734\n",
      "s2=2.0948\n",
      "sf2=0.0555\n",
      "sfg2=2.0393\n",
      "xd=(s1-sf2)/sfg2\n",
      "hd=hf2+xd*hfg2\n",
      "xa=0.3023\n",
      "ha=hf2+xa*hfg2\n",
      "wbc=0\n",
      "wda=0\n",
      "wcd=h1-hd\n",
      "wab=ha-hf1\n",
      "W=wab+wcd+wbc+wda\n",
      "Wrev=hfg1- (t2+459.7)*sfg1\n",
      "etat=(t1-t2)/(t1+459.7)*100\n",
      "eta=fur*etat\n",
      "#results\n",
      "print '%s %d %s' %(\"Thermal efficiency =\",etat,\"percent\")\n",
      "print '%s %.1f %s' %(\"\\n Furnace efficiency =\",eta,\"percent\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "from steam tables,\n",
        "Thermal efficiency = 45 percent\n",
        "\n",
        " Furnace efficiency = 33.8 percent\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 13 - Pg 204"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the thermal and overall efficiencies\n",
      "#Initialization of variables\n",
      "dhab=-123.1\n",
      "etac=0.5\n",
      "ha=348.5\n",
      "etaf=0.75\n",
      "eta=0.85\n",
      "hf=471.6\n",
      "hfg=731.6\n",
      "hc=1203.2\n",
      "dhcd=452.7\n",
      "#calculations\n",
      "dwabs=dhab/etac\n",
      "hbd=ha-dwabs\n",
      "dwcds=dhcd*eta\n",
      "dqa=hc-hbd\n",
      "etat=(dwcds+dwabs)/dqa*100\n",
      "eta=etat*etaf\n",
      "#results\n",
      "print '%s %.1f %s' %(\"Thermal efficiency =\",etat,\"percent\")\n",
      "print '%s %.1f %s' %(\"\\n Overall efficiency =\",eta,\"percent\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Thermal efficiency = 22.8 percent\n",
        "\n",
        " Overall efficiency = 17.1 percent\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 14 - Pg 205"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the thermal and overall efficiencies\n",
      "#Initialization of variables\n",
      "t=60 #F\n",
      "J=778.16\n",
      "p1=600 #psia\n",
      "p2=0.2563 #psia\n",
      "etaf=0.85 \n",
      "#calculations\n",
      "print '%s' %(\"From steam tables,\")\n",
      "vf=0.01604 #ft^3/lbm\n",
      "dw=-vf*(p1-p2)*144/J\n",
      "ha=28.06 #Btu/lbm\n",
      "hb=29.84 #Btu/lbm\n",
      "hd=1203.2 #Btu/lbm\n",
      "he=750.5 #Btu/lbm\n",
      "dqa=hd-hb\n",
      "dqr=ha-he\n",
      "dw=dqa+dqr\n",
      "dwturb=hd-he\n",
      "dwpump=ha-hb\n",
      "etat=dw/dqa*100\n",
      "eta=etat*etaf\n",
      "#results\n",
      "print '%s %.1f %s' %(\"Thermal efficiency =\",etat,\"percent\")\n",
      "print '%s %.1f %s' %(\"\\n Overall efficiency =\",eta,\"percent\")\n",
      "    \n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "From steam tables,\n",
        "Thermal efficiency = 38.4 percent\n",
        "\n",
        " Overall efficiency = 32.7 percent\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 15 - Pg 206"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the thermal and overall efficiencies\n",
      "#Initialization of variables\n",
      "dhab=-1.78\n",
      "etac=0.5\n",
      "ha=28.06\n",
      "eta=0.85\n",
      "hf=471.6\n",
      "hfg=731.6\n",
      "hd=1203.2\n",
      "dhcd=452.7\n",
      "#calculations\n",
      "dwabs=dhab/etac\n",
      "hbd=ha-dwabs\n",
      "dwcds=dhcd*eta\n",
      "dqa=hd-hbd\n",
      "etat=(dwcds+dwabs)/dqa*100\n",
      "eta=etat*eta\n",
      "#results\n",
      "print '%s %.1f %s' %(\"Thermal efficiency =\",etat,\"percent\")\n",
      "print '%s %.1f %s' %(\"\\n Overall efficiency =\",eta,\"percent\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Thermal efficiency = 32.5 percent\n",
        "\n",
        " Overall efficiency = 27.7 percent\n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 16 - Pg 207"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the coefficient of performance, hp required, work of compression and expansion\n",
      "#Initialization of variables\n",
      "Ta=500. #R\n",
      "Tr=540. #R\n",
      "#calculations\n",
      "cop=Ta/(Tr-Ta)\n",
      "hp=4.71/cop\n",
      "print '%s' %(\"From steam tables,\")\n",
      "ha=48.02\n",
      "hb=46.6\n",
      "hc=824.1\n",
      "hd=886.9\n",
      "Wc=-(hd-hc)\n",
      "We=-(hb-ha)\n",
      "#results\n",
      "print '%s %.1f' %(\"Coefficient of performance = \",cop)\n",
      "print '%s %.3f %s' %(\"\\n horsepower required per ton of refrigeration =\",hp,\"hp/ton refrigeration\")\n",
      "print '%s %.1f %s' %(\"\\n Work of compression =\",Wc,\"Btu/lbm\")\n",
      "print '%s %.2f %s' %(\"\\n Work of expansion =\",We,\"Btu/lbm\")"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "From steam tables,\n",
        "Coefficient of performance =  12.5\n",
        "\n",
        " horsepower required per ton of refrigeration = 0.377 hp/ton refrigeration\n",
        "\n",
        " Work of compression = -62.8 Btu/lbm\n",
        "\n",
        " Work of expansion = 1.42 Btu/lbm\n"
       ]
      }
     ],
     "prompt_number": 15
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 17 - Pg 209"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the coefficient of performance\n",
      "#Initialization of variables\n",
      "x=0.8\n",
      "he=26.28 #Btu/lbm\n",
      "hb=26.28 #Btu/lbm\n",
      "pe=98.76 #psia\n",
      "pc=51.68 #psia\n",
      "hc=82.71 #Btu/lbm\n",
      "hf=86.80+0.95\n",
      "#calculations\n",
      "dwisen=-(hf-hc)\n",
      "dwact=dwisen/x\n",
      "hd=hc-dwact\n",
      "cop=(hc-hb)/(hd-hc)\n",
      "#results\n",
      "print '%s %.2f' %(\"Coefficient of performance = \",cop)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Coefficient of performance =  8.96\n"
       ]
      }
     ],
     "prompt_number": 16
    }
   ],
   "metadata": {}
  }
 ]
}