{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 12 - The ideal gas and deviations of real gases"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1 - Pg 290"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the work done in the process\n",
      "#Initialization of variables\n",
      "import math\n",
      "n=1.3\n",
      "T1=460+60. #R\n",
      "P1=14.7 #psia\n",
      "P2=125. #psia\n",
      "R=1545.\n",
      "M=29.\n",
      "#calculations\n",
      "T2=T1*math.pow((P2/P1),((n-1)/n))\n",
      "wrev=R/M *(T2-T1)/(1-n)\n",
      "#results\n",
      "print '%s %d %s' %(\"Work done =\",wrev,\"ft-lbf/lbm\")\n",
      "print '%s' %(\"The answer is a bit different due to rounding off error in textbook\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Work done = -58988 ft-lbf/lbm\n",
        "The answer is a bit different due to rounding off error in textbook\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2 - Pg 290"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the change in kinetic energy\n",
      "#Initialization of variables\n",
      "import math\n",
      "P2=10. #psia\n",
      "P1=100. #psia\n",
      "T1=900. #R\n",
      "w=50 #Btu/lbm\n",
      "k=1.39\n",
      "cp=0.2418\n",
      "#calculations\n",
      "T2=T1*math.pow((P2/P1),((k-1)/k))\n",
      "T2=477\n",
      "KE=-w-cp*(T2-T1)\n",
      "#results\n",
      "print '%s %.1f %s' %(\"Change in kinetic energy =\",KE,\" Btu/lbm\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Change in kinetic energy = 52.3  Btu/lbm\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3 - Pg 301"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the final temperature of the system\n",
      "#Initialization of variables\n",
      "T1=900. #R\n",
      "P1=100. #psia\n",
      "P2=10. #psia\n",
      "#calculations\n",
      "print '%s' %(\"From table B-9\")\n",
      "pr1=8.411\n",
      "pr2=pr1*P2/P1\n",
      "T2=468. #R\n",
      "#results\n",
      "print '%s %d %s' %(\"Final temperature =\",T2,\"R \")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "From table B-9\n",
        "Final temperature = 468 R \n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4 - Pg 302"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calcuate the final temperature, pressure, enthalpy and the work done in the process\n",
      "#Initialization of variables\n",
      "cr=6\n",
      "p1=14.7 #psia\n",
      "t1=60.3 #F\n",
      "M=29.\n",
      "R=1.986\n",
      "#calculations\n",
      "print '%s' %(\"from table b-9\")\n",
      "vr1=158.58 \n",
      "u1=88.62 #Btu/lbm\n",
      "pr1=1.2147\n",
      "vr2=vr1/cr\n",
      "T2=1050. #R\n",
      "u2=181.47 #Btu/lbm\n",
      "pr2=14.686\n",
      "p2=p1*(pr2/pr1)\n",
      "dw=u1-u2\n",
      "h2=u2+T2*R/M\n",
      "#results\n",
      "print '%s %d %s' %(\"final temperature =\",T2,\" R\")\n",
      "print '%s %.1f %s' %(\"\\n final pressure =\",p2,\"psia\")\n",
      "print '%s %.2f %s' %(\"\\n work done =\",dw,\"Btu/lbm\")\n",
      "print '%s %.1f %s' %(\"\\n final enthalpy =\",h2,\" Btu/lbm\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "from table b-9\n",
        "final temperature = 1050  R\n",
        "\n",
        " final pressure = 177.7 psia\n",
        "\n",
        " work done = -92.85 Btu/lbm\n",
        "\n",
        " final enthalpy = 253.4  Btu/lbm\n"
       ]
      }
     ],
     "prompt_number": 4
    }
   ],
   "metadata": {}
  }
 ]
}