{
 "metadata": {
  "name": "",
  "signature": "sha256:db3a394cd915f3675da3a1ec91e93913eb152d495576bd0a47778fe0952f79fb"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 8 : Solving Material Balance Problems for Single Units without Reaction"
     ]
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      " Example 8.1 Page no. 197\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "# Variables\n",
      "# Basis : 1 min\n",
      "d_w =  1.0 ;            # Density of aqueous solution-[g/cubic metre]\n",
      "d_sol =  0.6 ;          # Density of organic solvent-[g/cubic metre]\n",
      "n_un = 8 ;              # Number of unknowns in the given problem\n",
      "n_ie  = 8 ;             # Number of independent equations\n",
      "\n",
      "# Calculation and Results\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",
      "# Material balance of Strep.\n",
      "x =  (200*10+10*0-200*0.2)/10;        #[g]\n",
      "print 'Strep per litre of solvent is  %.1f g .'%x\n",
      "\n",
      "cnc = x/(1000*d_sol) ;                #[g Strep/g of S]\n",
      "print 'Strep per gram of solvent is  %.4f g Strep/g of S .'%cnc\n",
      "\n",
      "m_fr = cnc/(1+cnc) ;                  #Mass fraction\n",
      "print 'Mass fraction of Strep is  %.3f g .'%m_fr"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Number of degree of freedom for the given system is  0 .\n",
        "Strep per litre of solvent is  196.0 g .\n",
        "Strep per gram of solvent is  0.3267 g Strep/g of S .\n",
        "Mass fraction of Strep is  0.246 g .\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      " Example 8.2  Page no. 199\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "# Variables\n",
      "F_O2 = 0.21 ;         # fraction of O2 in feed(F) \n",
      "F_N2 = 0.79 ;         # fraction of N2 in feed(F) \n",
      "P_O2 = 0.25 ;         # fraction of O2 in product(P)\n",
      "P_N2 = 0.75 ;         # fraction of N2 in  product(P)\n",
      "F = 100 ;             # Feed - [g mol]\n",
      "w = 0.80 ;            # Fraction of waste\n",
      "W = w*F ;             # Waste -[g mol]\n",
      "\n",
      "# Calculation\n",
      "# By analysis for degree of freedom , DOF comes to be zero \n",
      "P = F - W ;           # By overall balance - [g mol]\n",
      "W_O2 = (F_O2*F - P*P_O2)/100       # Fraction of O2 in waste stream by O2 balance \n",
      "W_N2 = (W - W_O2*100)/100 ;        #Fraction of N2 in waste stream\n",
      " \n",
      "# Results    \n",
      "print 'Composition of Waste Stream' \n",
      "print '  Component             Fraction in waste stream' \n",
      "print '  O2                    %.2f'%W_O2 \n",
      "print '  N2                    %.2f'%W_N2 "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Composition of Waste Stream\n",
        "  Component             Fraction in waste stream\n",
        "  O2                    0.16\n",
        "  N2                    0.64\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      " Example 8.3  Page no. 202\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "# Variables\n",
      "# Basis : 1 hr so F  = 1000 kg\n",
      "F = 1000 ;        # feed rate-[kg/hr]\n",
      "P = F/10.0 ;      # product mass flow rate -[kg/hr]\n",
      "\n",
      "n_un = 9 ;        # Number of unknowns in the given problem\n",
      "n_ie  = 9 ;       # Number of independent equations\n",
      "\n",
      "# Calculation and Result\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",
      "#  Overall mass balance: F  =  P+B\n",
      "B =  F-P ;                  # bottom mass flow rate -[kg/hr]\n",
      "print ' Bottom mass flow rate -              %.1f kg '%B\n",
      "\n",
      "# Composition of bottoms by material balances\n",
      "m_EtOH = 0.1*F-0.6*P ;      # By EtOH balance-[kg]\n",
      "m_H2O = 0.9*F - 0.4*P ;     # By H2O balance-[kg]\n",
      "total  = m_EtOH+m_H2O ;     #[kg]\n",
      "f_EtOH = m_EtOH/total ;     # Mass fraction of EtOH\n",
      "f_H2O = m_H2O/total ;       # Mass fraction of H2O\n",
      "\n",
      "print ' Mass of EtOH in bottom -             %.1f kg '%m_EtOH\n",
      "print ' Mass of H2O in bottom -              %.1f kg '%m_H2O\n",
      "print ' Mass fraction of EtOH in bottom -    %.3f '%f_EtOH\n",
      "print ' Mass fraction of H2O in bottom -     %.3f '%f_H2O"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Number of degree of freedom for the given system is  0 .\n",
        " Bottom mass flow rate -              900.0 kg \n",
        " Mass of EtOH in bottom -             40.0 kg \n",
        " Mass of H2O in bottom -              860.0 kg \n",
        " Mass fraction of EtOH in bottom -    0.044 \n",
        " Mass fraction of H2O in bottom -     0.956 \n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      " Example 8.4  Page no. 205\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from numpy import matrix\n",
      "\n",
      "# Variables\n",
      "# Given\n",
      "A = 200 ;             # Mass of added solution [kg] \n",
      "P_H2SO4 = .1863 ;     #Fraction of H2SO4 in P(Final solution)\n",
      "P_H2O = .8137 ;       #Fraction of H2O in P(Final solution)\n",
      "A_H2SO4 = .777 ;      #Fraction of H2SO4 in A(Added solution)\n",
      "A_H2O = .223 ;        #Fraction of H2O in A(Added solution)\n",
      "F_H2SO4 = .1243 ;     #Fraction of H2SO4 in F(Original solution)\n",
      "F_H2O = .8757 ;       #Fraction of H2O in F(Original solution)\n",
      "\n",
      "# Calculations\n",
      "# P - F = A - By overall balance\n",
      "a = matrix([[P_H2O,-F_H2O],[1,-1]]) ;      # Matrix of coefficient\n",
      "b = matrix([[A*A_H2O],[A]]) ;              # Matrix of contants\n",
      "a = a.I\n",
      "x = a*b ;                                  # Matrix of solutions- P = x(1) and F = x(2)\n",
      "\n",
      "#Results\n",
      "print ' Original solution taken- %.0i kg'%x[1]\n",
      "print '  Final solution or kilograms of battery acid formed- %.0i kg'%x[0]"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " Original solution taken- 1905 kg\n",
        "  Final solution or kilograms of battery acid formed- 2105 kg\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      " Example 8.5  Page no. 207\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from numpy import matrix\n",
      "\n",
      "# Variables\n",
      "# Given\n",
      "W = 100.0 ;      # Water removed - [kg]\n",
      "A_H2O = 0.80 ;   # Fraction of water in A(intial fish cake)\n",
      "A_BDC = 0.20 ;   #  Fraction of BDC(bone dry cake) in B(final dry fish cake)\n",
      "B_H2O = 0.40 ;   # Fraction of water in A(intial fish cake)\n",
      "B_BDC = 0.60 ;   #  Fraction of BDC(bone dry cake) in B(final dry fish cake)\n",
      "\n",
      "# Calculations\n",
      "a = matrix([[A_H2O, -B_H2O],[1, -1]]) ;       # Matrix of coefficient\n",
      "b = matrix([[W],[W]]) ;                       # Matrix of contants\n",
      "a = a.I\n",
      "x = a * b;                                    # Matrix of solutions- A = x(1) and B = x(2)\n",
      "\n",
      "# Results\n",
      "print 'Weight of the fish cake originally put into dryer -%.0i kg'%x[0]"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Weight of the fish cake originally put into dryer -150 kg\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      " Example 8.6  Page no. 209\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "# Composition of initial solution at 30 degree C\n",
      "s_30 = 38.8 ;                      #  solublity of Na2CO3 at 30 degree C, by using the table for solublity of Na2CO3-[g Na2CO3/100 g H2O]\n",
      "If_Na2CO3 =  s_30/(s_30+100) ;     # Initial mass fraction of Na2CO3\n",
      "If_H2O = 1-If_Na2CO3 ;             # Initial mass fraction of H2O\n",
      "\n",
      "# Composition of crystals\n",
      "# Basis : 1g mol Na2CO3.10H2O\n",
      "n_mol_Na2CO3 = 1 ;                 # Number of moles of Na2CO3\n",
      "n_mol_H2O = 10. ;                  # Number of moles of H2O\n",
      "mwt_Na2CO3 = 106. ;                # mol. wt of Na2CO3\n",
      "mwt_H2O = 18. ;                    # mol. wt of H2O\n",
      "\n",
      "# Calculation and Results\n",
      "m_Na2CO3 = mwt_Na2CO3*n_mol_Na2CO3 ;        # Mass of Na2CO3\n",
      "m_H2O = mwt_H2O*n_mol_H2O ;                 # Mass of H2O\n",
      "Cf_Na2CO3 =  m_Na2CO3/(m_Na2CO3+m_H2O) ;    # mass fraction of Na2CO3 \n",
      "Cf_H2O = 1-Cf_Na2CO3 ;                      # mass fraction of H2O\n",
      "\n",
      "n_un = 9. ;                     # Number of unknowns in the given problem\n",
      "n_ie  = 9. ;                    # Number of independent equations\n",
      "d_o_f =  n_un-n_ie ;            # Number of degree of freedom\n",
      "\n",
      "print 'Number of degree of freedom for the given system is  %i .'%d_o_f\n",
      "\n",
      "# Final composition of tank\n",
      "#Basis :I = 10000 kg\n",
      "# Material balance reduces to Accumulation  =  final -initial = in-out(but in = 0)\n",
      "I = 10000. ;               #initial amount of saturated solution-[kg]\n",
      "amt_C = 3000. ;            # Amount of crystals formed-[kg]\n",
      "Fm_Na2CO3 = I*If_Na2CO3-amt_C*Cf_Na2CO3 ;             # Mass balance of Na2CO3\n",
      "Fm_H2O = I*If_H2O-amt_C*Cf_H2O ;                      # Mass balance of H2O\n",
      "\n",
      "#To find temperature,T\n",
      "s_T =  (Fm_Na2CO3/Fm_H2O)*100 ;             # Solublity of Na2CO3 at temperature T\n",
      "s_20 = 21.5 ;                               #Solublity of Na2CO3 at temperature 20 degree C ,from given table-[g Na2CO3/100 g H2O]\n",
      "\n",
      "# Find T by interpolation\n",
      "T =  30-((s_30-s_T)/(s_30-s_20))*(30-20) ;       # Temperature -[degree C]\n",
      "print ' Temperature to which solution has to be cooled to get 3000 kg crystals is %.0f degree C .'%T"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Number of degree of freedom for the given system is  0 .\n",
        " Temperature to which solution has to be cooled to get 3000 kg crystals is 26 degree C .\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      " Example 8.7  Page no. 213\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "# Variables\n",
      "# Write given data\n",
      "B_in =  1.1 ;        # Flow rate in  of blood -[L/min]\n",
      "B_out = 1.2;         # Flow rate out of blood -[L/min]\n",
      "S_in = 1.7;          # Flow rate in  of solution -[L/min]\n",
      "\n",
      "# Composition of input blood\n",
      "B_in_CR = 2.72 ;     #[g/L]\n",
      "B_in_UR = 1.16 ;     #[g/L]\n",
      "B_in_U = 18 ;        #[g/L]\n",
      "B_in_P = 0.77 ;      #[g/L]\n",
      "B_in_K = 5.77 ;      #[g/L]\n",
      "B_in_Na = 13.0 ;     #[g/L]\n",
      "B_in_water = 1100 ;  #[mL/min]\n",
      "\n",
      "# Composition of output blood\n",
      "B_out_CR = 0.120 ;   #[g/L]\n",
      "B_out_UR = 0.060;    #[g/L]\n",
      "B_out_U = 1.51 ;     #[g/L]\n",
      "B_out_P = 0.040 ;    #[g/L]\n",
      "B_out_K = 0.120 ;    #[g/L]\n",
      "B_out_Na = 3.21 ;    #[g/L]\n",
      "B_out_water = 1200. ;     #[mL/min]\n",
      "\n",
      "# Calculation and Result\n",
      "n_un = 7. ;             # Number of unknowns in the given problem\n",
      "n_ie  = 7. ;            # Number of independent equations\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",
      "# Water balance in grams, assuming 1 ml is equivalent to 1 g\n",
      "S_in_water = 1700. ;              #[ml/min]\n",
      "S_out_water =  B_in_water+ S_in_water - B_out_water;\n",
      "S_out = S_out_water/1000. ;       #[L/min]\n",
      "print ' Flow rate of water in output solution is  %.2f L/min.'%S_out\n",
      "\n",
      "# The component balance in grams for CR,UR,U,P,K and Na are\n",
      "S_out_CR  =  (B_in*B_in_CR - B_out*B_out_CR)/S_out;\n",
      "S_out_UR  =  (B_in*B_in_UR - B_out*B_out_UR)/S_out;\n",
      "S_out_U  =  (B_in*B_in_U - B_out*B_out_U)/S_out;\n",
      "S_out_P  =  (B_in*B_in_P - B_out*B_out_P)/S_out;\n",
      "S_out_K  =  (B_in*B_in_K - B_out*B_out_K)/S_out;\n",
      "S_out_Na  =  (B_in*B_in_Na - B_out*B_out_Na)/S_out;\n",
      "print ' Component     Concentration(g/L) in output Dialysis solution   '\n",
      "print ' UR            %.2f    '%S_out_UR\n",
      "print ' CR            %.2f    '%S_out_CR\n",
      "print ' U             %.2f    '%S_out_U\n",
      "print ' P             %.2f    '%S_out_P\n",
      "print ' K             %.2f    '%S_out_K\n",
      "print ' Na            %.2f    '%S_out_Na"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Number of degree of freedom for the given system is  0 .\n",
        " Flow rate of water in output solution is  1.60 L/min.\n",
        " Component     Concentration(g/L) in output Dialysis solution   \n",
        " UR            0.75    \n",
        " CR            1.78    \n",
        " U             11.24    \n",
        " P             0.50    \n",
        " K             3.88    \n",
        " Na            6.53    \n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "code",
     "collapsed": true,
     "input": [],
     "language": "python",
     "metadata": {},
     "outputs": []
    }
   ],
   "metadata": {}
  }
 ]
}