{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 6 : Stoichiometry and Unit Operations"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 6.1   Page 346"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "a   performing overall material balance for 100kmol of feed we get  71.5 kmol as distillate and  28.5 kml as bottom product.    b   \n",
      " performing overall enthalpy balance we get Heat load of condenser =  6496490.0 kJ/kmol and Heat load of reboiler =  3394675.0 kJ/kmol.\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "\n",
    "# Variables \n",
    "# basis = 100kmol of feed\n",
    "Benzene = 100*.72                               # kmol\n",
    "Toulene = 100-Benzene                           #kmol\n",
    "# use fig 6.1\n",
    "# D = distillate, B = bottom\n",
    "# F = B + D        (i)   overall material balance\n",
    "xd = .995\n",
    "xb = .03 \n",
    "xf = .72\n",
    "# xd*D + xb*B = F*xf     (ii)    benzene balance\n",
    "# solving (i) and (ii)\n",
    "D = 71.5                                        #kmol\n",
    "B = 28.5                                        #kmol\n",
    "print \"a   performing overall material balance for 100kmol of feed we get \",D,\\\n",
    "\"kmol as distillate and \",B,\"kml as bottom product.    b   \"\n",
    "# enthalpy balance\n",
    "# use fig 6.2\n",
    "R = 1.95\n",
    "\n",
    "# Calculation \n",
    "v = D*(1+R)                                     #kmol    total overhead vapours\n",
    "To = 273.15                                     #K\n",
    "# using fig 6.2\n",
    "Ev = 42170.                                     #kJ/kmol    enthalpy of vapours overhead\n",
    "El = 11370.                                     #kJ/kmol    enthalpy of liquid\n",
    "E1 = Ev-El                                      # enthalpy removed in condenser\n",
    "Hc = E1*v                                       # heat load of condenser\n",
    "Hd = El*71.5\n",
    "Hb = 18780*28.5\n",
    "Hf = 44500*100\n",
    "Hn = Hd+Hc+Hb-Hf                                # kJ    heat load of reboiler\n",
    "\n",
    "# Result\n",
    "print \" performing overall enthalpy balance we get Heat load of condenser = \",Hc,\\\n",
    "\"kJ/kmol and Heat load of reboiler = \",Hn,\"kJ/kmol.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###  Example 6.2   Page 349"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "composition of vapour liquid mix :  mol fraction N2 =  0.71  in liquid phase and  0.859  in vapour phase.\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "\n",
    "# Variables \n",
    "# basis = 2000kg/h liquid feed rate\n",
    "F = 2000/28.84                      #kmol/h\n",
    "\n",
    "#D = distillate, W = residue flow rate\n",
    "#N2 balance\n",
    "# F*.79 = .999D + .422W    (i)\n",
    "# 54.840 = D + .4224W      (ii)\n",
    "# solving it\n",
    "W = 25.118                          #kmol/h\n",
    "D = 44.230                          #kmol/h\n",
    "#using fig 6.4 and 6.5\n",
    "# trial method is used for flash calculations\n",
    "# Trial I\n",
    "\n",
    "x = .75\n",
    "\n",
    "# from fig 6.4\n",
    "y = .8833\n",
    "\n",
    "# from fig 6.5\n",
    "Hl = 1083.65\n",
    "Hv = 6071.7\n",
    "\n",
    "# Calculation \n",
    "Hf = .3*Hv+Hv*.7\n",
    "\n",
    "# calculating we get Emix is not close to 2592.2kJ/kmol\n",
    "#Trial II\n",
    "x = .71\n",
    "y = .859\n",
    "Hl = 1085.6\n",
    "Hv = 6118.6\n",
    "Hf = .3*Hv+.7*Hl                     #kJ/kmol\n",
    "# which is aproox equal to 2595.2kJ/kmol, so flashing will occur\n",
    "\n",
    "# Result\n",
    "print \"composition of vapour liquid mix :  mol fraction N2 = \",x,\\\n",
    "\" in liquid phase and \",y,\" in vapour phase.\"\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###  Example 6.3   Page 353"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "After performing overall material balance we get Reflux, R =  93.369136 kmol/h and  recycle ratio =  0.05634472  kmol/kmol fresh feed.\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "\n",
    "# Variables \n",
    "# material balance\n",
    "# V2 vapour mix is a ternary azeotrope in which all cyclohexane of D1 is recycled\n",
    "# V2 stream\n",
    "# Cyclohexane balance\n",
    "# D1 = (.488/.024)*V2\n",
    "# IPA in V2 = .206V2\n",
    "# water in V2 = (1-.488-.206)*V2\n",
    "# W2 stream\n",
    "# IPA in W2 = (.23D1-.206V2)\n",
    "# water in W2 = (1-.024-.23)*D1-.306V2\n",
    "# W2 stream = 4.471V2 + 14.862V2\n",
    "# D3 is an azeotrope containing 67.5 mol% IPA\n",
    "# water in W3 stream = (1-.675)F\n",
    "# basis = 100 kmol/h fresh feed\n",
    "# W1+W3 = 100                (i)\n",
    "# .998W1 + .001W3 = 67.5    (ii)\n",
    "# solving it \n",
    "W1 = 67.603                     #kmol/h\n",
    "W3 = 32.397                     #kmol/h\n",
    "IPA1 = W3*.001 # IPA in W3\n",
    "#IPA2 = 4.471*V2 - .032   IPA in D3\n",
    "#C-1 = F+D3 = F1\n",
    "# water in D3 = 6.624V2 - .047-4.471V2+.032\n",
    "# water in W3 = 14.862V2-2.153V2+.015\n",
    "# solving them\n",
    "V2 = 2.624                      #kmol/h\n",
    "\n",
    "# Calculation \n",
    "D3 = 2.153*V2-.015\n",
    "D1 = 20.333*V2\n",
    "F1 = 6.624*V2+99.953\n",
    "R = 1.75*D1                     # = V1+V2-D1\n",
    "V1 = 144.1\n",
    "r = D3/100                      # recycle ratio\n",
    "\n",
    "# Result\n",
    "print \"After performing overall material balance we get Reflux, R = \",R,\\\n",
    "\"kmol/h and  recycle ratio = \",r,\" kmol/kmol fresh feed.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###  Example 6.4    Page 355"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Concentration of dissolved CO2 in the solution leaving the tower =  0.492054702187 kmol/kmol of MEA.\n"
     ]
    }
   ],
   "source": [
    "# solution\n",
    "\n",
    "# variables\n",
    "# basis 0.625 l/s of MEA solution\n",
    "c = 3.2                         #M  conc of MEA\n",
    "M = 61.                         # molar mass of MEA\n",
    "\n",
    "# calculation\n",
    "C = M*c                         #g/l  conc of MEA in sol\n",
    "MEAin = c*.625*3600/1000.       # kmol/h\n",
    "CO2diss = .166*7.2              #kmol/h    CO2 dissolved in lean MEA\n",
    "v = 26.107                      #m**3  sp. vol of gas at 318K and 101.3kPa  (table 7.8)\n",
    "qv = 1000/v                     #kmol/h \n",
    "CO2in = qv*.104                 # moles of CO2 in inlet gas\n",
    "CO2freegas = qv - CO2in\n",
    "\n",
    "#outgoing has 4.5% CO2\n",
    "GASout = CO2freegas/(1-.0455)   #kmol/h\n",
    "CO2abs = qv-GASout\n",
    "CO2 = CO2diss + CO2abs \n",
    "CO2conc = CO2/MEAin             #kmol/kmol MEA\n",
    "\n",
    "# Result\n",
    "print \"Concentration of dissolved CO2 in the solution leaving the tower = \",CO2conc,\\\n",
    "\"kmol/kmol of MEA.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 6.5   Page 356"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "a   Composition of final liquor :\n",
      "Component          mi kg/h\n",
      " NaOH              5529.30076871\n",
      " NaNO2             2522.73285015\n",
      " NaNO3             3163.59293325\n",
      " H2O               26299.5585151\n",
      " b\n",
      "Heat efeet of scrubbing system =  -2017.12645556  kW.\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "# Variables \n",
    "#(a)\n",
    "print \"a  \",\n",
    "# basis 50000 m**3/h of gas mix at 295.5K 100kPa\n",
    "v = 24.57                           #m**3/kmol sp vol of gas at 295.5K and 100kPa\n",
    "n1 = 50000/v                        # kmol/h    flow of incoming gas\n",
    "\n",
    "# Calculation \n",
    "NO2in = n1*.0546\n",
    "N2O4in = n1*.0214\n",
    "N2in = n1-NO2in-N2O4in\n",
    "\n",
    "#N2 is unaffected \n",
    "n2 = 1880.34/.95                    #kmol/h   outgoing gas flow\n",
    "# using tables 6.3 and 6.4 on page 357\n",
    "NO2rem = NO2in - (n2*.0393)\n",
    "N2O4rem = N2O4in - (n2*.0082)\n",
    "\n",
    "# rxn (ii)\n",
    "NaOHreac2 = 2*40*N2O4rem\n",
    "NaNO2pro2 = 69*N2O4rem\n",
    "NaNO3pro2 = 85*N2O4rem\n",
    "H2Opro2 = 18*N2O4rem\n",
    "\n",
    "# rxn (iii)\n",
    "NO2reac3 = 3*n2*.0025\n",
    "NaOHreac3 = 2*4.95*40\n",
    "NaNO3pro3 = 2*4.95*85\n",
    "H2Opro3 = 4.95*18\n",
    "NO2abs2 = 33.33-NO2reac3\n",
    "NaOHreac1 = 18.48*40\n",
    "NaNO2pro1 = 69*NO2abs2/2\n",
    "NaNO3pro1 = 85*NO2abs2/2\n",
    "H2Opro1 = 18*NO2abs2/2\n",
    "NaNO2t = NaNO2pro2 + NaNO2pro1\n",
    "NaNO3t = NaNO3pro2+NaNO3pro3\n",
    "H2Ot = H2Opro1+H2Opro2+H2Opro3\n",
    "NaOHt = NaOHreac1+NaOHreac2+NaOHreac3\n",
    "liq = 37500.                        #kg/h\n",
    "NaOHin = liq*.236\n",
    "NaOHout = NaOHin-NaOHt\n",
    "moist = n2*.045*18\n",
    "water = liq-NaOHin-H2Ot-moist       #kg/h\n",
    "\n",
    "# Result\n",
    "print \"Composition of final liquor :\"\n",
    "print \"Component          mi kg/h\"\n",
    "print \" NaOH             \",NaOHout\n",
    "print \" NaNO2            \",NaNO2t\n",
    "print \" NaNO3            \",NaNO3t\n",
    "print \" H2O              \",water\n",
    "print \" b\"\n",
    "\n",
    "#(b)\n",
    "#heat effect of scrubbing\n",
    "#using tables 6.6 and 6.7\n",
    "#fi1 = integ{59865.7+4545.8+10**-3 *T + 15266.3*10**-6*T**2-705.11*10**-9*T**3}\n",
    "fi1 = -155941.3/3600                #kW\n",
    "#similarly\n",
    "fi2 = 75.778                        #kW\n",
    "dH1 = (-346.303-450.1-285.83-(2*(-468.257)+2*33.18))/2          #kJ/mol NO2\n",
    "dH2 = -346.303-450.1-285.83-(2*(-468.257)+9.16)                 #kJ/mol N2O4\n",
    "dH3 = (2*(-450.1)-285.83+90.25-(2*(-468.257)+3*33.18))/3        # kJ/mol NO2\n",
    "dHdil = -469.837-(-468.257)                                     #kJ/mol NaOH\n",
    "fi3 = (dH1*1000*18.48+dH2*1000*27.32+dH3*1000*14.85+dHdil*1000*138.23)/3600         #kW\n",
    "fi4 = -fi1+fi2+fi3\n",
    "print \"Heat efeet of scrubbing system = \",fi4,\" kW.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 6.6  Page 361"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " Acetic acid that remained unextracted =  14.9726315789  percent.\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "\n",
    "# Variables \n",
    "#(a)\n",
    "# basis 100 kg feed mix\n",
    "# F = E +R = 100           (i)\n",
    "xf = .475\n",
    "xe = .82\n",
    "xr = .14\n",
    "#acetic acid balance\n",
    "# xf*F = xe*E + xr*R      (ii)\n",
    "#solving (i) & (ii)\n",
    "E = 49.2                #kg\n",
    "R = 50.8                #kg\n",
    "\n",
    "# Calculation \n",
    "a = R*xr                #kg  acetic acid leftover\n",
    "b= (a/(xf*100))*100.\n",
    "\n",
    "# Result\n",
    "print \" Acetic acid that remained unextracted = \",b,\" percent.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###  Example 6.7   Page 361"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " Flow rate of ether to the system =  249.7844  kg/h  and percentage of recovery oil =  91.4887470817 .\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "\n",
    "# Variables \n",
    "# referring to fig 6.9\n",
    "#basis 1000kg/h halibut livers\n",
    "F = 1000.               #kg/h\n",
    "OILin = F*.257\n",
    "Sin = F-OILin           # solid in the charge\n",
    "U = .23*Sin\n",
    "\n",
    "# Calculation \n",
    "OILu = U*.128\n",
    "Eu = U-OILu             # ether in underflow\n",
    "R = OILin-OILu          #kg/h   recovery of oil\n",
    "p = R*100/OILin\n",
    "O = R/.7 \n",
    "Eo = O-R\n",
    "Et = Eu+Eo\n",
    "\n",
    "# Result\n",
    "print \" Flow rate of ether to the system = \",Et,\\\n",
    "\" kg/h  and percentage of recovery oil = \",p,\".\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 6.8   Page 362"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " Summary :  \n",
      " Stream              Flow rate kg/h\n",
      " Feed                     1000.0\n",
      " Solvent                  806.383588647\n",
      " Extract                  1337.15318679\n",
      " Raffinate                469.230401854\n",
      " Acetic acid              271.256931608\n",
      " Top layer from D1        738.075719471\n",
      " Bottom layer from D1     327.820535714\n",
      " Feed to C3               797.050937568\n",
      " Overhead from C3         68.307869176\n",
      " Water waste              728.743068392\n",
      " Stream                   1806.38358865\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "\n",
    "# Variables \n",
    "F = 1000.                   #kg/h    Basis feed rate\n",
    "# using fig 6.11\n",
    "# W/A = 15.77/5.87\n",
    "# A+F+W = 1000\n",
    "# solving it\n",
    "W = 15.77*F/21.64           #kg/h\n",
    "A = F-W                     #kg/h\n",
    "# material balance across C3\n",
    "# R+R1 = D+W\n",
    "# W/D = 19.31/1.81\n",
    "\n",
    "# Calculation \n",
    "# solving it\n",
    "D = 1.81*W/19.31            #kg/h\n",
    "M1 = D+W\n",
    "# R1/R = 4.63/6.57\n",
    "R1 = 4.63*793/11.2\n",
    "R = M1-R1\n",
    "# material balance across C2\n",
    "m = .89                     # = E1/R1\n",
    "# E = A+E1+R1 = A+M11\n",
    "# M11/A = 15.6/3.97\n",
    "M11 = 15.6*A/3.97\n",
    "E = M11 + A\n",
    "E1 = M11 - R1\n",
    "# material balance across C1\n",
    "# F+S = M = E+R\n",
    "M = E+R\n",
    "S = D+E1\n",
    "AAloss = W*.4*100/(100*.3)\n",
    "AArec = 100-AAloss\n",
    "\n",
    "# Result\n",
    "print \" Summary :  \"\n",
    "print \" Stream              Flow rate kg/h\"\n",
    "print \" Feed                    \",F\n",
    "print \" Solvent                 \",S\n",
    "print \" Extract                 \",E\n",
    "print \" Raffinate               \",R\n",
    "print \" Acetic acid             \",A\n",
    "print \" Top layer from D1       \",E1\n",
    "print \" Bottom layer from D1    \",R1\n",
    "print \" Feed to C3              \",M1\n",
    "print \" Overhead from C3        \",D\n",
    "print \" Water waste             \",W\n",
    "print \" Stream                  \",M\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 6.9   Page 367"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Percent yield of glauber salt =  77.9421927531 .\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "\n",
    "# Variables \n",
    "# basis 100 kg free water\n",
    "Na2SO4in = 32.              #kg\n",
    "Win = 68.                   #kg\n",
    "\n",
    "# Calculation \n",
    "W1 = (180/142.)*32          #kg   water with Na2SO4\n",
    "Wfree1 = Win-W1\n",
    "GS1 = ((Na2SO4in+W1)*100)/Wfree1        #kg    glauber salt present in 100 kg free water\n",
    "W2 = (180*19.4)/142.                    # water associated with Na2SO4 in final mother liquor\n",
    "Wfree2 = 100-W2\n",
    "GS2 = ((19.4+W2)/Wfree2)*100.\n",
    "Y = GS1-GS2                 #kg\n",
    "p = Y*100/GS1\n",
    "\n",
    "# Result\n",
    "print \"Percent yield of glauber salt = \",p,\".\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###  Example 6.10   Page 368"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " Quantity if original solution to be fed to the crystallizer  per 1000kg crystals of MgSO4.7H2O =  1761.06816585 kg.\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "\n",
    "# Variables \n",
    "# basis 100kg free water in original sol\n",
    "# initial T = 353K\n",
    "W1 = (126/120.3)*64.2                    #kg\n",
    "Wfree1 = 100-W1\n",
    "MS1 = ((64.20+W1)*100)/32.76             # MgSO4.7H2O in 100kg free water\n",
    "\n",
    "\n",
    "# Calculation \n",
    "# 4% of original sol evaporates\n",
    "E = (MS1 + 100)*.04\n",
    "Wfree2 = 100-E                           # free water in mother liquor\n",
    "# at 303.15 K\n",
    "W2 = (126/120.3)*40.8\n",
    "Wfree3 = 100-W2\n",
    "MS2 = (W2+40.80)*Wfree2/Wfree3           # crystals of MgSO4.7H2O\n",
    "y = MS1-MS2                              #kg \n",
    "q = 501.2*1000/284.6                     # quantity of original sol to be fed\n",
    "\n",
    "# Result\n",
    "print \" Quantity if original solution to be fed to the crystallizer \\\n",
    " per 1000kg crystals of MgSO4.7H2O = \",q,\"kg.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###  Example 6.11   Page 370"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "a    Percentage recovery of p-DCB =  65.738385326 .    b   \n",
      "Additional recovery of p-DCB =  25.6258199306 .\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "\n",
    "# Variables \n",
    "# (a)\n",
    "print \"a   \",\n",
    "# using fig 6.12\n",
    "# peforming material balance at 290K\n",
    "a1 = 5.76\n",
    "b1 = 4.91\n",
    "\n",
    "# Calculation and  Result\n",
    "DCBs = b1*100/(a1+b1)                   # % of solid separated p-DCB\n",
    "DCBr1 = DCBs*100/70.                    # recovery of p-DCB\n",
    "print \"Percentage recovery of p-DCB = \",DCBr1,\".    b   \"\n",
    "\n",
    "#(b)\n",
    "#at 255K\n",
    "a2 = 5.76\n",
    "b2 = 10.22\n",
    "DCBs = b2*100/(a2+b2)\n",
    "DCBr2 = (DCBs*100)/70\n",
    "Ar = DCBr2-DCBr1\n",
    "print \"Additional recovery of p-DCB = \",Ar,\".\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###  Example 6.12   Page 371"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " Composition of various streams :  \n",
      " Component           T kg/h           D kg/h\n",
      "    A                 925.6            74.6 \n",
      "    B                 345.1            3654.9\n",
      "    C                  66.9             nil  \n",
      " Purity of top product = 69.2 percent A  Purity of bottom product = 98.0 percent  Make-up solvent = 66.9 kg/h.\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "\n",
    "# Variables \n",
    "F = 5000.                           #kg/h  solvent free mix fed to simple crystallization unit\n",
    "B1 = 4000/157.5                     # kmol/h   p-NCB in feed\n",
    "A1 = 1000/157.5                     # kmol/h   o-NCB in feed\n",
    "\n",
    "# Calculation \n",
    "# after crstallization mother liquor has 33.1 mol % B, A doesn't crstallizes\n",
    "m = A1/(1-.331)                     # mother liquor entering extractive crytallization unit\n",
    "B2 = m-A1\n",
    "\n",
    "# optimizing solid flux\n",
    "# dCt/dR = 1 - 2/R**3 = 0\n",
    "R = 2**(1/3)\n",
    "# referring fig 6.14\n",
    "# overall material balance\n",
    "# p-isomer (B)\n",
    "# .98D + xT = 4000      (i)\n",
    "# o-isomer (A)\n",
    "# .02D + (1-.05-x)T = 1000      (ii)\n",
    "# material balance around solvent recovery unit\n",
    "# B\n",
    "# 2.26Tx = .198G = xH         (iii)\n",
    "# A\n",
    "# 2.26T(.95-x) = .531G          (iv)\n",
    "# solving above eq\n",
    "T = 1337.6                          # kg/h\n",
    "D = 3729                            # kg/h\n",
    "G = 3939                            # kg/h\n",
    "x = .258\n",
    "\n",
    "# Result\n",
    "#putting these values we get composition of various streams\n",
    "print \" Composition of various streams :  \"\n",
    "print \" Component           T kg/h           D kg/h\"\n",
    "print \"    A                 925.6            74.6 \"\n",
    "print \"    B                 345.1            3654.9\"\n",
    "print \"    C                  66.9             nil  \"\n",
    "print \" Purity of top product = 69.2 percent A  Purity of bottom product \\\n",
    "= 98.0 percent  Make-up solvent = 66.9 kg/h.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###  Example 6.13   Page 383"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Dew Point =  252.97 K.\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "\n",
    "# Variables \n",
    "Pw1 = 12.84                 #Pa  v.p. of ice at 233.15K   (table 6.12)\n",
    "P1 = 101325.                #Pa\n",
    "\n",
    "# Calculation \n",
    "Hm = (Pw1/(P1-Pw1))         # kmol/kmol dry air\n",
    "P2 = 801325.                #Pa\n",
    "Pw2 = P2*.0001267/(1+.0001267)\n",
    "dp = -20.18 + 273.15        #K     from table 6.12\n",
    "\n",
    "# Result\n",
    "print \"Dew Point = \",dp,\"K.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###  Example 6.14   Page 384"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The absolute molar humidity =  0.0210583065135  kmol water vapour/kg dry air \n",
      "Absolute humidity =  0.0130982666514  kg moisture/kg dry air percent RH =  51.5084915085  percent saturation =  50.4873424594  \n",
      "Humid heat =  1.03010081064  kJ/kg dry air K \n",
      "Humid volume =  0.88462068344  m**3/kg dry air.\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "\n",
    "# Variables \n",
    "#Pa = v.p. at DP\n",
    "Pw = 2.0624                 #kPa\n",
    "P = 100.                    #kPa\n",
    "\n",
    "# Calculation \n",
    "Hm = Pw/(P-Pw)              # kmol water vapour / kmol dry air\n",
    "H = .622*Hm                 # kg moisture/kg dry air\n",
    "\n",
    "# at saturation, DB = WB = DP\n",
    "Ps = 4.004                  #kPa\n",
    "RH = Pw*100/Ps\n",
    "Hs = (Ps/(P-Ps))*.622\n",
    "s = H*100/Hs\n",
    "Ch = 1.006+1.84*H           #kJ/kg dry air K\n",
    "Vh = (.00073+.03448)*22.414*1.1062*1.0133           #m**3/kg dry air\n",
    "# using fig 6.15\n",
    "WB = 294.55                 #K\n",
    "ias = 62.3                  # kJ/kg dry air\n",
    "d = -.28                    # kJ/kg dry air\n",
    "ia = ias + d\n",
    "\n",
    "# Result\n",
    "print \"The absolute molar humidity = \",Hm,\\\n",
    "\" kmol water vapour/kg dry air \\nAbsolute humidity = \",H,\\\n",
    "\" kg moisture/kg dry air percent RH = \",RH,\" percent saturation = \",s,\\\n",
    "\" \\nHumid heat = \",Ch,\" kJ/kg dry air K \\nHumid volume = \",Vh,\" m**3/kg dry air.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###  Example 6.15   Page 385"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " the moisture added to the air =  5.96  g/kg dry air  DB temp of final air =  300.95 K  WB temp of final air =  298.15 K  The heating load of the steam coil per kg dry air =  108828.110731  kJ/h  Steam consumption =  50.3088529638  kg/h.\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "\n",
    "# Variables \n",
    "#basis 1kg of dry air entering the air washer\n",
    "#from fig 6.15\n",
    "H1 = 11.8                   #g/kg dry air\n",
    "H2 = 17.76                  #g/kg dry air\n",
    "H = H2-H1                   # moisture added during saturation\n",
    "DB = 300.95                 #K\n",
    "WB = 298.15                 #K\n",
    "DP = 297.15                 #K\n",
    "\n",
    "# Calculation \n",
    "Ch = 1.006+1.84*.01776      #kJ/kg dry air K\n",
    "dT = DB-DP\n",
    "Hs = Ch*3.8\n",
    "A = 25000.                  #m**3/h    actual air at 41 and 24 degree celcius\n",
    "# again from fig 6.15\n",
    "Vh = .9067                  #m**3/kg dry air\n",
    "qm = A/Vh                   #kg dry air/h\n",
    "fi = qm*Hs                  #kJ/h\n",
    "P = 300.                    #kPa\n",
    "lamda= 2163.2               #kJ/kg         by appendix IV.2\n",
    "SC = fi/lamda               #kg/h     steam consumption at the heater\n",
    "\n",
    "# Result\n",
    "print \" the moisture added to the air = \",H,\\\n",
    "\" g/kg dry air  DB temp of final air = \",DB,\\\n",
    "\"K  WB temp of final air = \",WB,\\\n",
    "\"K  The heating load of the steam coil per kg dry air = \",fi,\\\n",
    "\" kJ/h  Steam consumption = \",SC,\" kg/h.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###  Example 6.16   Page 387"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Air leaves th induced draft fan at  307.583067857  K.\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "\n",
    "# Variables \n",
    "# M = E+B+W\n",
    "Tav = (45+32.)/2 +273.15                #K   avg cooling water T\n",
    "# using steam tables (Appendix A IV.1)\n",
    "lamda = 2410.5                          #kJ/kg \n",
    "E = 530/lamda                           #kg/s\n",
    "Cl = 4.1868\n",
    "Ti = 45+273.15                          #K\n",
    "To = 32+273.15                          #K\n",
    "fi = 530.                               # = mc*Cl*(Ti-To)\n",
    "mc = 530/(Cl*(Ti-To))                   #kg/s\n",
    "W = .3*mc/100                           #kg/s\n",
    "\n",
    "\n",
    "# Calculation \n",
    "# dissolved solid balance\n",
    "# M*xm = (B+W)*xc\n",
    "# 500*10**-6*M = (B+.0292)*2000*10**-6\n",
    "# solving above eqs\n",
    "B = .0441                               #kg/s\n",
    "M = .2932                               #kg/s\n",
    "\n",
    "#energy balance on cooling tower\n",
    "# fi = ma*(i2-i1)\n",
    "# i2-i1 = 11.042 kJ/kg dry air\n",
    "# moisture balance \n",
    "#E = ma(H2-H1)\n",
    "H2 = .2199/48 + .0196\n",
    "iws = 2546.2                            # Appendix IV\n",
    "Ch1 = 1.006+1.84*.0196\n",
    "i1 = 1.006*(297.45-273.15)+.0196*iws+1.042*(308.15-297.5)       # kJ/kg dry air\n",
    "i2 = i1 + 11.04\n",
    "Tdb = ((i2 - 1.006*(301.25-273.15)-iws*H2)/1.05)+301.25         # K\n",
    "\n",
    "# Result\n",
    "print \"Air leaves th induced draft fan at \",Tdb,\" K.\"\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###  Example 6.17   Page 389"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "a   The heat loss rate rate from the hot air in the bed =  397963.39774  kW   b   The percentage heat recovery in hot water =  79.5581997436  percent.\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "\n",
    "# Variables \n",
    "# basis 1 kg dry air fed to tower\n",
    "# from fig 6.16 we get\n",
    "# at WB=330 K and DB=393 K\n",
    "H1 = .0972                          # kg/kg dry air\n",
    "DP = 325.15                         #K\n",
    "# at 313 K\n",
    "H2 = .0492                          # kg/kg dry air\n",
    "H = H1-H2                           # moisture condensed in tower\n",
    "\n",
    "# Calculation \n",
    "Ch1 = 1.006 + 1.84*H1               # kJ/kg dry air\n",
    "Ch2 = 1.006 + 1.84*H2\n",
    "ia1 = 1.006*(325-273) + H1*2596 + 1.185*(393-325)       # enthalpy of entering air\n",
    "ia2 = 1.006*(313-273) + H2*2574.4                       # enthalpy of outgoing air\n",
    "i = ia1-ia2\n",
    "qm = 2000/(1+H1)\n",
    "fi1 = qm*i                          # heat loss rate\n",
    "fi2 = 1.167*3600*4.1868*(323-305)   # heat gained by water\n",
    "r = fi2*100/fi1\n",
    "\n",
    "# Result\n",
    "print \"a   The heat loss rate rate from the hot air in the bed = \",fi1,\\\n",
    "\" kW   b   The percentage heat recovery in hot water = \",r,\" percent.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###  Example 6.18 Page 390"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "a   Volumetric flowrate of entering mixture =  1732.08256916  m**3/h   b   Mass flowrate of activated carbon =  2228.57142857  kg/h   c   Original mixture must be coole to  281.5  K at 405 kPa for achieving same concentration of the outlet mixture with adsorption.\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "\n",
    "# Variables \n",
    "# basis 800 kmol of inlet CS2-H2 mix\n",
    "Pi = 106.7                      #kPa  Total Pressure\n",
    "Pcs2i = 16.93                   # kPa\n",
    "n = 800.                        # kmol\n",
    "\n",
    "# Calculation \n",
    "ncs2i = Pcs2i*n/Pi              # kmol\n",
    "nh2i = n-ncs2i\n",
    "Po = 101.325                    # kPa\n",
    "Pcs2o = 6.19                    # kPa\n",
    "nh2o = 673.1                    # kmol\n",
    "ncs2o = Pcs2o*nh2o/(Po-Pcs2o)\n",
    "ncs2a = ncs2i-ncs2o\n",
    "mcs2a = ncs2a*76.1407           #kg\n",
    "r = 600.                        # kg/h  design adsorption rate\n",
    "Mi = n*r/mcs2a                  # kmol/h\n",
    "Vi = Mi*22.843                  # m**3/h\n",
    "mcs2ac = .32-.04                # kg  CS2 absorbed per kg BD activated carbon\n",
    "qm = r*1.04/mcs2ac              # kg/h\n",
    "C = ncs2o/nh2o                  # kmol CS2/kmol H2   = Pcs2/(P-Pcs2)\n",
    "Pcs2 = 24.763                   # kPa\n",
    "T = 281.5                       #K  by eq 5.24\n",
    "\n",
    "# Result\n",
    "print \"a   Volumetric flowrate of entering mixture = \",Vi,\\\n",
    "\" m**3/h   b   Mass flowrate of activated carbon = \",qm,\\\n",
    "\" kg/h   c   Original mixture must be coole to \",T,\\\n",
    "\" K at 405 kPa for achieving same concentration of the outlet mixture with adsorption.\" \n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###  Example 6.19   Page 391"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " The heat liberation rate in the tower =  70323.4193977  kJ/h.\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "\n",
    "# Variables \n",
    "# basis 4000 kg/h of NaOH produced\n",
    "Cl2p = 35.5*2*4000/80               # kg/h\n",
    "Mcl2 = Cl2p/71                      # kmol/h\n",
    "P = 101.325                         # kPa\n",
    "Pw = 2.0624                         # kPa\n",
    "\n",
    "# Calculation \n",
    "moist = (Pw/(P-Pw))*(18.0154/70.906)  \n",
    "Tmoist = Cl2p*moist                 # kg/h\n",
    "# for 90% onc of acid\n",
    "n = (10/18.0153)/(90/98.0776)       # kmol H2O/kmol acid\n",
    "Q = 134477/(18.*(n+1.7983)**2)      #kJ/kg H2O   by eq (ii)\n",
    "lambdav = 2459.                     # kJ/kg  (Appendix IV)\n",
    "heatload = Q+lambdav\n",
    "fi = heatload*18.74                 #kJ/h\n",
    "\n",
    "# Result\n",
    "print \" The heat liberation rate in the tower = \",fi,\" kJ/h.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###  Example 6.20   Page 393"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "a   Temp of feed water to absorber =  291.367208278 K.   b   Temp of aq NH3 sol leaving the absorber =  304.469504086 K.\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "\n",
    "# Variables \n",
    "# basis 100 kmol of feed gas\n",
    "# using table 5.1\n",
    "Sniai = 20.6*29.5909+62*28.6105+4.1*20.7723+11.1*19.2494+2.2*25.6503\n",
    "Snibi = (20.6*(-5.141)+62*1.0194+11.1*52.1135+2.2*33.4806)/1000\n",
    "Snici = (20.6*13.1829+62*(-.1476)+11.1*11.973+2.2*.3518)/10**6\n",
    "Snidi = (20.6*(-4.968)+62*.769+11.1*(-11.3173)+2.2*(-3.0832))/10**9\n",
    "Hgas = Sniai*(283-263) + Snibi*(283**2-263**2)/2 + Snici*(283**3-263**3)/3 + Snidi*(283**4-263**4)/4  #kJ\n",
    "Hnh3 = 1533.8                               #kJ \n",
    "\n",
    "# Calculation \n",
    "SniCmpi = (Hgas-Hnh3)/20                    # kJ/(K 97.8 kmol gas)  NH3 free gas\n",
    "Go = 97.8/.99995                            #kmol\n",
    "NH3a = (2.2-.005)*17                        # kg\n",
    "F1 = NH3a/.04                               # flowrate of 4% NH3 solution\n",
    "Water = F1-NH3a                             #kg\n",
    "dT1 = Hgas/(Water*4.1868)                   # K\n",
    "Twater = 307-dT1                            #K\n",
    "Wvp = 2.116                                 #kPa\n",
    "P = 5101.325                                #kPa\n",
    "moist = Go*Wvp/(P-Wvp)                      # kg\n",
    "W = Water + moist                           # total demineralised water\n",
    "dTactual = Hgas/(W*4.1868)                  #K\n",
    "# from table 5.59\n",
    "dHf1 = -80.093                              #kJmol NH3  of 4% NH3 sol\n",
    "dHf2 = -46.11                               #kJ/molNH3\n",
    "H = dHf1-dHf2                               # heat of 4% NH3 sol\n",
    "Hevl = -(H*NH3a*1000)/17.                   # total heat evolved\n",
    "\n",
    "# in absorber gas is further heated from 283K to 291.4K\n",
    "Hsol = Hevl-(2854.1*(291.4-283.15))         # kJ\n",
    "# c 0f 4% NH3 sol = c of water = 4.1868 kJ/kg K\n",
    "dT2 = Hsol/(F1*4.1868) \n",
    "To = 291.4+dT2\n",
    "\n",
    "# Result\n",
    "print \"a   Temp of feed water to absorber = \",Twater,\\\n",
    "\"K.   b   Temp of aq NH3 sol leaving the absorber = \",To,\"K.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###  Example 6.21   Page 396"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "a   Flowrate of incoming air on dry basis =  4.25  kg/s   b   Humidity of air leaving the drier =  0.056  kg/kg dry air.   c   Steam consumption in the heater =  0.181547726207  kg/h.\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "\n",
    "# Variables \n",
    "# basis : product rate of 100 kg/h\n",
    "H1 = .036                   # kg moist/ kg dry solid\n",
    "X1 = .25/.75                # kg /kg dry solid\n",
    "X2 = .02/.98                # kg/kg dry solid\n",
    "\n",
    "# Calculation \n",
    "# moist balance\n",
    "# ms*(X1-X2) = ma*(H2-H1)\n",
    "To = 273.15                 #K\n",
    "is1 = 1.43*(30-0)+X1*4.1868*30 \n",
    "is2 = 1.43*80+.0204*4.1868*80\n",
    "Tdb = 393.15                #K\n",
    "Tdp1 = 308.15               #K\n",
    "iwb1 = 2565.4               #kJ/kg\n",
    "Ch1 = 1.006+1.84*.036\n",
    "ia1 = 1.006*(Tdp1-273.15)+H1*iwb1+Ch1*(Tdb-Tdp1)\n",
    "H2 = .056\n",
    "Tdp2 = 315.55\n",
    "iwb2 = 2578.7\n",
    "ia2 = 1.006*(Tdp2-273.15)+H2*iwb2+(1.006+1.84*H2)*(323.15-Tdp2)\n",
    "ma = .085/(.056-.036)\n",
    "iaa = 1.006*(Tdp1-273.15)+H1*iwb1\n",
    "fi = 4.25*(218.68-iaa)      #kW\n",
    "lambda_ = 2133.0\n",
    "steam = fi/lambda_          # kg/h\n",
    "\n",
    "# Result\n",
    "print \"a   Flowrate of incoming air on dry basis = \",ma,\\\n",
    "\" kg/s   b   Humidity of air leaving the drier = \",H2,\\\n",
    "\" kg/kg dry air.   c   Steam consumption in the heater = \",steam,\" kg/h.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 6.22   Page 398"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "a   Bone dry production of the dryer =  471.96  kg/h.   b   The evaporation taking place in the dryer =  396.4464  kg/h.   c   The air circulation rate =  5377.43182932  m**3/h.\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "\n",
    "# Variables\n",
    "# basis cloth speed = 1.15 m/s\n",
    "prod = 1.15*1.2*3600*.095\n",
    "moisti = .90                    # kg/kg bone dry cloth \n",
    "moisto = .06\n",
    "evp = 471.96*(moisti-moisto)\n",
    "\n",
    "# using fig 6.15 and 6.16\n",
    "H1 = .01805 \n",
    "H2 = .0832\n",
    "dH = H2-H1\n",
    "qm1 = evp/dH                    # kg dry air/h\n",
    "Vh = .8837                      #m**3/kg dry air\n",
    "qv = qm1*Vh\n",
    "DP1 = 296.5                     #K\n",
    "DP2 = 322.5                     #K\n",
    "lambdaV2 = 2384.1               #kJ/kg\n",
    "To = 273.15                     #K\n",
    "\n",
    "# Calculation \n",
    "fi1 = prod*1.256*(368-303)+prod*.06*(368-303)*4.1868                # kJ/h\n",
    "fi2 = evp*(322.5-303.15)+evp*lambdaV2                               #kJ/h\n",
    "ia1 = 1.006*(303.15-273.15)+2556.4*.01805                           #kJ/kg dry air\n",
    "ia2 = 1.006*(322.8-273.15)+2591.5*.0832+(1.006+1.84*.0832)*(393-328.8)\n",
    "fi2 = ia2-ia1\n",
    "hlost = fi2-fi1                 # kJ/h\n",
    "# using Appendix IV\n",
    "h = 720.94                      #kJ/kg\n",
    "lambdav = 2046.5                # kJ/kg\n",
    "steami = (h+lambdav)*885        # kJ/h\n",
    "fi4 = h*885                     #kJ/h\n",
    "qm2 = 885/evp\n",
    "\n",
    "# Result\n",
    "print \"a   Bone dry production of the dryer = \",prod,\\\n",
    "\" kg/h.   b   The evaporation taking place in the dryer = \",evp,\\\n",
    "\" kg/h.   c   The air circulation rate = \",qv,\" m**3/h.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 6.23   Page 401"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Specific heat consumption of the system is  0.511230907457  kg steam/kg evaporation.\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "\n",
    "# Variables \n",
    "# basis : weak liquor flowrate = 1060 kg/h\n",
    "s1 = 1060*.04           #kg/h   solids in weak liquor\n",
    "liqr = s1/.25           #  kg/h  conc liquor leaving 4th effect\n",
    "evp = 1060-liqr         # kg/h\n",
    "lambdas = 2046.3        # kJ/kg\n",
    "Wf = 1060.              # kg/h\n",
    "C1f = 4.04\n",
    "T1 = 422.6\n",
    "Tf = 303\n",
    "lambdav1 = 2114.4\n",
    "\n",
    "\n",
    "# Calculation \n",
    "# enthalpy balance of 1st effect\n",
    "# Ws*lambdas = Wf*C1f*(T1-Tf) + (Wf-W1)*2114.4\n",
    "#putting values we get\n",
    "# Ws = 1345.57 - 1.033*W1\n",
    "# 2nd effect\n",
    "# W1 = 531.38+.510*W2\n",
    "# 3rd effect\n",
    "# W1 - 1.990*W2 = -1.027*W3\n",
    "# 4th effect\n",
    "# W2 - 1.983*W3 = -176.84\n",
    "#solving above eqs\n",
    "W1 = 862.               # kg/h\n",
    "W2 = 648.2              # kg/h\n",
    "W3 = 416.7              # kg/h\n",
    "Ws = 455.2              # kg/h\n",
    "eco = evp/Ws            # kg evaporation/kg steam\n",
    "spcon = 1/eco           # kg steam/kg evaporation\n",
    "\n",
    "# Result\n",
    "print \"Specific heat consumption of the system is \",spcon,\" kg steam/kg evaporation.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###  Example 6.24   Page 403"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "By mass balance, required cooling water flow in external cooler =  57684.2098978  kg/h.By enthalpy balance, overall rise in CCW temperature =  8.80728433048  K.\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "\n",
    "# Variables \n",
    "Fspd1 = 4300.                   # kg/h\n",
    "Bcrtn = Fspd1*600*10**-6        # kg/h\n",
    "Fspd2 = Bcrtn/.00645            # kg/h\n",
    "evp1 = Fspd1-Fspd2\n",
    "Fspd3 = Bcrtn/.057\n",
    "evp2 = Fspd2-Fspd3\n",
    "C3 = Bcrtn/.4\n",
    "evp3 = Fspd3-C3\n",
    "\n",
    "# Calculation \n",
    "fi1 = Fspd1*2.56*(468.15-373.15)+3900*450               # kJ/h\n",
    "fi2 = Fspd2*2.56*(463.15-468.15)+354.737*450            # kJ/h\n",
    "fi3 = Fspd3*2.56*(453.15-463.15)+38.813*450             # kJ/h\n",
    "fi = fi1+fi2+fi3\n",
    "mt = fi/(2.95*(503.15-478.15))                          # kg/h\n",
    "qt = mt/.71                                             # l/h\n",
    "mccw1 = 1755000/(8*4.1868)                              # kg/h\n",
    "mccw2 = mccw1*.9 \n",
    "dT2 = 159632/(mccw2*4.1868)\n",
    "mccw3 = mccw1-mccw2\n",
    "dT3 = 17466/(mccw3*4.1868)\n",
    "dT = (1755000+159632+17466)/(mccw1*4.1868)\n",
    "Fw = 1932098/(8*4.1868)                                 # kg/h\n",
    "\n",
    "# Result\n",
    "print \"By mass balance, required cooling water flow in external cooler = \",Fw,\\\n",
    "\" kg/h.By enthalpy balance, overall rise in CCW temperature = \",dT,\" K.\"\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Example 6.25   Page 405"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " Material balance thickener   ITEM    STREAM, kg/h   M2   O2   M1     O1    W   Mo Slurry     14917.5166812        52985.3076        26839.6907216        64907.4816404        55206.3736997        17803.3637049  Suspended solids     5206.21332174        15.89559228        5206.21332174        12.9814963281        2042.63582689        7156.95220938  Liquor    9711.30335947        52969.4120077        21632.7907216        64894.5001441          53163.7378728        10646.4114955   Na2O                 1116.75827836        1389.36162643        527.220818361        614.385800181        127.592970895         168.759164606\n"
     ]
    }
   ],
   "source": [
    "# solution \n",
    "\n",
    "# Variables \n",
    "#stream M2\n",
    "Vcaco3M2 = .349/2.711\n",
    "VliqrM2 = .651/1.167\n",
    "VslryM2 = Vcaco3M2+VliqrM2\n",
    "spgM2 = 1/VslryM2\n",
    "FsM2 = 2.845*3600*spgM2\n",
    "sM2 = FsM2*.349                             # kg/h\n",
    "liqrM2 = FsM2*.651\n",
    "Na2OM2 = liqrM2*.1342/1.167\n",
    "\n",
    "# Calculation \n",
    "#stream O2\n",
    "FsO2 = 14.193*3600*1.037                    # kg/h\n",
    "sO2 = FsO2*.0003\n",
    "liqrO2 = FsO2-sO2\n",
    "Na2OO2 = liqrO2*.0272/1.037\n",
    "#stream M1\n",
    "VM1 = .194/2.711 + .806/1.037               # l\n",
    "spgM1 = 1/VM1\n",
    "FsM1 = 5206.9/.194\n",
    "liqrM1 = FsM1 - 5206.9\n",
    "Na2OM1 = liqrM1*.0252/1.034\n",
    "# stream O1\n",
    "FsO1 = FsO2+FsM1-FsM2\n",
    "sO1 = FsO1*.0002\n",
    "liqrO1 = FsO1 - sO1\n",
    "Na2OO1 = liqrO1*.0096/1.014\n",
    "# stream W\n",
    "VW = .037/2.711 + .963\n",
    "spgW = 1/VW\n",
    "FsW = 14.977*3600*spgW\n",
    "sW = FsW*.037\n",
    "liqrW = FsW-sW\n",
    "Na2OW = liqrW*.0024\n",
    "# stream Mo\n",
    "VMo = .402/2.711 + .598/1.022\n",
    "spgMo = 1/VMo\n",
    "FsMo = 3.627*3600*spgMo\n",
    "sMo = FsMo*.402\n",
    "liqrMo = FsMo - sMo\n",
    "Na2OMo = liqrMo*.0162/1.022\n",
    "\n",
    "# Result\n",
    "print \" Material balance thickener   ITEM    STREAM, kg/h   M2   O2   M1\\\n",
    "     O1    W   Mo Slurry    \",FsM2,\"      \",FsO2,\"      \",FsM1,\"      \",FsO1,\\\n",
    "     \"      \",FsW,\"      \",FsMo,\" Suspended solids    \",sM2,\"      \",sO2,\\\n",
    "     \"      \",sM2,\"      \",sO1,\"      \",sW,\"      \",sMo,\" Liquor   \",liqrM2,\\\n",
    "     \"      \",liqrO2,\"      \",liqrM1,\"      \",liqrO1,\"        \",liqrW,\"      \",liqrMo,\\\n",
    "     \"  Na2O                \",Na2OM2,\"      \",Na2OO2,\"      \",Na2OM1,\"      \",Na2OO1,\"      \",Na2OW,\\\n",
    "     \"       \",Na2OMo\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
