{
 "metadata": {
  "name": "",
  "signature": "sha256:dbac782d2047bc932ec3aad32143307f0552c9467f7618787890ce24a03238d4"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 3 : Material and Energy Balances"
     ]
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "example 3.1 page number 90"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "import math \n",
      "\n",
      "# Variables\n",
      "w_C = 0.6;   #amount of carbon in coal\n",
      "N2_content = 40.   #in m3 per 100m3 air\n",
      "\n",
      "# Calculations\n",
      "air_consumed = N2_content/0.79;\n",
      "weight_air = air_consumed*(28.8/22.4);\n",
      "O2_content = air_consumed*32*(0.21/22.4);    #in kg\n",
      "\n",
      "H2_content = 20.   #in m3\n",
      "\n",
      "steam_consumed = H2_content*(18/22.4);\n",
      "\n",
      "C_consumption1 = (12./18)*steam_consumed;   #in reaction 1\n",
      "C_consumption2 = (24./32)*O2_content;    #in reaction 2\n",
      "\n",
      "total_consumption = C_consumption1+C_consumption2;\n",
      "coal_consumption = total_consumption/w_C;\n",
      "\n",
      "# Results\n",
      "print \"coal consumption = %f kg\"%(coal_consumption)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "coal consumption = 36.844485 kg\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "example 3.2 page number 91\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "import math \n",
      "\n",
      "# Variables\n",
      "NH3_required = (17./63)*1000;    #NH3 required for 1 ton of nitric acid\n",
      "NO_consumption = 0.96;\n",
      "HNO3_consumption = 0.92;\n",
      "\n",
      "# Calculations and Results\n",
      "NH3_consumed = NH3_required/(NO_consumption*HNO3_consumption);\n",
      "volume_NH3 = NH3_consumed*(22.4/17);\n",
      "print \"volume of ammonia consumed= %f cubic metre/h\"%(volume_NH3)\n",
      "\n",
      "NH3_content = 11.   #% by volume\n",
      "air_consumption = volume_NH3*((100-11)/11.);\n",
      "print \"volume of air consumed = %f cubic metre/h\"%(air_consumption)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "volume of ammonia consumed= 402.576490 cubic metre/h\n",
        "volume of air consumed = 3257.209779 cubic metre/h\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "example 3.3 page number 91\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "import math \n",
      "\n",
      "# Variables\n",
      "HCl_production = 500.   #required to be produced in kg\n",
      "NaCl_required = (117./73)*HCl_production;\n",
      "yield_ = 0.92;\n",
      "purity_NaCl= 0.96;\n",
      "\n",
      "# Calculations and Results\n",
      "actual_NaCl = NaCl_required/(purity_NaCl*yield_);\n",
      "print \"amount of NaCl required = %f kg\"%(actual_NaCl)\n",
      "\n",
      "purity_H2SO4 = 0.93;\n",
      "H2SO4_consumption = (98./73)*(HCl_production/(yield_*purity_H2SO4));\n",
      "print \"amount of H2SO4 consumed = %f kg\"%(H2SO4_consumption)\n",
      "\n",
      "Na2SO4_produced = (142/73.)*HCl_production;\n",
      "print \"amount of Na2SO4 produced = %f kg\"%(Na2SO4_produced)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "amount of NaCl required = 907.348124 kg\n",
        "amount of H2SO4 consumed = 784.517154 kg\n",
        "amount of Na2SO4 produced = 972.602740 kg\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "example 3.4 page number 92\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "import math \n",
      "\n",
      "# Variables\n",
      "C2H2_produced = (1./64)*0.86;   #in kmol\n",
      "volume_C2H2 = C2H2_produced*22.4*1000;    #in l\n",
      "\n",
      "# Calculations\n",
      "#assuming ideal behaviour,\n",
      "volume = (100/101.3)*(273./(273+30));\n",
      "time = (volume_C2H2/volume)*(1./60);\n",
      "\n",
      "# Results\n",
      "print \"time of service = %f hr\"%(time)\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "time of service = 5.640332 hr\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "example 3.5 page number 92\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "import math \n",
      "\n",
      "# Variables\n",
      "xv = 0.88;\n",
      "xf = 0.46;\n",
      "xl = 0.32;\n",
      "F= 100.   #in kg\n",
      "\n",
      "# Calculations and Results\n",
      "L = (F*(xf-xv))/(xl-xv);\n",
      "V = F-L;\n",
      "print \"L = %f Kg V = %f Kg\"%(L,V)\n",
      "Eo = (V*xv)/(F*xf);\n",
      "\n",
      "print \" effectiveness based on oversized partices = %f \"%(Eo)\n",
      "Eu = (L*(1-xl))/(F*(1-xf));\n",
      "\n",
      "print \"effectiveness based on undersized partices = %f\"%(Eu)\n",
      "E=Eu*Eo;\n",
      "\n",
      "print \"overall effectiveness = %f\"%(E)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "L = 75.000000 Kg V = 25.000000 Kg\n",
        " effectiveness based on oversized partices = 0.478261 \n",
        "effectiveness based on undersized partices = 0.944444\n",
        "overall effectiveness = 0.451691\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "example 3.6 page number 94\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "import math \n",
      "\n",
      "# Variables\n",
      "G1 = 3600.   #in m3/h\n",
      "P = 106.6    #in kPa\n",
      "T = 40   #in degree C\n",
      "\n",
      "# Calculations and Results\n",
      "q = G1*(P/101.3)*(273./((273+T)));   #in m3/s\n",
      "m = q/22.4;   #in kmol/h\n",
      "y1 = 0.02;\n",
      "Y1 = y1/(1-y1);\n",
      "\n",
      "print \"mole ratio of benzene = %f kmol benzene/kmol dry gas\"%(Y1)\n",
      "\n",
      "Gs = m*(1-y1);\n",
      "print \"moles of benzene free gas = %f kmol drygas/h\"%(Gs)\n",
      "\n",
      "#for 95% removal\n",
      "Y2 = Y1*(1-0.95);\n",
      "print \"final mole ratio of benzene = %f kmol benzene/kmol dry gas\"%(Y2)\n",
      "\n",
      "x2 = 0.002\n",
      "X2 = 0.002/(1-0.002);\n",
      "\n",
      "#at equilibrium y* = 0.2406X\n",
      "#part 1\n",
      "#for oil rate to be minimum the wash oil leaving the absorber must be in equilibrium with the entering gas\n",
      "\n",
      "y1 = 0.02;\n",
      "x1 = y1/(0.2406);\n",
      "X1 = x1/(1-x1);\n",
      "min_Ls = Gs*((Y1-Y2)/(X1-X2));\n",
      "print \"minimum Ls required = %f kg/h\"%(min_Ls*260)\n",
      "\n",
      "#for 1.5 times of the minimum\n",
      "Ls = 1.5*min_Ls;\n",
      "print \"flow rate of wash oil = %f kg/h\"%(Ls*260)\n",
      "X1 = X2 + (Gs*((Y1-Y2)/Ls));\n",
      "print \"concentration of benzene in wash oil = %f kmol benzene/kmol wash oil\"%(X1)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "mole ratio of benzene = 0.020408 kmol benzene/kmol dry gas\n",
        "moles of benzene free gas = 144.559497 kmol drygas/h\n",
        "final mole ratio of benzene = 0.001020 kmol benzene/kmol dry gas\n",
        "minimum Ls required = 8219.216789 kg/h\n",
        "flow rate of wash oil = 12328.825184 kg/h\n",
        "concentration of benzene in wash oil = 0.061109 kmol benzene/kmol wash oil\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "example 3.7 page number 95\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "from scipy.optimize import fsolve \n",
      "import math \n",
      "\n",
      "# Variables\n",
      "xf = 0.01\n",
      "Xf = xf/(1-xf);\n",
      "Feed = 100   #feed in kg\n",
      "\n",
      "# Calculations and Results\n",
      "c_nicotine = Feed*Xf;   #nicotine conc in feed\n",
      "c_water = Feed*(1-Xf)    #water conc in feed\n",
      "\n",
      "#part 1\n",
      "def  F1(x):\n",
      "    return  (x/150.)-0.9*((1-x)/99.);\n",
      "\n",
      "#initial guess\n",
      "x = 10.;\n",
      "y = fsolve(F1,x)\n",
      "print \"amount of nicotine removed N = %f kg\"%(y)\n",
      "#part 2\n",
      "def F2(x):\n",
      "    return  (x/50.)-0.9*((1-x)/99.);\n",
      "\n",
      "#initial guess\n",
      "x = 10.;\n",
      "N1 = fsolve(F2,x)\n",
      "print \"amount of nicotine removed in stage 1, N1 = %f kg\"%(N1)\n",
      "def F3(x):\n",
      "    return  (x/50.)-0.9*((1-x-N1)/99.);\n",
      "\n",
      "#initial guess\n",
      "x = 10.;\n",
      "N2 = fsolve(F3,x)\n",
      "print \"amount of nicotine removed in stage 2, N2 = %f kg\"%(N2)\n",
      "def F4(x):\n",
      "    return (x/50.)-0.9*((1-x-N2-N1)/99.);\n",
      "\n",
      "#initial guess\n",
      "x = 10.;\n",
      "N3 = fsolve(F4,x)\n",
      "\n",
      "print \"amount of nicotine removed in stage 3, N3 = %f kg\"%(N3)\n",
      "N = N1+N2+N3;\n",
      "print \"total amount of nicotine removed = %f kg\"%(N)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "amount of nicotine removed N = 0.576923 kg\n",
        "amount of nicotine removed in stage 1, N1 = 0.312500 kg\n",
        "amount of nicotine removed in stage 2, N2 = 0.214844 kg\n",
        "amount of nicotine removed in stage 3, N3 = 0.147705 kg\n",
        "total amount of nicotine removed = 0.675049 kg\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "example 3.8 page number 96\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "import math \n",
      "\n",
      "# Variables\n",
      "vp_water = 31.06   #in kPa\n",
      "vp_benzene = 72.92   #in kPa\n",
      "\n",
      "P = vp_water +vp_benzene;\n",
      "x_benzene = vp_benzene/P;\n",
      "x_water = vp_water/P;\n",
      "\n",
      "# Calculations\n",
      "initial_water = 50./18;   #in kmol of water\n",
      "initial_benzene = 50./78   #in kmol of benzene\n",
      "water_evaporated = initial_benzene*(x_water/x_benzene);\n",
      "water_left = (initial_water - water_evaporated);\n",
      "\n",
      "# Results\n",
      "print \"amount of water left in residue = %f kg\"%(water_left*18)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "amount of water left in residue = 45.085236 kg\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "example 3.9 page number 97\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "import math \n",
      "# Variables\n",
      "po_D = 4.93   #in kPa\n",
      "po_W = 96.3   #in kPa\n",
      "n = 0.75   #vaporization efficiency\n",
      "\n",
      "# Calculations and Results\n",
      "P = n*po_D+po_W;\n",
      "print \"P = %f kPa\"%(P)\n",
      "\n",
      "x_water = 96.3/100;\n",
      "x_dimethylanaline = 1-x_water;\n",
      "wt_dimethylanaline = (x_dimethylanaline*121)/(x_dimethylanaline*121+x_water*18);\n",
      "print \"weight of dimethylanaline in water = %f\"%(wt_dimethylanaline*100)\n",
      "\n",
      "#part 1\n",
      "n = 0.8;\n",
      "po_D = 32   #in kPa\n",
      "actual_vp = n*po_D;\n",
      "p_water = 100 - actual_vp;\n",
      "steam_required = (p_water*18)/(actual_vp*121);\n",
      "print \"amount of steam required = %f kg steam/kg dimethylanaline\"%(steam_required)\n",
      "\n",
      "#part 2\n",
      "x_water = p_water/100.;\n",
      "wt_water = x_water*18./(x_water*18+(1-x_water)*121.);\n",
      "print \"weight of water vapor = %f weight of dimethylanaline =%f\"%(wt_water*100,100*(1-wt_water))\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "P = 99.997500 kPa\n",
        "weight of dimethylanaline in water = 20.526340\n",
        "amount of steam required = 0.432335 kg steam/kg dimethylanaline\n",
        "weight of water vapor = 30.183916 weight of dimethylanaline =69.816084\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "example 3.10 page number 98\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "import math \n",
      "# Variables\n",
      "xf = 0.15;\n",
      "xl = (114.7)/(114.7+1000);\n",
      "xc = 1;\n",
      "\n",
      "# Calculations\n",
      "K2Cr2O7_feed = 1000*0.15;   #in kg\n",
      "\n",
      "n = 0.8;\n",
      "C = n*K2Cr2O7_feed;\n",
      "V = (K2Cr2O7_feed-120 - 880*0.103)/(-0.103);\n",
      "\n",
      "# Results\n",
      "print \"amount of water evaporated = %f kg\"%(V)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "amount of water evaporated = 588.737864 kg\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "example 3.11 page number 98\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "import math \n",
      "# Variables\n",
      "xc = round(106./286,3);\n",
      "xf = 0.25;\n",
      "xl = round(27.5/127.5,3);\n",
      "\n",
      "# Calculations\n",
      "water_present = 100*(1-xf);    #in kg\n",
      "V = 0.15*75;   #in kg\n",
      "C = (100*xf - 88.7*xl)/(xc-xl);\n",
      "Na2CO3_feed = 25./xc;\n",
      "\n",
      "yield_ = (C/Na2CO3_feed)*100;\n",
      "\n",
      "# Results\n",
      "print \"yield = %.1f %%\"%(yield_)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "yield = 55.9 %\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "example 3.12 page number 99\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "import math \n",
      "# Variables\n",
      "r = 50.   #weight of dry air passing through drier\n",
      "w1 = 1.60   #in kg per kg dry solid\n",
      "w2 = 0.1    #in kg/kg dry solid\n",
      "H0 = 0.016  #in kg water vapor/kg dry air\n",
      "H2 = 0.055  #in kg water vapor/kg dry air\n",
      "\n",
      "# Calculations and Results\n",
      "y = 1 - (w1-w2)/(r*(H2-H0));\n",
      "print \"fraction of air recirculated = %f\"%(y)\n",
      "\n",
      "H1 = H2 - (w1-w2)/r;\n",
      "print \"humidity of air entering the drier = %f kg water vapor/kg kg dry air\"%(H1)\n",
      "\n",
      "#check\n",
      "H11 = H2*y+H0*(1-y);\n",
      "if H1 == H11:\n",
      "    print \"fraction of air recirculated = %f  verified\"%(y)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "fraction of air recirculated = 0.230769\n",
        "humidity of air entering the drier = 0.025000 kg water vapor/kg kg dry air\n",
        "fraction of air recirculated = 0.230769  verified\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "example 3.13 page number 100\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "import math \n",
      "# Variables\n",
      "Hf = 0.012;\n",
      "Hi = 0.033;\n",
      "H1 = 0.0075;\n",
      "\n",
      "# Calculations and Results\n",
      "water_vapor = Hf/18.;   #in kmol of water vapor\n",
      "dry_air = 1/28.9;  #in kmol\n",
      "total_mass = water_vapor+dry_air;\n",
      "\n",
      "volume = 22.4*(298./273)*total_mass;\n",
      "weight = 60/volume;\n",
      "print \"weight of dry air handled per hr = %f kg\"%(weight)\n",
      "\n",
      "#part 1\n",
      "inlet_watervapor = 0.033/18;    #in kmol of water vapor\n",
      "volume_inlet = 22.4*(308./273)*(inlet_watervapor+dry_air);\n",
      "print \"volumetric flow rate of inlet air = %f cubic meter\"%(volume_inlet*weight)\n",
      "\n",
      "#part 2\n",
      "y = (Hf - Hi)/(H1 - Hi);\n",
      "print \"fraction of inlet air passing through cooler = %f\"%(y)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "weight of dry air handled per hr = 69.576029 kg\n",
        "volumetric flow rate of inlet air = 64.064786 cubic meter\n",
        "fraction of inlet air passing through cooler = 0.823529\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "example 3.14 page number 102\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "import math \n",
      "\n",
      "# Variables\n",
      "#x- moles of N2 and H2 recycled; y - moles of N2 H2 purged\n",
      "Ar_freshfeed = 0.2;\n",
      "#argon in fresh feed is equal to argon in purge \n",
      "\n",
      "# Calculations and Results\n",
      "y = 0.2/0.0633;   #argon in purge = 0.0633y\n",
      "x = (0.79*100 - y)/(1-0.79);\n",
      "print \"y = %f kmolx = %f kmol\"%(y,x)\n",
      "\n",
      "#part 1\n",
      "fraction = y/x;\n",
      "print \"fration of recycle that is purged = %f\"%(fraction)\n",
      "\n",
      "#part 2\n",
      "yield_ = 0.105*(100+x);\n",
      "print \"overall yield of ammonia = %f kmol\"%(yield_)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "y = 3.159558 kmolx = 361.144964 kmol\n",
        "fration of recycle that is purged = 0.008749\n",
        "overall yield of ammonia = 48.420221 kmol\n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "example 3.15 page number 107\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "import math \n",
      "# Variables\n",
      "H0_CH4 = -74.9   #in kJ\n",
      "H0_CO2 = -393.5   #in kJ\n",
      "H0_H2O = -241.8   #in kJ\n",
      "\n",
      "# Calculations\n",
      "delta_H0 = H0_CO2+2*H0_H2O-H0_CH4;\n",
      "\n",
      "# Results\n",
      "print \"change in enthalpy = %f kJ\"%(delta_H0)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "change in enthalpy = -802.200000 kJ\n"
       ]
      }
     ],
     "prompt_number": 15
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "example 3.16 page number 107\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "import math \n",
      "# Variables\n",
      "H0_glucose = -1273  #in kJ\n",
      "H0_ethanol = -277.6  #in kJ\n",
      "H0_CO2 = -393.5  #in kJ\n",
      "H0_H2O = -285.8   #in kJ\n",
      "\n",
      "# Calculations and Results\n",
      "#for reaction 1\n",
      "delta_H1 = 2*H0_ethanol+2*H0_CO2-H0_glucose;\n",
      "print \"enthalpy change in reaction 1 = %f KJ\"%(delta_H1)\n",
      "\n",
      "#for reaction 2\n",
      "delta_H2 = 6*H0_H2O+6*H0_CO2-H0_glucose;\n",
      "print \"enthalpy change in reaction 2 = %f kJ\"%(delta_H2)\n",
      "\n",
      "if delta_H1>delta_H2:\n",
      "    print  \"reaction 2 supplies more energy\"\n",
      "else:\n",
      "    print  \"reaction 1 supplies more energy\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "enthalpy change in reaction 1 = -69.200000 KJ\n",
        "enthalpy change in reaction 2 = -2802.800000 kJ\n",
        "reaction 2 supplies more energy\n"
       ]
      }
     ],
     "prompt_number": 16
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "example 3.17 page number 108\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "import math \n",
      "# Variables\n",
      "delta_H2 = 11.7   #in kJ/mol\n",
      "m_CuSO4 = 16  #in gm\n",
      "m_H2O = 384   #in gm\n",
      "\n",
      "# Calculations\n",
      "delta_H3 = -((m_CuSO4+m_H2O)*4.18*3.95*159.6)/(16*10**3)\n",
      "delta_H1 = delta_H3 - delta_H2;\n",
      "\n",
      "# Results\n",
      "print \"enthalpy of formation = %f kJ/mol\"%(delta_H1)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "enthalpy of formation = -77.578890 kJ/mol\n"
       ]
      }
     ],
     "prompt_number": 17
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "example 3.18 page number 108\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "import math \n",
      "# Variables\n",
      "H_combustion = 1560000    #in kJ/kmol \n",
      "H0_CO2 = 54.56   #in kJ/kmol\n",
      "H0_O2 = 35.2   #in kJ/kmol\n",
      "H0_steam = 43.38   #in kJ/kmol\n",
      "H0_N2 = 33.32   #in kJ/kmol\n",
      "\n",
      "# Calculations\n",
      "t = H_combustion/(2*H0_CO2+3*H0_steam+0.875*H0_O2+16.46*H0_N2);\n",
      "\n",
      "# Results\n",
      "print \"theoritical temperature of combustion = %f degree C\"%(t)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "theoritical temperature of combustion = 1905.908708 degree C\n"
       ]
      }
     ],
     "prompt_number": 18
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "example 3.19 page number 109\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "import math \n",
      "# Variables\n",
      "H_NaCl = 410.9   #in MJ/kmol\n",
      "H_H2SO4 = 811.3   #in MJ/kmol\n",
      "H_Na2SO4 = 1384   #in MJ/kmol\n",
      "H_HCl = 92.3   #in MJ/kmol\n",
      "\n",
      "# Calculations and Results\n",
      "Q = H_Na2SO4 + 2*H_HCl -2*H_NaCl-H_H2SO4;\n",
      "print \"heat of reaction = %f MJ\"%(Q)\n",
      "\n",
      "heat_required = 64.5*(500./73);\n",
      "coke_consumption = heat_required/19\n",
      "print \"amount of coke oven gas consumed = %f cubic meter\"%(coke_consumption)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "heat of reaction = -64.500000 MJ\n",
        "amount of coke oven gas consumed = 23.251622 cubic meter\n"
       ]
      }
     ],
     "prompt_number": 19
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "example 3.20 page number 109\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "import math \n",
      "# Variables\n",
      "cp_water = 146.5   #in kj/kg\n",
      "cp_steam = 3040   #in kJ/kg\n",
      "d = 0.102  #in m\n",
      "u = 1.5  #in m/s\n",
      "density = 1000   #in kg/m3\n",
      "\n",
      "# Calculations\n",
      "m = (3.14/4)*d**2*u*density;\n",
      "Q = m*(cp_steam-cp_water);\n",
      "\n",
      "# Results\n",
      "print \"rate of heat flow = %f kW\"%(Q)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "rate of heat flow = 35447.429385 kW\n"
       ]
      }
     ],
     "prompt_number": 20
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "example 3.22 page number 110\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "import math \n",
      "# Variables\n",
      "wt_C = 0.75   #in kg\n",
      "wt_H2 = 0.05   #in kg\n",
      "wt_O2 = 0.12   #in kg\n",
      "wt_N2 = 0.03   #in kg\n",
      "wt_S = 0.01    #in kg\n",
      "wt_ash = 0.04  #in kg\n",
      "\n",
      "# Calculations and Results\n",
      "O2_C = wt_C*(32./12);  #in kg\n",
      "O2_H2 = wt_H2*(16./2);   #in kg\n",
      "O2_S = wt_S*(32./32);   #in kg\n",
      "O2_required = O2_C+O2_H2+O2_S;\n",
      "\n",
      "oxygen_supplied = O2_required - wt_O2;\n",
      "air_needed = oxygen_supplied/0.23;\n",
      "print \"amount of air required = %f kg\"%(air_needed)\n",
      "\n",
      "volume = (22.4/28.8)*air_needed;\n",
      "print \"volume of air needed = %f cubic meter\"%(volume)\n",
      "\n",
      "air_supplied = 1.20*air_needed;\n",
      "N2_supplied = air_supplied*0.77;\n",
      "total_N2 = N2_supplied+wt_N2;\n",
      "\n",
      "O2_fluegas = air_supplied*0.23 - oxygen_supplied;\n",
      "\n",
      "wt_CO2 = wt_C+O2_C;\n",
      "wt_SO2 = wt_S+O2_S;\n",
      "\n",
      "moles_CO2 = wt_CO2/44;\n",
      "moles_SO2 = wt_SO2/64;\n",
      "moles_N2 = total_N2/28;\n",
      "moles_O2 = O2_fluegas/32;\n",
      "total_moles = moles_CO2+moles_SO2+moles_N2+moles_O2;\n",
      "\n",
      "x_CO2 = moles_CO2/total_moles;\n",
      "x_SO2 = moles_SO2/total_moles;\n",
      "x_N2 = moles_N2/total_moles;\n",
      "x_O2 = moles_O2/total_moles;\n",
      "\n",
      "print \"CO2 = %f %%\"%(x_CO2*100)\n",
      "print \"SO2 = %f %%\"%(x_SO2*100)\n",
      "print \"N2 = %f %%\"%(x_N2*100)\n",
      "print \"O2 = %f %%\"%(x_O2*100)\n",
      "\n",
      "# Note : answers are slightly different because of rounding error."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "amount of air required = 9.956522 kg\n",
        "volume of air needed = 7.743961 cubic meter\n",
        "CO2 = 15.365264 %\n",
        "SO2 = 0.076826 %\n",
        "N2 = 81.039264 %\n",
        "O2 = 3.518645 %\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "example 3.23 page number 110\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "import math \n",
      "# Variables\n",
      "C = 0.8   #in kg\n",
      "H2 = 0.05   #in kg\n",
      "S = 0.005   #in kg\n",
      "ash = 0.145  #in kg\n",
      "\n",
      "# Calculations and Results\n",
      "#required oxygen in kg\n",
      "C_O2 = C*(32./12);  \n",
      "H2_O2 = H2*(16./2);\n",
      "S_O2 = S*(32./32);\n",
      "O2_supplied = C_O2+S_O2+H2_O2;\n",
      "print \"amount of O2 supplied = %f kg\"%(O2_supplied)\n",
      "\n",
      "wt_air = O2_supplied*(100./23);\n",
      "wt_airsupplied = 1.25*wt_air;\n",
      "print \"amount of air supplied = %f kg\"%(wt_airsupplied)\n",
      "\n",
      "#flue gas composition\n",
      "m_N2 = wt_airsupplied*0.77;   #in kg\n",
      "mole_N2 = m_N2/28.;\n",
      "\n",
      "m_O2 = (wt_airsupplied-wt_air)*0.23;   #in kg\n",
      "mole_O2 = m_O2/32.;\n",
      "\n",
      "m_CO2 = C*(44/12.);   #in kg\n",
      "mole_CO2 = m_CO2/44.;\n",
      "\n",
      "m_H2O = H2*(18/2.);   #in kg\n",
      "mole_H2O = m_H2O/18.;\n",
      "\n",
      "m_SO2 = S*(64/32.);   #in kg\n",
      "mole_SO2 = m_SO2/64.;\n",
      "\n",
      "m = m_N2+m_O2+m_CO2+m_H2O+m_SO2\n",
      "\n",
      "#percent by weight\n",
      "w_N2 = m_N2/m;\n",
      "print \"percentage of N2 by weight = %f\"%(w_N2*100)\n",
      "\n",
      "w_O2 = m_O2/m;\n",
      "print \"percentage of O2 by weight = %f\"%(w_O2*100)\n",
      "\n",
      "w_CO2 = m_CO2/m;\n",
      "print \"percentage of CO2 by weight = %f\"%(w_CO2*100)\n",
      "\n",
      "w_H2O = m_H2O/m;\n",
      "print \"percentage of H2O by weight = %f\"%(w_H2O*100)\n",
      "\n",
      "w_SO2 = m_SO2/m;\n",
      "print \"percentage of SO2 by weight = %f\"%(w_SO2*100)\n",
      "\n",
      "m1 = mole_N2+mole_O2+mole_CO2+mole_H2O+mole_SO2\n",
      "\n",
      "#percent by mole \n",
      "x_N2 = mole_N2/m1;\n",
      "print \"percentage of N2 by mole = %f\"%(x_N2*100)\n",
      "\n",
      "x_O2 = mole_O2/m1;\n",
      "print \"percentage of O2 by mole = %f\"%(x_O2*100)\n",
      "\n",
      "x_CO2 = mole_CO2/m1;\n",
      "print \"percentage of CO2 by mole = %f\"%(x_CO2*100)\n",
      "\n",
      "x_H2O = mole_H2O/m1;\n",
      "print \"percentage of H2O by mole = %f\"%(x_H2O*100)\n",
      "\n",
      "x_SO2 = mole_SO2/m1;\n",
      "print \"percentage of SO2 by mole = %f\"%(x_SO2*100)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "amount of O2 supplied = 2.538333 kg\n",
        "amount of air supplied = 13.795290 kg\n",
        "percentage of N2 by weight = 72.506232\n",
        "percentage of O2 by weight = 4.331541\n",
        "percentage of CO2 by weight = 20.022357\n",
        "percentage of H2O by weight = 3.071612\n",
        "percentage of SO2 by weight = 0.068258\n",
        "percentage of N2 by mole = 77.261067\n",
        "percentage of O2 by mole = 4.038647\n",
        "percentage of CO2 by mole = 13.577066\n",
        "percentage of H2O by mole = 5.091400\n",
        "percentage of SO2 by mole = 0.031821\n"
       ]
      }
     ],
     "prompt_number": 22
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "example 3.24 page number 112\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "import math \n",
      "# Variables\n",
      "wt_H2 = 0.15;\n",
      "wt_C = 0.85;\n",
      "O2_H2 = wt_H2*(16./2);\n",
      "O2_C = wt_C*(32./12);\n",
      "\n",
      "# Calculations and Results\n",
      "total_O2 = O2_H2+O2_C;\n",
      "wt_air = total_O2/0.23;\n",
      "air_supplied = 1.15*(wt_air);\n",
      "N2_supplied = 0.77*air_supplied/28.;\n",
      "O2_supplied = 0.23*(air_supplied-wt_air)/32.;\n",
      "moles_CO2 = 0.85/12;\n",
      "\n",
      "print \"moles of CO2 = %f kmol\"%(moles_CO2)\n",
      "print \"moles of N2 = %f kmol \"%(N2_supplied)\n",
      "print \"moles of O2 = %f kmol\"%(O2_supplied)\n",
      "\n",
      "total_moles = N2_supplied+O2_supplied+moles_CO2;\n",
      "\n",
      "print \"percentage of CO2 = %f\"%((moles_CO2/total_moles)*100)\n",
      "print \"percentage of N2 = %f\"%((N2_supplied/total_moles)*100)\n",
      "print \"percentage of O2 = %f\"%((O2_supplied/total_moles)*100)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "moles of CO2 = 0.070833 kmol\n",
        "moles of N2 = 0.476667 kmol \n",
        "moles of O2 = 0.016250 kmol\n",
        "percentage of CO2 = 12.564671\n",
        "percentage of N2 = 84.552846\n",
        "percentage of O2 = 2.882483\n"
       ]
      }
     ],
     "prompt_number": 23
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "example 3.25 page number 113\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "import math \n",
      "# Variables\n",
      "N2 = 80.5   #in m3\n",
      "air_supplied = N2/0.79   #in m3\n",
      "volume_O2 = air_supplied*0.21;  #in m3\n",
      "O2_fluegas = 6.1   #in m3\n",
      "\n",
      "# Calculations\n",
      "O2_used = volume_O2 - O2_fluegas;\n",
      "excess_air_supplied = (O2_fluegas/O2_used)*100;\n",
      "\n",
      "# Results\n",
      "print \"percentage of excess air supplied = %f\"%(excess_air_supplied)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "percentage of excess air supplied = 39.872580\n"
       ]
      }
     ],
     "prompt_number": 24
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "example 3.26 page number 114\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "import math \n",
      "# Variables\n",
      "q_NTP = 10*(200/101.3)*(273./313);\n",
      "m_CO2 = 44*(q_NTP/22.4);\n",
      "s_CO2 = 0.85   #in kJ/kg K\n",
      "\n",
      "# Calculations\n",
      "Q = m_CO2*s_CO2*(40-20)   #Q = ms*delta_T\n",
      "\n",
      "d0 = 0.023   #in mm\n",
      "A0 = (3.14/4)*d0**2;\n",
      "di = 0.035   #in mm\n",
      "Ai = (3.14/4)*di**2;\n",
      "\n",
      "A_annular = Ai-A0;\n",
      "u = 0.15   #in m/s\n",
      "m_water = A_annular*(u*3600)*1000   #in kg/hr\n",
      "\n",
      "s_water = 4.19    #in kJ/kg K\n",
      "t = 15+(Q/(m_water*s_water));\n",
      "\n",
      "# Results\n",
      "print \"exit water temperature = %f degree C\"%(t)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "exit water temperature = 15.465164 degree C\n"
       ]
      }
     ],
     "prompt_number": 25
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "example 3.27 page number 114\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "import math \n",
      "# Variables\n",
      "F = 1000   #in kg\n",
      "xF = 0.01   \n",
      "\n",
      "# Calculations and Results\n",
      "solid_feed = F*xF;\n",
      "water_feed = F - solid_feed;\n",
      "\n",
      "tF = 40  #in degree C\n",
      "hF = 167.5   #in kJ/kg\n",
      "xL = 0.02;\n",
      "\n",
      "solid_liquor = 10  #in kg\n",
      "L = solid_liquor/xL;\n",
      "tL = 100  #in degree C\n",
      "hL = 418.6   #in kJ/kg\n",
      "\n",
      "V = F -L;\n",
      "\n",
      "tv = 100  #in degree C\n",
      "Hv = 2675   #in kJ/kg\n",
      "ts = 108.4  #in degree C\n",
      "Hs = 2690  #in kJ/kg\n",
      "tc = 108.4  #in degree C\n",
      "hc = 454   #in kJ/kg\n",
      "\n",
      "#applying heat balance\n",
      "S = (F*hF-V*Hv-L*hL)/(hc-Hs);\n",
      "print \"weight of steam required = %f kg/hr\"%(S)\n",
      "\n",
      "Q = S*(Hs-hc);\n",
      "U = 1.4   #in kW/m2K\n",
      "delta_t = ts-tL;\n",
      "A = 383.2/(U*delta_t);\n",
      "print \"area of heating surface = %f square meter\"%(A)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "weight of steam required = 616.860465 kg/hr\n",
        "area of heating surface = 32.585034 square meter\n"
       ]
      }
     ],
     "prompt_number": 26
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "example 3.28 page number 115\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "import math \n",
      "# Variables\n",
      "hF = 171  #in kJ/kg\n",
      "hD = 67   #in kJ/kg\n",
      "hL = hD;\n",
      "\n",
      "hW = 200  #in kJ/kg\n",
      "H = 540  #in kJ/kg\n",
      "\n",
      "print ('part 1')\n",
      "F = 1000   #in kg/h\n",
      "xF = 0.40\n",
      "xW = 0.02;\n",
      "xD = 0.97;\n",
      "\n",
      "# Calculations and Results\n",
      "D = F*(xF-xW)/(xD-xW);\n",
      "W = F-D;\n",
      "\n",
      "print \"bottom product = %f kg/hr\"%(W)\n",
      "print \"top product = %f kg/hr\"%(D)\n",
      "\n",
      "print ('part 2')\n",
      "L = 3.5*D;\n",
      "V = L+D;\n",
      "Qc = V*H-L*hL-D*hD;\n",
      "print \"condenser duty = %f KJ/hr\"%(Qc)\n",
      "\n",
      "print ('part 3')\n",
      "Qr = Qc - 24200;\n",
      "print \"rate of heat input to reboiler = %f kJ/hr\"%(Qr)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "part 1\n",
        "bottom product = 600.000000 kg/hr\n",
        "top product = 400.000000 kg/hr\n",
        "part 2\n",
        "condenser duty = 851400.000000 KJ/hr\n",
        "part 3\n",
        "rate of heat input to reboiler = 827200.000000 kJ/hr\n"
       ]
      }
     ],
     "prompt_number": 27
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "example 3.29 page number 117\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "import math \n",
      "# Variables\n",
      "F = 1000.;    #in kg\n",
      "V = 0.05*F;   #in kg\n",
      "xF = 0.48;\n",
      "xL = 75./(100+75);\n",
      "xC = 1.;\n",
      "\n",
      "# Calculations and Results\n",
      "C = (F*xF-950*xL)/(1-0.429);\n",
      "print  \"rate of crystal formation = %f kg\"%(C)\n",
      "\n",
      "L = F-C-V;\n",
      "\n",
      "#cooling water\n",
      "W = (F*2.97*(85-35)+126.9*75.2-V*2414)/(4.19*11);\n",
      "print \"rate of cooling water = %f kg\"%(W)\n",
      "\n",
      "delta_T1 = 56.;\n",
      "delta_T2 = 17.;\n",
      "delta_Tm = (delta_T1-delta_T2)/(math.log(delta_T1/delta_T2))\n",
      "U = 125;\n",
      "\n",
      "A=(F*2.97*(85-35)+126.9*75.2-V*2414)/(U*delta_Tm*3.6);\n",
      "print \"area = %f square meter\"%(A)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "rate of crystal formation = 127.595697 kg\n",
        "rate of cooling water = 810.216533 kg\n",
        "area = 2.536631 square meter\n"
       ]
      }
     ],
     "prompt_number": 28
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "example 3.30 page number 118\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "import math \n",
      "# Variables\n",
      "delta_n = 10-12.;  #mole per mole napthanlene\n",
      "\n",
      "#basis 1g\n",
      "moles_napthalene = (1./128);\n",
      "\n",
      "# Calculations and Results\n",
      "print ('part 1')\n",
      "Qv = 40.28   #in kJ\n",
      "Qp = Qv-(delta_n*moles_napthalene*8.3144*298./1000);\n",
      "print \"heat of combustion = %f kJ\"%(Qp)\n",
      "\n",
      "print ('part 2')\n",
      "delta_H = 44.05   #in kJ/gmol\n",
      "water_formed = 4./128;   #in g mol\n",
      "Qp1 = Qp - (delta_H*water_formed);\n",
      "print \"heat of combustion = %f kJ\"%(Qp1)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "part 1\n",
        "heat of combustion = 40.318714 kJ\n",
        "part 2\n",
        "heat of combustion = 38.942151 kJ\n"
       ]
      }
     ],
     "prompt_number": 29
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [],
     "language": "python",
     "metadata": {},
     "outputs": []
    }
   ],
   "metadata": {}
  }
 ]
}