{
 "metadata": {
  "name": "",
  "signature": "sha256:071044d67259dbca809a68700f00a2b22bbcf445c19f6ea5840022a417d2395b"
 },
 "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 149"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the Internal energy\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 149"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the Change in entropy\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 149"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the specific enthalpy\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 149"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the heat required\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 149"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the enthalpy and Quality\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 Quality =\",x)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "From mollier chart,\n",
        "enthalpy = 120 Btu/lbm\n",
        "\n",
        " Quality = 0.83\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6 - Pg 149"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the Heat transferred\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 150"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the work done and work required\n",
      "#Initialization of variables\n",
      "T1=100. #F\n",
      "P2=1000. #psia\n",
      "x=0.6\n",
      "J=778.16\n",
      "#calculations\n",
      "print '%s' %(\"From table 3,\")\n",
      "v=0.01613 #ft^3/lbm\n",
      "P1=0.9 #psia\n",
      "wrev=-v*(P2-P1)*144/J\n",
      "dv=0.000051 #ft^3/lbm\n",
      "wcomp=(P2+P1)/2 *dv*144/J\n",
      "wact=wrev/x\n",
      "#results\n",
      "print '%s %.1f %s' %(\"Work done =\",wrev,\"Btu/lbm\")\n",
      "print '%s %.1f %s' %(\"\\n In case 2, work required =\",wact,\" Btu/lbm\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "From table 3,\n",
        "Work done = -3.0 Btu/lbm\n",
        "\n",
        " In case 2, work required = -5.0  Btu/lbm\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8 - Pg 150"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the Heat transferred\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 9 - Pg 151"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the work done and Final state 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 10 - Pg 154"
     ]
    },
    {
     "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
    }
   ],
   "metadata": {}
  }
 ]
}