{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 08 : Diffusion in Solids"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.1, Page No 180"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#initialisation of variables\n",
      "t = 5.0   # thickness in mm\n",
      "c = 10.0  # concentration\n",
      "D = 1e-9 # diffusion coefficient\n",
      "\n",
      "#Calculations\n",
      "j  = D*c/(t*1e-3)\n",
      "\n",
      "#Results\n",
      "print(\"Outward flux is %.0e kg m^-2 s^-1\" %j)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Outward flux is 2e-06 kg m^-2 s^-1\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.2, Page No 186"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#initialisation of variables\n",
      "D_0 = 0.24e-4 \t# diffusion coefficient\n",
      "Q = 121e3\n",
      "R = 8.314\t# Universal gas constant\n",
      "T = 550 \t# temperature in Celsius\n",
      "k = 0.2 \t# thickness of pure Al sheet in mm\n",
      "d = 0.1 \t# penetration depth in mm\n",
      "c_x = 0.4 \t# concentration in percentage\n",
      "A  = 2.0 \t# Constant in percentage\n",
      "B = 2.0\t\t# Constant in percentage\n",
      "\n",
      "#Calculations\n",
      "x = d-k\n",
      "D_cu_al = D_0*math.exp(-Q/(R*(T+273))) \n",
      "k = (A-c_x)/B\n",
      "if k ==0.8 :\n",
      "    z = 0.9 # from table\n",
      "\n",
      "t = (x*1e-3)**2/(z**2*4*D_cu_al)\t# time in sec\n",
      "\n",
      "#Results\n",
      "print(\"Material can be kept at %d degree Celsius for nearly %d minute\" %(T,(t/60)))\t# answer in book is 100 min\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Material can be kept at 550 degree Celsius for nearly 102 minute\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.3, Page No 188"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#initialisation of variables\n",
      "D_0 = 0.7e-4 \t # diffusion coefficient\n",
      "Q = 157.0\t\t # Energy in kJ mol^-1, considered from table 8.2\n",
      "R = 8.314\t\t # Universal gas constant\n",
      "T = 950.0\t\t # temperature in Celsius\n",
      "c2 = 0.8 \t\t # concentration in percentage\n",
      "cs = 0 \t\t\t # concentration in percentage\n",
      "c_x = 0.6        # concentration in percentage\n",
      "t = 4.0          # time in hours\n",
      "a = 1.0          #let\n",
      "\n",
      "#Calculations\n",
      "A = cs\n",
      "B = c2-cs \n",
      "D = D_0*math.exp(-Q*1e3/(R*(T+273)))\n",
      "k = math.erf(((A-c_x)/B))*-1\n",
      "if k >0.7 :\n",
      "    if k<0.712 :\n",
      "           z = 0.81 # from table\n",
      "\n",
      "x = z*2*math.sqrt(D*t*3600.0)\n",
      "\n",
      "#Results\n",
      "print(\"Depth up to which machining is required is nearly %.2f mm\" %(x*1e3))\n",
      "\n",
      "# numerical value of answer in book is 0.75\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Depth up to which machining is required is nearly 0.72 mm\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.4 Page No 189"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#initialisation of variables\n",
      "D = 4e-17 \t\t# diffusion coefficient\n",
      "c1 = 0\n",
      "cs = 3e26\n",
      "c_x = 1e23 \t\t# number of atoms\n",
      "x = 2e-6 \t\t# depth in m\n",
      "\n",
      "#Calculations\n",
      "A = cs\n",
      "B = cs - c1\n",
      "k = (A-c_x)/B\n",
      "if k >0.99966 :\n",
      "    if k< 0.9997 :\n",
      "        z = 2.55    # from table\n",
      "\n",
      "t = x**2/(z**2*4*D)     # time in sec\n",
      "\n",
      "#Results\n",
      "print(\"Time required to get required boron concentration is %d sec\" %t)   # answer in book is 3845 sec\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Time required to get required boron concentration is 3844 sec\n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 8.5, Page No 194"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "#initialisation of variables\n",
      "r = 10.0   # radius in mm\n",
      "t = 4.0    # thickness in angstrom\n",
      "\n",
      "#Calculations\n",
      "r = 2*math.pi*r*1e-3*t*1e-10/(math.pi*(r*1e-3)**2)\n",
      "\n",
      "#Results\n",
      "print(\"Ratio of cross sectional areas is %.0e \" %r)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Ratio of cross sectional areas is 8e-08 \n"
       ]
      }
     ],
     "prompt_number": 15
    }
   ],
   "metadata": {}
  }
 ]
}