{
 "metadata": {
  "celltoolbar": "Raw Cell Format",
  "name": "",
  "signature": "sha256:c884249c28dc1486b445f3d4013b1d4277c7f2f132398c648a2fa82d33db0def"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 1: Crystallography"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.3.1,Page number 1-14"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#given data\n",
      "\n",
      "A=26.98                                 #atomic weight of Al\n",
      "N=6.023*10**26                          #Avogadro's number\n",
      "p=2700                                  #Density\n",
      "n=4                                     #FCC structure\n",
      "\n",
      "a=(n*A/(N*p))**(1./3)\n",
      "\n",
      "print\"Unit cell dimension of Al=\",\"{0:.3e}\".format(a),\"m\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Unit cell dimension of Al= 4.049e-10 m\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.3.2,Page number 1-15"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#given data\n",
      "\n",
      "As=28.1                                 #atomic weight of Si\n",
      "Ag=69.7                                 #atomic weight of Ga\n",
      "Aa=74.9                                 #atomic weight of As\n",
      "a_s=5.43*10**-8                         #lattice constant of Si\n",
      "aga=5.65*10**-8                         #lattice constant of GaAs\n",
      "ns=8                                    #no of atoms/unit cell in Si\n",
      "nga=4                                   #no of atoms/unit cell in GaAs\n",
      "N=6.023*10**23                          #Avogadro's number\n",
      "\n",
      "#p=(n*A)/(N*a**3) this is formula for density\n",
      "\n",
      "#for Si\n",
      "\n",
      "ps=(ns*As)/(N*a_s**3)\n",
      "\n",
      "print\"1) Density of Si=\",round(ps,4),\"gm/cm^3\"\n",
      "\n",
      "#for GaAs\n",
      "\n",
      "Aga=Ag+Aa                               #molecular wt of GaAs\n",
      "\n",
      "pga=(nga*Aga)/(N*aga**3)\n",
      "\n",
      "print\"2) Density of GaAs=\",round(pga,4),\"gm/cm^3\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "1) Density of Si= 2.3312 gm/cm^3\n",
        "2) Density of GaAs= 5.3244 gm/cm^3\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.3.3,Page number 1-16"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#given data\n",
      "\n",
      "A=63.5                                  #atomic weight of Cu\n",
      "N=6.023*10**23                          #Avogadro's number\n",
      "n=4                                     #FCC structure\n",
      "r=1.28*10**-8                            #atomic radius of Cu\n",
      "\n",
      "#for FCC\n",
      "\n",
      "a=4*r/(sqrt(2))                         #lattice constant\n",
      "p=(n*A)/(N*a**3)\n",
      "\n",
      "print\"Density of Cu=\",round(p,4),\"gm/cm^3\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Density of Cu= 8.887 gm/cm^3\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.3.4,Page number 1-17"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#given data\n",
      "\n",
      "A=50                                    #atomic weight of chromium\n",
      "N=6.023*10**23                          #Avogadro's number\n",
      "p=5.96                                  #Density\n",
      "n=2                                     #BCC structure\n",
      "\n",
      "#step 1 : claculation for lattice constant (a)\n",
      "\n",
      "a=(n*A/(N*p))**(1./3)\n",
      "\n",
      "#step 2 : radius of an atom in BCC\n",
      "\n",
      "r=sqrt(3)*a/4\n",
      "\n",
      "#step 3 : Atomic packing factor (APF)\n",
      "\n",
      "APF=n*((4./3)*math.pi*r**3)/a**3\n",
      "\n",
      "print\"Atomic packing factor (APF)=\",round(APF,4)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Atomic packing factor (APF)= 0.6802\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.3.5,Page number 1-17"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#given data\n",
      "\n",
      "A=120                                   #atomic weight of chromium\n",
      "N=6.023*10**23                          #Avogadro's number\n",
      "p=5.2                                   #Density\n",
      "n=2                                     #BCC structure\n",
      "m=20                                    #mass\n",
      "\n",
      "#step 1 : claculation for volume of unit cell(a**3)\n",
      "\n",
      "a=(n*A/(N*p))\n",
      "\n",
      "#step 2 : volume of 20 gm of the element\n",
      "\n",
      "v=m/p\n",
      "\n",
      "#step 3 :no of unit cell\n",
      "\n",
      "x=v/a\n",
      "\n",
      "print\"no of unit cell=\",\"{0:.3e}\".format(x)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "no of unit cell= 5.019e+22\n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.3.6,Page number 1-18"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#given data\n",
      "\n",
      "A=132.91                                 #atomic weight of chromium\n",
      "N=6.023*10**26                           #Avogadro's number\n",
      "p=1900                                   #Density\n",
      "a=6.14*10**-10                           #lattice constant\n",
      "\n",
      "#step 1 : type of structure\n",
      "\n",
      "n=(p*N*a**3)/A\n",
      "\n",
      "print\"n =\",round(n)\n",
      "\n",
      "print\"BCC structure\"\n",
      "\n",
      "#step 2: no of atoms/m**3\n",
      "\n",
      "x=n/a**3\n",
      "\n",
      "print\"no of atoms/m^3=\",\"{0:.3e}\".format(x)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "n = 2.0\n",
        "BCC structure\n",
        "no of atoms/m^3= 8.610e+27\n"
       ]
      }
     ],
     "prompt_number": 21
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.3.7,Page number 1-18"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#given data\n",
      "\n",
      "a=0.4049*10**-9                          #lattice constant\n",
      "t=0.006*10**-2                           #thickness of Al foil\n",
      "A=50*10**-4                              #Area of foil\n",
      "\n",
      "V1=a**3                                  #volume of unit cell\n",
      "\n",
      "V=A*t                                   #volume of the foil\n",
      "\n",
      "N=V/V1                                  #no of unit cell in the foil\n",
      "\n",
      "print\"no of unit cell in the foil=\",\"{0:.3e}\".format(N)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "no of unit cell in the foil= 4.519e+21\n"
       ]
      }
     ],
     "prompt_number": 23
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.5.1,Page number 1-29"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#given data\n",
      "\n",
      "#refer diagram from textbook\n",
      "\n",
      "#on joining centre of 3 anions,an equilateral triangle is formed and on joining centres of any anion and cation  a right angle triangle ABC os formed\n",
      "\n",
      "#where AC=rc+ra\n",
      "\n",
      "#and BC=ra\n",
      "\n",
      "#m(angle (ACB))=30 degree\n",
      "\n",
      "#therefore cos (30)=ra/(rc+ra)\n",
      "\n",
      "#assume rc/ra=r\n",
      "\n",
      "r=(1.0-math.cos(30.0*math.pi/180))/math.cos(math.pi*30/180)                 #by arrangimg terms we get value of r\n",
      "\n",
      "print\"critical radius ratio of ligancy 3=\",round(r,4)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "critical radius ratio of ligancy 3= 0.1547\n"
       ]
      }
     ],
     "prompt_number": 33
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.5.2,Page number 1-30"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#given data\n",
      "\n",
      "#refer diagram from textbook\n",
      "\n",
      "#in the said arrangement a cation is squeezed into 4 anions in a plane and 5th anion is in upper layer and 6th in bottom layer \n",
      "\n",
      "#join cation anion centres E and B and complete the triangle EBF\n",
      "\n",
      "#in triangle EBF m(angle F)=90 and EF=BF\n",
      "\n",
      "#m(angle B)=m(angle E)=45\n",
      "\n",
      "#and EB=rc+ra and BF=ra\n",
      "\n",
      "#cos(45)=ra/(rc+ra)\n",
      "\n",
      "#assume rc/ra=r\n",
      "\n",
      "r=(1-math.cos(45*math.pi/180))/math.cos(45*math.pi/180)                 #by arrangimg terms we get value of r\n",
      "\n",
      "print\"critical radius ratio for ligancy 6 =\",round(r,4)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.5.3,Page number 1-30"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#given data\n",
      "\n",
      "#refer diagram from textbook\n",
      "\n",
      "#since plane is square hence it is same as ligancy 6\n",
      "\n",
      "#in the said arrangement a cation is squeezed into 4 anions in a plane and 5th anion is in upper layer and 6th in bottom layer \n",
      "\n",
      "#join cation anion centres E and B and complete the triangle EBF\n",
      "\n",
      "#in triangle EBF m(angle F)=90 and EF=BF\n",
      "\n",
      "#m(angle B)=m(angle E)=45\n",
      "\n",
      "#and EB=rc+ra and BF=ra\n",
      "\n",
      "#cos(45)=ra/(rc+ra)\n",
      "\n",
      "#assume rc/ra=r\n",
      "\n",
      "r=(1-math.cos(45*math.pi/180))/math.cos(45*math.pi/180)                 #by arrangimg terms we get value of r\n",
      "\n",
      "print\"critical radius ratio for ligancy 8 =\",round(r,4)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "critical radius ratio for ligancy 8 = 0.4142\n"
       ]
      }
     ],
     "prompt_number": 38
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.5.4,Page number 1-31"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#given data\n",
      "\n",
      "#a tetrahedron CAEH can be considered with C as the apex of the tetrahedron.\n",
      "\n",
      "#the edges AE,AH and EH of the tetrahedron will then be the face of the cube faces ABEF,ADHF,EFHG resp.\n",
      "\n",
      "#from fig\n",
      "\n",
      "#AO=ra+rc and AJ=ra\n",
      "\n",
      "#AE=root(2)*a and AG=root(3)*a\n",
      "\n",
      "#AO/AJ=AG/AE=(ra+rc)/ra=root(3)*a/root(2)*a\n",
      "\n",
      "#assume rc/ra=r\n",
      "r=(math.sqrt(3)-math.sqrt(2))/math.sqrt(2)\n",
      "\n",
      "print\"critical radius ratio for ligancy 4 = \",round(r,4)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "critical radius ratio for ligancy 4 =  0.2247\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.5.5,Page number 1-32"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#given data\n",
      "\n",
      "#ligancy 8 represents cubic arrangment .8 anions are at the corners and touch along cube edgs.Along the body diagonal the central cation and the corner anion are in contact.\n",
      "\n",
      "#cube edge=2*ra\n",
      "\n",
      "#refer diagram from textbook\n",
      "\n",
      "#and body diagonal=root(3)*cube edge=root(3)[2*(rc+ra)]\n",
      "\n",
      "#assume rc/ra=r\n",
      "\n",
      "r=math.sqrt(3)-1.0\n",
      "\n",
      "print\"critical radius ratio of ligancy 8=\",round(r,4)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "critical radius ratio of ligancy 8= 0.7321\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.5.6,Page number 1-32"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#given data\n",
      "\n",
      "#for an ionic crystal exibiting HCP structure the arrangment of ions refere from textbook\n",
      "\n",
      "#at centre we have a cation with radius rc=OA\n",
      "\n",
      "#it is an touch with 6 anions with radius ra=AB\n",
      "\n",
      "#OB=OC=ra+rc\n",
      "\n",
      "#intrangle ODB ,m(angle (OBC))=60 degree ,m(angle (ODB))=90 degree\n",
      "\n",
      "#therefore cos(60)=BD/OB=AB/(OA+OB)=ra/(rc+ra)\n",
      "\n",
      "#assume rc/ra=r\n",
      "\n",
      "r=(1.-math.cos(60*math.pi/180))/math.cos(60*math.pi/180)                 #by arrangimg terms we get value of r\n",
      "\n",
      "print\"critical radius ratio 0f HCP structure=\",round(r,4)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "critical radius ratio 0f HCP structure= 1.0\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.6.2,Page number 1-35"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#given data\n",
      "\n",
      "#intercept of planeare in proportion a,b/3,2*c\n",
      "\n",
      "#as a,b and c are basic vectors the proportin of intercepts 1:1/3:2\n",
      "\n",
      "#therefore reciprocal\n",
      "\n",
      "r1=1\n",
      "\n",
      "r2=3\n",
      "\n",
      "r3=1./2\n",
      "\n",
      "#taking LCM of 2 and 1 is 2\n",
      "\n",
      "l=2\n",
      "\n",
      "m1=(l*r1)\n",
      "\n",
      "m2=(l*r2)\n",
      "\n",
      "m3=(l*r3)\n",
      "\n",
      "print\"miler indices=\",m3,m2,m1\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "miler indices= 1.0 6 2\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.6.4,Page number 1-38"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#given data\n",
      "\n",
      "r=1.414                                 #atomic radius in amstrong unit\n",
      "\n",
      "#for FCC structure\n",
      "\n",
      "a=4*r/math.sqrt(2)\n",
      "\n",
      "#part 1: plane(2,0,0)\n",
      "\n",
      "#the interplanar spacing of plane\n",
      "\n",
      "h1=2\n",
      "k1=0\n",
      "l1=0\n",
      "\n",
      "#we know that d=a/sqrt(h**2+k**2+l**2)\n",
      "\n",
      "d1=a/sqrt(h1**2+k1**2+l1**2)\n",
      "\n",
      "print\"1)interplanar spacing for (2,0,0) plane=\",round(d1,4),\"amstrong\"\n",
      "\n",
      "#part 2: plane(1,1,1)\n",
      "\n",
      "#the interplanar spacing of plane\n",
      "\n",
      "h2=1\n",
      "k2=1\n",
      "l2=1\n",
      "\n",
      "#we know that d=a/sqrt(h**2+k**2+l**2)\n",
      "\n",
      "d2=a/sqrt(h2**2+k2**2+l2**2)\n",
      "\n",
      "print\"2)interplanar spacing for(1,1,1) plane=\",round(d2,4),\"amstrong\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "1)interplanar spacing for (2,0,0) plane= 1.9997 amstrong\n",
        "2)interplanar spacing for(1,1,1) plane= 2.3091 amstrong\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.14.1,Page number 1-58"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#given data\n",
      "\n",
      "n=4                                     #FCC structure\n",
      "ro=2180                                 #density of NaCl\n",
      "M=23+35.5                               #molecular weight of NaCl\n",
      "N=6.023*10**26                          #Avogadro's number\n",
      "\n",
      "a=((n*M)/(N*ro))**(1.0/3)\n",
      "\n",
      "print\"Lattice constant=\",\"{0:.3e}\".format(a),\"m\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Lattice constant= 5.627e-10 m\n"
       ]
      }
     ],
     "prompt_number": 18
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.14.2,Page number 1-58"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#given data\n",
      "\n",
      "n=4                                     #FCC structure\n",
      "ro=8.9                                  #density of Cu atom\n",
      "A=63.55                                 #atomic weight of Cu atom\n",
      "N=6.023*10**23                          #Avogadro's number\n",
      "\n",
      "a=((n*A)/(N*ro))**(1./3)\n",
      "\n",
      "print\"1) Lattice constant=\",\"{0:.3e}\".format(a),\"cm\"\n",
      "\n",
      "r=math.sqrt(2)*a/4                       #radius of Cu atom\n",
      "\n",
      "d=2*r                                    #diameter of Cu atom\n",
      "\n",
      "print\"2) Diameter of Cu atom=\",\"{0:.3e}\".format(d),\"cm\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "1) Lattice constant= 3.620e-08 cm\n",
        "2) Diameter of Cu atom= 2.559e-08 cm\n"
       ]
      }
     ],
     "prompt_number": 25
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.14.3,Page number 1-59"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#given data\n",
      "\n",
      "n=8                                     #diamond structure\n",
      "A=12.01                                 #atomic wt\n",
      "N=6.023*10**23                          #Avogadro's number\n",
      "a=3.75*10**-8                           #lattice constant of diamond\n",
      "\n",
      "ro=(n*A)/(N*(a**3))\n",
      "\n",
      "print\"Density of diamond=\",round(ro,4),\"gm/cc\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Density of diamond= 3.025 gm/cc\n"
       ]
      }
     ],
     "prompt_number": 27
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.14.4,Page number 1-59"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#given data\n",
      "\n",
      "#intercept of planeare in proportion 3a:4b:infinity (plane parallel to z axis)\n",
      "\n",
      "#as a,b and c are basic vectors the proportin of intercepts 3:4:infinity\n",
      "\n",
      "#therefore reciprocal\n",
      "\n",
      "r1=1./3\n",
      "r2=1./4\n",
      "r3=0\n",
      "\n",
      "#taking LCM of 3 and 4 i.e. 12\n",
      "\n",
      "l=12\n",
      "\n",
      "m1=(l*r1)\n",
      "\n",
      "m2=(l*r2)\n",
      "\n",
      "m3=(l*r3)\n",
      "\n",
      "print\"miler indices=\",(m3,m2,m1)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "miler indices= (0, 3.0, 4.0)\n"
       ]
      }
     ],
     "prompt_number": 29
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.14.5,Page number 1-59"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#given data\n",
      "\n",
      "#intercept of planeare in proportion 3a:-2b:3/2c\n",
      "\n",
      "#as a,b and c are basic vectors the proportin of intercepts 3:-2:3/2\n",
      "\n",
      "#therefore reciprocal\n",
      "\n",
      "r1=1./3\n",
      "r2=-1./2\n",
      "r3=2./3\n",
      "\n",
      "#taking LCM of 3, 2 and 3/2 is 6\n",
      "\n",
      "l=6\n",
      "\n",
      "m1=(l*r1)\n",
      "\n",
      "m2=(l*r2)\n",
      "\n",
      "m3=(l*r3)\n",
      "\n",
      "print\"miler indices=\",(m3,m2,m1)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "miler indices= (4.0, -3.0, 2.0)\n"
       ]
      }
     ],
     "prompt_number": 31
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.14.6,Page number 1-59"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#given data\n",
      "\n",
      "#if a plane cut at length m,n,p on the three crystal axes,then\n",
      "\n",
      "#m:n:p=xa:yb:zc\n",
      "\n",
      "#when primitive vectors of unit cell and numbers x,y,z,are related to miller indices (h,k,l)of the plane by relation\n",
      "\n",
      "#1/x:1/y:1/z=h:k:l\n",
      "\n",
      "#since a=b=c (crystal is simple cubic)\n",
      "\n",
      "#and (h,k,l)=(1,2,3)\n",
      "\n",
      "#therefore reciprocal\n",
      "\n",
      "r1=1./1\n",
      "r2=1./2\n",
      "r3=1./3\n",
      "\n",
      "#taking LCM of 1 ,2 and 3 is 6\n",
      "\n",
      "l=6\n",
      "\n",
      "m=(l*r1)\n",
      "\n",
      "n=(l*r2)\n",
      "\n",
      "p=(l*r3)\n",
      "\n",
      "print\"ratio of intercepts=\",(m,n,p)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "ratio of intercepts= (6.0, 3.0, 2.0)\n"
       ]
      }
     ],
     "prompt_number": 35
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.14.7,Page number 1-60"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#given data\n",
      "\n",
      "#primitive vectors\n",
      "\n",
      "a=1.2                                   #in amstrong unit\n",
      "b=1.8                                   #in amstrong unit\n",
      "c=2                                    #in amstrong unit\n",
      "\n",
      "#miller indices of the plane\n",
      "\n",
      "h=2\n",
      "k=3\n",
      "l=1\n",
      "\n",
      "#therefore intercepts are a/h,b/k,c/l\n",
      "\n",
      "x=a/h\n",
      "y=b/k\n",
      "z=c/l\n",
      "\n",
      "#this gives intercepts along x axis as x amstrong but it is given tthat plane cut x axis at 1.2 amstrong .\n",
      "\n",
      "t=1.2/x\n",
      "\n",
      "#this shows that the plane under consideration is another plane which is parallel to it(to keep miller indices same)\n",
      "\n",
      "n=t*y                                   #Y intercept\n",
      "\n",
      "p=t*z                                   #Z intercept\n",
      "\n",
      "print\"1) Y intercept=\",n,\"amstrong\"\n",
      "\n",
      "print\"2)Z intercept=\",p,\"amstrong\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "1) Y intercept= 1.2 amstrong\n",
        "2)Z intercept= 4.0 amstrong\n"
       ]
      }
     ],
     "prompt_number": 37
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.14.8,Page number 1-61"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#given data\n",
      "\n",
      "#the interplanar spacing of plane\n",
      "\n",
      "h=1\n",
      "k=1\n",
      "l=0\n",
      "d=2                                     #interpanar spacing in amstrong unit\n",
      "\n",
      "#we know that d=a/sqrt(h**2+k**2+l**2) therefore\n",
      "\n",
      "a=d*math.sqrt(h**2+k**2+l**2)\n",
      "\n",
      "#for FCC structure\n",
      "\n",
      "r=math.sqrt(2)*a/4\n",
      "\n",
      "print\"radius r=\",(r),\"amstrong\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "radius r= 1.0 amstrong\n"
       ]
      }
     ],
     "prompt_number": 39
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.14.9,Page number 1-61"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#given data\n",
      "\n",
      "n=4                                     #for FCC structure\n",
      "\n",
      "#the interplanar spacing of plane\n",
      "\n",
      "h=1\n",
      "k=1\n",
      "l=1\n",
      "d=2.08*10**-10                          #distance\n",
      "A=63.54                                 #atomic weight of Cu\n",
      "N=6.023*10**26                          #amstrong no\n",
      "\n",
      "#we know that d=a/sqrt(h**2+k**2+l**2) therefore\n",
      "\n",
      "a=d*math.sqrt(h**2+k**2+l**2)\n",
      "\n",
      "#also (a**3*q)=n*A/N\n",
      "\n",
      "q=n*A/(N*a**3)\n",
      "\n",
      "print\"1)density=\",round(q,4),\"kg/m^3\"\n",
      "\n",
      "#for FCC structure\n",
      "\n",
      "r=math.sqrt(2)*a/4\n",
      "\n",
      "d=r*2\n",
      "\n",
      "print\"2)radius r=\",\"{0:.3e}\".format(r),\"m\"\n",
      "\n",
      "print\"3)diameter d=\",\"{0:.3e}\".format(d),\"m\"\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "1)density= 9024.4855 kg/m^3\n",
        "2)radius r= 1.274e-10 m\n",
        "3)diameter d= 2.547e-10 m\n"
       ]
      }
     ],
     "prompt_number": 44
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.14.10,Page number 1-62"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#given data\n",
      "\n",
      "A=63.546                                #atomic weight of Cu\n",
      "N=6.023*10**26                           #Avogadro's number\n",
      "p=8930                                  #Density\n",
      "n=1.23                                  #no.of electron per atom\n",
      "\n",
      "#density=mass/volume\n",
      "\n",
      "#therfore 1/volume=density/mass\n",
      "\n",
      "#since electron concentration is needed, let us find out no of atoms/volume(x)\n",
      "\n",
      "x=N*p/A\n",
      "\n",
      "#now one atom contribute n=1.23 electron\n",
      "\n",
      "#therefore x atoms contribute  y no of free electron\n",
      "\n",
      "y=x*n\n",
      "\n",
      "print\"free electron concentration=\",\"{0:.3e}\".format(y),\"electron/m^3\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "free electron concentration= 1.041e+29 electron/m^3\n"
       ]
      }
     ],
     "prompt_number": 46
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.14.11,Page number 1-62"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#given data\n",
      "\n",
      "#primitive vectors\n",
      "\n",
      "a=1.5                                   #in amstrong unit\n",
      "b=2                                     #in amstrong unit\n",
      "c=4.                                    #in amstrong unit\n",
      "\n",
      "#miller indices of the plane\n",
      "\n",
      "h=3\n",
      "k=2\n",
      "l=6\n",
      "\n",
      "#therefore intercepts are a/h,b/k,c/l\n",
      "\n",
      "x=a/h\n",
      "y=b/k\n",
      "z=c/l\n",
      "\n",
      "#this gives intercepts along x axis as x amstrong but it is given that plane cut x axis at 1.2 amstrong .\n",
      "\n",
      "t=1.5/x\n",
      "\n",
      "#this shows that the plane under consideration is another plane which is parallel to it(to keep miller indices same)\n",
      "\n",
      "n=t*y                                   #Y intercept\n",
      "\n",
      "p=t*z                                   #Z intercept\n",
      "\n",
      "print\"1) Y intercept=\",(n),\"amstrong\"\n",
      "\n",
      "print\"2)Z intercept=\",(p),\"amstrong\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "1) Y intercept= 3.0 amstrong\n",
        "2)Z intercept= 2.0 amstrong\n"
       ]
      }
     ],
     "prompt_number": 48
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.14.12,Page number 1-63"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#given data\n",
      "\n",
      "ro=7.87                                 #density of metal\n",
      "A=55.85                                 #atomic wt of metal\n",
      "N=6.023*10**23                          #Avogadro's number\n",
      "a=2.9*10**-8                            #lattice constant of metal\n",
      "\n",
      "n=(N*(a**3)*ro)/A\n",
      "\n",
      "print\"Number of atom per unit cell of a metal=\",round(n,0)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Number of atom per unit cell of a metal= 2.0\n"
       ]
      }
     ],
     "prompt_number": 52
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.14.13,Page number 1-63"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#given data\n",
      "\n",
      "n=2                                     #BCC structure\n",
      "ro=9.6*10**2                             #density of sodium crystal\n",
      "A=23                                    #atomic weight of sodium crystal\n",
      "N=6.023*10**26                           #Avogadro's number\n",
      "\n",
      "a=((n*A)/(N*ro))**(1./3)\n",
      "\n",
      "print\"Lattice constant=\",\"{0:.3e}\".format(a),\"m\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Lattice constant= 4.301e-10 m\n"
       ]
      }
     ],
     "prompt_number": 50
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.14.15,Page number 1-64"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#given data\n",
      "\n",
      "ro=2.7*10**3                             #density of metal\n",
      "A=27                                    #atomic wt of metal\n",
      "N=6.023*10**26                           #Avogadro's number\n",
      "a=4.05*10**-10                           #lattice constant of metal\n",
      "\n",
      "n=(N*(a**3)*ro)/A\n",
      "\n",
      "print\"1) Number of atom per unit cell of a metal=\",round(n,0)\n",
      "\n",
      "r=math.sqrt(2)*a/4                           #radius of metal\n",
      "\n",
      "print\"2) atomic radius of a metal=\",\"{0:.3e}\".format(r),\"m\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "1) Number of atom per unit cell of a metal= 4.0\n",
        "2) atomic radius of a metal= 1.432e-10 m\n"
       ]
      }
     ],
     "prompt_number": 56
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.14.16,Page number 1-64"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#given data\n",
      "\n",
      "n=2                                     #BCC structure\n",
      "ro=5.98*10**3                           #density of chromium\n",
      "A=50                                    #atomic wt of chromium\n",
      "N=6.023*10**26                          #Avogadro's number\n",
      "\n",
      "a=((n*A)/(N*ro))**(1./3)\n",
      "\n",
      "print\"1) Lattice constant=\",\"{0:.3e}\".format(a),\"m\"\n",
      "\n",
      "#for BCC\n",
      "\n",
      "r=math.sqrt(3)*a/4                           #radius of chromium\n",
      "\n",
      "APF=(n*(4./3)*math.pi*(r**3))/(a**3)\n",
      "\n",
      "print\"2) A.P.F. for chromium=\",round(APF,4)\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "1) Lattice constant= 3.028e-10 m\n",
        "2) A.P.F. for chromium= 0.6802\n"
       ]
      }
     ],
     "prompt_number": 60
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.14.17,Page number 1-65"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#given data\n",
      "\n",
      "n=4                                     #FCC structure\n",
      "ro=6250                                 #density\n",
      "M=60.2                                  #molecular weight\n",
      "N=6.023*10**26                           #Avogadro's number\n",
      "\n",
      "a=((n*M)/(N*ro))**(1./3)\n",
      "\n",
      "print\"Lattice constant=\",\"{0:.3e}\".format(a),\"m\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Lattice constant= 3.999e-10 m\n"
       ]
      }
     ],
     "prompt_number": 62
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.14.19,Page number 1-66"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#given data\n",
      "\n",
      "a=2.82*10**-9                           #lattice constant\n",
      "n=2                                     #FCC crystal\n",
      "t=17.167                                #glancing angle in degree\n",
      "q=math.pi/180*t                         #glancing angle in radians\n",
      "\n",
      "#assuming reflection in (1,0,0) plane\n",
      "\n",
      "h=1\n",
      "k=0\n",
      "l=0\n",
      "\n",
      "d=a/math.sqrt(h**2+k**2+l**2)\n",
      "\n",
      "#using Bragg's law , 2*d*sin(q)=n*la\n",
      "\n",
      "la=2*d*sin(q)/n\n",
      "\n",
      "print\"wavlength of X-ray=\",\"{0:.3e}\".format(la),\"m\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "wavlength of X-ray= 8.323e-10 m\n"
       ]
      }
     ],
     "prompt_number": 64
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.14.20,Page number 1-66"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#given data\n",
      "\n",
      "n=8                                     #Diamond structure\n",
      "ro=2.33*10**3                           #density of diamond\n",
      "M=28.9                                  #atomic  weight of diamond\n",
      "N=6.023*10**26                          #Avogadro's number\n",
      "\n",
      "a=((n*M)/(N*ro))**(1./3)\n",
      "\n",
      "print\"1) Lattice constant=\",\"{0:.3e}\".format(a),\"m\"\n",
      "\n",
      "r=math.sqrt(3)*a/8                           #radius of diamond structure\n",
      "\n",
      "print\"2) atomic radius of a metal=\",\"{0:.3e}\".format(r),\"m\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "1) Lattice constant= 5.482e-10 m\n",
        "2) atomic radius of a metal= 1.187e-10 m\n"
       ]
      }
     ],
     "prompt_number": 66
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.14.21,Page number 1-66"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#given data\n",
      "\n",
      "n=2                                     #BCC structure\n",
      "ro=8.57*10**3                            #density of chromium\n",
      "d=2.86*10**-10                           #nearest atoms distance\n",
      "\n",
      "#d=sqrt(3)/2*a\n",
      "\n",
      "a=2*d/math.sqrt(3)\n",
      "\n",
      "#now use formulae a**3*ro=n*A/N\n",
      "\n",
      "#therefore a**3*ro/n=mass of unit cell/(no of atoms pre unit cell)=mass of one atom\n",
      "\n",
      "m=a**3*ro/n\n",
      "\n",
      "print\"mass of one atom=\",\"{0:.3e}\".format(m),\"kg\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "mass of one atom= 1.543e-25 kg\n"
       ]
      }
     ],
     "prompt_number": 68
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.15.1,Page number 1-68"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#given data\n",
      "\n",
      "d=4.255*10**-10                          #interplaner spacing\n",
      "l=1.549*10**-10                          #wavelength of x ray\n",
      "\n",
      "#part 1: for smallest glancing angle(n=1)\n",
      "\n",
      "n1=1\n",
      "\n",
      "#using Bragg's law n*l=2*d*sin(q)\n",
      "\n",
      "q=math.degrees(math.asin(n1*l/(2*d)))\n",
      "\n",
      "print\"1)glancing angle=\",round(q,4),\"degree\"\n",
      "\n",
      "#part 2: for highst order\n",
      "\n",
      "#for highest order sin(q) not exceed one i.e maximum value is one\n",
      "\n",
      "#using Bragg's law n*l=2*d*sin(q)\n",
      "\n",
      "n2=2*d/l                                #since sin(q)is one\n",
      "\n",
      "print\"2)highest order possible =\",math.floor(n2)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "1)glancing angle= 10.4875 degree\n",
        "2)highest order possible = 5.0\n"
       ]
      }
     ],
     "prompt_number": 70
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.15.2,Page number 1-69"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#given data\n",
      "\n",
      "a=2.125*10**-10                          #lattice constant\n",
      "d=a/2                                   #interplaner spacing\n",
      "n=2                                     #second order maximum\n",
      "l=0.592*10**-10                          #wavelength of rock salt crystal\n",
      "\n",
      "#using Bragg's law\n",
      "\n",
      "q=math.degrees(math.asin((n*l)/(2*d)))                    #glancing angle\n",
      "\n",
      "print\"glancing angle=\",round(q,4),\"degree\"\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "glancing angle= 33.8608 degree\n"
       ]
      }
     ],
     "prompt_number": 72
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.15.3,Page number 1-69"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#given data\n",
      "\n",
      "n1=1                                    #for 1st order\n",
      "n2=2                                    #for 2nd order\n",
      "t=3.4                                   #angle where 1st order reflection done\n",
      "t1=t*math.pi/180                        #convert degree to radian\n",
      "\n",
      "m=math.sin(t1)\n",
      "\n",
      "#but from Bragg's law\n",
      "\n",
      "#n*l=2*d*sin(t)\n",
      "\n",
      "#for for constant distance(d) and wavelength(l) \n",
      "\n",
      "#order(n) is directly proportionl to sine of angle i.e (sin(t))\n",
      "\n",
      "#n1/n2=sin(t1)/sin(t2)\n",
      "\n",
      "#assume sin(t2)=a\n",
      "\n",
      "a=n2/n1*m\n",
      "\n",
      "t2=math.degrees(math.asin(a))                              #taking sin inverese in degree\n",
      "\n",
      "print\"second order reflection take place at an angle=\",round(t2,4),\"degree\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "second order reflection take place at an angle= 6.812 degree\n"
       ]
      }
     ],
     "prompt_number": 75
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.15.4,Page number 1-70"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#given data\n",
      "\n",
      "V=50*10**3                              #operating voltage of x-ray\n",
      "M=74.6                                  #molecular weight\n",
      "p=1.99*10**3                            #density\n",
      "n=4                                     #no of atoms per unit cell(for FCC structure)\n",
      "h=6.63*10**-34                           #plank's constant\n",
      "c=3*10**8                                #velocity \n",
      "e=1.6*10**-19                            #charge on electron\n",
      "N=6.023*10**26                           #Avogadro's number\n",
      "\n",
      "#step 1:clculating shortest wavelength\n",
      "\n",
      "l=h*c/(e*V)\n",
      "\n",
      "print\"1)shortest wavelength=\",(l),\"m\"\n",
      "\n",
      "#step:2 calculating distance(d)\n",
      "\n",
      "#now a**3*p=n*M/N therefore,\n",
      "\n",
      "a=(n*M/(N*p))**(1./3)\n",
      "\n",
      "#since KCl is ionic crystal herefore,\n",
      "\n",
      "d=a/2\n",
      "\n",
      "#step 3: calculaing glancing angle\n",
      "\n",
      "#using Bragg's law\n",
      "\n",
      "#n*l=2*d*sin(t)\n",
      "\n",
      "#assume sin(t)=a, wavelength is minimum i.e l and n=1\n",
      "\n",
      "n=1\n",
      "\n",
      "a=n*l/(2*d)\n",
      "\n",
      "t=math.degrees(math.asin(a))                             #taking sin inverese in degree\n",
      "\n",
      "print\"2) glancing angle=\",round(t,4),\"degree\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "1)shortest wavelength= 2.48625e-11 m\n",
        "2) glancing angle= 2.265 degree\n"
       ]
      }
     ],
     "prompt_number": 77
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.15.5,Page number 1-70"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#given data\n",
      "\n",
      "n=1.0                                     #first order maximum\n",
      "l=0.82*10**-10                          #wavelength of X ray\n",
      "qd=7.0                                    #glancing angle in degree\n",
      "qm=51./60                                #glancing angle in minute\n",
      "qs=48./3600                              #glancing angle in second\n",
      "\n",
      "q=qd+qm+qs                              #total glancin angle in degree\n",
      "\n",
      "#using Bragg's law n*l=2*d*sin(q)\n",
      "\n",
      "d=n*l/(2*math.sin(q*math.pi/180))\n",
      "\n",
      "a=3*10**-10                              #lattice constant\n",
      "\n",
      "#we know that d=a/root(h**2+k**2+l**2)\n",
      "\n",
      "#assume root(h**2+k**2+l**2) =m\n",
      "\n",
      "#arranging terms we get\n",
      "\n",
      "m=a/d\n",
      "\n",
      "print\"square root(h**2+k**2+l**2)=\",round(m,0)\n",
      "\n",
      "print\"hence possible solutions are (100),(010),(001)\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "square root(h**2+k**2+l**2)= 1.0\n",
        "hence possible solutions are (100),(010),(001)\n"
       ]
      }
     ],
     "prompt_number": 90
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.15.6,Page number 1-71"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#given data\n",
      "\n",
      "n=1                                     #first order maximum\n",
      "l=1j                                    #wavelength of X ray\n",
      "\n",
      "#part 1:for(100)\n",
      "\n",
      "#using Bragg's law n*l=2*d*sin(q)\n",
      "\n",
      "q1=5.4                                   #glancing angle in degree\n",
      "\n",
      "dl1=n*l/(2*math.sin(q1*math.pi/180))\n",
      "\n",
      "#part 2:for(110)\n",
      "\n",
      "#using Bragg's law n*l=2*d*sin(q)\n",
      "\n",
      "q2=7.6                                   #glancing angle in degree\n",
      "\n",
      "dl2=n*l/(2*math.sin(q2*math.pi/180))\n",
      "\n",
      "#part 3:for(111)\n",
      "\n",
      "#using Bragg's law n*l=2*d*sin(q)\n",
      "\n",
      "q3=9.4                                   #glancing angle in degree\n",
      "\n",
      "dl3=n*l/(2*math.sin(q3*math.pi/180))\n",
      "\n",
      "#for taking ratio divide all dl by dl1\n",
      "\n",
      "d1=dl1/dl1\n",
      "\n",
      "d2=dl2/dl1\n",
      "\n",
      "d3=dl3/dl1\n",
      "\n",
      "print\"cubic lattice structure is=\",d1,d2,d3"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " cubic lattice structure is= (1+0j) (0.711559669333+0j) (0.576199350225+0j)\n"
       ]
      }
     ],
     "prompt_number": 94
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.15.7,Page number 1-71"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#given data\n",
      "\n",
      "n=1                                     #first order maximum\n",
      "l=1.54*10**-10                           #wavelength of rock salt crystal\n",
      "q=21.7                                  #glancing angle in degree\n",
      "\n",
      "#using Bragg's law n*l=2*d*sin(q)\n",
      "\n",
      "d=n*l/(2*math.sin(q*math.pi/180))\n",
      "\n",
      "print\"lattice constant of crystal=\",\"{0:.3e}\".format(d),\"meter\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "lattice constant of crystal= 2.083e-10 meter\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.15.8,Page number 1-72"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#given data\n",
      "\n",
      "a=2.814*10**-10                          #lattice constant\n",
      "\n",
      "#the interplanar spacing of plane\n",
      "\n",
      "h=1\n",
      "k=0\n",
      "l=0\n",
      "\n",
      "d=a/math.sqrt(h**2+k**2+l**2)\n",
      "\n",
      "n=2                                     #first order maximum\n",
      "\n",
      "l=0.714*10**-10                         #wavelength of X-ray crystal\n",
      "\n",
      "#using Bragg's law\n",
      "\n",
      "q=math.degrees(math.asin((n*l)/(2*d)))                     #glancing angle\n",
      "\n",
      "print\"glancing angle=\",round(q,4),\"degree\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "glancing angle= 14.6984 degree\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.15.9,Page number 1-72"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#given data\n",
      "\n",
      "d=2.82*10**-10                           #interplaner spacing\n",
      "t=10                                    #glancing angle\n",
      "\n",
      "#for part 1\n",
      "\n",
      "n=1                                     #first order maximum\n",
      "\n",
      "#using Bragg's law n*l=2*d*sin(t)\n",
      "\n",
      "l=2*d*math.sin(math.pi*t/180)/n\n",
      "\n",
      "print\"1)wavelength=\",\"{0:.3e}\".format(l),\"meter\"\n",
      "\n",
      "#for part 2\n",
      "\n",
      "n1=2\n",
      "\n",
      "#using Bragg's law n*l=2*d*sin(q)\n",
      "\n",
      "q=math.degrees(math.asin(n1*l/(2*d)))\n",
      "\n",
      "print\"2)glancing angle=\",round(q,4),\"degree\"\n",
      "\n",
      "#for part 3\n",
      "\n",
      "#for highest order sin(q) not exceed one i.e maximum value is one\n",
      "\n",
      "#using Bragg's law n*l=2*d*sin(q)\n",
      "\n",
      "n2=2*d/l                                #since sin(q)is one\n",
      "\n",
      "print\"3)highest order possible =\",(floor(n2))\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "1)wavelength= 9.794e-11 meter\n",
        "2)glancing angle= 20.322 degree\n",
        "3)highest order possible = 5.0\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.15.10,Page number 1-73"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#given data\n",
      "\n",
      "#for line -A\n",
      "\n",
      "n1=1                                    #1st order maximum\n",
      "q1=30                                   #glancing angle in degree\n",
      "\n",
      "#using Bragg's law for line A n1*l1=2*d1*sin(q1)\n",
      "\n",
      "#d1=n1*l1/(2*sin(q1))\n",
      "\n",
      "#for line B\n",
      "\n",
      "l2=0.97                                 #wavelength in amstrong unit\n",
      "n2=3                                    #1st order maximum\n",
      "q2=60                                   #glancing angle in degree\n",
      "\n",
      "#using Bragg's law for line B n2*l2=2*d2*sin(q2)\n",
      "\n",
      "#since for both lines A and B we use same plane of same crystal,therefore\n",
      "\n",
      "#d1=d2\n",
      "\n",
      "#therefore equution became n2*l2=2*n1*l1/(2*sin(q1))*sin(q2)\n",
      "\n",
      "#by arranging terms we get\n",
      "\n",
      "\n",
      "l1=n2*l2*2*math.sin(q1*math.pi/180)/(2*n1*math.sin(q2*math.pi/180))\n",
      "\n",
      "print\"wavelength of the line A=\",round(l1,4),\"amstrong\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "wavelength of the line A= 1.6801 amstrong\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.15.11,Page number 1-74"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#given data\n",
      "\n",
      "n=1.0                                     #first order minimum\n",
      "d=5.5*10**-11                            #atomic spacing\n",
      "e=1.6*10**-19                            #charge on one electron\n",
      "Ee=10*10**3                              #energy in eV\n",
      "E=e*Ee                                  #energy in Joule\n",
      "m=9.1*10**-31                            #mass of elelctron\n",
      "h=6.63*10**-34                           #plank's constant\n",
      "\n",
      "l=h/math.sqrt(2*m*E)                         #wavelength\n",
      "\n",
      "#using Bragg's law\n",
      "\n",
      "q=math.degrees(math.asin((n*l)/(2*d)))                    #glancing angle\n",
      "\n",
      "print\"glancing angle=\",round(q,4),\"degree\"\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "glancing angle= 6.4129 degree\n"
       ]
      }
     ],
     "prompt_number": 18
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.15.12,Page number 1-74"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#given data\n",
      "\n",
      "a=2.814*10**-10                          #lattice constant\n",
      "\n",
      "#for rock salt\n",
      "\n",
      "d=a/2                                   #interplaner spacing\n",
      "\n",
      "n=1                                     #first order maximum\n",
      "\n",
      "l=1.541*10**-10                          #wavelength of rock salt crystal\n",
      "\n",
      "#using Bragg's law\n",
      "\n",
      "q=math.degrees(math.asin((n*l)/(2*d)))                     #glancing angl\n",
      "\n",
      "print\"glancing angle=\",round(q,4),\"degree\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "glancing angle= 33.2038 degree\n"
       ]
      }
     ],
     "prompt_number": 20
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.16.1,Page number 1-75"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#given data\n",
      "\n",
      "Ev=1.08                                 #average energy required to creaet a vacancy\n",
      "k=1.38*10**-23                           #boltzman constant in J/K\n",
      "e=1.6*10**-19                            #charge on 1 electron\n",
      "\n",
      "K=k/e                                   #boltzman constant in eV/K\n",
      "\n",
      "#for a low concentration of vacancies a relation is\n",
      "\n",
      "#n=Nexp(-Ev/KT)\n",
      "\n",
      "#since total no atom is 1 hence N=1\n",
      "\n",
      "#at 1000k\n",
      "\n",
      "T1=1000                                  #temperature\n",
      "\n",
      "n1=math.exp(-Ev/(K*T1))\n",
      "\n",
      "#at 500k\n",
      "\n",
      "T2=500                                   #temperature\n",
      "\n",
      "n2=math.exp(-Ev/(K*T2))\n",
      "\n",
      "v=(n1)/(n2)                                #ratio of vacancies\n",
      "\n",
      "print\"ratio of vacancies=\",round(v,4)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "ratio of vacancies= 274234.5745\n"
       ]
      }
     ],
     "prompt_number": 22
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.16.2,Page number 1-75"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#given data\n",
      "\n",
      "Ev=1.95                                 #average energy required to creaet a vacancy\n",
      "k=1.38*10**-23                           #boltzman constant in J/K\n",
      "e=1.6*10**-19                            #charge on 1 electron\n",
      "K=k/e                                   #boltzman constant in eV/K\n",
      "T=500                                   #temperature\n",
      "\n",
      "#for a low concentration of vacancies a relation is\n",
      "\n",
      "#n=Nexp(-Ev/KT)\n",
      "\n",
      "m=math.exp(-Ev/(K*T))                           #ratio of no of vacancies to no of atoms n/N\n",
      "\n",
      "print\"ratio of no of vacancies to no of atoms=\",\"{0:.3e}\".format(m)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "ratio of no of vacancies to no of atoms= 2.303e-20\n"
       ]
      }
     ],
     "prompt_number": 25
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.16.3,Page number 1-76"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#given data\n",
      "\n",
      "Ev=1.8                                  #average energy required to creaet a vacancy\n",
      "k=1.38*10**-23                           #boltzman constant in J/K\n",
      "e=1.6*10**-19                            #charge on 1 electron\n",
      "K=k/e                                   #boltzman constant in eV/K\n",
      "\n",
      "#for a low concentration of vacancies a relation is\n",
      "\n",
      "#n=Nexp(-Ev/KT)\n",
      "\n",
      "#ratio of vacancy is n/N assume be r=exp(-Ev/KT)\n",
      "\n",
      "#since total no atom is 1 hence N=1\n",
      "\n",
      "#at 1000k\n",
      "\n",
      "t1=-119                                  #temperature in degree\n",
      "T1=t1+273                               #temperature in kelvine\n",
      "r1=math.exp(-Ev/(K*T1))\n",
      "\n",
      "print\"1)ratio of vacancies at -119 degree=\",\"{0:.3e}\".format(r1)\n",
      "\n",
      "#at 500k\n",
      "\n",
      "t2=80                                    #temperature in degree\n",
      "\n",
      "T2=t2+273                               #temperature in kelvine\n",
      "\n",
      "r2=exp(-Ev/(K*T2))\n",
      "\n",
      "v=(r1)/(r2)                                #ratio of vacancies\n",
      "\n",
      "print\"2)ratio of vacancies at 80 degree=\",\"{0:.3e}\".format(r2)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "1)ratio of vacancies at -119 degree= 1.399e-59\n",
        "2)ratio of vacancies at 80 degree= 2.110e-26\n"
       ]
      }
     ],
     "prompt_number": 27
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.16.4,Page number 1-76"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#given data\n",
      "\n",
      "Ev=1.5                                  #energy of formaton of frankel defect\n",
      "k=1.38*10**-23                          #boltzman constant in J/K\n",
      "e=1.6*10**-19                           #charge on 1 electron\n",
      "K=k/e                                   #boltzman constant in eV/K\n",
      "T=700                                   #temperature\n",
      "N=6.023*10**26                          #avogadro's no\n",
      "\n",
      "#for a low concentration of vacancies a relation is\n",
      "\n",
      "#n=Nexp(-Ev/KT)\n",
      "\n",
      "m=math.exp(-Ev/(2*K*T))                        #ratio of no of vacancies to no of atoms n/N\n",
      "\n",
      "qs=5.56                                 #specific density\n",
      "q=5.56*10**3                            #real density ke/m**3\n",
      "M=0.143                                 #molecular weight in kg/m**3\n",
      "ma=M/N                                  #mass of one molecule\n",
      "v=ma/q                                  #vol of one molecule\n",
      "\n",
      "#v volume containe 1 molecule\n",
      "\n",
      "#therefore 1 m**3 containe x molecule\n",
      "\n",
      "x=1./v\n",
      "d=m*x                                   #defect per m**3\n",
      "dm=d*10**-9                              #defect per mm**3\n",
      "\n",
      "print\"number of frankel defects per mm^3=\",\"{0:.3e}\".format(dm)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "number of frankel defects per mm^3= 9.432e+16\n"
       ]
      }
     ],
     "prompt_number": 30
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [],
     "language": "python",
     "metadata": {},
     "outputs": []
    }
   ],
   "metadata": {}
  }
 ]
}