{
 "metadata": {
  "name": "",
  "signature": "sha256:847237c1ec4fe9b48879d56b25df72cea30519627c7c21f865146516f12f2299"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 2 : PVT Properties of Fluids - Equations of State"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.1 page : 13"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\t\t\t\n",
      "# Variables\n",
      "basis  =  1 \t\t\t#kmol n bumath.tane\n",
      "P = 1.013*10**5 \t\t\t#N/m**2\n",
      "R = 8.3143*10**3 \t\t\t#J/kmol K\n",
      "T = 272.6 \t\t\t#K\n",
      "\t\t\t\n",
      "# Calculations\n",
      "V = basis*R*T/P\n",
      "Ts = 373.1 \t\t\t#K\n",
      "Vs = basis*R*Ts/P\n",
      "\t\t\t\n",
      "# Results\n",
      "print \"Volume in case 1  =  %.2f m**3\"%(V)\n",
      "print \" Volume in case 2  =  %.2f m**3\"%(Vs)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Volume in case 1  =  22.37 m**3\n",
        " Volume in case 2  =  30.62 m**3\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.2 page : 15"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\t\t\t\n",
      "# Variables\n",
      "Vb = 30 \t\t\t#m**3/kmol\n",
      "P = 1.013*10**5 \t\t\t#Pa\n",
      "R = 8.3143*10**3 \t\t\t#J/kmol K\n",
      "T = 373.1 \t\t\t#K\n",
      "\t\t\t\n",
      "# Calculations\n",
      "Z = P*Vb/(R*T)\n",
      "\t\t\t\n",
      "# Results\n",
      "print \"Compressibility factor  =  %.3f\"%(Z)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Compressibility factor  =  0.980\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.3 page : 21"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "# Variables\n",
      "Pc = 22.12*10**6 \t\t\t#Pa\n",
      "Tc = 647.3 \t\t\t#K\n",
      "Vc = 0.05697 \t\t\t#m**3/Kmol\n",
      "R = 8.3143*10**3\n",
      "Tr = 0.7\n",
      "\t\t\t\n",
      "# Calculations\n",
      "Zc = Pc*Vc/(R*Tc) \n",
      "T = Tr*Tc\n",
      "Ps = 10**6 \t\t\t#Pa\n",
      "w = -math.log10(Ps/Pc) -1\n",
      "\t\t\t\n",
      "# Results\n",
      "print \"critical compressibility factor   =  %.3f\"%(Zc)\n",
      "print \" Accentric factor  =  %.4f\"%(w)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "critical compressibility factor   =  0.234\n",
        " Accentric factor  =  0.3448\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.4A page : 28"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\t\t\t\n",
      "# Variables\n",
      "basis =  1 \t\t\t#kmol ammonia\n",
      "P = 10**6 \t\t\t#pa\n",
      "a = 4.19\n",
      "b = 0.0373\n",
      "R = 8314.3\n",
      "Tc = 405.5\n",
      "Pc = 11.28*10**6\n",
      "\t\t\t\n",
      "# Calculations\n",
      "print (\"case a\")\n",
      "print (\"Umath.sing vandwerwaals equation, \")\n",
      "print (\"(P+a/v**2)*(V-b)  =  R*T, on solving by trail and error method,\")\n",
      "V = 3\n",
      "print \"Volume  =  %d m**3/kmol\"%(V)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "case a\n",
        "Umath.sing vandwerwaals equation, \n",
        "(P+a/v**2)*(V-b)  =  R*T, on solving by trail and error method,\n",
        "Volume  =  3 m**3/kmol\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.4B page : 28"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\t\t\t\n",
      "# Variables\n",
      "basis =  1. \t\t\t#kmol ammonia\n",
      "P = 10.**6 \t\t\t#pa\n",
      "a = 4.19\n",
      "b = 0.0373\n",
      "R = 8314.3\n",
      "Tc = 405.5\n",
      "Pc = 11.28*10**6\n",
      "\t\t\t\n",
      "# Calculations\n",
      "print (\"part b\")\n",
      "an = 27*R**2*Tc**2 /(64*Pc)\n",
      "bn = R*Tc/(8*Pc)\n",
      "V = 3\n",
      "\t\t\t\n",
      "# Results\n",
      "print \"Since an and bn are same as a and b, V is the same  =  %d m**3/kmol\"%(V)\n",
      "\n",
      "# note : rounding off error."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "part b\n",
        "Since an and bn are same as a and b, V is the same  =  3 m**3/kmol\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.4C page : 28"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\t\t\t\n",
      "# Variables\n",
      "print (\"part c\")\n",
      "print (\"USing SRK equation, P =  RT/(V-b) -alph*a/(V*(V+b))\")\n",
      "print (\"By trail and error method,\")\n",
      "\t\t\t\n",
      "# Calculations\n",
      "v2 = 2.98\n",
      "\t\t\t\n",
      "# Results\n",
      "print \"volume  =  %.2f m**3/kmol\"%(v2)\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "part c\n",
        "USing SRK equation, P =  RT/(V-b) -alph*a/(V*(V+b))\n",
        "By trail and error method,\n",
        "volume  =  2.98 m**3/kmol\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.5 page : 36"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\t\t\t\n",
      "# Variables\n",
      "Pc = 22.12*10**6 \t\t\t#Pa\n",
      "Tc = 647.3 \t\t\t#K\n",
      "Zc = 0.234\n",
      "T = 973.1 \t\t\t#K\n",
      "P = 25*10**6 \t\t\t#Pa\n",
      "\t\t\t\n",
      "# Calculations\n",
      "Tr = T/Tc\n",
      "Pr = P/Pc\n",
      "Z = 0.916\n",
      "Zn = Z+0.05*(Zc-0.27)\n",
      "\t\t\t\n",
      "# Results\n",
      "print \"Compresson factor  =  %.3f \"%(Zn)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Compresson factor  =  0.914 \n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 2.6 page : 39"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\t\t\t\n",
      "# Variables\n",
      "w = 0.3448\n",
      "Z0 = 0.898\n",
      "Z1 = 0.08\n",
      "\t\t\t\n",
      "# Calculations\n",
      "Z = Z0 + Z1*w\n",
      "\t\t\t\n",
      "# Results\n",
      "print \"Compression factor  =  %.3f \"%(Z)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Compression factor  =  0.926 \n"
       ]
      }
     ],
     "prompt_number": 10
    }
   ],
   "metadata": {}
  }
 ]
}