{
 "metadata": {
  "name": "",
  "signature": "sha256:86277517338e3080962ec366bf78a36ead36dc032944d5f67a8c58022c6af85a"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 13 : Ideal Gases"
     ]
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      " Example 13.1  Page No. 404\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Variables\n",
      "m_CO2 = 40. ;\t\t\t# Mass of CO2-[kg]\n",
      "mol_wt_CO2 = 44. ;\t\t\t# Molecular mass of 1kmol CO2 -[kg]\n",
      "mol_V = 22.42 ;\t\t\t# Molar of ideal gas at standard condition-[cubic metre/kg mol]\n",
      "\n",
      "# Calculations\n",
      "V_CO2 = (m_CO2 * mol_V)/(mol_wt_CO2);\t\t\t# volume of CO2-[cubic metre]\n",
      "\n",
      "# Results\n",
      "print 'Volume occupied by 40 kg CO2 at standard condition is  %.1f cubic metre.'%V_CO2\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Volume occupied by 40 kg CO2 at standard condition is  20.4 cubic metre.\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      " Example 13.2  Page No. 405\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Variables\n",
      "p =1. ;\t\t\t# Pressure -[atm]\n",
      "V = 22415. ;\t\t\t# Molar valume -[cubic centimetre/g mol]\n",
      "T = 273.15 ;\t\t\t# Temperature-[K]\n",
      "\n",
      "# Calculations\n",
      "R = (p*V/T);\t\t\t# Universal gas constant-[(cubic centimetre.atm)/(K.g mol)]\n",
      "\n",
      "# Results\n",
      "print 'Universal gas constant is  %.2f (cubic centimetre*atm)/(K*g mol). '%R\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Universal gas constant is  82.06 (cubic centimetre*atm)/(K*g mol). \n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "   Example 13.3     Page No.406\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Variables\n",
      "m_CO2 = 88. ;\t\t\t#   Mass of CO2-[lb]\n",
      "mol_wt_CO2 = 44.  ;\t\t#   Molecular mass of 1 lb mol CO2 -[lb]\n",
      "mol_V = 359. ; \t\t\t#   Molar volume-[cubic feet]\n",
      "\n",
      "#  State 1-standard condition\n",
      "P1 = 33.91 ; \t\t\t#   Pressure -[ft of water]\n",
      "T1 = 273.  ;\t\t\t#  Temperature-[K]\n",
      "\n",
      "#   State 2\n",
      "P2 = 32.2  ;\t\t\t#   Pressure -[ft of water]\n",
      "Tc = 15.  ;\t\t\t    #   Temperature-[degree C]\n",
      "T2 = Tc+273  ;\t\t\t#  Temperature-[K]\n",
      "\n",
      "# Calculations\n",
      "V1 = (m_CO2 * mol_V) / (mol_wt_CO2);\n",
      "V2 = (V1 * T2 * P1) / (T1 * P2);\n",
      "\n",
      "# Results\n",
      "print 'The volume occupied 88 lb of CO2 at given condition is  %.0f cubic feet.'%V2\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The volume occupied 88 lb of CO2 at given condition is  798 cubic feet.\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      " Example 13.4  Page No. 408\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Variables\n",
      "mol_wt_N2 = 28. ;\t# Molecular mass of 1 kg mol N2 -[kg]\n",
      "mol_V = 22.42 ;\t\t# Molar of ideal gas at standard condition-[cubic metre/kg mol]\n",
      "Tc =  27. ;\t\t\t# Temperature-[degree C]\n",
      "T = Tc + 273. ;\t\t#Temperature-[K]\n",
      "P = 100. ;\t\t\t#Pressure-[kPa]\n",
      "\t\t\t\n",
      "Ps = 101.3 ;\t\t# Pressure -[kPa]\n",
      "Ts = 273. ;\t\t\t#Temperature-[K]\n",
      "\n",
      "# Calculations\n",
      "V = (T *  Ps *  mol_V)/(Ts *  P) ;\t\t\t# Volume occupied by N2-[cubic metre]\n",
      "D_N2 = mol_wt_N2/V ;\t\t\t            # Density of N2 at given condition-[kg/cubic metre]\n",
      "\n",
      "# Results\n",
      "print ' Density of N2 at given condition is  %.3f kg/cubic metre.'%D_N2\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " Density of N2 at given condition is  1.122 kg/cubic metre.\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 13.5 Page No. 409 \n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Variables\n",
      "mol_wt_N2 = 28. ;\t\t\t# Molecular mass of 1 lb mol N2 -[lb]\n",
      "mol_wt_air = 29. ;\t\t\t# Molecular mass of 1 lb mol air -[lb]\n",
      "mol_V = 359. ;\t\t\t    # Molar volume of ideal gas-[cubic feet]\n",
      "\t\n",
      "Tf =  80. ;\t\t\t# Temperature-[degree F]\n",
      "T = Tf + 460. ;\t\t#Temperature-[degree Rankine]\n",
      "P = 745. ;\t\t\t#Pressure-[mm of Hg]\n",
      "\n",
      "Ps = 760. ;\t\t\t# Pressure -[mm of Hg]\n",
      "Ts = 492. ;\t\t\t#Temperature-[degree Rankine]\n",
      "\n",
      "# Calculations\n",
      "D_air = (Ts *  P *  mol_wt_air)/(T *  Ps *  mol_V) ;\t\t# Density of air at given condition-[lb/cubic feet]\n",
      "D_N2 = (Ts *  P *  mol_wt_N2)/(T *  Ps *  mol_V) ;\t\t\t# Density of N2 at given condition-[lb/cubic feet]\n",
      "sg_N2 = D_N2/D_air ;\t\t\t                            # Specific gravity of N2 compared to air at given condition \n",
      "\n",
      "# Results\n",
      "print ' Specific gravity of N2 compared to air at given condition  is  %.3f .'%sg_N2\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " Specific gravity of N2 compared to air at given condition  is  0.966 .\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      " Example 13.6   Page No. 414\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Variables\n",
      "F_gas =  1. ;\t\t\t    # Flue gas [kg mol]\n",
      "mf_CO2 = 14./100 ;\t\t\t# [mol fraction]\n",
      "mf_O2 = 6./100 ;\t\t\t# [mol fraction]\n",
      "mf_N2 = 80./100 ;\t\t\t# [mol fraction]\n",
      "P = 765. ;\t\t\t        #Pressure-[mm of Hg]\n",
      "T =  400. ;\t\t\t        # Temperature-[degree F]\n",
      "\n",
      "# Calculations\n",
      "p_CO2 = P * mf_CO2 ;\t\t# Partial pressure of CO2-[mm of Hg]\n",
      "p_O2 = P * mf_O2 ;\t\t\t# Partial pressure of O2-[mm of Hg]\n",
      "p_N2 = P * mf_N2 ;\t\t\t# Partial pressure of N2-[mm of Hg]\n",
      "\n",
      "# Results\n",
      "print ' Component            pi(Partial pressure-[mm of Hg]) '\n",
      "print '  CO2                  %.1f mm of Hg '%p_CO2\n",
      "print ' O2                   %.1f mm of Hg '%p_O2\n",
      "print ' N2                   %.1f mm of Hg '%p_N2\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " Component            pi(Partial pressure-[mm of Hg]) \n",
        "  CO2                  107.1 mm of Hg \n",
        " O2                   45.9 mm of Hg \n",
        " N2                   612.0 mm of Hg \n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      " Example 13.7  Page no. 416\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "# Variables\n",
      "G = 100. ;\t\t\t# Basis: Pyrolysis Gas-[lb mol] \n",
      "ub_CO = 10./100 ;\t# fraction of CO left unburnt\n",
      "ex_air = 40./100 ;\t# fraction of excess air\n",
      "m_vol = 359. ;\t\t# molar volume of gas at std. cond.-[cubic feet]\n",
      "Ts = 492. ;\t\t\t# Standard temperature -[degree Rankine]\n",
      "Ps = 29.92 ;\t\t#Standard pressure -[in. Hg]\n",
      "\n",
      "# Calculations\n",
      "# Analysis of entering gas of entering gas\n",
      "Tf1 =  90. ;\t\t\t# Temperature of gas-[degree F]\n",
      "T_gas = Tf1 +  460. ;\t#Temperature of gas-[degree Rankine]\n",
      "P_gas = 35. ;\t\t\t#Pressure-[in. Hg]\n",
      "CO2 = 6.4/100 ;\t\t\t# mol fraction of CO2\n",
      "O2 = 0.1/100 ;\t\t\t# mol fraction of O2\n",
      "CO = 39./100 ;\t\t\t# mol fraction of CO\n",
      "H2 = 51.8/100 ;\t\t\t# mol fraction of H2\n",
      "CH4 = 0.6/100 ;\t\t\t# mol fraction of CH4\n",
      "N2 = 2.1/100 ;\t\t\t# mol fraction of N2\n",
      "\n",
      "# Analysis of entering air\n",
      "Tf2 = 70. ;\t\t\t    # Temperature of air -[degree F]\n",
      "T_air = Tf2 +  460. ;\t#Temperature of air-[degree Rankine]\n",
      "P_air = 29.4 ;\t\t\t#Pressure of air [in. Hg]\n",
      "f_N2 = 79./100 ;\t\t\t# mol fraction of N2\n",
      "f_O2 =  21./100 ;\t\t\t# mol fraction of O2\n",
      "\n",
      "\n",
      "O2r_O2 = O2 * G ;\t\t\t#  O2 required by O2-[lb mol]\n",
      "O2r_CO = CO * G/2 ;\t\t\t# O2 required by CO-[lb mol]\n",
      "O2r_H2 = H2 * G/2 ;\t\t\t# O2 required by H2-[lb mol]\n",
      "O2r_CH4 = G * CH4 * 2 ;\t\t\t# O2 required by CH4-[lb mol]\n",
      "O2r_total = O2r_O2 +  O2r_CO +  O2r_H2 +  O2r_CH4 ;\t\t\t# Total O2 required-[lb mol]\n",
      "ex_O2 = ex_air * O2r_total ;\t\t\t# Excess O2-[lb mol]\n",
      "total_O2 = ex_O2 +  O2r_total ;\t\t\t# Total amt of O2 in air-[lb mol]\n",
      "total_N2 = total_O2 * (f_N2/f_O2);\t\t\t# Total amt of in air-[lb mol]\n",
      "air = total_O2 +  total_N2 ;\t\t\t# Total air entering -[lb mol]\n",
      "\n",
      "# Product analysis\n",
      "P_CO = ub_CO * CO * G ;\t\t\t#Unburnt CO in P-[lb mol]\n",
      "P_N2 = N2 * G +   total_N2 ;\t\t\t#  N2 in P-[lb mol]\n",
      "P_CO2 =  (CO2 +  CO +  CH4) * G - 1 * P_CO;\t\t\t#CO2 in P-[lb mol]\n",
      "P_H2O = (H2 +  2 * CH4) * G ;\t\t\t# H2 in P-[lb mol]\n",
      "P_O2 = (CO2 +  O2 +  0.5 * CO) * G +  total_O2 -P_CO2-0.5 * (P_H2O +  P_CO);\t\t\t# O2 in P-[lb mol]\n",
      "P = P_CO +  P_N2 +  P_CO2 +  P_H2O +  P_O2 ;\t\t\t# Product-[lb mol]\n",
      "Tf3 =  400  ;\t\t\t# Temperature of product-[degree F]\n",
      "T_prod = Tf3 +  460 ;\t\t\t#Temperature of product-[degree Rankine]\n",
      "P_prod =  35 ;\t\t\t# Pressure of product -[in.Hg]\n",
      "V_gas = (G * m_vol * T_gas * Ps)/(Ts * P_gas);\n",
      "V_air = (air * m_vol * T_air * Ps)/(Ts * P_air);\n",
      "V_prod = (P * m_vol * T_prod * Ps)/(Ts * P_prod);\n",
      "air_ft3 = V_air/V_gas ;\t\t\t#Air supplied per ft**3 of gas entered-[cubic feet]\n",
      "P_ft3 =  V_prod/V_gas ;\t\t\t#Product gas produced per ft**3 of gas entered-[cubic feet]\n",
      "\n",
      "# Results\n",
      "print ' Air supplied per ft**3 of gas entered %.2f cubic feet. '%air_ft3\n",
      "print ' Product gas produced per ft**3 of gas entered %.2f cubic feet.'%P_ft3\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " Air supplied per ft**3 of gas entered 3.57 cubic feet. \n",
        " Product gas produced per ft**3 of gas entered 5.75 cubic feet.\n"
       ]
      }
     ],
     "prompt_number": 15
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      " Example 13.8 Page No. 419\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Variables\n",
      "T1c = 15. ;\t\t\t    # Temperature of F & P -[degree C] \n",
      "T1 =  273.  +  T1c ;S\t# Temperature of F & P -[K] \n",
      "P1 =  105. ;\t\t\t# Pressure of F & P -[kPa]\n",
      "\n",
      "# Calculations\n",
      "# F analysis\n",
      "F_CO2 = 1.2/100 ;\t\t\t# Volume fraction \n",
      "F_odr = 98.8/100 ;\t\t\t# Volume fraction \n",
      "\n",
      "# P analysis\n",
      "P_CO2 = 3.4/100 ;\t\t\t# Volume fraction \n",
      "P_odr = 96.6/100 ;\t\t\t# Volume fraction \n",
      " \n",
      "Tc_CO2 =  7. ;\t\t\t#Temperature CO2 -[degree C] \n",
      "T_CO2 =  273. +  Tc_CO2 ;\t\t\t# Temperature CO2 -[K]\n",
      "P_CO2 =  131. ;\t\t\t# Pressure of CO2 -[kPa]\n",
      "CO2 = 0.0917 ;\t\t\t# Volume flow rate of CO2-[cubic metre/min]\n",
      "# Convert given volume flow rate of CO2 at temperature of F & P\n",
      "nw_CO2 = (CO2 *  T1 *  P_CO2)/(T_CO2 *  P1) ;\t\t\t# volume flow rate of CO2 at temperature of F & P-[cubic metre]\n",
      "\n",
      "from numpy import matrix\n",
      "a = matrix([[F_odr,-P_odr],[1, -1]]);\t\t\t# Matrix formed by coefficients of unknown\n",
      "b = matrix([[0],[-nw_CO2]]) ;\t\t\t# Matrix formed by constants\n",
      "a = a.I\n",
      "x = a*b ;\t\t\t# matrix of solution, x(1) = F;x(2) = P\n",
      "F = x[0] ;\t\t\t#Volume flow rate of entering gas-[cubic metre/min]\n",
      "P = x[1] ;\t\t\t#Volume flow rate of product [cubic metre/min]\n",
      "\n",
      "# Results\n",
      "print 'Volume flow rate of entering gas is %.2f cubic metre/min'%F\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Volume flow rate of entering gas is 5.17 cubic metre/min\n"
       ]
      }
     ],
     "prompt_number": 16
    },
    {
     "cell_type": "code",
     "collapsed": true,
     "input": [],
     "language": "python",
     "metadata": {},
     "outputs": []
    }
   ],
   "metadata": {}
  }
 ]
}