{
 "metadata": {
  "name": "",
  "signature": "sha256:c20c5ffc14398659aab9089e6b803cb3218676cd974382b644456d53b86a097c"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Diffusion Mass Transfer"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 14.1 Page 884"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "import math\n",
      "\n",
      "T = 293.  \t    \t\t\t\t;#[K] Temperature\n",
      "Ma = 2       \t\t\t\t\t;#[kg/kmol] Molecular Mass\n",
      "#Table A.8 Hydrogen-Air Properties at 298 K\n",
      "Dab1 = .41*math.pow(10,-4);     #[m^2/s] diffusion coefficient\n",
      "#Table A.8 Hydrogen-Water Properties at 298 K\n",
      "Dab2 = .63*math.pow(10,-8);     #[m^2/s] diffusion coefficient\n",
      "#Table A.8 Hydrogen-iron Properties at 293 K\n",
      "Dab3 = .26*math.pow(10,-12);    #[m^2/s] diffusion coefficient\n",
      "#Table A.4 Air properties at 293 K\n",
      "a1 = 21.6*math.pow(10,-6);      #[m^2/s] Thermal Diffusivity\n",
      "#Table A.6 Water properties at 293 K\n",
      "k = .603        \t\t\t\t;#[W/m.K] conductivity\n",
      "rho = 998       \t\t\t\t;#[kg/m^3] Density\n",
      "cp = 4182       \t\t\t\t;#[J/kg] specific Heat\n",
      "#Table A.1 Iron Properties at 300 K\n",
      "a3 = 23.1 * math.pow(10,-6);    #[m^2/s]\n",
      "#calculations\n",
      "\n",
      "#Equation 14.14\n",
      "#Hydrogen-air Mixture\n",
      "DabT1 = Dab1*math.pow(T/298.,1.5);# [m^2/s] mass diffusivity\n",
      "J1 = -DabT1*1;             \t\t#[kmol/s.m^2]  Total molar concentration\n",
      "j1 = Ma*J1;               \t\t#[kg/s.m^2] mass Flux of Hydrogen\n",
      "Le1 = a1/DabT1;             \t# Lewis Number Equation 6.50\n",
      "\n",
      "#Hydrogen-water Mixture\n",
      "DabT2 = Dab2*math.pow(T/298.,1.5);# [m^2/s] mass diffusivity\n",
      "a2 = k/(rho*cp)              \t;#[m^2/s] thermal diffusivity  \n",
      "J2 = -DabT2*1             \t;#[kmol/s.m^2]  Total molar concentration\n",
      "j2 = Ma*J2               \t;#[kg/s.m^2] mass Flux of Hydrogen\n",
      "Le2 = a2/DabT2             \t;# Lewis Number Equation 6.50\n",
      "\n",
      "#Hydrogen-iron Mixture\n",
      "DabT3 = Dab3*math.pow(T/298.,1.5);# [m^2/s] mass diffusivity\n",
      "J3 = -DabT3*1;             \t#[kmol/s.m^2]  Total molar concentration\n",
      "j3 = Ma*J3;               \t#[kg/s.m^2] mass Flux of Hydrogen\n",
      "Le3 = a3/DabT3             \t;# Lewis Number Equation 6.50\n",
      "#results\n",
      "\n",
      "print '%s %.1e' %('a (m^2/s) in 1 = ',a1)\n",
      "print '%s %.1e' %('\\n a (m^2/s) in 2 = ',a2)\n",
      "print '%s %.1e' %('\\na (m^2/s) in 3 = ',a3)\n",
      "print '%s %.1e' %('\\nDab (m^2/s) in 1 = ',DabT1)\n",
      "print '%s %.1e' %('\\n Dab (m^2/s) in 2 = ',DabT2)\n",
      "print '%s %.1e' %('\\n Dab (m^2/s) in 3 = ',DabT3)\n",
      "print '%s %.1e' %('\\n Le  in 1 = ',Le1)\n",
      "print '%s %.1e' %('\\n Le  in 2 = ',Le2)\n",
      "print '%s %.1e' %('\\n Le  in 3 = ',Le3)\n",
      "print '%s %.1e' %('\\n ja (kg/s.m^2) in 1 = ',j1)\n",
      "print '%s %.1e' %('\\n ja (kg/s.m^2) in 2 = ',j2)\n",
      "print '%s %.1e' %('\\n ja (kg/s.m^2) in 3 = ',j3)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "a (m^2/s) in 1 =  2.2e-05\n",
        "\n",
        " a (m^2/s) in 2 =  1.4e-07\n",
        "\n",
        "a (m^2/s) in 3 =  2.3e-05\n",
        "\n",
        "Dab (m^2/s) in 1 =  4.0e-05\n",
        "\n",
        " Dab (m^2/s) in 2 =  6.1e-09\n",
        "\n",
        " Dab (m^2/s) in 3 =  2.5e-13\n",
        "\n",
        " Le  in 1 =  5.4e-01\n",
        "\n",
        " Le  in 2 =  2.4e+01\n",
        "\n",
        " Le  in 3 =  9.1e+07\n",
        "\n",
        " ja (kg/s.m^2) in 1 =  -8.0e-05\n",
        "\n",
        " ja (kg/s.m^2) in 2 =  -1.2e-08\n",
        "\n",
        " ja (kg/s.m^2) in 3 =  -5.1e-13\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 14.2 Page 898"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable Initialization\n",
      "\n",
      "import math\n",
      "import numpy\n",
      "from numpy import linalg\n",
      "import matplotlib\n",
      "from matplotlib import pyplot\n",
      "\n",
      "T = 298          \t\t\t;#[K] Temperature\n",
      "D = 10*math.pow(10,-6)     \t;#[m]\n",
      "L = 100*math.pow(10,-6);    #[m]\n",
      "H = .5            \t\t\t;# Moist Air Humidity\n",
      "p = 1.01325      \t\t\t;#[bar]\n",
      "#Table A.6 Saturated Water vapor Properties at 298 K\n",
      "psat = .03165;            \t#[bar] saturated Pressure\n",
      "#Table A.8 Water vapor-air Properties at 298 K\n",
      "Dab = .26*math.pow(10,-4);  #[m^2/s] diffusion coefficient\n",
      "#calculations\n",
      "\n",
      "C = p/(8.314/100. *298)     ;#Total Concentration\n",
      "#From section 6.7.2, the mole fraction at x = 0 is\n",
      "xa0 = psat/p;\n",
      "#the mole fraction at x = L is\n",
      "xaL = H*psat/p;\n",
      "\n",
      "#Evaporation rate per pore Using Equation 14.41 with advection\n",
      "N = (math.pi*D*D)*C*Dab/(4*L)*2.303*math.log10((1-xaL)/(1-xa0))    ;#[kmol/s]\n",
      "\n",
      "#Neglecting effects of molar averaged velocity Equation 14.32\n",
      "#Species transfer rate per pore\n",
      "Nh = (math.pi*D*D)*C*Dab/(4*L)*(xa0-xaL)        ;#[kmol/s]\n",
      "#results\n",
      "\n",
      "print '%s %.2e %s' %('\\n Evaporation rate per pore Without advection effects',Nh,'kmol/s')\n",
      "print '%s %.2e %s' %('and With Advection effects',N,'kmol/s')\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        " Evaporation rate per pore Without advection effects 1.30e-14 kmol/s\n",
        "and With Advection effects 1.34e-14 kmol/s\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 14.3 Page 898"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable Initialization\n",
      "\n",
      "import math\n",
      "\n",
      "D = .005     \t\t\t\t\t\t;#[m] Diameter\n",
      "L = 50*math.pow(10,-6);          \t#[m] Length\n",
      "h = .003            \t\t\t\t;#[m] Depth\n",
      "Dab = 6*math.pow(10,-14)        \t;#[m^2/s] Diffusion coefficient\n",
      "Cas1 = 4.5*math.pow(10,-3)        \t;#[kmol/m^3] Molar concentrations of water vapor at outer surface\n",
      "Cas2 = 0.5*math.pow(10,-3)        \t;#[kmol/m^3] Molar concentrations of water vapor at inner surface\n",
      "#calculations\n",
      "\n",
      "#Transfer Rate through cylindrical wall Equation 14.54\n",
      "Na = Dab/L*(math.pi*D*D/4. + math.pi*D*h)*(Cas1-Cas2);    #[kmol/s]\n",
      "#results\n",
      "\n",
      "print '%s %.2e %s' %('\\n Rate of water vapor molar diffusive ttansfer through the trough wall ',Na,'kmol/s');\n",
      "#END"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        " Rate of water vapor molar diffusive ttansfer through the trough wall  3.20e-16 kmol/s\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 14.4 Page 902"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable Initialization\n",
      "\n",
      "import math\n",
      "\n",
      "D = .2             \t\t\t;#[m] Diameter\n",
      "L = 2*math.pow(10,-3)       ;#[m] Thickness\n",
      "p = 4              \t\t\t;#[bars] Helium Pressure\n",
      "T = 20+273.        \t\t\t;#[K] Temperature\n",
      "#Table A.8 helium-fused silica (293K) Page 952\n",
      "Dab = .4*math.pow(10,-13)\t;#[m^2/s] Diffusion coefficient\n",
      "#Table A.10 helium-fused silica (293K)\n",
      "S = .45*math.pow(10,-3)\t\t;#[kmol/m^3.bar] Solubility\n",
      "#calculations\n",
      "\n",
      "# By applying the species conservation Equation 14.43 and 14.62\n",
      "dpt = -6*(.08314)*T*(Dab)*S*p/(L*D);\n",
      "\n",
      "#results\n",
      "print '%s %.2e %s' %('\\n The rate of change of the helium pressure dp/dt',dpt,' bar/s');\n",
      "#END"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        " The rate of change of the helium pressure dp/dt -2.63e-11  bar/s\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 14.5 Page 904"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable Initialization\n",
      "\n",
      "import math\n",
      "\n",
      "Dab = 8.7*math.pow(10,-8)       ;#[m^2/s] Diffusion coefficient\n",
      "Sab = 1.5*math.pow(10,-3)       ;#[kmol/m^3.bar] Solubility\n",
      "L = .0003              \t\t\t;#[m] thickness of bar\n",
      "p1 = 3                \t\t\t;#[bar] pressure on one side\n",
      "p2 = 1                \t\t\t;#[bar] pressure on other side\n",
      "Ma = 2                \t\t\t;#[kg/mol] molecular mass of Hydrogen\n",
      "#calculations\n",
      "\n",
      "#Surface molar concentrations of hydrogen from Equation 14.62\n",
      "Ca1 = Sab*p1       \t\t\t\t; #[kmol/m^3]\n",
      "Ca2 = Sab*p2       \t\t\t\t; #[kmol/m^3]\n",
      "#From equation 14.42 to 14.53 for obtaining mass flux\n",
      "N = Dab/L*(Ca1-Ca2) ;       \t#[kmol/s.m^2]\n",
      "n = Ma*N            ;       \t#[kg/s.m^2] on Mass basis\n",
      "#results\n",
      "\n",
      "print '%s %.2e %s' %('\\n The Hydrogen mass diffusive flux n =',n,' (kg/s.m^2)');\n",
      "#END"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        " The Hydrogen mass diffusive flux n = 1.74e-06  (kg/s.m^2)\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 14.6 Page 909 "
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable Initialization\n",
      "\n",
      "import math\n",
      "\n",
      "Dab = 2*math.pow(10,-12)        \t;#[m^2/s] Diffusion coefficient\n",
      "Ca0 = 4*math.pow(10,-3)        \t\t;#[kmol/m^3] Fixed Concentration of medication\n",
      "Na = -.2*math.pow(10,-3)       \t\t;#[kmol/m^3.s] Minimum consumption rate of antibiotic\n",
      "k1 = .1            \t\t\t\t\t;#[s^-1] Reaction Coefficient\n",
      "#calculations\n",
      "\n",
      "#For firsst order kinetic reaction Equation 14.74\n",
      "m = math.pow((k1/Dab),.5);\n",
      "L = math.acosh(-k1*Ca0/Na) /m;\n",
      "#results\n",
      "\n",
      "print '%s %.1f %s' %('\\n Maximum Thickness of a bacteria laden biofilm, that may be siccessfully treated is ',L*math.pow(10,6), 'mu-m');\n",
      "#END"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        " Maximum Thickness of a bacteria laden biofilm, that may be siccessfully treated is  5.9 mu-m\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 14.7 Page 913"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable Initialization\n",
      "\n",
      "import math\n",
      "\n",
      "Dap = .1*math.pow(10,-12)       ;#[m^2/s] Diffusion coefficient of medication with patch\n",
      "Das = .2*math.pow(10,-12)       ;#[m^2/s] Diffusion coefficient of medication with skin\n",
      "L = .05                \t\t\t;#[m] patch Length\n",
      "rhop = 100             \t\t\t;#[kg/m^3] Density of medication on patch\n",
      "rho2 = 0               \t\t\t;#[kg/m^3] Density of medication on skin\n",
      "K = .5                 \t\t\t;#Partition Coefficient\n",
      "t = 3600*24*7          \t\t\t;#[s] Treatment time\n",
      "#calculations\n",
      "\n",
      "#Applying Conservation of species equation 14.47b\n",
      "#By analogy to equation 5.62, 5.26 and 5.58\n",
      "D = 2*rhop*L*L/(math.sqrt(math.pi))*math.sqrt(Das*Dap*t)/(math.sqrt(Das)+math.sqrt(Dap)/K);\n",
      "#results\n",
      "\n",
      "print '%s %.1f %s' %('\\n Total dosage of medicine delivered to the patient over a one-week time period is',D*math.pow(10,6) ,'mg');"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        " Total dosage of medicine delivered to the patient over a one-week time period is 28.7 mg\n"
       ]
      }
     ],
     "prompt_number": 10
    }
   ],
   "metadata": {}
  }
 ]
}