{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 5 Atoms and Ion Moments in Materials "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5_2 pgno:160"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Activation Energy for Interstitial Atoms in cal/mol: 27865.0\n"
     ]
    }
   ],
   "source": [
    "#EXAMPLE 5.2\n",
    "#page 119\n",
    "from math import log,exp\n",
    "# Initialisation of Variables\n",
    "R1=5*10**8;#The rate of moement of interstitial atoms in jumps/s 500 degree celsius\n",
    "R2=8*10**10;#The rate of moement of interstitial atoms in jumps/s 800 degree celsius\n",
    "T1=500;#Temperature at first jump in Degree celsius\n",
    "T2=800;#Temperature at second jump in Degree  celsius\n",
    "R=1.987;#Gas constant in cal/mol-K\n",
    "#CALCULATIONS\n",
    "Q=log(R2/R1)/(exp(1/(R*(T1+273)))-exp(1/(R*(T2+273))));#Activation Energy for Interstitial    Atoms in cal/mol\n",
    "print \"Activation Energy for Interstitial Atoms in cal/mol:\",round(Q)\n",
    "#answer in book is wrong\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5_3 pgno:166"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "concentration gradient in percent/cm: 0.0001\n",
      "concentration gradient in percent/cm**3.cm: -1.995e+19\n"
     ]
    }
   ],
   "source": [
    "# Initialisation of Variables\n",
    "X=0.1;#Thickness of SIlicon Wafer in cm\n",
    "n=8.;#No. of atoms in silicon per cell\n",
    "ni=1.;#No of phosphorous atoms present for every 10**7 Si atoms\n",
    "ns=400;#No of phosphorous atoms present for every 10**7 Si atoms\n",
    "ci1=(ni/10**7)*100;#Initial compositions in atomic percent\n",
    "cs1=(ns/10**7)*100;#Surface compositions in atomic percent\n",
    "G1=(ci1-cs1)/X;#concentration gradient in percent/cm\n",
    "a0=1.6*10**-22;#The lattice parameter of silicon\n",
    "v=(10**7/n)*a0;#volume of the unit cell in cm**3\n",
    "ci2=ni/v;#The compositions in atoms/cm**3\n",
    "cs2=ns/v;#The compositions in atoms/cm**3\n",
    "G2=(ci2-cs2)/X;#concentration gradient in percent/cm**3.cm\n",
    "print \"concentration gradient in percent/cm:\",G1\n",
    "print \"concentration gradient in percent/cm**3.cm:\",G2\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5_4 pgno:167"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "total number no.of Ni atoms per second is  6.17256e+13\n",
      "nickel atoms removed from the Ni/MgO interface is  7.2e-10\n",
      "the thickness is 1.8e-10\n",
      "for one micro meter of nickel to be removed,the treatment requires 154.0\n"
     ]
    }
   ],
   "source": [
    "# Initialisation of Variables\n",
    "cin=8.573*10**22;\n",
    "dx=0.05;\n",
    "d=9*10**-12;\n",
    "j=d*cin/dx;\n",
    "A=2*2;\n",
    "tn=A*j;\n",
    "print \"total number no.of Ni atoms per second is \",tn\n",
    "nm=tn/(8.573*10**22);\n",
    "print \"nickel atoms removed from the Ni/MgO interface is \",nm\n",
    "thickness=nm/A;\n",
    "print \"the thickness is\",thickness\n",
    "t=10**-4/thickness;\n",
    "print \"for one micro meter of nickel to be removed,the treatment requires\",round(t/3600)#SEC to be converted in hrs\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5_5 pgno:171"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Minimum thickness of  the membrane of Natoms in cm 0.013\n",
      "Minimum thickness of  the membrane of Hatoms in cm 0.073\n"
     ]
    }
   ],
   "source": [
    "from math import pi,log,exp\n",
    "# Initialisation of Variables\n",
    "N=1;#N0. of atoms on one side of iron bar\n",
    "H=1;#No. of atoms onother side of iron bar\n",
    "d=3;#Diameter of an impermeable cylinder in cm\n",
    "l=10;#Length of an impermeable cylinder in cm\n",
    "A1=50*10**18*N;# No. of gaseous Atoms per cm**3 on one side \n",
    "A2=50*10**18*H;#No. of gaseous Atom per cm**3 on one  side\n",
    "B1=1*10**18*N;#No. of gaseous atoms per cm**3 on another side\n",
    "B2=1*10**18*H;#No. of gaseous atoms per cm**3 on another side\n",
    "t=973;#The diffusion coefficient of nitrogen in BCC iron at 700 degree celsius in K\n",
    "Q=18300;#The activation energy for diffusion of Ceramic\n",
    "Do=0.0047;#The pre-exponential term of ceramic\n",
    "R=1.987;#Gas constant in cal/mol.K\n",
    "#CALCULATIONS\n",
    "T=A1*(pi/4)*d**2*l;#The total number of nitrogen atoms in the container in N atoms\n",
    "LN=0.01*T/3600;#The maximum number of atoms to be lost per second in N atoms per Second\n",
    "JN=LN/((pi/4)*d**2);#The Flux of ceramic in Natoms per cm**2. sec.\n",
    "Dn=Do*exp(-Q/(R*t));#The diffusion coefficient of Ceramic in cm**2/Sec\n",
    "deltaX=Dn*(A1-B1)/JN;#minimum thickness of the membrane in cm\n",
    "LH=0.90*T/3600;#Hydrogen atom loss per sec.\n",
    "JH=LH/((pi/4)*d**2);#The Flux of ceramic in Hatoms per cm**2. sec.\n",
    "Dh=Do*exp(-Q/(R*t));#The diffusion coeficient of Ceramic in cm**2/Sec\n",
    "deltaX2=((1.86*10**-4)*(A2-B2))/JH;#Minimum thickness of  the membrane in cm\n",
    "print \"Minimum thickness of  the membrane of Natoms in cm\", round(deltaX,3)\n",
    "print \"Minimum thickness of  the membrane of Hatoms in cm\",round(deltaX2,3)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5_6 pgno:174"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The number of tungsten atoms per cm**3: 6.30824936432e+22\n",
      "The number of thorium atoms per cm**3: 6.30824936432e+20\n",
      "The concentration gradient of Tungsten in atoms/cm**3.cm: -6.30824936432e+22\n",
      "The diffusion coeficient  of Tungsten in cm**2/Sec: 2.89066552915e-12\n",
      "Volume Diffusion in Th atoms/cm**2.sec.: 1.82350389868e+11\n",
      "The diffusion coeficient  of Tungsten in cm**2/Sec: 1.64051460984e-09\n",
      "Grain boundry Diffusion in Th atoms/cm**2.sec.: 1.03487752447e+14\n",
      "The Surface diffusion coeficient of Tungsten in cm**2/Sec: 1.93723957013\n",
      "Surface Diffusion in Th atoms/cm**2.sec.: 1.22205902868e+15\n"
     ]
    }
   ],
   "source": [
    "from math import exp\n",
    "# Initialisation of Variables\n",
    "n=2;#no of atoms/ cell in BCC Tungsten\n",
    "a0=3.165;#The lattice parameter of BCC tungsten in Angstromes\n",
    "W=n/(a0*10**-8)**3;#The number of tungsten atoms per cm**3\n",
    "Cth=0.01*W;#The number of thorium atoms per cm**3\n",
    "Cg=-Cth/0.01;#The concentration gradient of Tungsten in atoms/cm**3.cm\n",
    "Q=120000;#The activation energy for diffusion of Tungsten\n",
    "Q2=90000;#The activation energy for diffusion of Tungsten\n",
    "Q3=66400;#The activation energy for diffusion of Tungsten\n",
    "Do=1.0;#The pre-exponential term of Tungsten\n",
    "Do2=0.74;#The pre-exponential term of Tungsten\n",
    "Do3=0.47;#The pre-exponential term of Tungsten\n",
    "R=1.987;#Gas constant in cal/mol.K\n",
    "t=2273;#The diffusion coefficient of nitrogen in BCC iron at 2000 degree celsius in K\n",
    "#CALCULATIONS\n",
    "D1=Do*exp(-Q/(R*t));#The diffusion coeficient  of Tungsten in cm**2/Sec\n",
    "J1=-D1*Cg;#Volume Diffusion in Th atoms/cm**2.sec.\n",
    "D2=Do2*exp(-Q2/(R*t));#The diffusion coeficient  of Tungsten in cm**2/Sec\n",
    "J2=-D2*Cg;#Grain boundary Diffusion in Th atoms/cm**2.sec.\n",
    "D3=0.47*exp(-66400/(1.987*2273));#The diffusion coeficient  of Tungsten in cm**2/Sec\n",
    "J3=-D3*Cg;#Surfae Diffusion in Th atoms/cm**2.sec.\n",
    "\n",
    "print \"The number of tungsten atoms per cm**3:\",W\n",
    "print \"The number of thorium atoms per cm**3:\",Cth\n",
    "print \"The concentration gradient of Tungsten in atoms/cm**3.cm:\",Cg\n",
    "print \"The diffusion coeficient  of Tungsten in cm**2/Sec:\",D1\n",
    "print \"Volume Diffusion in Th atoms/cm**2.sec.:\",J1\n",
    "print \"The diffusion coeficient  of Tungsten in cm**2/Sec:\",D2\n",
    "print \"Grain boundry Diffusion in Th atoms/cm**2.sec.:\",J2\n",
    "print \"The Surface diffusion coeficient of Tungsten in cm**2/Sec:\",D3*10**7\n",
    "print \"Surface Diffusion in Th atoms/cm**2.sec.:\",J3/10\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5_7 pgno:178"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "the combution temperatures are [ 39.09194444  14.38111111   5.29041667   1.94625   ]\n"
     ]
    }
   ],
   "source": [
    "import numpy\n",
    "from math import exp\n",
    "T=numpy.array([1173, 1273, 1373, 1473])#kelvins\n",
    "t=numpy.array([0, 0, 0, 0])\n",
    "#in K\n",
    "t[0]=0.0861/exp(-16558/T[0])\n",
    "t[1]=0.0861/exp(-16558/T[1])\n",
    "t[2]=0.0861/exp(-16558/T[2])\n",
    "t[3]=0.0861/exp(-16558/T[3])\n",
    "print \"the combution temperatures are\",(0.5*t/3600)\n",
    "#the difference in asnwer is due to round off error\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 5_8 pgno:180"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Time requried to  successfully carburize a batch of 500 steel gears at 1000 degree centigrade: 3.2993917076\n",
      "The cost of carburizing per Part of steel rods  at 900 degree centigrade 20\n",
      "The cost of carburizing per Part of steel rods  at 1000 degree centigrade 9.9\n"
     ]
    }
   ],
   "source": [
    "from math import exp\n",
    "# Initialisation of Variables\n",
    "H=10;#Required time to successfully carburize a batch of 500 steel gears\n",
    "t1=1173;#Temperature at carburizing a batch of   500 steel gears in K\n",
    "t2=1273;#Temperature at carburizing a batch of   500 steel gears in K\n",
    "Q=32900;#The activation energy for diffusion  of BCC steel\n",
    "R=1.987;#Gas constant in cal/mol.K\n",
    "c1=1000;#cost per hour to operate the carburizing furnace at 900\u0002degree centigrades\n",
    "c2=1500;#Cost per hour to operate the carburizing furnace at 1000 degree centigrade\n",
    "H2=(exp(-Q /(R*t1))*H*3600)/exp(-Q /(R*t2));# Time requried to  successfully carburize a batch of 500 steel gears at 1000 degree centigrade\n",
    "Cp1=c1*H/500;#The cost per Part of steel rods  at 900 degree centigrade\n",
    "Cv=(c2*3.299)/500;#The cost per Part of steel rods  at 1000 degree centigrade\n",
    "print \"Time requried to  successfully carburize a batch of 500 steel gears at 1000 degree centigrade:\",H2/3600\n",
    "print \"The cost of carburizing per Part of steel rods  at 900 degree centigrade\",Cp1\n",
    "print \"The cost of carburizing per Part of steel rods  at 1000 degree centigrade\",round(Cv,2)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
