{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 4 : molecular transport and the general property balance"
     ]
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 4.1 - Page No :99\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math\n",
      "\n",
      "# Variables\n",
      "# given\n",
      "id_ = 2.067;  \t\t\t #[in] - inside diameter\n",
      "t = 0.154;  \t\t\t #[in] - wall thickness\n",
      "od = id_+2*t;  \t\t\t #[in] - outer diameter\n",
      "a = 1.075;  \t\t\t #[in**2] - wall sectional area of metal\n",
      "A = a*(1./144);  \t\t #[ft**2] - wall sectional area of metal in ft**2\n",
      "deltaz = 5./12;  \t\t #[ft] - length of transfer in z direction\n",
      "T2 = 10+273.15;  \t\t #[K] - temperature at the top\n",
      "T1 = 0+273.15;  \t\t #[K] - temperature at the bottom\n",
      "q = -3.2;  \t\t\t     #[Btu/hr] - heat transferred\n",
      "\n",
      "# Calculations\n",
      "deltaT = (T2-T1)+8;  \t\t\t #[degF]\n",
      "k = round(-(q/A)/(deltaT/deltaz),2);\n",
      "\n",
      "# Results\n",
      "print \"Thermal conductivity = %.2f Btu h**-1 ft**-1 degF**-1\"%(k);\n",
      "Alm = round((2*math.pi*deltaz*((od-id_)/(2*12)))/math.log(od/id_),3);  \t\t\t #[ft**2]  log-mean area\n",
      "kincorrect = round(k*(A/Alm),3);\n",
      "print \"kincorrect = %.3f Btu h**-1 ft**-1 degF**-1 \"%(kincorrect);\n",
      "print \"The error is a factor of %.1f\"%(32.4)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Thermal conductivity = 9.92 Btu h**-1 ft**-1 degF**-1\n",
        "kincorrect = 0.306 Btu h**-1 ft**-1 degF**-1 \n",
        "The error is a factor of 32.4\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 4.2 - Page No :100\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math \n",
      "\n",
      "\n",
      "# Variables\n",
      "# given\n",
      "T1 = 0.;     \t\t\t #[degC]\n",
      "T2 = 10.;  \t    \t\t #[degC]\n",
      "km = 17.17;  \t\t\t #[W/m*K]\n",
      "l = 1.;  \t\t    \t #[m]\n",
      "r2 = 1.1875;\n",
      "r1 = 1.0335;\n",
      "deltaT = T1-T2;\n",
      "\n",
      "# Calculations\n",
      "# umath.sing the formula Qr = -km*((2*pi*l)/ln(r2/r1))*deltaT;\n",
      "Qr = -km*((2*math.pi*l)/math.log(r2/r1))*deltaT;\n",
      "\n",
      "# Results\n",
      "print \"Heat loss = %.0f W \\nThe plus sign indicates that the heat flow is radially out from the center\"%(Qr);\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Heat loss = 7767 W \n",
        "The plus sign indicates that the heat flow is radially out from the center\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 4.3 - Page No :100\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "# Variables\n",
      "# given\n",
      "km = 9.92;  \t        \t\t #[Btu/h*ft*degF]\n",
      "Alm = round(0.242*(12./5),3);  \t\t\t #[ft**2]\n",
      "T1 = 0.;  \t\t\t             #[degC]\n",
      "T2 = 10.;             \t\t\t #[degC]\n",
      "deltaT = (T1-T2)*1.8;  \t\t\t #[degF]\n",
      "r2 = 1.1875;\n",
      "r1 = 1.0335;\n",
      "deltar = round((r2-r1)/12,3);  \t\t\t #[ft]\n",
      "\n",
      "# Calculations\n",
      "# using the formula Qr/Alm = -km*(deltaT/deltar)\n",
      "Qr = (-km*Alm*(deltaT/deltar));\n",
      "\n",
      "# Results\n",
      "print \" qr by log-mean area method = %.0f Btu/h\"%(Qr);\n",
      "\n",
      "\n",
      "# in SI units \n",
      "Alm = 0.177;  \t\t\t #[m**2]\n",
      "T1 = 0;  \t\t\t #[degC]\n",
      "T2 = 10;  \t\t\t #[degC]\n",
      "km = 17.17;  \t\t\t #[W/m*K]\n",
      "r2 = 1.1875;\n",
      "r1 = 1.0335;\n",
      "deltaT = T1-T2;\n",
      "deltar = (r2-r1)*0.0254;  \t\t\t #[m]\n",
      "\n",
      "# umath.sing the same formula\n",
      "Qr = (-km*(deltaT/deltar))*Alm;\n",
      "print \" qr in SI units = %.0f W\"%(Qr);\n",
      "\n",
      "# Note : Answers are wrong in book. Please calculate manually."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " qr by log-mean area method = 7980 Btu/h\n",
        " qr in SI units = 7769 W\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 4.4 - Page No :101\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from scipy.integrate import quad \n",
      "\n",
      "# Variables\n",
      "# given\n",
      "x1 = 0;  \t\t\t #[cm]\n",
      "x2 = 30;  \t\t\t #[cm]\n",
      "p1 = 0.3;  \t\t\t #[atm]\n",
      "p2 = 0.03;  \t\t\t #[atm]\n",
      "D = 0.164;  \t\t\t #[am**2/sec]\n",
      "R = 82.057;  \t\t\t #[cm**3*atm/mol*K]\n",
      "T = 298.15;  \t\t\t #[K]\n",
      "\n",
      "# Calculations\n",
      "# using the formula Nax*int(dx/Ax) = -(D/RT)*int(1*dpa)\n",
      "def f4(x): \n",
      "\t return 1./((math.pi/4)*(10-(x/6))**2)\n",
      "\n",
      "a =  quad(f4,x1,x2)[0]\n",
      "\n",
      "def f5(p): \n",
      "\t return 1\n",
      "\n",
      "b =  quad(f5,p1,p2)[0]\n",
      "Nax = -((D/(R*T))*b)/a;\n",
      "\n",
      "# Results\n",
      "print \"Mass transfer rate = %.2e mol/sec = %.2e mol/h  \\nthe plus sign indicates diffusion to the right\"%(Nax,Nax*3600);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Mass transfer rate = 2.37e-06 mol/sec = 8.53e-03 mol/h  \n",
        "the plus sign indicates diffusion to the right\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 4.5 - Page No :105\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from sympy import *\n",
      "\n",
      "# Variables\n",
      "# given\n",
      "r = Symbol('r')\n",
      "ro = 0.5;  \t\t\t #[inch] - outside radius\n",
      "ro = 0.0127;  \t\t #[m] - outside radius in m\n",
      "Tg = 2.*10**7;  \t #[J/m**3*sec] - heat generated by electric current\n",
      "Tw = 30.;  \t\t\t #[degC] - outside surface temperature\n",
      "km = 17.3;  \t\t #[W/m*K] - mean conductivity\n",
      "\n",
      "# Calculations\n",
      "# using the formula T = Tw+(Tg/4*km)*(ro**2-r**2)\n",
      "T = Tw+(Tg/(4*km))*(ro**2-r**2);\n",
      "\n",
      "# Results\n",
      "print \"T = \",T,\n",
      "print \" where r is in meters and T is in degC\"\n",
      "def t(r):\n",
      "    return Tw+(Tg/(4*km))*(ro**2-r**2);\n",
      "\n",
      "print \"At the centre line r = 0, the maximum temperature is %.1f degC. \\\n",
      "\\nAt the outside the temperature reduces to the boundary condition value of %.2f degC.\\\n",
      "\\nThe distribution is parabolic between these 2 limits\"%(t(0),t(0.0127));\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "T =  -289017.341040462*r**2 + 76.6156069364162  where r is in meters and T is in degC\n",
        "At the centre line r = 0, the maximum temperature is 76.6 degC. \n",
        "At the outside the temperature reduces to the boundary condition value of 30.00 degC.\n",
        "The distribution is parabolic between these 2 limits\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 4.7 - Page No :119\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import math\n",
      "\n",
      "# Variables\n",
      "# given\n",
      "r = 10.**-3;  \t\t\t #[m] - radius\n",
      "l = 1.;  \t\t\t     #[m] - length\n",
      "Q = 10.**-7;  \t\t\t #[m**3/s] - flow rate\n",
      "pressure = 1.01325*10**5\n",
      "sPage_No = 1.1;\n",
      "pwater = 1000.;  \t\t #[kg/m**3] - density of water at 4degC\n",
      "\n",
      "# Calculations\n",
      "deltap = round((145 * pressure)/14.696,-4)\n",
      "pfluid = sPage_No *pwater;\n",
      "mu = abs(r*-(deltap)*(math.pi*r**3))/((4*Q)*(2*l));\n",
      "mupoise = mu*10;\n",
      "mucentipoise = mupoise*100;\n",
      "\n",
      "# Results\n",
      "print \" mu = %.3f Ns-m**-2 = %.2f poise = %.0f cP\"%(mu,mupoise,mucentipoise);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " mu = 3.927 Ns-m**-2 = 39.27 poise = 3927 cP\n"
       ]
      }
     ],
     "prompt_number": 2
    }
   ],
   "metadata": {}
  }
 ]
}