{
 "metadata": {
  "name": "",
  "signature": "sha256:86a66a56e6c068c1b5488c8e726c9aecdd48422f90b429aec4b5cc311da3bb32"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 5 - Actual Gases"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1 - Pg 74"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the volume occupied by the gas and also the tabulated volume\n",
      "#Initialization of variables\n",
      "m=20. #lbm\n",
      "P=1000. #psia\n",
      "T=580. #R\n",
      "R=35.12\n",
      "#calculations\n",
      "print '%s' %(\"From table 5-2,\")\n",
      "z=0.667\n",
      "V=z*m*R*T/(P*144.)\n",
      "vt=0.0935\n",
      "vtt=vt*m\n",
      "#results\n",
      "print '%s %.3f %s' %(\"Volume occupied =\",V,\"cu ft\")\n",
      "print '%s %.2f %s' %(\"\\n Tablulated value for volume =\",vtt,\" cu ft\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "From table 5-2,\n",
        "Volume occupied = 1.887 cu ft\n",
        "\n",
        " Tablulated value for volume = 1.87  cu ft\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2 - Pg 74"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the pressure obtained and theoretical pressure\n",
      "#Initialization of variables\n",
      "m=90 #lbm\n",
      "T=200+459.7 #R\n",
      "Tc=232.7+459.7 #R\n",
      "R0=1545.\n",
      "M=120.9\n",
      "V=30. #cu ft\n",
      "#calculations\n",
      "R=R0/M\n",
      "print '%s' %(\"From fig 5.5\")\n",
      "z=0.883\n",
      "P=z*R*m*T/V/144.\n",
      "vc=V/m\n",
      "P2=156.1 #psia\n",
      "#results\n",
      "print '%s %.2f %s' %(\"Pressure obtained =\",P,\"psia\")\n",
      "print '%s %.1f %s' %(\"\\n Theoretical pressure =\",P2,\"psia\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "From fig 5.5\n",
        "Pressure obtained = 155.08 psia\n",
        "\n",
        " Theoretical pressure = 156.1 psia\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3 - Pg 84"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the heat added in both cases\n",
      "#Initialization of variables\n",
      "import math\n",
      "T1=140+460. #R\n",
      "T2=240 +460. #R\n",
      "N=1.\n",
      "#calculations\n",
      "Q=N*(9.47*(T2-T1)-3.47*1000. *math.log(T2/T1) -1.16*math.pow(10,6) *(1/T2-1/T1))\n",
      "Tm=(T1+T2)/2\n",
      "Cp=9.47-3.47*1000. /Tm +1.16*math.pow(10,6) /Tm/Tm\n",
      "Q2=N*Cp*(T2-T1)\n",
      "#results\n",
      "print '%s %d %s' %(\"Heat added in case 1 =\",Q,\"Btu\")\n",
      "print '%s %.1f %s' %(\"\\n Heat added in case 2 =\",Q2,\"Btu\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Heat added in case 1 = 688 Btu\n",
        "\n",
        " Heat added in case 2 = 687.7 Btu\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4 - Pg 85"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#calculate the heat added in both cases\n",
      "#Initialization of variables\n",
      "import math\n",
      "Rj=1.985\n",
      "N=1\n",
      "T1=540.+460 #R\n",
      "T2=3540.+460 #R\n",
      "#calculations\n",
      "Q=N*(14.215*(T2-T1)-6.53*1000. *math.log(T2/T1) -1.41*math.pow(10,6) *(1/T2-1/T1))\n",
      "Tm=(T1+T2)/2\n",
      "Cv=14.215-6.53*1000. /Tm +1.41*math.pow(10,6) /Tm/Tm\n",
      "Q2=N*Cv*(T2-T1)\n",
      "#results\n",
      "print '%s %.1f %s' %(\"Heat added in case 1 =\",Q,\"Btu\")\n",
      "print '%s %.1f %s' %(\"\\n Heat added in case 2 =\",Q2,\"Btu\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Heat added in case 1 = 34650.0 Btu\n",
        "\n",
        " Heat added in case 2 = 35485.8 Btu\n"
       ]
      }
     ],
     "prompt_number": 6
    }
   ],
   "metadata": {}
  }
 ]
}