{
 "metadata": {
  "name": "",
  "signature": "sha256:cbda57f5092671910369ce2a43538fa17705152cf0ccb12e90ebe176631fb4e1"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 10 - Vapors"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1 - Pg 154"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the specific volume, enthalpy and entropy of the gas\n",
      "#Initialization of variables\n",
      "import math\n",
      "p=3000. #psia\n",
      "T=250. #F\n",
      "#calculations\n",
      "print '%s' %(\"From table 1, keenan and keynes,\")\n",
      "vf=0.01700\n",
      "print '%s' %(\"From table 4,\")\n",
      "dvf=-18.3*math.pow(10,-5)\n",
      "v=vf+dvf\n",
      "print '%s' %(\"From table 1,\")\n",
      "hf=218.48\n",
      "print '%s' %(\"From table 4,\")\n",
      "dhf=6.13\n",
      "h=hf+dhf\n",
      "sf=0.3675\n",
      "dsf=-4.34*math.pow(10,-3)\n",
      "s=sf+dsf\n",
      "#results\n",
      "print '%s %.5f %s' %(\"Specific volume =\",v,\" cu ft/lb\")\n",
      "print '%s %.2f %s' %(\"\\n Enthalpy =\",h,\" Btu/lb\")\n",
      "print '%s %.4f %s' %(\"\\n Entropy  =\",s,\" Btu/lb per deg R\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "From table 1, keenan and keynes,\n",
        "From table 4,\n",
        "From table 1,\n",
        "From table 4,\n",
        "Specific volume = 0.01682  cu ft/lb\n",
        "\n",
        " Enthalpy = 224.61  Btu/lb\n",
        "\n",
        " Entropy  = 0.3632  Btu/lb per deg R\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2 - Pg 157"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the state of the gas and moisture content\n",
      "#Initialization of variables\n",
      "h=1100 #Btu/lb\n",
      "P=100 #psia\n",
      "#calculations\n",
      "print '%s' %(\"From table 2 of keenan and keynes,\")\n",
      "hg=1187.2 #Btu/lb\n",
      "hfg=888.8 #Btu/lb\n",
      "y=-(h-hg)/hfg*100\n",
      "#results\n",
      "print '%s %.2f %s %.2f %s' %(\"The state is\",P,\"psia with a moisture content of\",y,\"percent\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "From table 2 of keenan and keynes,\n",
        "The state is 100.00 psia with a moisture content of 9.81 percent\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3 - Pg 157"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the state of steam\n",
      "#Initialization of variables\n",
      "print '%s' %(\"From table 1 of keenan and keynes,\")\n",
      "v1=0.2688\n",
      "#calculations\n",
      "v2=3.060\n",
      "p2=200 #psia\n",
      "t2=600 #F\n",
      "#results\n",
      "print '%s %d %s %d %s' %(\"State of steam is\",p2, \"psia and\",t2,\"F\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "From table 1 of keenan and keynes,\n",
        "State of steam is 200 psia and 600 F\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4 - Pg 157"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the state of steam\n",
      "#Initialization of variables\n",
      "print '%s' %(\"From table 2 of keenan and keynes,\")\n",
      "t1=439.60 #F\n",
      "u1=1118.4 #Btu/lb\n",
      "#calculations\n",
      "p2=380 #psia\n",
      "#results\n",
      "print '%s %d %s %.2f %s' %(\"The state of steam is saturated at\",p2,\"psia and\",t1,\"F\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "From table 2 of keenan and keynes,\n",
        "The state of steam is saturated at 380 psia and 439.60 F\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 5 - Pg 157"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calcualte the state of steam and moisture content\n",
      "#Initialization of variables\n",
      "print '%s' %(\"From table 2 of keenan and keynes,\")\n",
      "p1=1 #in of Hg\n",
      "s=1.9812 \n",
      "#calculations\n",
      "sf=2.0387\n",
      "sfg=1.9473\n",
      "y=-(s-sf)/sfg*100\n",
      "#results\n",
      "print '%s %d %s %.2f %s' %(\"The state is\",p1, \"in of Hg with a moisture content of\",y, \"percent\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "From table 2 of keenan and keynes,\n",
        "The state is 1 in of Hg with a moisture content of 2.95 percent\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6 - Pg 161"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the final state of steam and temperature. Also calculate the final enthalpy\n",
      "#Initialization of variables\n",
      "print '%s' %(\"From table 1 of keenan and keynes,\")\n",
      "h1=1204.8 #Btu/lb\n",
      "q=174. #Btu/lb\n",
      "#calculations\n",
      "h2=h1+q\n",
      "p2=30. #psia\n",
      "t2=720. #F\n",
      "#results\n",
      "print '%s %d %s %d %s' %(\"Final state of steam is\",p2,\"psia and\",t2,\" F\")\n",
      "print '%s %.1f %s' %(\"\\n Final enthalpy is\",h2,\"Btu/lb\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "From table 1 of keenan and keynes,\n",
        "Final state of steam is 30 psia and 720  F\n",
        "\n",
        " Final enthalpy is 1378.8 Btu/lb\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7 - Pg 161"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the final specific volume and final state of steam\n",
      "#Initialization of variables\n",
      "print '%s' %(\"From table 1 of keenan and keynes,\")\n",
      "p=70 #psia\n",
      "x=0.1\n",
      "p2=198 #psia\n",
      "#calculations\n",
      "v1=6.206\n",
      "v2=0.017\n",
      "vx=v1-x*(v1-v2)\n",
      "t2=1400 #F\n",
      "#results\n",
      "print '%s %.3f %s' %(\"Final specific volume =\",vx,\"cu ft\")\n",
      "print '%s %d %s %d %s' %(\"\\n Final state is\",p2,\"psia and\",t2,\"F\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "From table 1 of keenan and keynes,\n",
        "Final specific volume = 5.587 cu ft\n",
        "\n",
        " Final state is 198 psia and 1400 F\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8 - Pg 162"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the final state of steam\n",
      "#Initialization of variables\n",
      "print '%s' %(\"From table 1 of keenan and keynes,\")\n",
      "p=400 #psia\n",
      "t1=700 #F\n",
      "p2=85 #psia\n",
      "#calculations\n",
      "s2=1.6398 #units/lb\n",
      "t2=350 #F\n",
      "#results\n",
      "print '%s %d %s %d %s' %(\"Final state of steam is\",p2,\"psia and\",t2,\"F\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "From table 1 of keenan and keynes,\n",
        "Final state of steam is 85 psia and 350 F\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 9 - Pg 162"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the work of compression and heat removed\n",
      "#Initialization of variables\n",
      "import math\n",
      "p1=20. #psia\n",
      "p2=140. #psia\n",
      "J=778.\n",
      "t2=150. #F\n",
      "t1=30. #F\n",
      "#calculations\n",
      "print '%s' %(\"From Table A-3,\")\n",
      "v1=2.0884 #cu ft/lb\n",
      "v2=0.33350 #cu ft/lb\n",
      "h2=95.709\n",
      "h1=81.842\n",
      "n=math.log(p2/p1) /math.log(v1/v2)\n",
      "W=(p2*v2-p1*v1)*144/(1-n)\n",
      "du=h2-h1 + (p1*v1-p2*v2)*144/J\n",
      "Q=du+W/J\n",
      "s2=0.17718\n",
      "s1=0.18126\n",
      "Q2=((t2+t1)/2 +460) *(s2-s1)\n",
      "#results\n",
      "print '%s %d %s' %(\"Work of compression =\",W,\"ft-lb\")\n",
      "print '%s %.3f %s' %(\"\\n Heat removed per pound of refrigerant =\",Q,\" Btu/lb\")\n",
      "print '%s %.4f %s' %(\"\\n Heat removed in case 2 =\",Q2,\" Btu\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "From Table A-3,\n",
        "Work of compression = -11671 ft-lb\n",
        "\n",
        " Heat removed per pound of refrigerant = -2.046  Btu/lb\n",
        "\n",
        " Heat removed in case 2 = -2.2440  Btu\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 10 - Pg 163"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the specific enthalpy of exhaust steam\n",
      "#Initialization of variables\n",
      "print '%s' %(\"From table 1 of keenan and keynes,\")\n",
      "intt=440000 #lb/hr\n",
      "out=255000 #lb/hr\n",
      "p1=400 #psia\n",
      "t1=700 #F\n",
      "p2=35 #psia\n",
      "t2=290 #F\n",
      "vel=500 #ft/s\n",
      "hp=44000 #hp\n",
      "ent=1362.7 #Btu/lb\n",
      "#calculations\n",
      "ein=ent*intt\n",
      "eout=hp*2544 + out*1183 + 925000.\n",
      "h2= (ein-eout)/185000.\n",
      "#results\n",
      "print '%s %d %s' %(\"Specific enthalpy of exhaust steam =\",h2,\"Btu/lb\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "From table 1 of keenan and keynes,\n",
        "Specific enthalpy of exhaust steam = 1000 Btu/lb\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 11 - Pg 165"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calcualte the final state of steam and loss of available energy\n",
      "#Initialization of variables\n",
      "print '%s' %(\"From table 1 of keenan and keynes,\")\n",
      "h1=1351.1 #Btu/lb\n",
      "p1=600. #psia\n",
      "t1=700. #F\n",
      "p2=234. #psia\n",
      "h2=1.6865\n",
      "h1=1.5875\n",
      "t3=101.74\n",
      "#calculations\n",
      "t2=660. #F\n",
      "loss= (h2-h1)*(t3+459.69)\n",
      "#results\n",
      "print '%s %d %s %d %s' %(\"Final state of steam is\",p2,\" psia and\",t2,\"F\")\n",
      "print '%s %.1f %s' %(\"\\n Loss of available energy =\",loss,\"Btu/lb\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "From table 1 of keenan and keynes,\n",
        "Final state of steam is 234  psia and 660 F\n",
        "\n",
        " Loss of available energy = 55.6 Btu/lb\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 12 - Pg 165"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the state of vapor and also the quality\n",
      "#Initialization of variables\n",
      "print '%s' %(\"From table 2 of keenan and keynes,\")\n",
      "p1=98.87 #psia\n",
      "p2=31.78 #psia\n",
      "t1=80 #F\n",
      "h2=26.365 #btu/lb\n",
      "h1=11.554 #btu/lb\n",
      "hfg=67.203 #btu/lb\n",
      "#calculations\n",
      "x=(h2-h1)/hfg*100\n",
      "#results\n",
      "print '%s %.2f %s %.2f %s' %(\"The state of vapor leaving is\",p2, \"psia with a quality of\",x, \" percent\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "From table 2 of keenan and keynes,\n",
        "The state of vapor leaving is 31.78 psia with a quality of 22.04  percent\n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 13 - Pg 167"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the mean state in the line and also the moisture content\n",
      "#Initialization of variables\n",
      "ps=216 #psig\n",
      "pb=29.12 #in of Hg\n",
      "p2=0.4 #in\n",
      "t2=244 #F\n",
      "#calculations\n",
      "pa=0.491*pb\n",
      "pabs=pa + p2*0.491\n",
      "plb=pa+ ps\n",
      "hcal=1166.5 #Btu/lb\n",
      "h2=1200.1 #Btu/lb\n",
      "h3=831.9 #Btu/lb\n",
      "y=-(hcal-h2)/h3*100\n",
      "#results\n",
      "print '%s %.1f %s %.2f %s' %(\"Mean state in the line is\",plb,\" psia with a moisture content of\",y,\"percent\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Mean state in the line is 230.3  psia with a moisture content of 4.04 percent\n"
       ]
      }
     ],
     "prompt_number": 15
    }
   ],
   "metadata": {}
  }
 ]
}