{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 12 :  Recycle Bypass Purge and the Industrial Application of Material Balance"
     ]
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      " Example 12.1  Page No.349\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from numpy import matrix\n",
      "\t\t\t\n",
      "# Variables            \n",
      "F = 10000. ;\t\t\t#[lb/hr]\n",
      "\t\t\t\n",
      "NaOH_F = 40./100 ;\t    \t\t#[wt. fraction]\n",
      "NaOH_P1 = 95./100 ;\t    \t\t#[wt. fraction of NaOH filter cake]\n",
      "NaOH_P2 = (0.05 *  45)/100 ;\t\t\t#[wt. fraction of NaOH in NaOH soln.]\n",
      "H2O_P2 = (0.05 *  55)/100 ;\t\t\t#[wt. fraction of H2O in NaOH soln.]\n",
      "NaOH_R = 45./100;\t\t\t#[wt. fraction]\n",
      "NaOH_G = 50./100;\t\t\t#[wt. fraction]\n",
      "\t\t\t\n",
      "P = (NaOH_F *  F)/(NaOH_P1 + NaOH_P2) ;\t\t\t#[lb/hr]\n",
      "\t\t\t\n",
      "W = F-P ;\t\t\t# [lb/hr]\n",
      "\n",
      "# Calculations & Results\t\n",
      "a = matrix([[NaOH_G,-NaOH_R],[1,-1]]) \t\t\t# matrix formed of coefficients of unknown\n",
      "b = matrix([[F*NaOH_F],[P]]);\t\t\t# matrix formed by constant\n",
      "a = a.I\n",
      "x = a*b ;\t\t\t# matrix of solutions . x(1) = G, x(2) = R\n",
      "G = x[0] ;\t\t\t# [lb/hr]\n",
      "R = x[1] ;\t\t\t# [lb/hr]\n",
      " \n",
      "print '(a)  Flow rate of water removed by evaporator is  %.1f lb/hr'%W\n",
      "print 'The recycle rate of the process is %.1f lb/hr'%R\n",
      "\n",
      "\t\t\t\n",
      "NaOH_H = 45./100 ;\t\t\t#[wt fraction]\n",
      "H2O_H = 55./100 ;\t\t\t#[wt fraction]\n",
      "\n",
      "a1 = matrix([[NaOH_G,-NaOH_H],[NaOH_G,-H2O_H]]) ;\t\t\t# matrix formed of coefficients of unknown\n",
      "b1 = matrix([[((NaOH_P1+NaOH_P2)* P)],[(H2O_P2) *  P]]);\t\t\t# matrix formed by constant\n",
      "x1 = a1**-1\n",
      "x1 = x1*b1 ;\t\t\t# matrix of solutions nw_G = x1(1);H = x1(2)\n",
      "nw_G1 = x1[0] ;\t\t\t# [lb/hr]\n",
      "H = x1[1];\t\t\t# [lb/hr]\n",
      "\n",
      "nw_F = (NaOH_H *  H + (NaOH_P1 + NaOH_P2) *  P)/NaOH_F ;\t\t\t#[lb/hr]\n",
      "print ' (b)  Total feed rate when filterate is not recycled is %.1f lb/hr'%nw_F\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a)  Flow rate of water removed by evaporator is  5886.9 lb/hr\n",
        "The recycle rate of the process is 38868.9 lb/hr\n",
        " (b)  Total feed rate when filterate is not recycled is 53727.5 lb/hr\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      " Example 12.2  Page No.357\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Variables\n",
      "F_Bz = 100. ;\t\t\t# Fresh benzene feed / basis - [mol]\n",
      "con_Bz = .95 ;\t\t\t# Fraction of conversion of benzene\n",
      "sp_con = .20 ;\t\t\t# Fraction of single pass conversion\n",
      "ex_H2 = .20 ;\t\t\t# Fraction of exces H2 used in fresh feed\n",
      "R_Bz = 22.74 ;\t\t\t# Benzene in Recycle stream - [mol %]\n",
      "R_H2 = 78.26 ;\t\t\t# H2 in Recycle stream - [mol %]\n",
      "TLV_Bz = 0.5 ;\t\t\t# TLV value of benzene -[ppm]\n",
      "TLV_C6H12 = 300. ;\t\t\t# TLV value of cyclohexane -[ppm]\n",
      "TLV_H2 = 1000. ;\t\t\t# TLV value of H2 -[ppm]\n",
      "\n",
      "# Calculations\n",
      "F_H2 = F_Bz*3*(1+ex_H2) ;\t\t\t# H2 in Feed - [mol]\n",
      "F = F_Bz + F_H2 ;\t\t\t# Total feed - [mol]  \n",
      "\n",
      "ex_r = con_Bz*F_Bz/(-(-1)) ;\t\t\t# Extent of reaction\n",
      "\n",
      "P_Bz = F_Bz -1*(ex_r) ;\t\t\t# Benzene in P ,by benzene balance - [mol]\n",
      "P_H2 = F_H2 + -3*(ex_r) ;\t\t\t# H2 in P ,by H2 balance - [mol]\n",
      "P_C6H12 = 0 + 1*(ex_r) ;\t\t\t# Cyclohexane in P ,by cyclohexane balance - [mol]\n",
      "P = P_Bz + P_H2 + P_C6H12 ;\t\t\t# Total Product - [ mol]\n",
      "\n",
      "R = ((-(-ex_r))/(sp_con) - F_Bz)/(R_Bz/100.) ;\t\t\t# Recycle stream - [mol]\n",
      "R_by_F = R/F ;\t\t\t# Ratio of R to F \n",
      "\n",
      "TLV = (P_Bz/P)*(1/TLV_Bz) + (P_H2/P)*(1./TLV_H2) + (P_C6H12/P)*(1/TLV_C6H12) ;\t\t\t# TLV (environmental index) \n",
      "\n",
      "# Results\n",
      "print 'Ratio of R to F is %.2f .'%R_by_F\n",
      "print ' TLV (environmental index) is %.3f .'%TLV\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Ratio of R to F is 3.58 .\n",
        " TLV (environmental index) is 0.059 .\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      " Example 12.3  Page No.359\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Variables\n",
      "RR = 8.33 ;\t\t\t# Recycle ratio\n",
      "F = 100. ;\t\t\t# Overall feed/basis - [lb]\n",
      "F_g = 0.40 ;\t\t\t# Fraction of glucose in overall feed \n",
      "F_w = 0.60 ;\t\t\t# Fraction of water in overall feed \n",
      "F_dash_f = 0.04 ; \t\t\t# Fraction of fructose in feed to reactor\n",
      "P = F   \t\t\t# By overall balance -[lb]\n",
      "R = P/RR ;\t\t\t# Recycle stream - [lb]\n",
      "P_w = (F_w * F)/ P ;\t\t\t# Fraction of water in product(P), by overall water balance\n",
      "R_w = P_w ;\t\t\t#Fraction of water in recycle (R), since both R and P has same composition\n",
      "\n",
      "# Calculations\t\t\n",
      "F_dash = F +R ;\t\t\t# Feed to reactor ,by total balance -[lb]\n",
      "R_f = (F_dash*F_dash_f)/R ;\t\t\t# Fraction of fructose in recycle stream \n",
      "R_g = 1 - (R_f + R_w) ;\t\t\t# Fraction of glucose in recycle stream\n",
      "F_dash_g = (F*F_g + R*R_g)/F_dash ;\t\t\t# Fraction of glucose i feed to reactor\n",
      "\n",
      "f_con = ((F_dash*F_dash_g) - (R + P)*R_g)/(F_dash*F_dash_g) ;\t\t\t# Fraction of conversion of glucose in reactor\n",
      "\n",
      "# Results\n",
      "print 'Fraction of conversion of glucose in reactor is %.2f .'%f_con\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Fraction of conversion of glucose in reactor is 0.93 .\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      " Example 12.4   Page No.362\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Variables\n",
      "F = 100. ;\t\t\t# Overall feed/basis - [kg]\n",
      "F_com = 0.10 ;\t\t\t# Mass fraction of component in fresh feed \n",
      "F_w = 0.90 ;\t\t\t# Mass fraction of water in fresh feed \n",
      "P_w = 0.10 ;\t\t\t# Mass fraction of water in product\n",
      "P_com = 0.90 ;\t\t\t#Mass fraction of component in product\n",
      "F_dash_com = 0.03 ;\t\t\t#Mass fraction of component in feed to reactor\n",
      "W_w = 1. ;\t\t\t# Mass fraction of water in W(waste)\n",
      "C_con = .40 ;\t\t\t# Fraction of conversion of component in reactor\n",
      "\n",
      "# Calculations\n",
      "P = F_com*F/P_com ;\t\t\t#By component balance- Product - [kg]\n",
      "W = F - P ;\t\t\t# By overall balance - waste(W)- [kg]\n",
      "\n",
      "Rw = (F*F_com - F*F_com*C_con)/C_con ;\t\t\t# Mass of component in recycle(R) - [kg]\n",
      "F_dash = ( F*F_com + Rw  )/F_dash_com ;\t\t\t# By component balance - feed to reactor(F') -[kg]\n",
      "R = F_dash - F ;\t\t\t                    # Recycle(R) - By total balance -[kg]\n",
      "w = Rw/R ;\t\t\t                            # Mass fraction of component in recycle(R) \n",
      "\n",
      "# Results\n",
      "print 'Recycle(R) stream-  %.0f kg '%R\n",
      "print ' Mass fraction of component in recycle(R)-   %.4f .'%w\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Recycle(R) stream-  733 kg \n",
        " Mass fraction of component in recycle(R)-   0.0205 .\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      " Example 12.5  Page No.367\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Variables\n",
      "F = 100.        \t\t\t# Overall feed/basis - [kg]\n",
      "F_n_C5H12 = 0.80 ;\t\t\t# Fraction of n_C5H12 in overall feed \n",
      "F_i_C5H12 = 0.20 ;\t\t\t# Fraction of i_C5H12in overall feed \n",
      "S_i_C5H12 = 1. ;\t\t\t# Fraction of i_C5H12 in isopentane stream\n",
      "P_n_C5H12 = .90 ;\t\t\t# Fraction of n_C5H12 in overall product\n",
      "P_i_C5H12 = .10 ;\t\t\t# Fraction of i_C5H12 in overall product\n",
      "\n",
      "# Calculations\n",
      "P = (F*F_n_C5H12)/P_n_C5H12 ;\t\t\t#Product Material Balance of n_C5H12 -[kg]\n",
      "S = F - P ;\t\t\t# Isopentane stream (S) from overall material balance - [kg]\n",
      "\n",
      "from numpy import matrix\n",
      "a = matrix([[1,-1],[F_n_C5H12,-1]]) ;\t\t\t# Matrix of coefficients of unknown \n",
      "b = matrix([[S],[0]]) ;\t\t\t# Matrix of constants\n",
      "a = a.I\n",
      "x = a*b         \t\t\t# Matrix of solutions, x(1) = x , x(2) = y\n",
      "\n",
      "xf = x[0]/F ;\t    \t\t# Fraction of butane-free gas going to isopentane tower \n",
      "\n",
      "# Results\n",
      "print 'Fraction of butane-free gas going to isopentane tower is %.3f .'%xf\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Fraction of butane-free gas going to isopentane tower is 0.556 .\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      " Example 12.6  Page No.369\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Variables\n",
      "F = 100. ;\t\t\t# Overall feed/basis - [mole]\n",
      "F_H2 = 0.673 ;\t\t\t# Mole fraction of H2 in overall feed \n",
      "F_CO = 0.325 ;\t\t\t# Mole fraction of i_C5H12in overall feed \n",
      "F_CH4 = .002 ;\t\t\t# Mole fraction of CH4 in overall feed \n",
      "E_CH3OH = 1. ;\t\t\t#  Mole fraction of CH3OH in Exit(E)\n",
      "\t\n",
      "z = .032 ;\n",
      "CO_con = .18 ;\t\t\t# Fraction of conversion of CO in reactor\n",
      "\n",
      "# Calculations\n",
      "#By using eqn.(c) and (d)\n",
      "P = F_CH4*F/z ;\t\t\t# Purge stream - [mole]\n",
      "\n",
      "# Using eqn.(a) , (b) and (c)\n",
      "x_plus_y = 1 - z ;\t\t\t# x + y \n",
      "E = (F_H2*F + F_CO*F + 3*F_CH4*F - P*(x_plus_y + 3*z ))/3 ;\t\t\t# Exit stream - [mole]\n",
      "\n",
      "# By using eqn. (d)\n",
      "y = ( F_CO*F - E )/P ;\t\t\t# Mole fraction of CO \n",
      "\n",
      "# By using eqn. (a)\n",
      "x = 1 - z - y ;\t\t\t# Mole fraction of H2 \n",
      "\n",
      "# Lastly by using eqn.(e)\n",
      "R = ( F_CO*F - P*y - F_CO*F*CO_con )/(y*CO_con) ;\t\t\t# Recycle steam - [mole]\n",
      "\n",
      "# Results\n",
      "print 'Moles of recycle(R) per mole of feed(F) -                      %.4f '%(R/F)\n",
      "print ' Moles of CH3OH(E) per mole of feed(F)   -                      %.4f '%(E/F)\n",
      "print ' Moles of Purge(P) per mole of feed(F)   -                      %.4f '%(P/F);\n",
      "print ' Composition of Purge '\n",
      "print '  Component                 Mole fraction '\n",
      "print '  H2                        %.3f '%x\n",
      "print '  CO                        %.3f '%y\n",
      "print '  CH4                       %.3f '%z\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Moles of recycle(R) per mole of feed(F) -                      7.0556 \n",
        " Moles of CH3OH(E) per mole of feed(F)   -                      0.3125 \n",
        " Moles of Purge(P) per mole of feed(F)   -                      0.0625 \n",
        " Composition of Purge \n",
        "  Component                 Mole fraction \n",
        "  H2                        0.768 \n",
        "  CO                        0.200 \n",
        "  CH4                       0.032 \n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "code",
     "collapsed": true,
     "input": [],
     "language": "python",
     "metadata": {},
     "outputs": []
    }
   ],
   "metadata": {}
  }
 ]
}