From fffcc90da91b66ee607066d410b57f34024bd1de Mon Sep 17 00:00:00 2001 From: Jovina Dsouza Date: Mon, 7 Jul 2014 16:34:28 +0530 Subject: adding book --- .../Chapter 1 .ipynb | 1483 ++++++++++++++++++++ 1 file changed, 1483 insertions(+) create mode 100755 Beginning_C++_through_Game_Programming/Chapter 1 .ipynb (limited to 'Beginning_C++_through_Game_Programming/Chapter 1 .ipynb') diff --git a/Beginning_C++_through_Game_Programming/Chapter 1 .ipynb b/Beginning_C++_through_Game_Programming/Chapter 1 .ipynb new file mode 100755 index 00000000..b7bd8ecd --- /dev/null +++ b/Beginning_C++_through_Game_Programming/Chapter 1 .ipynb @@ -0,0 +1,1483 @@ +{ + "metadata": { + "name": "" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 1:. Fundamentals of Mass Transfer" + ] + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 1.1 Page number:6" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Illustration 1.1\n", + "#(a)Find Total molar concentration in gas feed\n", + "#(b)Find Density of gas feed\n", + "#(c)The composition of the gas feed, expressed in terms of mass fractions\n", + "#Variable declaration\n", + "T = 300 # [K]\n", + "P = 500 # [kPa]\n", + "R = 8.314 # [J/mole.K]\n", + "\n", + "\n", + "# Solution (a)\n", + "# Using equation 1.7 \n", + "C = P/(R*T) # [Total molar concentration, kmole/cubic m]\n", + "print\"Total molar concentration in the gas feed is\",round(C,1),\"kmole/cubic m\\n\\n\" \n", + "\n", + "#Illustration 1.1 (b)\n", + "# Solution (b)\n", + "\n", + "# Mixture of gases \n", + "# Components a-CH4 , b-C2H6 , c-nC3H8 , d-nC4H10\n", + "# Basis: 100 kmole of gas mixture\n", + "n_a = 88 # [kmole]\n", + "n_b = 4 # [kmole]\n", + "n_c = 5 # [kmole]\n", + "n_d = 3 # [kmole]\n", + "M_a = 16.04 # [gram/mole]\n", + "M_b = 30.07 # [gram/mole]\n", + "M_c = 44.09 # [gram/mole]\n", + "M_d = 58.12 # [gram/mole]\n", + "m_a = n_a*M_a # [kg]\n", + "m_b = n_b*M_b # [kg]\n", + "m_c = n_c*M_c # [kg]\n", + "m_d = n_d*M_d # [kg]\n", + "n_total = n_a+n_b+n_c+n_d # [kmole]\n", + "m_total = m_a+m_b+m_c+m_d # [kg]\n", + "M_avg = m_total/n_total # [kg/kmole]\n", + "row = C*M_avg # [mass density, kg/cubic m]\n", + "print\"Average molecular weight of gas feed is \",round(M_avg,2),\"kg/kmole\\n\" \n", + "print\"Density of gas feed is \",round(row,2),\"kg/cubic m\\n\\n\" \n", + "\n", + "#Illustration 1.1 (c)\n", + "\n", + "\n", + "# Mass fraction of each component\n", + "x_a = m_a/m_total \n", + "x_b = m_b/m_total \n", + "x_c = m_c/m_total \n", + "x_d = m_d/m_total \n", + "print\"Mass fraction of CH4, C2H6, nC3H8, nC4H10 are\",round(x_a,3),round(x_b,3),round(x_c,3),round(x_d,3),\"respectively\" " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Total molar concentration in the gas feed is 0.2 kmole/cubic m\n", + "\n", + "\n", + "Average molecular weight of gas feed is 19.27 kg/kmole\n", + "\n", + "Density of gas feed is 3.86 kg/cubic m\n", + "\n", + "\n", + "Mass fraction of CH4, C2H6, nC3H8, nC4H10 are 0.733 0.062 0.114 0.091 respectively\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 1.2 Page number:7" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Example 1.2 \n", + "#Concentration of a Potassium Nitrate Wash Solution \n", + "#Variable declaration\n", + "# Component a-KNO3 b-H20\n", + "T = 293.0 # [K]\n", + "s_eqm = 24.0 # [percent by weight, %]\n", + "row = 1162.0 # [density of saturated solution, kg/cubic m]\n", + "\n", + "\n", + "#Illustration 1.2 (a) \n", + "# Solution (a)\n", + "\n", + "# Basis: 100 kg of fresh wash solution\n", + "m_a = (s_eqm/100)*100 # [kg]\n", + "m_b = 100 - m_a # [kg]\n", + "M_a = 101.10 # [gram/mole]\n", + "M_b = 18.02 # [gram.mole]\n", + "\t# Therefore moles of component 'a' and 'b' are\n", + "n_a = m_a/M_a # [kmole]\n", + "n_b = m_b/M_b # [kmole]\n", + "\n", + "m_total = 100 # [basis, kg]\n", + "n_total = n_a+n_b # [kmole]\n", + "\t# Average molecular weight\n", + "M_avg = m_total/n_total # [kg/kmole]\n", + "\t# Total molar density of fresh solution\n", + "C = row/M_avg # [kmole/cubic m]\n", + "print\"Total molar density of fresh solution is\",round(C,2),\"kmole/cubic m\\n\\n\" \n", + "\n", + "#Illustration 1.2 (b)\n", + "# Solution (b)\n", + "\n", + "# mole fractions of components 'a' and 'b'\n", + "x_a = n_a/n_total \n", + "x_b = n_b/n_total \n", + "print\"Mole fraction of KNO3 and H2O is\",round(x_a,3),round(x_b,3) " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Total molar density of fresh solution is 51.77 kmole/cubic m\n", + "\n", + "\n", + "Mole fraction of KNO3 and H2O is 0.053 0.947\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 1.3 Page number:9" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Illustration 1.3\n", + "# Page: 9\n", + "# Material Balances on a Bio- Artificial Kidney\n", + "\n", + "\n", + "#Variable declaration\n", + "f_a = 45.0 \t\t\t\t# [percent of blood cells by volume]\n", + "f_b = 55.0 \t\t\t\t# [percent of plasma by volume]\n", + "r = 1200.0 \t\t\t\t# [Rate of blood which is pumped through artificial \t\t\t\t\tkidney, mL/minute]\n", + "m_urine = 1540.0 \t\t\t# [mass of urine collected, g]\n", + "x_u = 1.3 \t\t\t\t# [urea concentration, percent by weight]\n", + " # Data for sample of blood plasma\n", + "c_urea = 155.3 \t\t\t# [mg/dL]\n", + "d = 1.0245 \t\t\t\t# [specfic gravity of plasma]\n", + "\n", + "#CALCULATION\n", + "\t#Illustration 1.3 (a)\n", + "\t# Solution (a)\n", + "\n", + "\t# Basis: 4 hours\n", + "\t# Assuming that the rate of formation and decomposition of urea during the procedure is \t\tnegligible and that no urea is removed by the patient\u2019s kidneys\n", + "\t# Therefore urea in \u201cclean\u201d blood = urea in \u201cdirty\u201d blood - urea in urine\n", + "\n", + "m_u = m_urine*(x_u/100) \t\t# [mass of urea in urine, g]\n", + "\t# total volume of plasma that flows through the artificial kidney in 4 hours\n", + "V_b = r*60*(f_b/100)*(1.0/100.0)*4 \t# [dL]\n", + "\t# urea in dirty blood from given plasma concentration\n", + "m_ud = c_urea*(1.0/1000.0)*V_b \t# [g]\n", + "\t\t\t\t\t# urea removal efficiency\n", + "n = (m_u/m_ud)*100 \n", + "#RESULT\n", + "print\"Urea removal efficiency is \",round(n,1),\"%\"\n", + " \n", + "\t#Illustration 1.3 (b)\n", + "\t# Solution (b)\n", + "#CALCULATION\n", + "m_uc = m_ud-m_u \t\t\t# [mass of urea on clean blood, g]\n", + "m_p = d*100*V_b \t\t\t# [Mass of plasma entering, g]\n", + "m_rem = m_p-m_urine \t\t\t# [Mass of plasma remaining, g]\n", + "V_brem = m_rem/(d*100) \t\t# [Volume of plasma remaining, dL]\n", + "#RESULT\n", + "c_y = (m_uc*1000)/V_brem \t\t# [urea concentration in remaining plasma, mg/dL]\n", + "print\"urea concentration in the plasma of the cleansed blood is\",round(c_y),\"mg/dL\" " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Urea removal efficiency is 8.1 %\n", + "urea concentration in the plasma of the cleansed blood is 144.0 mg/dL\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 1.6 Page number:21" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Illustration 1.6\n", + "#Calculation of Diffusivity by the Wilke-Lee Equation\n", + "import math\n", + "\n", + "#VARIABLE DECLARATION\n", + "\n", + "T = 273 \t\t\t\t# [K]\n", + "P = 1 \t\t\t\t\t# [bar]\n", + "\t# 1 bar = 10**5 Pa\n", + "\t# Values of the Lennard-Jones parameters (sigma and E/K) are obtained from Appendix B:\n", + "sigma_a = 4.483 \t\t\t# [1st Lennard-Jones parameter, Angstrom]\n", + "sigma_b = 3.620 \t\t\t# [Angstrom]\n", + "d_a = 467.0 \t\t\t\t# [d = E/K 2nd Lennard-Jones parameter, K]\n", + "d_b = 97.0 \t\t\t\t# [K]\n", + "M_a = 76.0 \t\t\t\t# [gram/mole]\n", + "M_b = 29.0 \t\t\t\t# [gram/mole]\n", + "\n", + "\n", + "#CALCULATION\n", + "\n", + "sigma_ab = (sigma_a+sigma_b)/2 \t\t# [Angstrom]\n", + "d_ab =math.sqrt(d_a*d_b) \t\t# [K]\n", + "M_ab = 2/((1/M_a)+(1/M_b)) \t\t\t# [gram/mole]\n", + "T_star = T/d_ab \n", + "a = 1.06036 \n", + "b = 0.15610 \n", + "c = 0.19300 \n", + "d = 0.47635 \n", + "e = 1.03587 \n", + "f = 1.52996 \n", + "g = 1.76474 \n", + "h =3.89411 \n", + "ohm = ((a/T_star**b)+(c/math.exp(d*T_star))+(e/math.exp(f*T_star))+(g/math.exp(h*T_star))) \n", + "\n", + "\t# Substituting these values into the Wilke-Lee equation yields (equation 1.49)\n", + "D_ab = ((10**-3*(3.03-(.98/math.sqrt(M_ab)))*T**1.5)/(P*(math.sqrt(M_ab))*(sigma_ab**2)*ohm)) \t\t\n", + "#RESULT\n", + "\t\t\t\t\t\t# [square cm/s]\n", + "print\"The diffusivity of carbon disulfide vapor in air at 273 K and 1 bar is\",round(D_ab,4),\"square cm/s\\n\" \n", + "\n", + "\t# The math.experimental value of D_ab obtained from Appendix A:\n", + "D_abexp = (.894/(P*10**5))*10**4 \t\t\t# [square cm/s]\n", + "percent_error = ((D_ab-D_abexp)/D_abexp)*100 \t\t# [%]\n", + "\n", + "#RESULT\n", + "\n", + "print\"The percent error of the estimate, compared to the math.experimental value is\",round(percent_error,1),\"%\" " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The diffusivity of carbon disulfide vapor in air at 273 K and 1 bar is 0.0952 square cm/s\n", + "\n", + "The percent error of the estimate, compared to the math.experimental value is 6.5 %\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 1.7 Page number:22" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Illustration 1.7\n", + "#Calculation of Diffusivity by the Wilke-Lee Equation \n", + "#with Estimated Values of the Lennard-Jones Parameters\n", + "import math\n", + "\n", + "#VARIABLE DECLARATION\n", + "\n", + "\t# A-C3H5Cl B-air\n", + "T = 298.0 \t\t\t\t\t# [K]\n", + "P = 1.0 \t\t\t\t\t\t# [bar]\n", + "\n", + "\t# Values of the Lennard-Jones parameters for allyl chloride must be estimated from \t\tequations (1.46) and (1.47).\n", + "\t\t# From Table 1.2\n", + "V_bA = 3*14.8+5*3.7+24.6 \t\t\t# [cubic cm/mole]\n", + "\t\t\t\t\t\t# From equation 1.46\n", + "sigma_A = 1.18*(V_bA)**(1.0/3.0) \t\t\t# [1st Lennard-Jones parameter, Angstrom]\n", + "\t# Normal boiling-point temperature for allyl chloride is Tb = 318.3 K\n", + "\t# From equation 1.47, E/K = 1.15*Tb\n", + "T_b = 318.3 \t\t\t\t\t# [K]\n", + "d_A = 1.15*T_b \t\t\t\t# [2nd Lennard-Jones parameter for C3H5Cl E/K, \t\t\t\t\t\t\tK]\n", + "M_A = 76.5 \t\t\t\t\t# [gram/mole]\n", + "\n", + "\t# Lennard-Jones parameters for air\n", + "sigma_B = 3.62 \t\t\t\t# [Angstrom]\n", + "d_B = 97 \t\t\t\t\t# [2nd Lennard-Jones parameter for air E/K, K]\n", + "\n", + "M_B = 29.0 \t\t\t\t\t# [gram/mole]\n", + "\n", + "sigma_AB = (sigma_A+sigma_B)/2 \t\t# [Angstrom]\n", + "d_AB = math.sqrt(d_A*d_B) \t\t\t# [K]\n", + "M_AB = 2/((1/M_A)+(1/M_B)) \t\t\t# [gram/mole]\n", + "\n", + "T_star = T/d_AB \n", + "a = 1.06036 \n", + "b = 0.15610 \n", + "c = 0.19300 \n", + "d = 0.47635 \n", + "e = 1.03587 \n", + "f = 1.52996 \n", + "g = 1.76474 \n", + "h =3.89411 \n", + "ohm = ((a/T_star**b)+(c/math.exp(d*T_star))+(e/math.exp(f*T_star))+(g/math.exp(h*T_star))) \n", + " \n", + "\t# Substituting these values into the Wilke-Lee equation yields (equation 1.49)\n", + "D_AB = ((10**-3*(3.03-(.98/math.sqrt(M_AB)))*T**1.5)/(P*(math.sqrt(M_AB))*(sigma_AB**2)*ohm)) # [square cm/s]\n", + "print\"The diffusivity of allyl chloride in air at 298 K and 1 bar is\",round(D_AB,4),\"square cm/s\\n\"\n", + "\n", + "\t# The experimental value of D_AB reported by Lugg (1968) is 0.098 square cm/s\n", + "D_ABexp = .098 \t\t\t\t\t# [square cm/s]\n", + "percent_error = ((D_AB-D_ABexp)/D_ABexp)*100 \t\t# [%]\n", + "print\"The percent error of the estimate, compared to the experimental value is\",round(percent_error,1),\"%\" " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The diffusivity of allyl chloride in air at 298 K and 1 bar is 0.0992 square cm/s\n", + "\n", + "The percent error of the estimate, compared to the experimental value is 1.2 %\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 1.8 Page number:26" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Illustration 1.8\n", + "#Calculation of Liquid Diffusivity in Aqueous Solution \n", + "import math\n", + "#Variable declaration\n", + "\n", + "\t# solute A-C2H60 solvent B-water\n", + "T = 288\t\t \t\t\t\t# [K]\n", + "\n", + "\t# Critical volume of solute\n", + "V_c = 167.1 \t\t\t\t\t# [cubic cm/mole]\n", + "\t# Calculating molar volume using equation 1.48\n", + "V_ba = 0.285*(V_c)**1.048 \t\t\t# [cubic cm/mole]\n", + "u_b = 1.153 \t\t\t\t\t# [Viscosity of liquid water at 288 K, cP]\n", + "M_solvent = 18 \t\t\t\t# [gram/mole]\n", + "phi_b = 2.26 \t\t\t\t\t# [association factor of solvent B]\n", + "\n", + "#Illustration 1.8 (a) \n", + "\t# Solution (a)\n", + "\n", + "\t# Using the Wilke-Chang correlation, equation 1.52\n", + "D_abo1 = (7.4*10**-8)*(math.sqrt(phi_b*M_solvent))*T/(u_b*(V_ba)**.6) # [diffusivity of solute A \tin very dilute solution in solvent B, square cm/s]\n", + "\n", + "#RESULT\n", + "print\"Diffusivity of C2H60 in a dilute solution in water at 288 K is\",round(D_abo1,8),\"square cm/s\" \n", + "\t# The experimental value of D_abo reported in Appendix A is 1.0 x 10**-5 square cm/s\n", + "D_aboexp = 1*10**-5 \t\t\t\t\t# [square cm/s]\n", + "percent_error1 = ((D_abo1-D_aboexp)/D_aboexp)*100 \t# [%]\n", + "\n", + "print\"The percent error of the estimate, compared to the experimental value is\",round(percent_error1,1),\"%\" \n", + "\n", + "\t#Illustration 1.8 (b) \n", + "\t# Solution (b)\n", + "#CALCULATION\n", + "\t# Using the Hayduk and Minhas correlation for aqueous solutions equation 1.53\n", + "E = (9.58/V_ba)-1.12 \n", + "D_abo2 = (1.25*10**-8)*(((V_ba)**-.19)-0.292)*(T**1.52)*(u_b**E) \t# [square cm/s]\n", + "\n", + "#RESULT\n", + "print\"\\n\\nDiffusivity of C2H60 in a dilute solution in water at 288 K is\",round(D_abo2,8),\"square cm/s\\n\" \n", + "percent_error2 = ((D_abo2-D_aboexp)/D_aboexp)*100 \t\t\t# [%]\n", + "print\"The percent error of the estimate, compared to the experimental value is\",round(percent_error2,1),\"%\" " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Diffusivity of C2H60 in a dilute solution in water at 288 K is 1.002e-05 square cm/s\n", + "The percent error of the estimate, compared to the experimental value is 0.2 %\n", + "\n", + "\n", + "Diffusivity of C2H60 in a dilute solution in water at 288 K is 9.91e-06 square cm/s\n", + "\n", + "The percent error of the estimate, compared to the experimental value is -0.9 %\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 1.9 Page number:27" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Illustration 1.9\n", + "#Calculation of Liquid Diffusivity in Dilute Nonaqueous Solution\n", + "\n", + "import math\n", + "#Variable declaration\n", + "\t# A-acetic acid(solute) B-acetone(solvent)\n", + "T = 313 \t\t\t\t\t # [K]\n", + "\t# The following data are available (Reid, et al., 1987):\n", + "\n", + "\t# Data for acetic acid\n", + "T_bA = 390.4 \t\t\t\t\t# [K]\n", + "T_cA = 594.8 \t\t\t\t\t# [K]\n", + "P_cA = 57.9 \t\t\t\t\t# [bar]\n", + "V_cA = 171 \t\t\t\t\t# [cubic cm/mole]\n", + "M_A = 60 \t\t\t\t\t# [gram/mole]\n", + "\n", + "\t# Data for acetone\n", + "T_bB = 329.2 \t\t\t\t\t# [K]\n", + "T_cB = 508 \t\t\t\t\t# [K]\n", + "P_cB = 47 \t\t\t\t\t# [bar]\n", + "V_cB = 209 \t\t\t\t\t# [cubic cm/mole]\n", + "u_bB = 0.264 \t\t\t\t\t# [cP]\n", + "M_B = 58 \t\t\t\t\t# [gram/mole]\n", + "phi = 1 \n", + "\n", + "#CALCULATION\n", + "\n", + "\t#Illustration 1.9 (a) -\n", + "\t# Solution (a)\n", + "\t# Using equation 1.48\n", + "V_bA = 0.285*(V_cA)**1.048 \t\t\t# [cubic cm/mole]\n", + "\n", + "\t# Using the Wilke-Chang correlation , equation 1.52\n", + "D_abo1 = (7.4*10**-8)*(math.sqrt(phi*M_B))*T/(u_bB*(V_bA)**.6) \n", + "\n", + "#RESULT\n", + "print\"Diffusivity of acetic acid in a dilute solution in acetone at 313 K using the Wilke-Chang correlation is\",round(D_abo1,8),\"square cm/s\\n\" \n", + "\t# From Appendix A, the experimental value is 4.04*10**-5 square cm/s\n", + "D_aboexp = 4.04*10**-5 \t\t\t\t\t# [square cm/s]\n", + "percent_error1 = ((D_abo1-D_aboexp)/D_aboexp)*100 \t\t# [%]\n", + "\n", + "print\"The percent error of the estimate, compared to the experimental value is \",round(percent_error1,1),\"%\" \n", + "\n", + "#Illustration 1.9 (b)\n", + "# Solution (b)\n", + "\n", + "#CALCULATION\n", + "# Using the Hayduk and Minhas correlation for nonaqueous solutions\n", + "\n", + "V_bA = V_bA*2 \t\t\t\t\t\t\t# [cubic cm/mole]\n", + "V_bB = 0.285*(V_cB)**1.048 \t\t\t\t\t# [cubic cm/mole]\n", + "\n", + "\t\t# For acetic acid (A)\n", + "T_brA = T_bA/T_cA \t\t\t\t\t\t# [K]\n", + "\t\t# Using equation 1.55 \n", + "alpha_cA = 0.9076*(1+((T_brA)*math.log(P_cA/1.013))/(1-T_brA)) \n", + "sigma_cA = (P_cA**(2.0/3.0))*(T_cA**(1.0/3.0))*(0.132*alpha_cA-0.278)*(1-T_brA)**(11.0/9.0) # [dyn/cm]\n", + "\n", + "# For acetone (B)\n", + "T_brB = T_bB/T_cB \t\t\t\t\t\t# [K]\n", + "\t\t# Using equation 1.55 \n", + "alpha_cB = 0.9076*(1+((T_brB*math.log(P_cB/1.013))/(1-T_brB))) \n", + "sigma_cB = (P_cB**(2.0/3.0))*(T_cB**(1.0/3.0))*(0.132*alpha_cB-0.278)*(1-T_brB)**(11.0/9.) # [dyn/cm]\n", + "\n", + "# Substituting in equation 1.54\n", + "D_abo2 = (1.55*10**-8)*(V_bB**0.27)*(T**1.29)*(sigma_cB**0.125)/((V_bA**0.42)*(u_bB**0.92)*(sigma_cA**0.105)) \n", + "\n", + "#RESULT\n", + "\n", + "print\"Diffusivity of acetic acid in a dilute solution in acetone at 313 K using the Hayduk and Minhas correlation is\",round(D_abo2,7),\"square cm/s\\n\" \n", + "\n", + "percent_error2 = ((D_abo2-D_aboexp)/D_aboexp)*100 # [%]\n", + "print\"The percent error of the estimate, compared to the experimental value is\",round(percent_error2),\"%\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Diffusivity of acetic acid in a dilute solution in acetone at 313 K using the Wilke-Chang correlation is 5.596e-05 square cm/s\n", + "\n", + "The percent error of the estimate, compared to the experimental value is 38.5 %\n", + "Diffusivity of acetic acid in a dilute solution in acetone at 313 K using the Hayduk and Minhas correlation is" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " 3.84e-05 square cm/s\n", + "\n", + "The percent error of the estimate, compared to the experimental value is -5.0 %\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 1.10 Page number:30" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Illustration 1.10\n", + "#Diffusion Coefficients in the System Acetone-Benzene\n", + "\n", + "#Variable declaration\n", + "\t# acetone-1 benzene-2\n", + "T = 298 \t\t\t\t\t# [K]\n", + "x_1 = 0.7808 \n", + "x_2 = 1-x_1 \n", + "\n", + "#CALCULATIONS\n", + "\t# The infinite dilution diffusivities are\n", + "D_12o = 2.75*10**-9 \t\t\t\t# [square m/s]\n", + "D_21o = 4.15*10**-9 \t\t\t\t# [square m/s]\n", + "\t# From the NRTL equation, for this system at the given temperature and concentration the \tthermodynamic correction factor r = 0.871.\n", + "r = 0.871 \n", + "D_12exp = 3.35*10**-9 \t\t\t\t# [square m/s]\n", + "\n", + "\n", + "\t# Using equation 1.56\n", + "D_12 = (D_12o**x_2)*(D_21o**x_1) \n", + "D_12 = D_12*r \n", + "\n", + "#RESULT\n", + "print\"The theoritical value of Fick diffusivity is\",round(D_12,11),\"square m/s\" \n", + "\t# The predicted value of the Fick diffusivity is in excellent agreement with the \texperimental result." + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The theoritical value of Fick diffusivity is 3.3e-09 square m/s\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 1.11 Page number:32" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Illustration 1.11\n", + "#Calculation of Effective Diffusivity in a Multicompo-nent Gas Mixture \n", + "\n", + "#Variable declaration\n", + "# ammonia-1 nitrogen-2 hydrogen-3\n", + "T = 300 \t\t\t\t\t# [K]\n", + "P = 1 \t\t\t\t\t\t# [bar]\n", + "y_1 = .40 \n", + "y_2 = .20 \n", + "y_3 = .40 \n", + "import math\n", + "\n", + "\t# Lennard-Jones parameter for ammonia\n", + "sigma_1 = 2.9 \t\t\t\t\t# [Angstrom]\n", + "d_1 = 558.3 \t\t\t\t\t# [E/K, K]\n", + "M_1 = 17.0 \t\t\t\t\t# [gram/mole]\n", + "\n", + "\t# Lennard-Jones parameter for nitrogen\n", + "sigma_2 = 3.798 \t\t\t\t# [Angstrom]\n", + "d_2 = 71.4 \t\t\t\t\t# [E/K, K]\n", + "M_2 = 28.0 \t\t\t\t\t# [gram/mole]\n", + "\n", + "\t# Lennard-Jones parameter for hydrogen \n", + "sigma_3 = 2.827 \t\t\t\t# [Angstrom]\n", + "d_3 = 59.7 \t\t\t\t\t# [E/K, K]\n", + "M_3 = 2.0 \t\t\t\t\t# [gram/mole]\n", + "\n", + "\t# Binary diffusivitiy of ammonia in nitrogen (D_12)\n", + "\n", + "#CALCULATIONS\n", + "\n", + "\n", + "sigma_12 = (sigma_1+sigma_2)/2 \t\t# [Angstrom]\n", + "d_12 = math.sqrt(d_1*d_2) \t\t\t# [K]\n", + "M_12 = 2/((1/M_1)+(1/M_2)) \t\t\t# [gram/mole]\n", + "\n", + "T_star12 = T/d_12 \n", + "a = 1.06036 \n", + "b = 0.15610 \n", + "c = 0.19300 \n", + "d = 0.47635 \n", + "e = 1.03587 \n", + "f = 1.52996 \n", + "g = 1.76474 \n", + "h = 3.89411 \n", + "ohm12 = ((a/T_star12**b)+(c/math.exp(d*T_star12))+(e/math.exp(f*T_star12))+(g/math.exp(h*T_star12))) \n", + " \n", + "\t# Substituting these values into the Wilke-Lee equation yields (equation 1.49)\n", + "D_12 = ((10**-3*(3.03-(.98/math.sqrt(M_12)))*T**1.5)/(P*(math.sqrt(M_12))*(sigma_12**2)*ohm12)) # [square cm/s]\n", + "print\"The diffusivitiy of ammonia in nitrogen\",round(D_12,3),\"square cm/s\"\n", + "\n", + "\t# Binary diffusivitiy of ammonia in hydrogen (D_13)\n", + "\n", + "sigma_13 = (sigma_1+sigma_3)/2 \t\t# [Angstrom]\n", + "d_13 = math.sqrt(d_1*d_3) \t\t\t# [K]\n", + "M_13 = 2/((1/M_1)+(1/M_3)) \t\t\t# [gram/mole]\n", + "\n", + "T_star13 = T/d_13 \n", + "a = 1.06036 \n", + "b = 0.15610 \n", + "c = 0.19300 \n", + "d = 0.47635 \n", + "e = 1.03587 \n", + "f = 1.52996 \n", + "g = 1.76474 \n", + "h = 3.89411 \n", + "ohm13 = ((a/T_star13**b)+(c/math.exp(d*T_star13))+(e/math.exp(f*T_star13))+(g/math.exp(h*T_star13))) \n", + " \n", + "\t# Substituting these values into the Wilke-Lee equation yields (equation 1.49)\n", + "D_13 = ((10**-3*(3.03-(.98/math.sqrt(M_13)))*T**1.5)/(P*(math.sqrt(M_13))*(sigma_13**2)*ohm13)) \t\t\t\t\t# [square cm/s]\n", + "\n", + "#RESULT\n", + "\n", + "print\"The diffusivitiy of ammonia in hydrogen\",round(D_13,3),\"square cm/s\\n\" \n", + "\n", + "\t# Figure 1.5 shows the flux of ammonia (N_1) toward the catalyst surface, where \n", + "\t# it is consumed by chemical reaction, and the fluxes of nitrogen (N_2) and hydrogen \t\t(N_3)\n", + "\t# produced by the reaction migrating away from the same surface.\n", + "\n", + "\t# Therefore N_1 = N_2+N_3 \n", + "\t# From equation 1.59\n", + "\t# N_2 = -(0.5)*N_1 and N_3 = -(1.5)*N_1\n", + "\n", + "\t# Substituting in equation (1.58) we obtain\n", + "D_1eff = (1+y_1)/((y_2+0.5*y_1)/D_12 + (y_3+1.5*y_1)/D_13) \t\t# [square cm/s]\n", + "\n", + "#RESULT\n", + "\n", + "print\"The effective diffusivity of ammonia in the gaseous mixture is\",round(D_1eff,3),\"square cm/s\" " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The diffusivitiy of ammonia in nitrogen 0.237 square cm/s\n", + "The diffusivitiy of ammonia in hydrogen 0.728 square cm/s\n", + "\n", + "The effective diffusivity of ammonia in the gaseous mixture is 0.457 square cm/s\n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 1.12 Page number:34" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Illustration 1.12\n", + "#Calculation of Effective Diffusivity in a Multicomponent Stagnant Gas Mixture\n", + "\n", + "#Variable declaration\n", + "\t# ammonia-1 nitrogen-2 hydrogen-3\n", + "T = 300 \t\t\t\t\t# [K]\n", + "P = 1 \t\t\t\t\t\t# [bar]\n", + "y_1 = 0.40 \n", + "y_2 = 0.20 \n", + "y_3 = 0.40 \n", + "\n", + "#CALCULATIONS\n", + "\n", + "\t# The binary diffusivities are the same as for Example 1.11.\n", + "D_12 = 0.237 \t\t\t\t\t# [square cm/s]\n", + "D_13 = 0.728 \t\t\t\t\t# [square cm/s]\n", + "\n", + "\t# mole fractions of nitrogen (2) and hydrogen (3) on an ammonia (1)-free base from \tequation (1.61)\n", + "y_21 = y_2/(1-y_1) \n", + "y_31 = y_3/(1-y_1) \n", + "\t# Substituting in equation (1.60) gives us\n", + "D_1eff = 1/((y_21/D_12)+(y_31/D_13)) \n", + "print\"The effective diffusivity of ammonia in the gaseous mixture is\",round(D_1eff,3),\"square cm/s\" " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The effective diffusivity of ammonia in the gaseous mixture is 0.431 square cm/s\n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 1.13 Page number:36" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Illustration 1.13\n", + "#Calculation of Effective Diffusivity of a Dilute Solute in a Homogeneous Mixture of Solvents\n", + "\n", + "#VARIABLE DECLARATION\n", + "\n", + "\t# acetic acid-1 water-2 ethyl alcohol-3\n", + "T = 298 \t\t\t\t\t# [K]\n", + "\t# The data required data for water at 298 K\n", + "u_2 = 0.894 \t\t\t\t\t# [cP]\n", + "V_c1 = 171 \t\t\t\t\t# [cubic cm/mole]\n", + "\t# From equation 1.48\n", + "V_b1 = 62.4 \t\t\t\t\t# [cubic cm/mole]\n", + "\t# Substituting in equation (1.53)\n", + "\t# the infinite dilution diffusion coefficient of acetic acid in water at 298 K\n", + "E = (9.58/V_b1)-1.12 \n", + "D_abo12 = (1.25*10**-8)*(((V_b1)**-.19)-0.292)*(T**1.52)*(u_2**E) # [square cm/s]\n", + "\n", + "import math\n", + "\t# Data for acetic acid\n", + "T_b1 = 390.4 \t\t\t\t\t# [K]\n", + "T_c1 = 594.8 \t\t\t\t\t# [K]\n", + "P_c1 = 57.9 \t\t\t\t\t# [bar]\n", + "V_c1 = 171 \t\t\t\t\t# [cubic cm/mole]\n", + "M_1 = 60.0 \t\t\t\t\t# [gram/mole]\n", + "\n", + "\t# Data for ethanol\n", + "T_b3 = 351.4 \t\t\t\t\t# [K]\n", + "T_c3 = 513.9 \t\t\t\t\t# [K]\n", + "P_c3 = 61.4 \t\t\t\t\t# [bar]\n", + "V_c3 = 167 \t\t\t\t\t# [cubic cm/mole]\n", + "M_3 = 46.0 \t\t\t\t\t# [gram/mole]\n", + "u_3 = 1.043 \t\t\t\t\t# [cP]\n", + "\n", + "\n", + "#CALCULATION\n", + "\n", + "\t# Using the Hayduk and Minhas correlation for nonaqueous solutions\n", + "\n", + "\t# According to restriction 3 mentioned above, the molar volume of the acetic acid to be \tused in equation (1.54) should be\t\n", + "V_b1 = V_b1*2 \t\t\t\t\t# [cubic cm/mole]\n", + "\t# The molar volume of ethanol is calculated from equation (1.48)\n", + "V_b3 = 60.9 \t\t\t\t\t# [cubic cm/mole]\n", + "\n", + "\n", + "\t# For acetic acid (1)\n", + "T_br1 = T_b1/T_c1 \t\t\t\t# [K]\n", + "\t# Using equation 1.55 \n", + "alpha_c1 = 0.9076*(1+((T_br1)*math.log(P_c1/1.013))/(1-T_br1)) \n", + "sigma_c1 = (P_c1**(2.0/3.0))*(T_c1**(1.0/3.0))*(0.132*alpha_c1-0.278)*(1-T_br1)**(11.0/9.0) # \t\t\t\t\t\t\t\t\t\t\t[dyn/cm]\n", + "\n", + "\t# For ethanol (3)\n", + "T_br3 = T_b3/T_c3 \t\t\t\t# [K]\n", + "\t# Using equation 1.55 \n", + "alpha_c3 = 0.9076*(1+((T_br3*math.log(P_c3/1.013))/(1-T_br3))) \n", + "sigma_c3 = (P_c3**(2.0/3.0))*(T_c3**(1.0/3.0))*(0.132*alpha_c3-0.278)*(1-T_br3)**(11.0/9.0) # [dyn/cm]\n", + "\n", + "\t# Substituting in equation 1.54\n", + "D_abo13 = (1.55*10**-8)*(V_b3**0.27)*(T**1.29)*(sigma_c3**0.125)/((V_b1**0.42)*(u_3**0.92)*(sigma_c1**0.105)) \n", + "\n", + "\t# The viscosity of a 40 wt% aqueous ethanol solution at 298 K is u_mix = 2.35 cP\n", + "u_mix = 2.35 \t\t\t\t\t# [cP]\n", + "\t# The solution composition must be changed from mass to molar fractions following a \t\t\tprocedure similar to that illustrated in Example 1.2\n", + "\t# Accordingly, a 40 wt% aqueous ethanol solution converts to 20.7 mol%.\n", + "\t# Therefore mole fraction of ethanol (x_3) and water (x_2) \n", + "\n", + "x_3 = 0.207 \n", + "x_2 = 1-x_3 \n", + "\t# Using equation 1.62\n", + "D_1eff = ((x_2*D_abo12*(u_2**0.8))+(x_3*D_abo13*(u_3**0.8)))/(u_mix**0.8) \n", + "\n", + "#RESULT\n", + "\n", + "print\"The diffusion coefficient of acetic acid at very low concentrations diffusing into a mixed solvent containing 40.0 wt percent ethyl alcohol in water at a temperature of 298 K is\",round(D_1eff,7),\"cm^2/s\\n\\n\" \n", + "\n", + "\t# The experimental value reported by Perkins and Geankoplis (1969) is \n", + "D_1exp = 5.71*10**-6 # [square cm/s]\n", + "percent_error = ((D_1eff-D_1exp)/D_1exp)*100 # [%]\n", + "\n", + "\n", + "print\"The error of the estimate is \",round(percent_error,1),\"%\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The diffusion coefficient of acetic acid at very low concentrations diffusing into a mixed solvent containing 40.0 wt percent ethyl alcohol in water at a temperature of 298 K is 5.9e-06 cm^2/s\n", + "\n", + "\n", + "The error of the estimate is 3.2 %\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 1.14 Page number:39" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Illustration 1.14\n", + "#Steady-State Equimolar Counterdiffusion\n", + "\n", + "\n", + "#Variable declaration\n", + "\t# Binary gaseous mixture of components A and B\n", + "P = 1 \t\t\t\t\t\t # [bar]\n", + "T = 300 \t\t\t # [K]\n", + "R = 8.314 \t\t\t\t\t # [cubic m.Pa/mole.K]\n", + "delta = 1 \t\t\t\t\t # [mm]\n", + "y_A1 = 0.7 \n", + "y_A2 = 0.2 \n", + "D_AB = 0.1 \t\t\t\t\t # [square cm/s]\n", + "\n", + "\t# Using equation 1.72\n", + "#CALCULATION\n", + "\n", + "N_A = (D_AB*10**-4)*(P*10**5)*(y_A1-y_A2)/(R*T*delta*10**-3) \n", + "\n", + "#RESULT\n", + "\n", + "print\"The molar flux of component A is\",round(N_A,1),\"mole/square m.s\" " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The molar flux of component A is 0.2 mole/square m.s\n" + ] + } + ], + "prompt_number": 12 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 1.15 Page number:41" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Illustration 1.15\n", + "#Steady-State Diffusion of A Through Stagnant B\n", + "\n", + "#Variable declaration\n", + "\t\t# Diffusion of A through stagnant B\n", + "P_total = 1.0 \t\t\t\t\t\t# [bar]\n", + "P_B1 = 0.8 \t\t\t\t\t\t# [bar]\n", + "P_B2 = 0.3 \t\t\t\t\t\t# [bar]\n", + "\n", + "import math\n", + "\n", + "#Calculation\n", + "\t# Using equation 1.83\n", + "P_BM = (P_B2-P_B1)/(math.log(P_B2/P_B1)) \t\t# [bar]\n", + "\t# using the result of Example 1.14, we have\n", + "N_A = 0.2 \t\t\t\t\t\t# [mole/square m.s]\n", + "N_A = N_A*P_total/P_BM \t\t\t\t\t# [moloe/square m.s]\n", + "\n", + "#Result\n", + "\n", + "print\"The molar flux of component A is\",round(N_A,2),\"mole/square m.s\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The molar flux of component A is 0.39 mole/square m.s\n" + ] + } + ], + "prompt_number": 13 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 1.16 Page number:44" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Illustration 1.16\n", + "#Production of Nickel Carbonyl: Steady-State, One-Dimensional Binary Flux Calculation\n", + "import math\n", + "#Variable declaration\n", + "\t# Nickel Carbonyl-A carbon monoxide-B\n", + "T = 323 \t\t\t\t\t# [K]\n", + "P = 1 \t\t\t\t\t\t# [atm]\n", + "R = 8.314 \t\t\t\t\t# [cubic m.Pa/mole.K]\n", + "y_A1 = 1.0 \n", + "y_A2 = 0.5 \n", + "delta = 0.625 \t\t\t\t\t# [mm]\n", + "D_AB = 20 \t\t\t\t\t# [square mm/s]\n", + "\n", + "#Calculations\n", + "\n", + "\n", + "\t# The stoichiometry of the reaction determines the relation between the fluxes: from \t\t\tequation (1-59), N_B = - 4N_A and N_A + N_B = -3NA\n", + "\t# Molar flux fraction si_A = N_A/(N_A+N_B) = N_A/(-3*N_A) = -1/3\n", + "si_A = -1.0/3.0 \n", + "\t# Using equation 1.78\n", + "N_A = si_A*(D_AB*10**-6*P*10**5*math.log((si_A-y_A2)/(si_A-y_A1))/(R*T*delta*10**-3)) \n", + "\n", + "#Result\n", + "\n", + "print\"The molar flux of component A is\",round(N_A,3),\"mole/square m.s\" \n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The molar flux of component A is 0.187 mole/square m.s\n" + ] + } + ], + "prompt_number": 14 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 1.19 Page number:54" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Illustration 1.19\n", + "#Steady- State Molecular Diffusion in Liquids\n", + "import math\n", + "\n", + "#Variable declaration\n", + "# a-CuS04 b-H2O\n", + "T = 273 \t\t\t\t\t\t# [K]\n", + "delta = 0.01 \t\t\t\t\t\t# [mm]\n", + "sol_ab = 24.3 \t\t\t\t\t\t# [gram/100 gram water]\n", + "den_ab = 1140 \t\t\t\t\t\t# [kg/cubic m]\n", + "D_ab = 3.6*10**-10 \t\t\t\t\t# [square m/s]\n", + "den_b = 999.8 \t\t\t\t\t\t# [kg/cubic m]\n", + "\n", + "\n", + "#Calcualtions\n", + "\n", + "\t# both fluxes are in the same direction therefore, they are both positive and relation \tis N_b = 5N_a (where N_b and N_a are molar fluxes of component 'a' and 'b') \n", + "\t# From equation (1.76), si_a = 1/6 = 0.167\n", + "si_a = 0.167 \n", + "\t# Calculation of mole fraction of component 'a'\n", + "\t# Basis: 100 gram H2O (b)\n", + "M_a = 159.63 \t\t\t\t\t\t# [gram/mole]\n", + "M_b = 18 \t\t\t\t\t\t# [gram/mole]\n", + "M_c =249.71 \t\t\t\t\t\t# [here M_c is molecular mass of hydrated \t\t\t\t\t\t\t CuSO4, gram/mole]\n", + "m_a = 24.3 \t\t\t\t\t\t# [gram]\n", + "m_c = m_a*(M_a/M_c) \t\t\t\t\t# [here m_c is the mass of CuSO4 in 24.3 \t\t\t\t\t\t\tgram of crystal, gram]\n", + "m_d = m_a-m_c \t\t\t\t\t\t# [here m_d is mass of hydration of water \t\t\t\t\t\t\tin the crystal, gram]\n", + "m_b_total = 100+m_d \t\t\t\t\t# [total mass of water, gram]\n", + "\n", + "x_a1 = (m_c/M_a)/((m_c/M_a)+(m_b_total/M_b)) \n", + "x_a2 = 0 \n", + "\n", + "\t# At point 1, the average molecular weight is\n", + "M_1 = x_a1*M_a+(1-x_a1)*M_b \t\t\t\t# [gram/mole]\n", + "\t# At point 2, the average molecular weight is\n", + "M_2 = x_a2*M_a+(1-x_a2)*M_b\n", + "\t# Molar density at point 1 and 2\n", + "row_1 = den_ab/M_1 \t\t\t\t\t# [kmole/cubic m]\n", + "row_2 = den_b/M_2\n", + "row_avg = (row_1+row_2)/2 \t\t\t\t# [kmole/cubic m]\n", + "\n", + "\t# Using equation 1.96\n", + "\n", + "N_a = si_a*D_ab*row_avg*math.log((si_a-x_a2)/(si_a-x_a1))/(delta*10**-3) \t# [kmole/square \t\t\t\t\t\t\t\t\t\tm.s]\n", + "rate = N_a*M_c*3600 \t\t\t\t\t# [kg/square m of crystal surface area \t\t\t\t\t\t\tper hour]\n", + "\n", + "#Result\n", + "\n", + "print\"the rate at which the crystal dissolves in solution is\",round(rate),\"kg/square m of crystal surface area per hour\" \n", + " \n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "the rate at which the crystal dissolves in solution is 30.0 kg/square m of crystal surface area per hour\n" + ] + } + ], + "prompt_number": 15 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 1.20 Page number:58" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Illustration 1.20\n", + "# Steady-State Molecular Diffusion in Porous Solid \n", + "\n", + "#Variable declaration\n", + "\t# A-hydrogen B-ethane\n", + "T = 373 \t\t\t\t\t# [K]\n", + "P = 10 \t\t\t\t\t# [atm]\n", + "d = 4000 \t\t\t\t\t# [Angstrom]\n", + "e = 0.4 \t\t\t\t\t# [porosity]\n", + "t = 2.5 \t\t\t\t\t# [tortuosity]\n", + "D_AB = 0.86/P \t\t\t\t\t# [square cm/s]\n", + "k = 1.3806*10**-23 \t\t\t\t# [J/K]\n", + "import math\n", + "\n", + "#Calculation\n", + "\n", + "# Using data from Appendix B for hydrogen and ethane, and equation (1.45)\n", + "sigma_A = 2.827 \t\t\t\t# [Angstrom]\n", + "sigma_B = 4.443 \t\t\t\t# [Angstrom]\n", + "sigma_AB = ((sigma_A+sigma_B)/2)*10**-10 \t# [m]\n", + "\n", + "lamda=k*T/(math.sqrt(2)*3.14*(sigma_AB**2)*P*1.01325*10**5) # [m]\n", + "lamda=lamda*10**10 # [Angstrom]\n", + "\t\t# From equation 1.101\n", + "K_n = lamda/d \n", + "\n", + "#Result\n", + "\n", + "print\"The value of a dimensionless ratio, Knudsen number is \",round(K_n,3) \n", + "\t# If K_n is less than 0.05 then diffusion inside the pores occurs only by ordinary \t\tmolecular diffusion and equation 1.100 can be used to calculate D_ABeff\n", + "D_ABeff = D_AB*e/t \n", + "print\"The effective diffusivity of hydrogen in ethane is\",round(D_ABeff,3),\"square cm /s\" " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The value of a dimensionless ratio, Knudsen number is 0.022\n", + "The effective diffusivity of hydrogen in ethane is 0.014 square cm /s\n" + ] + } + ], + "prompt_number": 16 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 1.21 Page number:60" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Illustration 1.21\n", + "#Knudsen Diffusion in Porous Solid \n", + "\n", + "#Variable declaration\n", + "\t# a-oxygen b-nitrogen\n", + "T = 293 \t\t\t\t\t\t# [K]\n", + "P = 0.1 \t\t\t\t\t\t# [atm]\n", + "d = 0.1*10**-6 \t\t\t\t\t# [m]\n", + "e = 0.305 \t\t\t\t\t \t# [porosity]\n", + "t = 4.39 \t\t\t\t\t\t# [tortuosity]\n", + "k = 1.3806*10**-23 \t\t\t\t\t# [J/K]\n", + "l = 2*10**-3 \t\t\t\t\t\t# [m]\n", + "R = 8.314 \t\t\t\t\t\t# [cubic m.Pa/mole.K]\n", + "x_a1 = 0.8 \n", + "x_a2 = 0.2 \n", + "M_a = 32.0 \t\t\t\t\t\t# [gram/mole]\n", + "M_b = 28.0 \t\t\t\t\t\t# [gram/mole]\n", + "\n", + "#Calculation\n", + "\n", + "import math\n", + "\t# Using data from Appendix B for oxygen and nitrogen, and equation (1.45)\n", + "sigma_a = 3.467 \t\t\t\t\t# [Angstrom]\n", + "sigma_b = 3.798 \t\t\t\t\t# [Angstrom]\n", + "sigma_AB = ((sigma_a+sigma_b)/2)*10**-10 \t\t# [m]\n", + "\n", + "lamda = k*T/(math.sqrt(2)*3.14*(sigma_AB**2)*P*1.01325*10**5) # [m]\n", + "\t# From equation 1.101\n", + "K_n = lamda/d \n", + "\n", + "#Result\n", + "\n", + "print\"The value of a dimensionless ratio, Knudsen number is \",round(K_n,3) \n", + "\t# If K_n is greater than 0.05 then transport inside the pores is mainly by Knudsen \t\t\tdiffusion\n", + "\t# Using equation 1.103\n", + "\n", + "\n", + "#Calculation\n", + "\n", + "D_Ka = (d/3)*(math.sqrt(8*R*T)/math.sqrt(3.14*M_a*10**-3)) # [square m/s]\n", + "\n", + "\t# Using equation 1.107\n", + "D_Kaeff = D_Ka*e/t \t\t\t\t\t# [square m/s]\n", + "\n", + "p_a1 = (x_a1*P)*1.01325*10**5 \t\t\t\t# [Pa]\n", + "p_a2 = (x_a2*P)*1.01325*10**5 \t\t\t\t# [Pa]\n", + "\n", + "\t# Using equation 1.108\n", + "N_a = D_Kaeff*(p_a1-p_a2)/(R*T*l) \t\t\t# [mole/square m.s]\n", + "\t# Now using the Graham\u2019s law of effusion for Knudsen diffusion\n", + "\t# N_b/N_a = -math.sqrt(M_a/M_b) ,therefore\n", + "N_b = -N_a*math.sqrt(M_a/M_b) \t\t\t\t# [mole/square m.s]\n", + "\n", + "\n", + "#Result\n", + "\n", + "print\"The diffusion fluxes of both components oxygen and nitrogen are \",round(N_a,5),\"mole/square m.s and\",round(N_b,5),\"mole/square m.s respectively\\n\" \n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The value of a dimensionless ratio, Knudsen number is 6.813\n", + "The diffusion fluxes of both components oxygen and nitrogen are 0.00127 mole/square m.s and -0.00136 mole/square m.s respectively\n", + "\n" + ] + } + ], + "prompt_number": 17 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 1.22 Page number:61" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Illustration 1.22\n", + "#2 Combined Molecular and Knudsen Diffusion in a Porous Solid \n", + "\n", + "#Variable declaration\n", + "\t# a-oxygen b-nitrogen\n", + "T = 293 \t\t\t\t\t\t# [K]\n", + "P = 0.1 \t\t\t\t\t\t# [atm]\n", + "d = 0.3*10**-6 \t\t\t\t\t# [m]\n", + "e = 0.305 \t\t\t\t\t\t# [porosity]\n", + "t = 4.39 \t\t\t\t\t\t# [tortuosity]\n", + "k = 1.3806*10**-23 \t\t\t\t\t# [J/K]\n", + "R = 8.314 \t\t\t\t\t\t# [cubic m.Pa/mole.K]\n", + "l = 2*10**-3 \t\t\t\t\t\t# [m]\n", + "D_ab = 2.01*10**-4 \t\t\t\t\t# [square m/s]\n", + "y_a1 = 0.8 \n", + "y_a2 = 0.2 \n", + "\n", + "\n", + "#Calculations\n", + "\n", + "import math\n", + "\t# Using data from Appendix B for oxygen and nitrogen, and equation (1.45)\n", + "sigma_a = 3.467 \t\t\t\t\t# [Angstrom]\n", + "sigma_b = 3.798 \t\t\t\t\t# [Angstrom]\n", + "sigma_AB = ((sigma_a+sigma_b)/2)*10**-10 \t\t# [m]\n", + "\n", + "lamda = k*T/(math.sqrt(2)*3.14*(sigma_AB**2)*P*1.01325*10**5) # [m]\n", + "\t# From equation 1.101\n", + "K_n = lamda/d \n", + "print\"The value of a dimensionless ratio,Knudsen number is \",round(K_n,2) \n", + "\n", + "\t# It means that both molecular and Knudsen diffusion are important and equation (1.109) \t\tmust be used to calculate N_a\n", + "\t# From example 1.21 N_b/N_a = -1.069\n", + "\t# Therefore si_a = 1/(1+(N_b/N_a))\n", + "si_a = 1/(1+(-1.069)) \n", + "\n", + "\t# From equation 1.100\n", + "D_abeff = D_ab*e/t \t\t\t\t\t\t# [square m/s]\n", + "\n", + "\t# From equation 1.103\n", + "D_Ka = 0.440*10**-4\t\t\t\t\t\t# [square m/s]\n", + "\n", + "\t# Using equation 1.107\n", + "D_Kaeff = D_Ka*e/t \t\t\t\t\t\t# [square m/s]\n", + "\n", + "Y_a = 1+(D_abeff/D_Kaeff) \n", + "\n", + "\t# Using equation 1.109 to calculate N_a\n", + "N_a = (si_a*P*1.01325*10**5*D_abeff*math.log((si_a*Y_a-y_a2)/(si_a*Y_a-y_a1)))/(R*T*l) \n", + "N_b = -1.069*N_a \n", + "\n", + "\n", + "#RESULTS\n", + "print\"The diffusion fluxes of both components oxygen and nitrogen are\",round(N_a,5),\"mole/square m.s and\",round(N_b,5),\"mole/square m.s respectively\" " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The value of a dimensionless ratio,Knudsen number is 2.27\n", + "The diffusion fluxes of both components oxygen and nitrogen are 0.00311 mole/square m.s and -0.00332 mole/square m.s respectively\n" + ] + } + ], + "prompt_number": 18 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 1.23 Page number:62" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Illustration 1.23\n", + "#Dextrin Diffusion in a Porous Membrane\n", + "\n", + "#Variable declaration\n", + "\n", + "\t# A-beta dextrin B-water\n", + "T = 293 \t\t\t\t\t\t# [K]\n", + "d = 88.8 \t\t\t\t\t\t# [Average pore diameter, Angstrom]\n", + "d_mol = 17.96 \t\t\t\t\t\t# [Molecular diameter, Angstrom]\n", + "e = 0.0233 \t\t\t\t\t\t# [porosity]\n", + "t = 1.1 \t\t\t\t\t\t# [tortuosity]\n", + "D_AB = 3.22*10**-6 \t\t\t\t\t# [square cm/s]\n", + "\n", + "#Calculation\n", + "\n", + "\t# Using equation 1.111 to calculate restrictive factor\n", + "K_r = (1-(d_mol/d))**4\n", + "\n", + "\t# Using equation 1.110 to calculate effective diffusivity\n", + "D_ABeff = e*D_AB*K_r/t \t\t\t\t# [square cm/s]\n", + "\n", + "#Result\n", + "\n", + "print\"The effective diffusivity of beta-dextrin at 298 K is\",round(D_ABeff,10),\"square cm/s\" " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The effective diffusivity of beta-dextrin at 298 K is 2.76e-08 square cm/s\n" + ] + } + ], + "prompt_number": 19 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 1.24 Page number:63" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Illustration 1.24\n", + "#Hydrodynamic Flow in a Porous Diaphragm\n", + "\n", + "#Variable declaration\n", + "\t# a-nitrogen\n", + "P_atm = 1.01325*10**5 \t\t\t\t\t # [Pa]\n", + "T = 300 \t \t\t\t\t # [K]\n", + "P_2 = 10130 \t\t\t\t\t\t # [Pa]\n", + "P_1 = 500+P_2 \t\t\t\t\t\t # [Pa]\n", + "d = 0.01*10**-2 \t\t\t\t\t# [average pore diameter, m]\n", + "u = 180 \t\t\t\t\t\t# [micro Poise]\n", + "u = 180*10**-6*10**-1 \t\t\t\t\t# [Pa.s] \n", + "l = 25.4*10**-3 \t\t\t\t\t# [m]\n", + "v = 0.05 \t\t\t\t\t\t# [volumetric flow rate, cubic m/square \t\t\t\t\t\t\tm.s]\n", + "R = 8.314 \t\t\t\t\t\t# [cubic m.Pa/mole.K]\n", + "\n", + "\n", + "#Calculations\n", + "\n", + "\t# Solution (a)\n", + "\n", + "P_avg = (P_1+P_2)/2 \t\t\t\t\t# [Pa]\n", + "\t# The mean free path for nitrogen is from equation (1.102)\n", + "lamda = 0.622*10**-6 \t\t\t\t\t# [m]\n", + "K_n = lamda/d \n", + "\t# Therefore, Knudsen diffusion will not occur and all the flow observed is of a \thydrodynamic nature.\n", + "\n", + "\t# From the ideal gas law, the nitrogen flux corresponding to the volumetric flow rate of \t0.05 m3/m2-s at 300 K and 1 atm\n", + " \n", + "N_a = P_atm*v/(R*T) \t\t\t\t\t# [mole/square m.s]\n", + "\t# Using equation 1.113\n", + "B_o = u*R*T*N_a*l/(P_avg*(P_1-P_2)) \t\t\t# [square m]\n", + "\n", + "#RESULT\n", + "\n", + "print\"The value of the viscous flow parameter is\",round(B_o,13),\"square m\\n\\n\" \n", + "\n", + "\t#Illustration 1.24 (b) - Page:64\n", + "\t# Solution (b)\t\n", + "\n", + "#Calculation\n", + "\n", + "T1 = 393 \t\t\t\t\t\t# [K]\n", + "u = 220 \t\t\t\t\t\t# [micro Poise]\n", + "u = 220*10**-6*10**-1 \t\t\t\t\t# [Pa.s]\n", + "\t# Substituting in equation (1.113) the new values of temperature and viscosity and the \tvalue of B_o, obtained in part (a) while maintaining the pressure conditi# ons unchanged, \twe get N_a\n", + "N_a1 = B_o*P_avg*(P_1-P_2)/(l*T*u*R) \t\t\t# [mole/square m.s]\n", + "v1 = N_a1*R*T/P_atm \t\t\t\t\t# [cubic m(measured at 300 K and 1 atm)/ \t\t\t\t\t\t\tsquare m.s]\t\n", + "\n", + "#Result\n", + "\n", + "print\"The nitrogen flow to be expected at 393 K with the same pressure difference is \",round(v1,3),\"cubic m/sqm.s (measured at 300 K and 1 atm)\" \n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The value of the viscous flow parameter is 4.463e-10 square m\n", + "\n", + "\n", + "The nitrogen flow to be expected at 393 K with the same pressure difference is 0.041 cubic m/sqm.s (measured at 300 K and 1 atm)\n" + ] + } + ], + "prompt_number": 20 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file -- cgit