{
 "metadata": {
  "name": "",
  "signature": "sha256:63ec806cc789e6d4e52abc481b4c69dbae196d3a1063d71df1549638fb7b9752"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 2:Properties of Pure Substances"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex2.1, PG-28"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# initialization of variables\n",
      "\n",
      "m=10;  #mass of saturated water in kg\n",
      "\n",
      "    # All the necessary values are taken from table C.2\n",
      " \n",
      "# part (a)\n",
      " \n",
      "P=0.001; # Pressure in MPa\n",
      "vf=0.001; #specific volume of saturated liquid at 0.001 Mpa in Kg/m^3\n",
      "vg=129.2; # specific volume of saturated vapour at 0.001 Mpa in Kg/m^3\n",
      "deltaV=m*(vg-vf) # by properties of pure substance \n",
      "# result\n",
      "print \"The Volume change at pressure \",(P),\" MPa is\",round(deltaV),\" m^3 \\n\"\n",
      "\n",
      "# part (b) \n",
      "\n",
      "P=0.26;  # Pressure in MPa\n",
      "vf=0.0011; #   specific volume of saturated liquid at 0.26 MPa( it is same from at 0.2 and 0.3 MPa upto 4 decimals)\n",
      "vg=(P-0.2)*(0.6058-0.8857)/(0.3-0.2)+0.8857;  # specific volume of saturated vapour by interpolation of Values at 0.2 MPa and 0.3 MPa\n",
      "deltaV=m*(vg-vf) # by properties of pure substance \n",
      "# result\n",
      "print \"The Volume change at pressure \",(P),\" MPa is\",round(deltaV,2),\" m^3 \\n\"\n",
      "\n",
      "# part (c) \n",
      "P=10;  # Pressure in MPa\n",
      "vf=0.00145; # specific volume of saturated liquid at 10 MPa\n",
      "vg=0.01803; # specific volume of saturated vapour at 10 MPa\n",
      "deltaV=m*(vg-vf) # by properties of pure substance \n",
      "# result\n",
      "print \"The Volume change at pressure \",(P),\" MPa is\",round(deltaV,4),\" m^3 \\n\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The Volume change at pressure  0.001  MPa is 1292.0  m^3 \n",
        "\n",
        "The Volume change at pressure  0.26  MPa is 7.17  m^3 \n",
        "\n",
        "The Volume change at pressure  10  MPa is 0.1658  m^3 \n",
        "\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex2.2, PG-29"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#    initialization of variables\n",
      "m=4.0 # mass of water in kg\n",
      "V=1.0 # volume in m^3\n",
      "T=150 # temperature of water in degree centigrade\n",
      "\n",
      "# TABLE C.1 is used for values in wet region\n",
      "# Part (a)\n",
      "P=475.8 # pressure in KPa in wet region at temperature of 150 *C\n",
      "print \" The pressure is\",round(P,2),\" kPa \\n\"\n",
      "\n",
      "# Part (b)\n",
      "#first we determine the dryness fraction\n",
      "v=V/m # specific volume of water\n",
      "vg=0.3928 #  specific volume of saturated vapour @150 degree celsius\n",
      "vf=0.00109 # specific volume of saturated liquid @150 degree celsius\n",
      "x=(v-vf)/(vg-vf); # dryness fraction\n",
      "mg=m*x; # mass of vapour\n",
      "print \" The mass of vapour present is\",round(mg,3),\" kg \\n\"\n",
      "\n",
      "# Part(c) \n",
      "Vg=mg*vg; # volume of vapour\n",
      "print \" The volume of vapour is\",round(Vg,3),\" m^3\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " The pressure is 475.8  kPa \n",
        "\n",
        " The mass of vapour present is 2.542  kg \n",
        "\n",
        " The volume of vapour is 0.998  m^3\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex2.3, PG-29"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#    initialization of variables\n",
      "m=2 # mass of water in kg\n",
      "P=220 # pressure in KPa\n",
      "x=0.8 # quality of steam\n",
      "\n",
      "# Table C.2 is used for values\n",
      "\n",
      "vg=(P-200)*(0.6058-0.8857)/(300-200)+0.8857 # specific volume of saturated vapour @ given pressure by interpolating\n",
      "vf=0.0011 # specific volume of saturated liquid @ 220 KPa\n",
      "v=vf+x*(vg-vf)# property of pure substance\n",
      "V=m*v # total volume\n",
      "#result\n",
      "print \"The Total volume of the mixture is \",round(V,3),\" m^3\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The Total volume of the mixture is  1.328  m^3\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex2.4, PG-30"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#   initialization of variables\n",
      "m=2 # mass of water in kg\n",
      "P=2.2 # pressure in Mpa\n",
      "T=800 # temperature in degree centigrade\n",
      " # Table C.3 is used for values\n",
      "v=0.2467+(P-2)*(0.1972-0.2467)/(2.5-2) # specific volue by interpolatin between 2 and 2.5 MPa\n",
      "V=m*v # final volume\n",
      "print \"The Final Volume is\",round(V,3),\" m^3\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The Final Volume is 0.454  m^3\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex2.5, PG-32"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#    initialization of variables\n",
      "V=0.6 # volume of tyre in m^3\n",
      "Pgauge=200 # gauge pressure in KPa\n",
      "T=20+273 # temperature converted to kelvin\n",
      "Patm=100 # atmospheric pressure in KPa\n",
      "R=287 # gas constant in Nm/kg.K\n",
      "Pabs=(Pgauge+Patm)*1000 # calculating absolute pressue in Pa \n",
      "\n",
      "m=Pabs*V/(R*T)# mass from ideal gas equation\n",
      "print \"The Mass of air is\",round(m,2),\" Kg\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The Mass of air is 2.14  Kg\n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Ex2.6, PG-33"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#    initialization of variables\n",
      "T=500+273 # temperature of steam in kelvin\n",
      "rho=24.0 # density in Kg/m^3\n",
      "R=0.462 # gas constant from Table B.2\n",
      "v=1/rho # specific volume and density relation\n",
      "# PART (a)\n",
      "P=rho*R*T # from Ideal gas equation\n",
      "print \" PART (a) The Pressure is \",int(P),\" KPa \\n\"\n",
      "# answer is approximated in textbook\n",
      "\n",
      "# PART (b)\n",
      "a=1.703 #  van der Waal's constant a value from Table B.7\n",
      "b=0.00169 # van der Waal's constant b value from Table B.7\n",
      "P=(R*T/(v-b))-(a/v**2) # Pressure from van der Waal's equation\n",
      "print \" PART (b) The Pressure is \",int(P),\" KPa \\n\"\n",
      "# answer is approximated in textbook\n",
      "\n",
      "# PART (c)\n",
      "a=43.9 # van der Waal's constant a value from Table B.7\n",
      "b=0.00117 # van der Waal's constant b value from Table B.7\n",
      "\n",
      "P=(R*T/(v-b))-(a/(v*(v+b)*math.sqrt(T))) # Redlich-Kwong equation\n",
      "print \" PART (c) The Pressure is \",int(P),\" KPa \\n\"\n",
      "# answer is approximated in textbook\n",
      "\n",
      "# PART (d)\n",
      "Tcr=947.4 # compressibilty temperature from table B.3\n",
      "Pcr=22100 # compressibility pressure from table B.3\n",
      "\n",
      "TR=T/Tcr # reduced temperature\n",
      "PR=P/Pcr # reduced pressure\n",
      "Z=0.93 # from compressiblility chart\n",
      "P=Z*R*T/v # Pressure in KPa\n",
      "print \" PART (d) The Pressure is \",int(P),\" KPa \\n\"\n",
      "# answer is approximated in textbook\n",
      "\n",
      "# PART (e)\n",
      "P=8000 # pressure from steam table @ 500*c and v= 0.0417 m^3\n",
      "print \" PART (e) The Pressure is \",int(P),\" KPa \\n\"\n",
      "# answer is approximated in textbook\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " PART (a) The Pressure is  8571  KPa \n",
        "\n",
        " PART (b) The Pressure is  7952  KPa \n",
        "\n",
        " PART (c) The Pressure is  7934  KPa \n",
        "\n",
        " PART (d) The Pressure is  7971  KPa \n",
        "\n",
        " PART (e) The Pressure is  8000  KPa \n",
        "\n"
       ]
      }
     ],
     "prompt_number": 23
    }
   ],
   "metadata": {}
  }
 ]
}