{
 "metadata": {
  "name": "",
  "signature": "sha256:03c09e4ffd933027d277b1c64cc2c94bd3c72b7cbc229c1b8170ffd14e813958"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 11 :  Material Balance Problems involving Multiple Units"
     ]
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      " Example 11.1  Page no. 311\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "# Variables \n",
      "\n",
      "w_A1 = 1                 #concentration of A in 1\n",
      "w_B2 = 1                 #  concentration of B in 2\n",
      "w_A3 = 0.8               # concentration of A in 3\n",
      "w_B3 = 0.2               # concentration of B in 3\n",
      "w_C4 = 1                 # concentration of C in 4\n",
      "w_A5  = 0.571            #concentration of A in 5\n",
      "w_B5  = 0.143            #concentration of B in 5\n",
      "w_C5  =  0.286           #concentration of C in 5\n",
      "w_D6 = 1                 # concentration of D in 6\n",
      "w_A7 = 0.714             # concentration of A in 7\n",
      "w_B7 = 0.286             # concentration of B in 7\n",
      "w_B8 = 0.333             #concentration of B in 8\n",
      "w_C8 = .667              #concentration of C in 8\n",
      "\n",
      "us1 = 2                  # Species involved in unit 1\n",
      "us2 = 3 ;                # Species involved in unit 2\n",
      "us3 = 4 ;                # Species involved in unit 3\n",
      "\n",
      "# Caculations \n",
      "total_sp = us1+us2+us3   #  Total species in system\n",
      "\n",
      "# Results\n",
      "print 'Number of possible equations are 9, they are as follows- '\n",
      "print ' Subsystem 1'\n",
      "print '       A: F1*w_A1+F2*0  =  F3*w_A3     (a)'\n",
      "print '       B:F1*0 + F2*w_B2 = F3*w_B3      (b)'\n",
      "print ' Subsystem 2'\n",
      "print '       A: F3*w_A3+F4*0  =  F5*w_A5     (c)'\n",
      "print '       B:F3*w_B3 + F4*0 = F5*w_B5      (d)'\n",
      "print '       C: F3*0+F4*w_C4 = F5*w_C5       (e)'\n",
      "print ' Subsystem 3'\n",
      "print '       A: F5*w_A5+F6*0  =  F7*w_A7+F8*0     (f)'\n",
      "print '       B:F5*w_B5 + F6*0 = F7*0+F8*w_B8      (g)'\n",
      "print '       C: F5*w_C5+F6*0 = F7*0+F8*w_C8       (h)'\n",
      "print '       D:F5*w_C5+F6*0 = F7*0+F8*w_C8        (i)'\n",
      "print ' The above equations do not form a unique set'\n",
      "\n",
      "# By inspection we can see that only 7 equations are independent \n",
      "#Independent Equations are: \n",
      "# Subsystem 1\n",
      "#A: F1*w_A1+F2*0  =  F3*w_A3 (a)\n",
      "#B:F1*0 + F2*w_B2 = F3*w_B3 (b)\n",
      "#Subsystem 2\n",
      "#A: F3*w_A3+F4*0  =  F5*w_A5 (c)\n",
      "# C: F3*0+F4*w_C4 = F5*w_C5 (e)\n",
      "# Subsystem 3\n",
      "#A: F5*w_A5+F6*0  =  F7*w_A7+F8*0 (f)\n",
      "#B:F5*w_B5 + F6*0 = F7*0+F8*w_B8 (g)\n",
      "#D:F5*w_C5+F6*0 = F7*0+F8*w_C8 (i)\n",
      "\n",
      "print ' Number of independent equations are 7 '"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Number of possible equations are 9, they are as follows- \n",
        " Subsystem 1\n",
        "       A: F1*w_A1+F2*0  =  F3*w_A3     (a)\n",
        "       B:F1*0 + F2*w_B2 = F3*w_B3      (b)\n",
        " Subsystem 2\n",
        "       A: F3*w_A3+F4*0  =  F5*w_A5     (c)\n",
        "       B:F3*w_B3 + F4*0 = F5*w_B5      (d)\n",
        "       C: F3*0+F4*w_C4 = F5*w_C5       (e)\n",
        " Subsystem 3\n",
        "       A: F5*w_A5+F6*0  =  F7*w_A7+F8*0     (f)\n",
        "       B:F5*w_B5 + F6*0 = F7*0+F8*w_B8      (g)\n",
        "       C: F5*w_C5+F6*0 = F7*0+F8*w_C8       (h)\n",
        "       D:F5*w_C5+F6*0 = F7*0+F8*w_C8        (i)\n",
        " The above equations do not form a unique set\n",
        " Number of independent equations are 7 \n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      " Example 11.2  Page no.315\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "from numpy import matrix\n",
      "\n",
      "# Variables \n",
      "\n",
      "G = 1400           #[kg]\n",
      "n_un = 16          # Number of unknowns in the given problem(excluding extent of reactions)\n",
      "n_ie  = 16 ;       # Number of independent equations\n",
      "d_o_f =  n_un-n_ie      # Number of degree of freedom\n",
      "\n",
      "print 'For unit 1 number of degree of freedom for the given system is  %i .'%d_o_f\n",
      "\n",
      "o1_air = 0.995 ;           # Mass fraction of air at out of unit 1 in A\n",
      "i1_air = 0.95 ;            # Mass fraction air at in of unit 1 in G\n",
      "i1_wtr = 0.02;             # Mass fraction water at in of unit 1 in G\n",
      "F1_wtr = 0.81 ;            # Mass fraction of water at out of unit 1 in F\n",
      "o1_wtr = 0.005 ;           # Mass fraction of water at out of unit 1 in A\n",
      "o2_wtr = 0.96 ;            # Mass fraction of water at out of unit 2 in B\n",
      "o3_wtr = 0.01;             # Mass fraction of water at out of unit 3 in D\n",
      "i1_act = 0.03 ;            # Mass fraction of acetone at in of unit 1 in G\n",
      "F1_act = 0.19 ;            #  Mass fraction of acetone at out of unit 1 in F\n",
      "o3_act = 0.99 ;            #  Mass fraction of acetone at out of unit 3 in D\n",
      "o2_act  = 0.04 ;           #  Mass fraction of acetone at out of unit 2 in B\n",
      "\n",
      "# Calculations \n",
      "A = G*i1_air/o1_air ;             #air-[kg]\n",
      "F = G*i1_act/F1_act ;             #[kg]\n",
      "W = (F*F1_wtr+A*o1_wtr-G*i1_wtr)/1       #Pure water in -[kg]\n",
      "\n",
      "n_un = 9 ;               # Number of unknowns in the given problem(excluding extent of reactions)\n",
      "n_ie  = 9 ;              # Number of independent equations\n",
      "d_o_f =  n_un-n_ie \n",
      "\n",
      "print ' For unit 2 and 3 number of degree of freedom for the given system is  %i .'%d_o_f\n",
      "\n",
      "a = matrix([[o3_act, o2_act],[o3_wtr, o2_wtr]]);\n",
      "b = matrix([[F*F1_act],[F*F1_wtr]])\n",
      "a = a.I\n",
      "x = a*b \n",
      "\n",
      "# Results\n",
      "print ' W-Pure water in to unit 1  -  %.2f kg/hr'%W\n",
      "print ' A-Air out of unit 1        -  %.2f kg/hr'%A\n",
      "print ' F-out of unit 1            -  %.2f kg/hr'%F\n",
      "print ' B-out of unit 2            -  %.2f kg/hr'%x[1]\n",
      "print ' D-out of unit 3            -  %.2f kg/hr'%x[0]"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "For unit 1 number of degree of freedom for the given system is  0 .\n",
        " For unit 2 and 3 number of degree of freedom for the given system is  0 .\n",
        " W-Pure water in to unit 1  -  157.74 kg/hr\n",
        " A-Air out of unit 1        -  1336.68 kg/hr\n",
        " F-out of unit 1            -  221.05 kg/hr\n",
        " B-out of unit 2            -  186.15 kg/hr\n",
        " D-out of unit 3            -  34.90 kg/hr\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      " Example 11.3 Page no. 318\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from numpy import matrix\n",
      "\n",
      "# Variables \n",
      "P = 6205.                #[lb mol/hr]\n",
      "amt_F = 560. ;           #[bbl]\n",
      "C_F = 0.50 ;             # [mol fraction]\n",
      "H2_F = 0.47 ;            #[mol fraction]\n",
      "S_F = 0.03 ;             #[mol fraction]\n",
      "\n",
      "CH4_G = 0.96 ;           #[mol fraction]\n",
      "C2H2_G = 0.02 ;          #[mol fraction]\n",
      "CO2_G = 0.02 ;           #[mol fraction]\n",
      "\n",
      "O2_A = 0.21 ;            #[mol fraction]\n",
      "N2_A = 0.79 ;            #[mol fraction]\n",
      "\n",
      "# Analysis of air into Oil furnace(A1)\n",
      "O2_A1 = 0.20  ;          #[mol fraction]\n",
      "N2_A1 = 0.76  ;          #[mol fraction]\n",
      "CO2_A1 = 0.04  ;         #[mol fraction]\n",
      "\n",
      "#Stack gas(P) analysis\n",
      "N2_P = .8493  ;          #[mol fraction]\n",
      "O2_P = .0413  ;          #[mol fraction]\n",
      "SO2_P = .0010 ;          # [mol fraction]\n",
      "CO2_P = .1084  ;         #[mol fraction]\n",
      "\n",
      "# Degree of freedom analysis \n",
      "n_un = 5;         \n",
      "n_ie  = 5 ;\n",
      "d_o_f =  n_un-n_ie;     # Number of degree of freedom\n",
      "print 'Number of degree of freedom for the given system is  %i .'%d_o_f\n",
      "\n",
      "\n",
      "# Calculations & Results\n",
      "F = P* SO2_P/S_F ;      # [lb mol/hr]\n",
      "a = matrix([[2*CH4_G+C2H2_G, -1, 0, 0],[0, 0, N2_A, N2_A1],[CO2_G ,-.5, O2_A, O2_A1+CO2_A1], \n",
      "            [CH4_G+2*C2H2_G+CO2_G,0,0,CO2_A1]]);# matrix of coefficients\n",
      "b = matrix([[-F*H2_F],[P*N2_P],[P*(O2_P+CO2_P+SO2_P)],[(P*CO2_P-F*C_F)]]);       # matrix of constants\n",
      "a = a.I\n",
      "x = a*b \n",
      "G = x[0]\n",
      "m_F = 7.91\n",
      "Fc = (F*m_F)/(7.578*42)         # Fuel gas consumed -[bbl/hr]\n",
      "time = amt_F/Fc ;               # Time for which available fuel gas lasts-[hr]\n",
      "\n",
      " \n",
      "print '(1) Fuel gas consumed(F) is  %.2f bbl/hr .'%Fc\n",
      "print '(2) Time for which available fuel gas lasts is  %.0f hr .'%time\n",
      "\n",
      "# For increase in arsenic and mercury level\n",
      "F_oil = Fc*42;                            #[gal/hr]\n",
      "Em_ars2 =  (3.96 *10**(-4))/1000.0 ;      # [lb/gal]\n",
      "Em_Hg2 =  (5.92 *10**(-4))/1000.0 ;       # [lb/gal]\n",
      "ars_F = F_oil*Em_ars2 \n",
      "Hg_F = F_oil*Em_Hg2 \n",
      "G_gas = G*359                             #[ft**3/hr]\n",
      "Em_ars1 =  (2.30 *10**(-4))/10**6 ;       # [lb/ft**3]\n",
      "Em_Hg1 =  (1.34 *10**(-4))/10**6 ;        # [lb/ft**3]\n",
      "ars_G = G_gas*Em_ars1;\n",
      "Hg_G = G_gas*Em_Hg1 ;\n",
      "in_ars = ((ars_F-ars_G)/ars_G)*100        #[% increase in Arsenic emission]\n",
      "in_Hg = ((Hg_F-Hg_G)/Hg_G)*100            #[% increase in Mercury emission]\n",
      "\n",
      "print '(3) Increase in Arsenic emission is  %.1f %% .'%in_ars\n",
      "print '(4) Increase in Mercury emission is  %.1f %% .'%in_Hg"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Number of degree of freedom for the given system is  0 .\n",
        "(1) Fuel gas consumed(F) is  5.14 bbl/hr .\n",
        "(2) Time for which available fuel gas lasts is  109 hr .\n",
        "(3) Increase in Arsenic emission is  107.4 % .\n",
        "(4) Increase in Mercury emission is  432.3 % .\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      " Example 11.4   Page no. 322\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from numpy import matrix\n",
      "\n",
      "# Variables \n",
      "M = 1000. ;             #[lb]\n",
      "F_s = 16/100.           # Fraction of sugar in F\n",
      "F_w = 25/100.           # Fraction of  water in F\n",
      "F_p = 59/100.           # Fraction of pulp in F\n",
      "D_p = 80/100.           # Fraction of pulp in D\n",
      "E_s = 13/100.           # Fraction of sugar in E\n",
      "E_p = 14/100.           # Fraction of pulp in E\n",
      "G_p = 95/100.           # Fraction of pulp in G\n",
      "H_s = 15/100.           # Fraction of sugar in H\n",
      "K_s = 40/100.           # Fraction of sugar in K\n",
      "\n",
      "# Calculations \n",
      "K_w = 1 - K_s\n",
      "K = M/K_s;\n",
      "L = K_w*K;\n",
      "\n",
      "# For evaporator equations are \n",
      "H_w = 1- H_s\n",
      "H = K_s*K/H_s\n",
      "J = H - K; \n",
      "\n",
      "# For screen equations are \n",
      "E_w = 1 - (E_p + E_s) \n",
      "\n",
      "a1 = matrix([[1,-1],[E_p,-G_p]])\n",
      "b1 = matrix([[H,],[0,]]) \n",
      "a1 = a1.I\n",
      "x1 = a1*b1\n",
      "E = x1[0] \n",
      "G = x1[1] \n",
      "G_s = (E_s*E - H_s *H )/G\n",
      "G_w = 1 -(G_s + G_p) \n",
      "\n",
      "a2 = matrix([[1,-1],[F_p,-D_p]])          # Matrix of coefficients of unknown\n",
      "\n",
      "F = 7818.93    \n",
      "D = 1152.2634 \n",
      "\n",
      "D_s = (F_s*F - E_s*E )/D                  # By sugar balance\n",
      "D_w = 1 -(D_s + D_p)                      # summation of wt. fraction is 1\n",
      "\n",
      "S_rec = M/(F*F_s) ;                      # Fraction of sugar recovered \n",
      "\n",
      "\n",
      "# Results\n",
      "print 'Flow streams and their respective compositions.'\n",
      "print ' M = %.0f lb  '%M\n",
      "print '  Sugar: %.2f '%1\n",
      "\n",
      "print ' L = %.0f lb  '%L\n",
      "print '  Water: %.2f'%1\n",
      "\n",
      "print ' K = %.0f lb  '%K\n",
      "print '  Sugar: %.2f'%K_s\n",
      "print '  Water: %.2f'%K_w\n",
      "\n",
      "print ' J = %.0f lb  '%J\n",
      "print '  Water: %.2f '%1\n",
      "\n",
      "print ' H = %.0f lb  '%H\n",
      "print '  Sugar: %.2f'%H_s\n",
      "print '  Water: %.2f'%H_w\n",
      "\n",
      "print ' G = %.0f lb  '%G\n",
      "print '  Sugar: %.3f'%G_s\n",
      "print '  Water: %.3f'%G_w\n",
      "print '  Pulp : %.2f'%G_p\n",
      "\n",
      "print ' E = %.0f lb  '%E\n",
      "print '  Sugar: %.2f'%E_s\n",
      "print '  Water: %.2f'%E_w\n",
      "print '  Pulp : %.2f'%E_p\n",
      "\n",
      "print ' D = %.0f lb  '%D\n",
      "print '  Sugar: %.3f'%D_s\n",
      "print '  Water: %.3f'%D_w\n",
      "print '  Pulp : %.2f'%D_p\n",
      "\n",
      "print ' F = %.0f lb  '%F\n",
      "print '  Sugar: %.2f'%F_s\n",
      "print '  Water: %.2f'%F_w\n",
      "print '  Pulp : %.2f'%F_p"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Flow streams and their respective compositions.\n",
        " M = 1000 lb  \n",
        "  Sugar: 1.00 \n",
        " L = 1500 lb  \n",
        "  Water: 1.00\n",
        " K = 2500 lb  \n",
        "  Sugar: 0.40\n",
        "  Water: 0.60\n",
        " J = 4167 lb  \n",
        "  Water: 1.00 \n",
        " H = 6667 lb  \n",
        "  Sugar: 0.15\n",
        "  Water: 0.85\n",
        " G = 1152 lb  \n",
        "  Sugar: 0.014\n",
        "  Water: 0.036\n",
        "  Pulp : 0.95\n",
        " E = 7819 lb  \n",
        "  Sugar: 0.13\n",
        "  Water: 0.73\n",
        "  Pulp : 0.14\n",
        " D = 1152 lb  \n",
        "  Sugar: 0.204\n",
        "  Water: -0.004\n",
        "  Pulp : 0.80\n",
        " F = 7819 lb  \n",
        "  Sugar: 0.16\n",
        "  Water: 0.25\n",
        "  Pulp : 0.59\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      " Example 11.5  Page no.324\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "# Variables  \n",
      "F = 15.                #[L/hr]\n",
      "cs_in = 10.            #Nutrient conc. input vessel  - [g nutrient/L substrate]\n",
      "V1 = 100. ;            # [L]\n",
      "V2 = 50. ;             #[L]\n",
      "Yxs = 0.2 ;            # [cells/g]\n",
      "umax = 0.4 ;           #[hr** - 1]\n",
      "Ks = 2. ;              #[g/L] - Monod constant\n",
      "\n",
      "# Calculations\n",
      "u1 = F/V1              #[hr** - 1] #[hr** - 1]\n",
      "cs_out = (Ks * u1/umax)/(1 - (u1/umax)) \n",
      "\n",
      "x_out = Yxs * (cs_in - cs_out)      #[g cells / L substrate]\n",
      "\n",
      "u2 = F/V2;\n",
      "cs_out1 = (Ks * u2/umax)/(1 - (u2/umax))          #Nutrient conc. output vessel  - [g nutrient/L substrate]\n",
      "x_out1 = Yxs * (cs_in - cs_out1)                  #[g cells / L substrate]\n",
      "\n",
      "x_out2 =  1.73                      # From eqn. (e),(f) and (g) - [g cells / L substrate]\n",
      "\n",
      "# Results\n",
      "print 'g cells/L from option 1 is %.2f.'%x_out\n",
      "print 'g cells/L from option 2 is %.2f.'%x_out2\n",
      "print 'By comparing option 1 and option 2 the respective answers are essentially the same.'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "g cells/L from option 1 is 1.76.\n",
        "g cells/L from option 2 is 1.73.\n",
        "By comparing option 1 and option 2 the respective answers are essentially the same.\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "code",
     "collapsed": true,
     "input": [],
     "language": "python",
     "metadata": {},
     "outputs": []
    }
   ],
   "metadata": {}
  }
 ]
}