{
 "metadata": {
  "name": "",
  "signature": "sha256:a7839feeb371e4231dbf99a0d3738674ff633956f5fb373aea54d56b513c13f8"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 14 : The RTD and Size Distribution of Solids in Fluidized Beds"
     ]
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 1, Page 343"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from scipy.optimize import fsolve \n",
      "import math \n",
      "\n",
      "#INPUT\n",
      "Fo=2.7;                         #Feed rate in kg/min\n",
      "Fof=0.9;                        #Feed rate of fines in feed in kg/min\n",
      "Foc=1.8;                        #Feed rate of coarse in feed in kg/min\n",
      "W=17.;                           #Bed weight in kg\n",
      "kf=0.8;                         #Elutriation of fines in min**-1\n",
      "kc=0.0125;                      #Elutriation of coarse in min**-1\n",
      "\n",
      "#CALCULATION\n",
      "F1guess=1;                      #Guess value of F1\n",
      "def solver_func(F1):            #Function defined for solving the system\n",
      "    return F1-(Fof/(1.+(W/F1)*kf))-(Foc/(1.+(W/F1)*kc));#Eqn.(17)\n",
      "\n",
      "F1=fsolve(solver_func,F1guess)\n",
      "F1f=Fof/(1.+(W/F1)*kf);          #Flow rate of fines in entrained streams from Eqn.(16)\n",
      "F1c=Foc/(1.+(W/F1)*kc);          #Flow rate of coarse in entrained streams from Eqn.(16)\n",
      "F2f=Fof-F1f;                    #Flow rate of fines in overflow streams from Eqn.(9)\n",
      "F2c=Foc-F1c;                    #Flow rate of coarse in overflow streams from Eqn.(9)\n",
      "tbarf=1./((F1/W)+kf);            #Mean residence time of fines from Eqn.(12)\n",
      "tbarc=1./((F1/W)+kc);            #Mean residence time of coarse from Eqn.(12)\n",
      "\n",
      "#OUTPUT\n",
      "print 'Flow rate in entrained stream:\\tFines:%fkg/min\\tCoarse:%fkg/min'%(F1f,F1c);\n",
      "print 'Flow rate in overflow stream:\\tFines:%fkg/min\\tCoarse:%fkg/min'%(F2f,F2c);\n",
      "print 'Mean residence time:\\tFines:%fmins\\tCoarse:%fmins'%(tbarf,tbarc);\n",
      "\n",
      "#====================================END OF PROGRAM ======================================================"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Flow rate in entrained stream:\tFines:0.100000kg/min\tCoarse:1.600000kg/min\n",
        "Flow rate in overflow stream:\tFines:0.800000kg/min\tCoarse:0.200000kg/min\n",
        "Mean residence time:\tFines:1.111111mins\tCoarse:8.888889mins\n"
       ]
      }
     ],
     "prompt_number": 30
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 2, Page 344\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "\n",
      "import math\n",
      "from numpy import linspace,array,zeros\n",
      "from scipy.optimize import fsolve\n",
      "from matplotlib.pyplot import *\n",
      "%matplotlib inline\n",
      "#Variable declaration\n",
      "dt=4.;          #Diameter of reactor in m\n",
      "ephsilonm=0.4; #Void fraction of static bed\n",
      "rhos=2500.;     #Density of solid in the bed in kg/m**3\n",
      "Lm=1.2;        #Height of static bed in m\n",
      "Fo=3000;       #Feed rate in kg/hr\n",
      "beta1=1.2;     #Increase in density of solids\n",
      "dp=array([3,4,5,6,7,8,9,10,11,12,3,14,16,18,20,22,24,26,28,30])*10**-2;#Size of particles in mm\n",
      "po=[0,0.3,0.8,1.3,1.9,2.6,3.5,4.4,5.7,6.7,7.5,7.8,7.5,6.3,5.0,3.6,2.4,1.3,0.5,0];#Size distribution of solids in mm**-1\n",
      "k=array([0,10,9.75,9.5,8.75,7.5,6.0,4.38,2.62,1.20,0.325,0,0,0,0,0,0,0,0,0])*10**-4;#Elutriation constant in s**-1\n",
      "pi=3.14;\n",
      "\n",
      "#CALCULATION\n",
      "W=(pi/4*dt**2)*Lm*(1-ephsilonm)*rhos;#Weight of solids in bed\n",
      "n=len(dp);\n",
      "i=0;\n",
      "F1guess=1000.;#Guess value for F1\n",
      "F1c=linspace(2510,2700,10);\n",
      "F1 = zeros(n)\n",
      "x = zeros(n)\n",
      "c = zeros(n)\n",
      "a = zeros(n)\n",
      "while i<n:\n",
      "    if k[i]==0:\n",
      "        x[i]=0\n",
      "        #break \n",
      "    else:\n",
      "        x[i]=0#(float(po[i])/(W*k[i]/float(F1)))*math.log(1.+(W*k[i]/F1));         \n",
      "    def solver_func(Fo):\n",
      "        return F1/(Lm*Fo)-x[i];\n",
      "\n",
      "    F1[i] = fsolve(solver_func,F1guess);#Using inbuilt function fsolve for solving Eqn.(20) for F1\n",
      "    #c[i]=F1c[i]/(Lm*Fo);\n",
      "    if F1[i]==0:\n",
      "        a[i]=0;\n",
      "    else:\n",
      "        a[i]=(po[i]/(W*k[i]/F1[i]))*math.log(1+(W*k[i]/F1[i]));\n",
      "\n",
      "    i=i+1;\n",
      "\n",
      "#plot(F1,c);\n",
      "\n",
      "#xtitle('F1 vs a,c','F1','a,c');\n",
      "F1n=2500.;#The point were both the curves meet\n",
      "F2=beta1*Fo-F1n;#Flow rate of the second leaving stream\n",
      "j=0;\n",
      "m=len(dp);\n",
      "p1 = zeros(m)\n",
      "p2 = zeros(m)\n",
      "tbar = zeros(m)\n",
      "while j<m:\n",
      "    p1[j]=(1./F1n)*((Fo*po[j])/(1.+(W/F1n)*k[j]));#Size distribution of stream 1 in mm**-1 from Eqn.(16)\n",
      "    p2[j]=k[j]*W*p1[j]/F2;#Size distribution of stream 2 in mm**-1 from Eqn.(7)\n",
      "    if p1[j]==0 and p2[j]==0:\n",
      "        tbar[j]=0;\n",
      "    elif p1[j]==0:\n",
      "        tbar[j]=(W*p1[j])/(F2*p2[j]);\n",
      "    elif  p2[j]==0:\n",
      "        tbar[j]=(W*p1[j])/(F1n*p1[j]);\n",
      "    else:\n",
      "        tbar[j]=(W*p1[j])/(F1n*p1[j]+F2*p2[j]);#Average time in hr from Eqn.(11)\n",
      "    j=j+1;\n",
      "\n",
      "#OUTPUT\n",
      "print 'Flow rate of stream 1:%fkg/hr'%F1n\n",
      "print 'Flow rate of stream 2:%fkg/hr'%F2\n",
      "j=0;\n",
      "print 'tbar(hr)'\n",
      "while j<m:\n",
      "    print '%f'%tbar[j]\n",
      "    j=j+1;\n",
      "\n",
      "#DISCLAIMER: The value obtained for tbar is deviating highly\n",
      "#form the one given in textbook. However, the value obtained by manual calculation is close to #\n",
      "#the   ones obtained from the program."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Populating the interactive namespace from numpy and matplotlib\n",
        "Flow rate of stream 1:2500.000000kg/hr"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "Flow rate of stream 2:1100.000000kg/hr\n",
        "tbar(hr)\n",
        "0.000000\n",
        "8.962153\n",
        "8.964162\n",
        "8.966171\n",
        "8.972205\n",
        "8.982279\n",
        "8.994397\n",
        "9.007522\n",
        "9.021824\n",
        "9.033397\n",
        "9.040543\n",
        "9.043200\n",
        "9.043200\n",
        "9.043200\n",
        "9.043200\n",
        "9.043200\n",
        "9.043200\n",
        "9.043200\n",
        "9.043200\n",
        "0.000000\n"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stderr",
       "text": [
        "WARNING: pylab import has clobbered these variables: ['draw_if_interactive', 'pi']\n",
        "`%pylab --no-import-all` prevents importing * from pylab and numpy\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 3, Page 351\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "dp=1;  #Particle size in mm\n",
      "Fo=10; #Feed rate in kg/min\n",
      "k=0.1; #Particle shrinkage rate in mm/min\n",
      "\n",
      "#CALCULATION\n",
      "R=k/2;             #Particle shrinkage rate in terms of radius\n",
      "W=(Fo*dp/2)/(4*R); #Bed weight from Eqn.(42)\n",
      "\n",
      "#OUTPUT\n",
      "print 'Weight of bed:%d kg' %W\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Weight of bed:25 kg\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 4, Page 352\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "#Variable declaration\n",
      "dpi=[1.05,0.95,0.85,0.75,0.65,0.55,0.45,0.35,0.25,0.15,0.05]; #Mean size in mm\n",
      "Fo=[0,0.5,3.5,8.8,13.5,17.0,18.2,17.0,13.5,7.3,0]#*10**-2  #Feed rate in kg/s\n",
      "for i in range(len(Fo)):\n",
      "    Fo[i] = Fo[i] * 10**-2\n",
      "k=[0,0,0,0,0,0,0,0,2.0,12.5,62.5]#*10**-5;#Elutriation constant in s**-1\n",
      "for i in range(len(k)):\n",
      "    k[i] = k[i] * 10**-5\n",
      "\n",
      "R=-1.58*10**-5;#Rate of particle shrinkage in mm/s\n",
      "deldpi=0.1;#Size intervals in mm\n",
      "\n",
      "#CALCULATION\n",
      "n=len(dpi);\n",
      "m=1;#Starting with the largest value size interval that contains solids\n",
      "W = [0]\n",
      "while m<n-1:\n",
      "    W.append((Fo[m]-R*W[m-1]/deldpi)/(k[m]-R/deldpi-3*R/dpi[m]));#From Eqn.(33)\n",
      "    m=m+1;\n",
      "\n",
      "Wt=sum(W);#Total sum\n",
      "\n",
      "#OUTPUT\n",
      "print '\\nTotal mass in the bed:%fkg'%Wt\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "Total mass in the bed:7168.981263kg\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 5, Page 353\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "dpi=[0.17,0.15,0.13,0.11,0.09,0.07,0.05,0.03,0.01];#Mean size of particles in mm\n",
      "a=[0,0.95,2.45,5.2,10.1,23.2,35.65,20.0,2.45]#*10**-2;#Feed composition Fo(dpi)/Fo\n",
      "for i in range(len(a)):\n",
      "    a[i] = a[i] * 10**-2\n",
      "\n",
      "y=[0,0,0,0,0,0,0.625,10.225,159.25]#*10**-6;#Elutriation and cyclone efficiency k(dpi)(1-eta(dpi))\n",
      "for i in range(len(y)):\n",
      "    y[i] = y[i] * 10**-6\n",
      "\n",
      "\n",
      "F=0.01;          #Rate at which solids are withdrawn in kg/s\n",
      "W=40000;         #Weight of bed in kg\n",
      "dp1=0.11         #Initial size in mm\n",
      "dp2=0.085;       #Size after shrinking in mm\n",
      "dpmin=0.01;      #Minimum size in mm\n",
      "deldpi=2*10**-2; #Size inerval in mm\n",
      "t=20.8;          #Time in days\n",
      "si=1;\n",
      "\n",
      "#CALCULATION\n",
      "kdash=math.log((dp1-dpmin)/(dp2-dpmin))/(t*24*3600);#Rate of particle shrinkage from Eqn.(24)\n",
      "n=len(dpi);\n",
      "m=1;\n",
      "Fo=0.05;#Initial value of Fo\n",
      "F1 = [0];\n",
      "s=0;\n",
      "c=0;\n",
      "t=1E-6;\n",
      "R = [0]\n",
      "x = [0]\n",
      "F1 = [0]\n",
      "while m<n:\n",
      "    R.append(-kdash*(dpi[m]-dpmin));#Rate of size change\n",
      "    x.append((a[m]*Fo-W*R[m-1]*F1[m-1]/deldpi)/(F+(W*y[m])-(W*R[m]/deldpi)-3*W*R[m]/dpi[m]));#Eqn.(34)\n",
      "    F1.append(x[m]*F);\n",
      "    c=c+x[m];\n",
      "    m=m+1;\n",
      "    if abs(c-1)<t:\n",
      "        break\n",
      "    Fo=Fo+0.0001;#Incrementing Fo\n",
      "\n",
      "#OUTPUT\n",
      "print 'Feed rate with deldpi=%fmm is %fg/hr'%(deldpi,Fo);\n",
      "i=0;\n",
      "print 'Bed composition'\n",
      "for i in x:\n",
      "    print '%f'%(i*100)\n",
      "    i=i+1;\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Feed rate with deldpi=0.020000mm is 0.050800g/hr\n",
        "Bed composition\n",
        "0.000000\n",
        "0.652911\n",
        "1.859952\n",
        "4.400781\n",
        "9.668999\n",
        "25.654298\n",
        "28.575890\n",
        "2.317749\n",
        "0.019493\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [],
     "language": "python",
     "metadata": {},
     "outputs": []
    }
   ],
   "metadata": {}
  }
 ]
}