{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter No - 2 : Gas Laws And Properties\n",
      "    "
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example No :  2.1 - Page No :  22"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "# Given data\n",
      "P1= 250 # in kN/m**2\n",
      "V1= 6.2 # in m**3\n",
      "V2= 1.82 # in m**3\n",
      "# Formula P1*V1 = P2*V2\n",
      "P2= P1*V1/V2 # in kN/m**2\n",
      "print \"Pressure of air after compression = %0.1f kN/m**2 \" %P2"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Pressure of air after compression = 851.6 kN/m**2 \n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example No :  2.2 - Page No :  22"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "guagePressure= 1500 # in kN/m**2\n",
      "atmPressure= 100 # in kN/m**2\n",
      "P1= guagePressure+atmPressure # in kN/m**2\n",
      "V1= 0.1 # in m**3\n",
      "V2= 0.4 # in m**3\n",
      "# Formula P1*V1 = P2*V2\n",
      "P2= P1*V1/V2 # in kN/m**2\n",
      "NewGuagePressure= P2-atmPressure # in kN/m**2\n",
      "print \"New guage pressure = %0.f kN/m**2 (3 bar)\" %NewGuagePressure"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "New guage pressure = 300 kN/m**2 (3 bar)\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example No :  2.3 - Page No :  23"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "P1= -4+101.3 # in kN/m**2\n",
      "V1= 96+475 # in cm**3\n",
      "V2= 96 # in cm**3\n",
      "# Formula P1*V1 = P2*V2\n",
      "P2= P1*V1/V2 # in kN/m**2\n",
      "print \"Pressure at the end of the compression stroke = %0.1f kN/m**2 \" %P2\n",
      "print \"Pressure at the end of the compression stroke = %0.3f bar  \" %(P2*10**-2)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Pressure at the end of the compression stroke = 578.7 kN/m**2 \n",
        "Pressure at the end of the compression stroke = 5.787 bar  \n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example No :  2.4 - Page No :  25"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "V0= 1 # in m**3\n",
      "t= 300 # in \u00b0C\n",
      "V= V0*(1+t/273) # in m**3\n",
      "print \"The volume occupied = %0.1f m**3 \" %V"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The volume occupied = 2.1 m**3 \n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example No :  2.5 - Page No :  25"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "V1= 2 # in m**3\n",
      "T1= 30+273 # in K\n",
      "T2= 230+273 # in K\n",
      "# V1/T1 = V0/T0 = V2/T2\n",
      "V2= V1*T2/T1 # in m**3\n",
      "print \"The final volume = %0.3f m**3 \" %V2"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The final volume = 3.320 m**3 \n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example No :  2.6 - Page No :  29"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "P1= 7*10**5 # in N/m**2\n",
      "V1= 3 # in m**3\n",
      "V2= 9 # in m**3\n",
      "T1= 150+273 # in K\n",
      "T2= 10+273 # in K\n",
      "# Formula P1*V1/T1 = P2*V2/T2\n",
      "P2= P1*V1*T2/(T1*V2) # in N/m**2\n",
      "print \"Pressure of the gas = %0.3f bar \" %(P2*10**-5)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Pressure of the gas = 1.561 bar \n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example No :  2.7 - Page No :  29"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "P1= 100 # in kN/m**2\n",
      "V1byV2= 12 # in \n",
      "T1= 115+273 # in K\n",
      "T2= 180+273 # in K\n",
      "# Formula P1*V1/T1 = P2*V2/T2\n",
      "P2= P1*V1byV2*T2/T1 # in N/m**2\n",
      "print \"Absolute pressure at the end of compression stroke = %0.2f bar \" %(P2*10**-2)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Absolute pressure at the end of compression stroke = 14.01 bar \n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example No :  2.8 - Page No :  30"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "mR= 8314.3 # in J/kg-mole-K\n",
      "P= 200*10**3 # in N/m**2\n",
      "T= 30+273 # in K\n",
      "# Formula P*V = mR*T\n",
      "V= mR*T/P # in m**3\n",
      "print \"The molecular volume of all the gases = %0.3f m**3 \" %V"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The molecular volume of all the gases = 12.596 m**3 \n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example No :  2.9 - Page No :  30"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "P1= 96 # in kN/m**2\n",
      "P2= 725 # in kN/m**2\n",
      "V1= 600 # in cm**3\n",
      "V2= 100 # in cm**3\n",
      "T1= 100+273 # in K\n",
      "# Formula P1*V1/T1 = P2*V2/T2\n",
      "T2= P2*V2*T1/(P1*V1) # in K\n",
      "print \"Temperature at the end of compression = %0.3f \u00b0C \" %(T2-273)\n",
      "# Note:- In the book, There is an error to calculate the value of T2."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Temperature at the end of compression = 196.488 \u00b0C \n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example No :  2.10 - Page No :  30"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "MR= 8314.2 # in J/kg-mole-K\n",
      "mass= 44 # Molecular mass of carbon dioxide in kg\n",
      "R= MR/mass # in J/kg-K\n",
      "P= 11 # in MPa\n",
      "P=P*10**6 # in Pa\n",
      "V= 50*10**-3 # in m**3\n",
      "T= 18+273 # in K\n",
      "# Formula P*V= m*R*T\n",
      "m= P*V/(R*T) # in kg\n",
      "m=round(m) # in kg\n",
      "MolecularVolume= MR*T/P # in m**3\n",
      "D= m/V # density of the gas in kg/m**3\n",
      "SpecificVolume= 1/D # in m**3/kg\n",
      "print \"The mass of the gas = %0.f kg \" %m\n",
      "print \"The Molecular volume = %0.2f m**3 \" %MolecularVolume\n",
      "print \"The density of the gas = %0.f kg/m**3 \" %D\n",
      "print \"The specific volume of the gas = %0.3f m**3/kg \" %SpecificVolume"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The mass of the gas = 10 kg \n",
        "The Molecular volume = 0.22 m**3 \n",
        "The density of the gas = 200 kg/m**3 \n",
        "The specific volume of the gas = 0.005 m**3/kg \n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example No :  2.11 - Page No :  31"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "P1= 350 # in kN/m**2\n",
      "P1=P1*10**3 # in N/m**2\n",
      "P2= 1.05 # in kN/m**2\n",
      "P2=P2*10**6 # in N/m**2\n",
      "V= 0.3 # in m**3\n",
      "R= 0.29 # in kJ/kg-K\n",
      "R= R*10**3 # in j/kgK\n",
      "T1= 35+273 # in K\n",
      "# Formula P*V= m*R*T\n",
      "m= P1*V/(R*T1) # in kg\n",
      "# Formula P1*V1/T1 = P2*V2/T2 and since V1= V2\n",
      "T2= P2*T1/P1 # in K\n",
      "print \"Temperature at constant volume compression = %0.f \u00b0C \" %(T2-273)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Temperature at constant volume compression = 651 \u00b0C \n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example No :  2.12 - Page No :  31"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "g1= 1.75 # gauge reading in bar\n",
      "atm= 1.013 # in atmospheric pressure in bar\n",
      "P1= g1+atm # in bar\n",
      "T1= 12+273 # in K\n",
      "T2= 45+273 # in K\n",
      "# Formula P1*V1/T1 = P2*V2/T2 and since V1= V2\n",
      "P2= P1*T2/T1 # in bar\n",
      "g2=P2-atm # tyre gauge reading in bar \n",
      "print\"Tyre guage reading at 45\u00b0C = %0.2f bar \"%g2"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Tyre guage reading at 45\u00b0C = 2.07 bar \n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example No :  2.13 - Page No :  37"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "Q= 120 # in kJ\n",
      "W= 150 # in kJ\n",
      "E= Q-W # change in internal energy in kJ\n",
      "print \"The internal energy of the system decreases by %0.0f kJ\" %abs(E)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The internal energy of the system decreases by 30 kJ\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example No :  2.14 - Page No :  37"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "Q= -40 # in kJ/kg\n",
      "W= -80 # in kJ/kg\n",
      "E= Q-W # change in internal energy in kJ/kg\n",
      "print \"Change in internal energy = %0.0f kJ/kg \" %E\n",
      "print \"Thus internal energy of the working substance increases \""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Change in internal energy = 40 kJ/kg \n",
        "Thus internal energy of the working substance increases \n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example No :  2.15 - Page No :  37"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "Int_energy_changes= 20 # in kJ/kg\n",
      "Q= 0 # in kJ\n",
      "W= -90 # in kJ\n",
      "E= Q-W # change in internal energy in kJ/kg\n",
      "m= E/Int_energy_changes # in kg\n",
      "print \"The mass of the fluid in the system = %0.1f kg \" %m"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The mass of the fluid in the system = 4.5 kg \n"
       ]
      }
     ],
     "prompt_number": 15
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example No :  2.16 - Page No :  38"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "U= 2800 # in kJ/kg\n",
      "P= 20 # in bar\n",
      "P= P*10**5 # in N/m**2\n",
      "V= 0.23/1000 # in m**3\n",
      "SP= U+P*V # specific enthalpy in kJ/kg\n",
      "print \"The specific enthalpy = %0.0f kJ/kg \" %SP"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The specific enthalpy = 3260 kJ/kg \n"
       ]
      }
     ],
     "prompt_number": 16
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example No :  2.17 - Page No :  38"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "h1= 210 #first heat transfer in kJ\n",
      "h2= -20 # second heat transfer in kJ\n",
      "h3= -190 # third heat transfer in kJ\n",
      "h4= 60 # fourth heat transfer in kJ\n",
      "W1= -180 # first work transfer in kJ\n",
      "W2= 200 # second  work transfer in kJ\n",
      "W3= -300 # third  work transfer in kJ\n",
      "# Total Heat transfer = Total work transfer\n",
      "W4= h1+h2+h3+h4-W1-W2-W3 # forth  work transfer in kJ\n",
      "print \"Fourth work transfer = %0.0f kJ is :\" %W4\n",
      "print \"Thus the system delivers\",int(W4),\"kJ of work\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Fourth work transfer = 340 kJ is :\n",
        "Thus the system delivers 340 kJ of work\n"
       ]
      }
     ],
     "prompt_number": 17
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example No :  2.18 - Page No :  47"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "Cv= 0.718 # in kJ/kgK\n",
      "R= 0.278 # in kJ/kgK\n",
      "T1= 15+273 # in K\n",
      "T2= 135+273 # in K\n",
      "m= 2 # mass in kg\n",
      "V1= 0.7 # in m**3\n",
      "Q= m*Cv*(T2-T1) # in kJ\n",
      "print \"Heat supplied to gas = %0.2f kJ \" %Q\n",
      "# Formula P1*V1= m*R*T1\n",
      "P1= m*R*T1/V1 # in kN/m**2 absolute\n",
      "# From P1/T1= P2/T2\n",
      "P2= P1*T2/T1 # in kN/m**2\n",
      "print \"The final pressure = %0.1f kN/m**2 \" %P2\n",
      "# Note : The calculation in the book is not accurate"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Heat supplied to gas = 172.32 kJ \n",
        "The final pressure = 324.1 kN/m**2 \n"
       ]
      }
     ],
     "prompt_number": 18
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example No :  2.19 - Page No :  48"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "Cv= 1.005 # in kJ/kgK\n",
      "T1= 200+273 # in K\n",
      "T2= 15+273 # in K\n",
      "V1= 0.12 # in m**3\n",
      "m= 0.25 # mass in kg\n",
      "Q= m*Cv*(T1-T2) # in kJ\n",
      "print \"Heat extracted from the gas = %0.2f kJ \" %Q\n",
      "# From V1/T1= V2/T2\n",
      "V2= V1*T2/T1 # in m**3\n",
      "print \"The final volume of the gas = %0.3f m**3 \" %V2"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Heat extracted from the gas = 46.48 kJ \n",
        "The final volume of the gas = 0.073 m**3 \n"
       ]
      }
     ],
     "prompt_number": 19
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example No :  2.20 - Page No :  48"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "m=2 # molecular mass\n",
      "UGC= 8.3143 # universal gas constant in kJ/kg-mole-K\n",
      "Cp= 14.41 # in kJ/kg-K\n",
      "R= UGC/m # in kJ/kgK\n",
      "Cv= Cp-R # in kJ/kgK\n",
      "gama= Cp/Cv \n",
      "print \"The value of R = %0.3f kJ/kgK is :\" %R\n",
      "print \"The value of Cv = %0.3f kJ/kgK \" %Cv\n",
      "print \"The value of gama = %0.1f\" %gama"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of R = 4.157 kJ/kgK is :\n",
        "The value of Cv = 10.253 kJ/kgK \n",
        "The value of gama = 1.4\n"
       ]
      }
     ],
     "prompt_number": 20
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example No :  2.21 - Page No :  48"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "Cp = 0.796 # in kJ/kg-K\n",
      "Cv = 0.67 # in kJ/kg-K\n",
      "P1=1 # in bar\n",
      "P1= P1*10**5 # in N/m**2\n",
      "P2=3.5 # in bar\n",
      "P2= P2*10**5 # in N/m**2\n",
      "V1= 0.12 # in m**3\n",
      "V2= 0.05 # in m**3\n",
      "m=1 # in kg\n",
      "R= Cp-Cv # in kJ/kg-K\n",
      "R= R*10**3 # in J/kg-K\n",
      "# Formula P*V= m*R*T\n",
      "T1= P1*V1/(m*R) # in K\n",
      "# Formula P1*V1/T1 = P2*V2/T2\n",
      "T2= P2*V2*T1/(P1*V1) # in K\n",
      "T= T2-T1 # Temperature rise in K\n",
      "print \"Temperature rise = %0.1f K \" %T\n",
      "E= m*Cv*(T2-T1) # change in internal energy kJ\n",
      "print \"Change in internal energy = %0.1f kJ \" %E"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Temperature rise = 43.7 K \n",
        "Change in internal energy = 29.2 kJ \n"
       ]
      }
     ],
     "prompt_number": 21
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example No :  2.22 - Page No :  49"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "CO2= 0.12 #volume of CO2 in m**3\n",
      "CO= 0.25 # in m**3\n",
      "H2= 0.06 # in m**3\n",
      "CH4= 0.02 # in m**3\n",
      "N2= 0.55 # in m**3\n",
      "R= 8.3143 # Universal gas constant in kJ/kg-mol-K\n",
      "mm_CO2= 44 # molecular mass of CO2\n",
      "mm_CO= 28 \n",
      "mm_H2= 2 \n",
      "mm_CH4= 16 \n",
      "mm_N2= 28 \n",
      "Gm_CO2= 5.28 # gravimetric mass of CO2\n",
      "Gm_CO= 7.00 \n",
      "Gm_H2= 0.12 \n",
      "Gm_CH4= 0.32 \n",
      "Gm_N2= 15.40 \n",
      "total_Gm= Gm_CO2+Gm_CO+Gm_H2+Gm_CH4+Gm_N2 \n",
      "Per_relative_CO2= Gm_CO2/total_Gm*100 # in %\n",
      "Per_relative_CO= Gm_CO/total_Gm*100 # in %\n",
      "Per_relative_H2= Gm_H2/total_Gm*100 # in %\n",
      "Per_relative_CH4= Gm_CH4/total_Gm*100 # in %\n",
      "Per_relative_N2= Gm_N2/total_Gm*100 # in %\n",
      "print \"Analysis % Relative : \"\n",
      "print \"CO2      :   \",round(Per_relative_CO2,1)\n",
      "print \"CO       :   \",round(Per_relative_CO,1)\n",
      "print \"H2       :   \",round(Per_relative_H2,3)\n",
      "print \"CH4      :   \",round(Per_relative_CH4,2)\n",
      "print \"N2       :   \",round(Per_relative_N2,1)\n",
      "App_Gas_Constant= R/total_Gm # in kJ/kg-K\n",
      "mol_Vol= 22.4 #mole volume at NTP in m**3\n",
      "Average_Density= total_Gm/mol_Vol # in kg/m**3 at NTP\n",
      "print \"The Apparent gas constant = %0.4f kJ/kg-K \" %App_Gas_Constant\n",
      "print \"The average density = %0.3f kg/m**3 at NTP. \" %Average_Density"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Analysis % Relative : \n",
        "CO2      :    18.8\n",
        "CO       :    24.9\n",
        "H2       :    0.427\n",
        "CH4      :    1.14\n",
        "N2       :    54.8\n",
        "The Apparent gas constant = 0.2957 kJ/kg-K \n",
        "The average density = 1.255 kg/m**3 at NTP. \n"
       ]
      }
     ],
     "prompt_number": 22
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example No :  2.23 - Page No :  50"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "Cv = 652 # in J/kg-K\n",
      "R= 287 # in J/kg-K\n",
      "Cp= Cv+R # in J/kg-K\n",
      "m=0.3 # in kg\n",
      "P= 1.5*10**5 # in N/m**2\n",
      "V= 0.283 # in m**3\n",
      "# Formula P*V= m*R*T\n",
      "T= P*V/(m*R) # in K\n",
      "T= T-273 # in \u00b0C\n",
      "T1= -40 # in \u00b0C\n",
      "delta_U= m*Cv*(T-T1) # in J\n",
      "print \"Internal energy = %0.3f kJ \" %(delta_U*10**-3)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Internal energy = 50.862 kJ \n"
       ]
      }
     ],
     "prompt_number": 23
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example No :  2.24 - Page No :50  "
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "H2= 0.50 #volume of H2 in m**3\n",
      "CH4= 0.19 # in m**3\n",
      "CO= 0.18 # in m**3\n",
      "C2H4= 0.02 # in m**3\n",
      "CO2= 0.05 # in m**3\n",
      "N2= 0.06 # in m**3\n",
      "P= 100 # pressure of mixture in kN/m**2\n",
      "mm_CO2= 44 # molecular mass of CO2\n",
      "mm_CO= 28 \n",
      "mm_H2= 2 \n",
      "mm_CH4= 16 \n",
      "mm_C2H4= 28 \n",
      "mm_N2= 28 \n",
      "R= 8.3143 # Universal gas constant in kJ/kg-mol-K\n",
      "R_H2= R/mm_H2 # gas constant for H2\n",
      "R_CO2= R/mm_CO2 \n",
      "R_CO= R/mm_CO \n",
      "R_C2H4= R/mm_C2H4 \n",
      "R_CH4= R/mm_CH4 \n",
      "R_N2= R/mm_N2 \n",
      "M= mm_CO2*CO2+mm_H2*H2+mm_CH4*CH4+mm_CO*CO+mm_C2H4*C2H4+mm_N2*N2 # in kg\n",
      "print \"Apparent molecular mass of the gas = %0.2f kg \" %M\n",
      "mol_Vol= 22.4 #mole volume at NTP in m**3\n",
      "density= M/mol_Vol # in kg/m**3\n",
      "print \"Density of the mixture             = %0.3f kg/m**3 \" %density\n",
      "mixture_G_constant= R/M # in kJ/kg-K \n",
      "print \"The mixture gas constant           = %0.3f kJ/kg-K \" %mixture_G_constant\n",
      "P_H2= P*H2 #partial pressure of H2 in kN/m**2\n",
      "P_CH4= P*CH4 # in kN/m**2\n",
      "P_CO= P*CO # in kN/m**2\n",
      "P_C2H4= P*C2H4 # in kN/m**2\n",
      "P_CO2= P*CO2 # in kN/m**2\n",
      "P_N2= P*N2 # in kN/m**2\n",
      "print \"The partial pressure of H2         = %0.0f kN/m**2\" %P_H2\n",
      "print \"The partial pressure of CH4        = %0.0f kN/m**2\" %P_CH4\n",
      "print \"The partial pressure of CO         = %0.0f kN/m**2\" %P_CO\n",
      "print \"The partial pressure of C2H4       = %0.0f kN/m**2\" %P_C2H4\n",
      "print \"The partial pressure of CO2        = %0.0f kN/m**2\" %P_CO2\n",
      "print \"partial pressure of N2             = %0.0f kN/m**2\" %P_N2"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Apparent molecular mass of the gas = 13.52 kg \n",
        "Density of the mixture             = 0.604 kg/m**3 \n",
        "The mixture gas constant           = 0.615 kJ/kg-K \n",
        "The partial pressure of H2         = 50 kN/m**2\n",
        "The partial pressure of CH4        = 19 kN/m**2\n",
        "The partial pressure of CO         = 18 kN/m**2\n",
        "The partial pressure of C2H4       = 2 kN/m**2\n",
        "The partial pressure of CO2        = 5 kN/m**2\n",
        "partial pressure of N2             = 6 kN/m**2\n"
       ]
      }
     ],
     "prompt_number": 24
    }
   ],
   "metadata": {}
  }
 ]
}