{
 "metadata": {
  "name": "",
  "signature": "sha256:1a66a7b358047512cb72cb60b5347f9bd68c40105b1c8a4914776231ef293db4"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 11 : Real Gas"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 11.1 Page No : 394"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\t\t\t\n",
      "# Variables\n",
      "P = 70.e5 \t\t\t#Pa\n",
      "T = 150. + 273 \t\t\t#K\n",
      "Z = 0.55 \t\t\t#Compressibility factor\n",
      "R = 8314.3/44 \t\t\t#J/kgK\n",
      "\t\t\t\n",
      "# Calculations and Results\n",
      "#For propane\n",
      "v = Z*R*T/P \t\t\t#m**3/kg\n",
      "print \"Specific volume for propane = %.2e m**3/kg\"%(v)\n",
      "\t\t\t#ideal gas\n",
      "v = R*T/P \t\t\t#m**3/kg\n",
      "print \"Specific volume for ideal gas = %2.3e m**3/kg\"%(v)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Specific volume for propane = 6.28e-03 m**3/kg\n",
        "Specific volume for ideal gas = 1.142e-02 m**3/kg\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 11.2 Page No : 396"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\t\t\t\n",
      "# Variables\n",
      "Z = 1.04 \t\t\t#Compressiblity factor\n",
      "pc = 3.77e6 \t\t\t#Pa \t\t\t#crticial pressure\n",
      "Tc = 132.5 \t\t\t#K\n",
      "vc = 0.0883 \t\t\t#m**3/kmol\n",
      "p = 10.e5 \t\t\t#Pa\n",
      "T = 300. \t\t\t#K\n",
      "\t\t\t\n",
      "# Calculations and Results\n",
      "R = 287. \t\t\t#J/kgK\n",
      "pR = p/pc \t\t\t#reduced pressure\n",
      "TR = T/Tc \t\t\t#reduced temperature\n",
      "v = Z*R*T/p \t\t\t#m**3/kg\n",
      "vR = v/vc \t\t\t#reduced volume\n",
      "\n",
      "print \"Reduced pressure = %.5f \"%(pR)\n",
      "print \"Reduced temperature = %.5f \"%(TR)\n",
      "print \"Reduced volume = %.3f \"%(vR)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Reduced pressure = 0.26525 \n",
        "Reduced temperature = 2.26415 \n",
        "Reduced volume = 1.014 \n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 11.3 Page No : 397"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\t\t\t\n",
      "# Variables\n",
      "pR = 0.26525 \t\t\t#reduced pressure\n",
      "TR = 2.26415 \t\t\t#reduced temperature\n",
      "pc = 22.09 \t\t\t#bar \t\t\t#critical pressure of water\n",
      "Tc = 647.3 \t\t\t#K \t\t\t#critical temperature of water\n",
      "\t\t\t\n",
      "# Calculations and Results\n",
      "p = pR*pc \t\t\t#bar\n",
      "T = TR*Tc \t\t\t#K\n",
      "print \"Temperature at which steam would beahve similar to air at 10 bar and 27\u00b0C = %.1f K\"%(T)\n",
      "\n",
      "print \"Pressure at which steam would beahve similar to air at 10 bar and 27\u00b0C = %.2f bar\"%(p)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Temperature at which steam would beahve similar to air at 10 bar and 27\u00b0C = 1465.6 K\n",
        "Pressure at which steam would beahve similar to air at 10 bar and 27\u00b0C = 5.86 bar\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 11.4 Page No : 399"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\t\t\t\n",
      "# Variables\n",
      "pc = 3.77e6 \t\t\t#Pa \t\t\t#critical pressure\n",
      "p = 5.65e6 \t\t\t#Pa\n",
      "Tc = 132.5 \t\t\t#K \t\t\t#critical temperature\n",
      "T = 300 \t\t\t#K\n",
      "\n",
      "\t\t\t\n",
      "# Calculations and Results\n",
      "pR = p/pc \t\t\t#reduced pressure\n",
      "TR = T/Tc \t\t\t#reduced temperature\n",
      "\t\t\t#from generalized compressibilty chart\n",
      "Z =0.97\n",
      "print \"From the generalized compressiblity chart,\\\n",
      " at reduced pressure of %.1f and reduced temperature of %.2f, Z = %.2f\"%(pR,TR,Z)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "From the generalized compressiblity chart, at reduced pressure of 1.5 and reduced temperature of 2.26, Z = 0.97\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 11.5 Page No : 299"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "T =150.+273 \t\t\t#K\n",
      "p = 7e6 \t\t\t#Pa\n",
      "\n",
      "#Part (i)\n",
      "print \"Parti\"\n",
      "v = (8314.3/44)*T/p \t\t\t#m**3/kg\n",
      "print \"Specific volume for gaseous propane using ideal gas equation = %.4f m**3/kg\"%(v)\n",
      "\n",
      "#Part(ii)\n",
      "print \"Partii\"\n",
      "pc = 4.26e6 \t\t\t#Pa \t\t\t#critical pressure\n",
      "Tc = 370. \t\t\t#K \t\t\t#critical temperature\n",
      "\n",
      "pR = p/pc \t\t\t#reduced pressure\n",
      "TR = T/Tc \t\t\t#reduced temperature\n",
      "Z = 0.56 \t\t\t#compressibility factor\n",
      "print \"From the generalized compressiblity chart,\\\n",
      " at reduced pressure of %.1f and reduced temperature of %.2f, Z = %.2f\"%(pR,TR,Z)\n",
      "v = Z*v\n",
      "print \"Specific volume for gaseous propane using generalized compressiblity chart = %.5f m**3/kg\"%(v)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Parti\n",
        "Specific volume for gaseous propane using ideal gas equation = 0.0114 m**3/kg\n",
        "Partii\n",
        "From the generalized compressiblity chart, at reduced pressure of 1.6 and reduced temperature of 1.14, Z = 0.56\n",
        "Specific volume for gaseous propane using generalized compressiblity chart = 0.00639 m**3/kg\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 11.6 Page No : 404"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\t\t\t\n",
      "# Variables\n",
      "m = 5.\t\t\t#kg \t\t\t#mass of CO2\n",
      "T = 300. \t\t\t#K\n",
      "R = 8314.3/44 \t\t\t#J/kgK\n",
      "V = 1.5 \t\t\t#m**3\n",
      "\n",
      "#Part(i)\n",
      "print \"Parti\"\n",
      "p = m*R*T/V\n",
      "print \"Pressure exerted by CO2using ideal gas equation) = %.2f kPa\"%(p*.001)\n",
      "\n",
      "#Part(ii)\n",
      "print \"Partii\"\n",
      "R = 8.3143 \t\t\t#J/kmolK\n",
      "a = 0.3658e3 \t\t\t#kPam**6/kmol**2\n",
      "b = 0.0428 \t\t\t#m**3.kmol\n",
      "v = 44*V/m \t\t\t#m**3/kmol\n",
      "p = T*R/(v-b) - a/v**2\n",
      "print \"Pressure exerted by CO2using van der Waals equation) = %.1f kPa\"%(p)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Parti\n",
        "Pressure exerted by CO2using ideal gas equation) = 188.96 kPa\n",
        "Partii\n",
        "Pressure exerted by CO2using van der Waals equation) = 187.5 kPa\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 11.7 Page No : 406"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "\t\t\t\n",
      "# Variables\n",
      "M = 28. \t\t\t#g/mol\n",
      "m = 3.5\t\t\t#kg\n",
      "V = 0.015 \t\t\t#m**3\n",
      "v = V/m \t\t\t#m**3/kg\n",
      "T = 473. \t\t\t#K\n",
      "R = 8314.3/M \t\t\t#J/kgK\n",
      "\t\t\t\n",
      "# Calculations and Results\n",
      "\n",
      "#Part(i)\n",
      "print \"Parti\"\n",
      "p = m*R*T/V \t\t\t#Pa\n",
      "print \"Pressure using ideal gas equation of state) = %.2f MPa\"%(p*1e-6)\n",
      "\n",
      "#Part(ii)\n",
      "print \"Partii\"\n",
      "pc = 3.39e6 \t\t\t#Pa \t\t\t#critical pressure\n",
      "Tc = 126.2 \t\t\t#K \t\t\t#critical temperature\n",
      "vc = 0.0899 \t\t\t#m**3/kmol \t\t\t#critical volume\n",
      "\n",
      "TR = T/Tc \t\t\t#reduced temperature\n",
      "vR = v/(R*Tc/pc) \t\t\t#reduced volume\n",
      "Z = 1.1 \t\t\t#Compressibility factor\n",
      "print \"From the generalized compressiblity chart, \\\n",
      " at reduced volume of %.4f and reduced temperature of %.2f, Z = %.2f\"%(vR,TR,Z)\n",
      "p = Z*R*T/v \t\t\t#Pa\n",
      "print \"Pressure using generalised compressibility chart) = %.3f MPa\"%(p*1e-6)\n",
      "\n",
      "#Part(iii)\n",
      "print \"Partiii\"\n",
      "a = 0.1366e6 \t\t\t#Pam**5/kmol**2\n",
      "b = 0.0386 \t\t\t#m**3/kmol\n",
      "p = (8314.3*T/(v*M - b)) - a/(v*M)**2\n",
      "print \"Pressure using van der Waals equation) = %.2f MPa\"%(p*1e-6)\n",
      "\n",
      "#Part(iv)\n",
      "print \"Partiv\"\n",
      "a = (0.427*(R*M)**2*Tc**2.5/pc)\n",
      "b = 0.0866*(R*M*Tc/pc)\n",
      "\n",
      "p = (R*M*T/(v*M-b))-(a/(((v*M)**2 + v*M*b)*(T**0.5)))\n",
      "print \"Pressure using Redlich-Kwong equation of state) = %.2f MPa\"%(p*1e-6)\n",
      "\n",
      "\n",
      "#Part(v)\n",
      "print \"Partv\"\n",
      "A0 = 136.2315\n",
      "a = 0.02617\n",
      "B0 = 0.05046\n",
      "b = -0.00691\n",
      "c = 42000\n",
      "\n",
      "A = A0*(1 - a/(v*M))\n",
      "B = B0*(1 - b/(v*M))\n",
      "eps = c/(T**3 * v*M)\n",
      "p = ((8314.3)*T*(1-eps)*(v*M+B))/(v*M)**2 - 1e3*A/(v*M)**2\n",
      "print \"Pressure using ideal gas equation of state) = %.2f MPa\"%(p*1e-6)\n",
      "\n",
      "\t\t\t#---Note--- \t\t\t\n",
      "# Calculations and Results to Part(iv) in the textbook is 40.58 MPa which is wrong. \n",
      "#  The correct solution (38.13 MPa) is computed here.\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Parti\n",
        "Pressure using ideal gas equation of state) = 32.77 MPa\n",
        "Partii\n",
        "From the generalized compressiblity chart,  at reduced volume of 0.3877 and reduced temperature of 3.75, Z = 1.10\n",
        "Pressure using generalised compressibility chart) = 36.049 MPa\n",
        "Partiii\n",
        "Pressure using van der Waals equation) = 38.83 MPa\n",
        "Partiv\n",
        "Pressure using Redlich-Kwong equation of state) = 38.13 MPa\n",
        "Partv\n",
        "Pressure using ideal gas equation of state) = 39.79 MPa\n"
       ]
      }
     ],
     "prompt_number": 1
    }
   ],
   "metadata": {}
  }
 ]
}