{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 4 : Ideal Gases and Gas Mixtures"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.1 page no : 79"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "\n",
      "# Variables \n",
      "P1 = 760.               #mmHg standard conditions\n",
      "T1 = 273.15;            #K\n",
      "\n",
      "# Calculation and  Result \n",
      "V1 = 22.4143 * 10**-3;  #m**3/mol\n",
      "R1 = P1 * V1 / T1;\n",
      "print \"Gas constant R = %.4e m**3 mmHg / (molK)\"%R1\n",
      "P2 = 101325;            #N/m**2\n",
      "T2 = 273.15;            #K\n",
      "V2 = 22.4143 * 10**-3;  #m**3/mol\n",
      "R2 = P2 * V2 / T2;      #J/molK\n",
      "R3 = R2 / 4.184;        #cal/molK\n",
      "print \"Gas constant R in MKS system = %.3f cal/molK\"%R3\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Gas constant R = 6.2365e-02 m**3 mmHg / (molK)\n",
        "Gas constant R in MKS system = 1.987 cal/molK\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.2 page no : 80"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables \n",
      "T = 350.                #K\n",
      "P = 1;                  #bar\n",
      "\n",
      "# Calculation \n",
      "V1 = 22.4143 * 10**-3;  #m**3 (suffix 1 represents at STD)\n",
      "P1 = 1.01325;           #bar\n",
      "T1 = 273.15;            #K\n",
      "V = P1 * V1 * T/(T1 * P);\n",
      "\n",
      "# Result \n",
      "print \"Molar volume = %.2e m**3/mol\"%V\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Molar volume = 2.91e-02 m**3/mol\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.3 page no : 80"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables \n",
      "P = 10.                     #bar oxygen cylinder gas\n",
      "T = 300.;                   #K\n",
      "V = 150.;                   #L\n",
      "P1 = 1.01325;               #bar ( \\suffix 1 represents at STD)\n",
      "T1 = 273.15;                #K\n",
      "\n",
      "# Calculation \n",
      "V2 = T1 * P * V /(T * P1);  #m**3\n",
      "V1 = 22.4143;               #m**3/mol\n",
      "N = V2 / V1;                #mol\n",
      "MO2 = 32.;\n",
      "m = N * MO2/1000;\n",
      "\n",
      "# Result \n",
      "print \"Mass of oxygen in the cylinder = %.4f kg\"%m\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Mass of oxygen in the cylinder = 1.9243 kg\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.4 page no: 81"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# variables \n",
      "P = 195.                #kPa pressure\n",
      "T = 273.                #K automobile tyre\n",
      "P1 = 250                #kPa pressure\n",
      "\n",
      "# Calculation \n",
      "T1 = P1 * T / P;\n",
      "\n",
      "# Result\n",
      "print \"Maximum temperature to which tyre may be heated = \",T1,\"K\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Maximum temperature to which tyre may be heated =  350.0 K\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.5 page no : 81\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "# variables \n",
      "V = 250.                    #L  carbon dioxide\n",
      "T = 300.                    #K  temperature\n",
      "V1 = 1000.                  #L  \n",
      "P1 = 100.                   #kPa cylinder\n",
      "T1 = 310.                   #K temperature\n",
      "\n",
      "# Calculation \n",
      "P = T * P1 * V1 /(T1 * V);\n",
      "\n",
      "# Result\n",
      "print \"Original pressure in the cylinder = %.1f kPa\"%P\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Original pressure in the cylinder = 387.1 kPa\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.6 pageno : 85"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# variables \n",
      "Vper1 = 70.                 #% ( 1 = HCl) rubber showed\n",
      "Vper2 = 20.                 #% ( 2 = Cl2) volume\n",
      "Vper3 = 10.                 #% ( 3 = CCl4)\n",
      "M1 = 36.45                  # molecular weights\n",
      "M2 = 70.90\n",
      "M3 = 153.8\n",
      "\n",
      "# Calculation \n",
      "m1 = Vper1 * M1\n",
      "m2 = Vper2 * M2\n",
      "m3 = Vper3 * M3\n",
      "mper1 = m1 * 100/(m1+ m2 + m3);\n",
      "mper2 = m2 * 100/(m1+ m2 + m3);\n",
      "mper3 = m3 * 100/(m1+ m2 + m3);\n",
      "\n",
      "# Result\n",
      "print \" (a) weight percent of HCl= %.2f%%\"%mper1\n",
      "print \"weight percent of Cl2 = %.2f %%\"%mper2\n",
      "print \"weight percent of CCl4 = %.2f %%\"%mper3\n",
      "\n",
      "m = (m1 + m2 + m3)/(Vper1 + Vper2 + Vper3);\n",
      "print \"(b)average molecular weight = %.3f kg\"%m\n",
      "v = 22.4143;                #m**3/kmol\n",
      "Vtotal = v * (Vper1 + Vper2 + Vper3);\n",
      "D = (m1 + m2 + m3)/Vtotal;\n",
      "print \"(c)Density at standard condiions = %.4f kg/m**3\"%D\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " (a) weight percent of HCl= 46.33%\n",
        "weight percent of Cl2 = 25.75 %\n",
        "weight percent of CCl4 = 27.93 %\n",
        "(b)average molecular weight = 55.075 kg\n",
        "(c)Density at standard condiions = 2.4571 kg/m**3\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.7 page no : 85"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# variables \n",
      "per1 = 93.                      #% ( 1 = methane)\n",
      "per2 = 4.5;                     #% (2 = ethane)\n",
      "per3 = 100 - (per1 + per2);     #% ( 3 = N2);\n",
      "T = 300.                        #K  natural gas \n",
      "p = 400.                        #kPa\n",
      "P3 = p * per3 / 100;\n",
      "v = 10.                         #m**3\n",
      "V2 = per2 * v / 100;\n",
      "M1 = 16.032;\n",
      "M2 = 30.048;\n",
      "M3 = 28;\n",
      "N1 = per1;\n",
      "N2 = per2;\n",
      "N3 = per3;\n",
      "\n",
      "# Calculation \n",
      "m1 = M1 * N1;\n",
      "m2 = M2 * N2;\n",
      "m3 = M3 * N3;\n",
      "m = m1 + m2 + m3;\n",
      "Vstp = 100 * 22.4143 * 10**-3;  #m3 at STP\n",
      "D = m /(1000 * Vstp);\n",
      "Pstp = 101.325;                 #kPa\n",
      "T1 = 273.15;                    #K\n",
      "V = T * Pstp * Vstp / ( T1 * p);\n",
      "D1 = m /(1000 * V);\n",
      "Mavg = m /100;\n",
      "mper1 = m1 * 100 / (m1 + m2 + m3);\n",
      "mper2 = m2 * 100 / (m1 + m2 + m3);\n",
      "mper3 = m3 * 100 / (m1 + m2 + m3);\n",
      "\n",
      "# Result\n",
      "print \"(a) Partial pressure of nitrogen = \",P3,\"kPa\"\n",
      "print \"(b) pure-component volume of ethane = \",V2,\"m**3\"\n",
      "print \"(c) Density at standard conditions = %.4f kg/m**3\"%D\n",
      "print \"(d) Density at given condition = %.4f kg/m**3\"%D1\n",
      "print \"(e) Average molecular weight = %.2f\"%Mavg\n",
      "print \"(f) weight percent of Methane = %.2f %%\"%mper1\n",
      "print \"weight percent of Ethane = %.2f %%\"%mper2\n",
      "print \"weight percent of Nitrogen = %.2f %%\"%mper3\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a) Partial pressure of nitrogen =  10.0 kPa\n",
        "(b) pure-component volume of ethane =  0.45 m**3\n",
        "(c) Density at standard conditions = 0.7567 kg/m**3\n",
        "(d) Density at given condition = 2.7200 kg/m**3\n",
        "(e) Average molecular weight = 16.96\n",
        "(f) weight percent of Methane = 87.90 %\n",
        "weight percent of Ethane = 7.97 %\n",
        "weight percent of Nitrogen = 4.13 %\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.8 pageno : 87"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# variables \n",
      "per1 = 20.                          #% ( 1 = ammonia) \n",
      "Vstp = 22.4143;                     #m**3/kmol\n",
      "Pstp = 101.325;                     #kPa\n",
      "Tstp = 273.15;                      #K\n",
      "V1 = 100.                           #m**3 ammonia air\n",
      "P1 = 120.                           #kPa  absorption column\n",
      "T1 = 300.                           #K\n",
      "P2 = 100.                           #kPa  gas leaves\n",
      "T2 = 280.                           #K    gas leaves\n",
      "per2 = 90.                          #% (absorbed)\n",
      "\n",
      "# Calculation \n",
      "N = V1 * P1 * Tstp / (Vstp * Pstp * T1);            #kmol\n",
      "Nair = (1 - per1 / 100) * N;\n",
      "N1 = per1 * N/100;\n",
      "Nabs = per2 * N1 / 100;\n",
      "N2 = N1 - Nabs;                     #leaving\n",
      "Ntotal = Nair + N2;\n",
      "Vstp1 = Ntotal * Vstp;              #m**3\n",
      "V2 = Vstp1 * Pstp * T2 / (Tstp * P2);\n",
      "\n",
      "# Result\n",
      "print \"Volume of gas leaving = \",V2, \"m**3\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Volume of gas leaving =  91.84 m**3\n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.9 pageno : 89"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# variables \n",
      "V = 100.                    #m**3  air\n",
      "Ptotal = 100.               #kPa   air\n",
      "Pwater = 4.                 #kPa   pressure\n",
      "Pair = Ptotal - Pwater; \n",
      "T = 300.                    #K   air\n",
      "T1 = 275.                   #K   air cooled\n",
      "Vstp = 22.4143;             #m**3/kmol\n",
      "Tstp = 273.15;              #K\n",
      "Pstp = 101.325;             #kPa\n",
      "Pwater1 = 1.8;              #kPa\n",
      "\n",
      "# Calculation \n",
      "Pair1 = Ptotal - Pwater1;\n",
      "V1 = V * Pair * T1 / ( T * Pair1);\n",
      "Nwater = V * Pwater * Tstp/ (Vstp * Pstp * T);\n",
      "Nwater1 = V1 * Pwater1 * Tstp/ (Vstp * Pstp * T1);\n",
      "m = (Nwater - Nwater1) * 18.02;\n",
      "\n",
      "# Result\n",
      "print \"(a) volume of air after dehumidification = %.2f m**3\"%V1\n",
      "print \"(b) Mass of water vapour removed = %.3f kg\"%m\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a) volume of air after dehumidification = 89.61 m**3\n",
        "(b) Mass of water vapour removed = 1.618 kg\n"
       ]
      }
     ],
     "prompt_number": 15
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.10 pageno : 90"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# variables \n",
      "V = 100.                    #m**3 rate \n",
      "P = 600.                    #kPa  gas\n",
      "T = 310.                    #K   gas\n",
      "per1 = 20.                  #% ( H2S entering )\n",
      "per2 = 2.                   #% ( H2S leaving )\n",
      "Pstp = 101.325;             #kPa\n",
      "Tstp = 273.15;              #K\n",
      "Vstp = 22.414;              #m**3/kmol\n",
      "\n",
      "# Calculation \n",
      "Vstp1 = V * P * Tstp / ( T * Pstp)\n",
      "N = Vstp1 / Vstp;\n",
      "N1 = N * per1 / 100;\n",
      "N2 = N - N1;                # ( 2 = inerts)\n",
      "Nleaving = N2 / ( 1 - per2 / 100);\n",
      "N1leaving = per2 * Nleaving / 100;\n",
      "mabsorbed = (N1 - N1leaving) * 34.08;       #( molecular wt. = 34.08)\n",
      "mgiven = 100.               #kg/h\n",
      "Vactual = mgiven * V / mabsorbed;\n",
      "Nactual = Nleaving * Vactual / V;           # actual moles leaving\n",
      "Vstpl = Nactual * Vstp;     # volume leaving at STP\n",
      "P2 = 500.                   #kPa\n",
      "T2 = 290.                   #K\n",
      "V2 = Vstpl * Pstp * T2 / ( P2 * Tstp);\n",
      "Precovery = (N1 - N1leaving)*100 / N1;\n",
      "\n",
      "# Result\n",
      "print \"(a)Volume of gas entering per hour %.2f m**3/h\"%Vactual\n",
      "print \"(b)Volume of gas leaving per hour %.2f m**3/h\"%V2\n",
      "print \"(c)Percentage recovery of H2S %.2f %%\"%Precovery\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a)Volume of gas entering per hour 68.63 m**3/h\n",
        "(b)Volume of gas leaving per hour 62.89 m**3/h\n",
        "(c)Percentage recovery of H2S 91.84 %\n"
       ]
      }
     ],
     "prompt_number": 17
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.11 pageno : 92"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# variables \n",
      "#N2 + 3H2 = 2NH3\n",
      "V1 = 100.                       #m**3 ( 1 = N2) cubic metres\n",
      "V2 = V1 * 3                     # ( According to Avagadros principle, equal\n",
      "                                #volumes of all gases under similar condition\n",
      "                                # contains same no. of moles)\n",
      "                                \n",
      "print \"(a)Volume of hydrogen required at same condition = \",V2,\"m**3\"\n",
      "P1 = 20.                        #bar  \n",
      "T1 = 350.                       #K nitrogen\n",
      "P2 = 5.                         #bar\n",
      "T2 = 290.                       #K hydrogen\n",
      "\n",
      "# Calculation and  Result\n",
      "V3 = 3 * V1 * P1 * T2 / ( P2 * T1)\n",
      "print \"(b)Volume required at 50 bar and 290K = %.3f m**3\"%V3\n",
      "m = 1000                        #kg ( ammonia )\n",
      "N = m / 17.03                   #kmol\n",
      "N1 = N/2.                       # ( nitrogen)\n",
      "N2 = N * 3 / 2.                 #(hydrogen)\n",
      "P3 = 50.                        #bar\n",
      "T3 = 600.                       #K\n",
      "Pstp = 1.01325                  #bar\n",
      "Tstp = 273.15                   #K\n",
      "Vstp = 22.414                   #m**3/kmol\n",
      "V1stp = N1 * Vstp\n",
      "V4 = V1stp * Pstp * T3 / (P3 * Tstp)        # ( nitrogen at 50 bar and 600K)\n",
      "V5 = V4 * 2                                 # ( ammonia at 50 bar and 600K)\n",
      "V6 = V4 * 3                                 # ( hydrogen at 50 bar and 600K)\n",
      "print \"(c)Volume of nitrogen at 50 bar and 600K = %.1f m**3\"%V4\n",
      "print \"   Volume of hydrogen at 50 bar and 600K = %.1f m**3\"%V6\n",
      "print \"   Volume of ammonia at 50 bar and 600K = %.1f m**3\"%V5\n",
      "\n",
      "\n",
      "# note : answers may vary because of rounding error."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a)Volume of hydrogen required at same condition =  300.0 m**3\n",
        "(b)Volume required at 50 bar and 290K = 994.286 m**3\n",
        "(c)Volume of nitrogen at 50 bar and 600K = 29.3 m**3\n",
        "   Volume of hydrogen at 50 bar and 600K = 87.9 m**3\n",
        "   Volume of ammonia at 50 bar and 600K = 58.6 m**3\n"
       ]
      }
     ],
     "prompt_number": 21
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.12 pageno : 92"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# variables \n",
      "N = 100.                    #kmol producer gas\n",
      "P1 = 25.                    #% ( Carbon monoxide )\n",
      "P2 = 4.                     #% ( Carbon Dioxide )\n",
      "P3 = 3.                     #% ( Oxygen )\n",
      "P4 = 68.                    #% ( Nitrogen )\n",
      "\n",
      "# Calculation \n",
      "N1 = N * P1/100 \n",
      "N2 = N * P2/100 \n",
      "N3 = N * P3/100 \n",
      "N4 = N * P4/100 \n",
      "NC = N1 + N2 \n",
      "m = NC * 12 \n",
      "Ngas = N / m                #moles of gas for 1 kg of Carbon\n",
      "Vstp = 22.4143              #m**3/kmol\n",
      "Vstp1 = Vstp * Ngas \n",
      "P = 1.                      #bar\n",
      "T = 290.                    #k\n",
      "Pstp = 1.01325              #bar\n",
      "Tstp = 273.15               #K\n",
      "V = T * Vstp1 * Pstp / (Tstp * P ) \n",
      "print \"(a)Volume of gas at 1 bar and 290 K per kg Carbon = %.2f m**3\"%V\n",
      "\n",
      "#CO + 1/2 * O2 = CO2\n",
      "Nrequired  = N1/2 - N3      #(oxygen required)\n",
      "Nsupplied = Nrequired * 1.2 \n",
      "PO1 = 21.                   #% ( Oxygen percent in air)\n",
      "Nair = Nsupplied * 100/PO1 \n",
      "V1 = 100.                   #m**3 \n",
      "Vair = V1 * Nair / N \n",
      "print \"(b)Volume of air required = %.2f m**3\"%Vair\n",
      "NCO2 = N2 + N1 \n",
      "NO2 = Nsupplied - Nrequired \n",
      "NN2 = N4 + (Vair * (1 - PO1/ 100)) \n",
      "Ntotal = NCO2 + NO2 + NN2 \n",
      "PCO2 = NCO2 * 100 / Ntotal \n",
      "PO2 = NO2 * 100 / Ntotal \n",
      "PN2 = NN2 * 100 / Ntotal \n",
      "\n",
      "# Result\n",
      "print \"Percent composition of Carbon Dioxide = %.2f %%\"%PCO2\n",
      "print \"Percent composition of Oxygen = %.2f %%\"%PO2\n",
      "print \"Percent composition of Nitrogen = %.2f %%\"%PN2\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a)Volume of gas at 1 bar and 290 K per kg Carbon = 6.93 m**3\n",
        "(b)Volume of air required = 54.29 m**3\n",
        "Percent composition of Carbon Dioxide = 20.45 %\n",
        "Percent composition of Oxygen = 1.34 %\n",
        "Percent composition of Nitrogen = 78.21 %\n"
       ]
      }
     ],
     "prompt_number": 23
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.13 pageno : 94"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# variables \n",
      "#4HCl + O2 = 2Cl2 + 2H2O\n",
      "n = 1.                      #mol ( Basis 1 mol of HCl )\n",
      "NO2 = n / 4 \n",
      "NO2supp = 1.5 * NO2 \n",
      "Nair = NO2supp * 100 / 21 \n",
      "V = 100.                    #m**3\n",
      "Vair = V * Nair / n \n",
      "print \"(a)Volume of air admitted = %.1f m**3\"%Vair\n",
      "\n",
      "# Calculation \n",
      "P1 = 80.                    #% ( HCl converted)\n",
      "Ncon = n * P1 /100 \n",
      "N2 = Ncon/4                 # oxygen required\n",
      "NH2O = Ncon / 2 \n",
      "NCl2 = Ncon / 2 \n",
      "nHCl = n - Ncon \n",
      "nO2 = NO2supp - N2 \n",
      "Nnitro = Nair - NO2supp \n",
      "Ntotal = nHCl + nO2 + NH2O + NCl2 + Nnitro \n",
      "V1 = V * Ntotal \n",
      "P1 = 1.                     #bar\n",
      "T1 = 290.                   #K\n",
      "P2 = 1.2                    #bar\n",
      "T2 = 400.                   #K\n",
      "V2 = V1 * P1 * T2 / ( P2 * T1) \n",
      "print \"(b)Volume of gas leaving = %.2f m**3\"%V2\n",
      "VCl2 = NCl2 * V \n",
      "Pstp = 1.01325              #bar\n",
      "Tstp = 273.                 #K\n",
      "Vstp = 22.4143              #m**3/kmol\n",
      "Vstp1 = Tstp * P1 * VCl2 / (T1 * Pstp) \n",
      "Nstp = Vstp1/Vstp \n",
      "m = Nstp * 70.90 \n",
      "print \"(c)Kilograms of Chlorine produced = %.1f kg\"%m\n",
      "Ntotaldry = nHCl + nO2 + NCl2 + Nnitro          #dry basis\n",
      "p1 = nHCl*100/Ntotaldry \n",
      "p2 = nO2*100/Ntotaldry \n",
      "p3 = NCl2*100/Ntotaldry \n",
      "p4 = Nnitro*100/Ntotaldry \n",
      "\n",
      "# Result\n",
      "print \"(d)Percent composition of HCl in exit stream = %.2f %%\"%p1\n",
      "print \"   Percent composition of Oxygen in exit stream = %.1f %%\"%p2\n",
      "print \"   Percent composition of Chlorine in exit stream = %.2f %%\"%p3\n",
      "print \"   Percent composition of nitrogen in exit stream = %.2f %%\"%p4\n",
      "\n",
      "# note : answers may vary because of rouding error."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a)Volume of air admitted = 178.6 m**3\n",
        "(b)Volume of gas leaving = 297.21 m**3\n",
        "(c)Kilograms of Chlorine produced = 117.6 kg\n",
        "(d)Percent composition of HCl in exit stream = 9.15 %\n",
        "   Percent composition of Oxygen in exit stream = 8.0 %\n",
        "   Percent composition of Chlorine in exit stream = 18.30 %\n",
        "   Percent composition of nitrogen in exit stream = 64.54 %\n"
       ]
      }
     ],
     "prompt_number": 24
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.14 pageno: 95"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# variables \n",
      "# CO2 = CO + 1/2 * O2\n",
      "P1 = 1.                 #bar \n",
      "T1 = 3500.              #K pressure\n",
      "P2 = 1.                 #bar \n",
      "T2 = 300.               #K heated\n",
      "V2 = 25.                #L CO2\n",
      "\n",
      "# Calculation \n",
      "V1 = V2 * P2 * T1 / ( P1 * T2 ) \n",
      "\n",
      "# Result\n",
      "print \"(a)Final volume of gas if no dissociation occured = %.3f m**3\"%(V1/1000)\n",
      "Pstp = 1.01325          #bar\n",
      "Tstp = 273.             #K\n",
      "Vstp = 22.4143          #m**3\n",
      "N2 = V2 * P2 * Tstp / ( Vstp * Pstp * T2) \n",
      "\n",
      "# let x be the fraction dissociated, then after dissociation,\n",
      "# CO2 = (1 - x)mol, CO = xmol, O2 = (0.5*x)mol\n",
      "#total moles = 1 - x + x + o.5 * x = 1 + 0.5 * x \n",
      "V = 350.                #L\n",
      "N1 = V * P1 * Tstp / (Vstp * Pstp * T1) \n",
      "\n",
      "# 1 + 0.5 * x = N1, therefore\n",
      "x = (N1 - 1) / 0.5  \n",
      "p = x*100 \n",
      "print \"(b)CO2 converted = %.f %%\"%p\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a)Final volume of gas if no dissociation occured = 0.292 m**3\n",
        "(b)CO2 converted = 40 %\n"
       ]
      }
     ],
     "prompt_number": 28
    }
   ],
   "metadata": {}
  }
 ]
}