{

 "metadata": {

  "name": "",

  "signature": "sha256:8787be2af1a94b63ca8412df85bcd749a00e2c5c652303af986ee37d2e29e569"

 },

 "nbformat": 3,

 "nbformat_minor": 0,

 "worksheets": [

  {

   "cells": [

    {

     "cell_type": "heading",

     "level": 1,

     "metadata": {},

     "source": [

      "Chapter03:Crystal Structure"

     ]

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex3.1:pg-50"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "#Example 3.1: miller indices\n",

      "import math \n",

      "#given data \n",

      "x1=1.0;#\n",

      "x2=1.0;#\n",

      "x3=2.0;#\n",

      "h1=1/x1;#\n",

      "h2=1/x2;#\n",

      "h3=1/x3;#\n",

      "print \"Miller indices of the plane (112) are: \",h1,\",\",h2,\",\",h3\n",

      "x11=0.0;#\n",

      "x21=0.0;#\n",

      "x31=1.0;#\n",

      "h11=inf;#\n",

      "h21=inf;#\n",

      "h31=1/x31;#\n",

      "print \"Miller indices of the plane (001) are : \",h11,\",\",h21,\",\",h31\n",

      "x111=1.0;#\n",

      "x211=0.0;#\n",

      "x311=1.0;#\n",

      "h111=1/x111;#\n",

      "h211=inf;#\n",

      "h311=1/x311;#\n",

      "print \"Miller indices of the plane (101) are : \",h111,\",\",h211,\",\",h311\n"

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "Miller indices of the plane (112) are:  1.0 , 1.0 , 0.5\n",

        "Miller indices of the plane (001) are :  inf , inf , 1.0\n",

        "Miller indices of the plane (101) are :  1.0 , inf , 1.0\n"

       ]

      }

     ],

     "prompt_number": 2

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex3.2:pg-51"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "#Example 3.2: miller indices\n",

      " \n",

      "#given data \n",

      "x1=0.0;#\n",

      "x2=2.0;#\n",

      "x3=0.0;#\n",

      "h1=inf;#\n",

      "h2=1/x2;#\n",

      "h3=inf;#\n",

      "print\"Miller indices of the plane (020) are: \",h1,\",\",h2,\",\",h3\n",

      "x11=1.0;#\n",

      "x21=2.0;#\n",

      "x31=0;#\n",

      "h11=1/x11;#\n",

      "h21=1/x21;#\n",

      "h31=inf;#\n",

      "print\"Miller indices of the plane (120) are : \",h11,\",\",h21,\",\",h31\n",

      "x111=2.0;#\n",

      "x211=2.0;#\n",

      "x311=0.0;#\n",

      "h111=1/x111;#\n",

      "h211=1/x211;#\n",

      "h311=inf;#\n",

      "print\"Miller indices of the plane (220) are : \",h111,\",\",h211,\",\",h311\n",

      "#miller indices for plane (120) is calculated wrong in the book\n"

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "Miller indices of the plane (020) are:  inf , 0.5 , inf\n",

        "Miller indices of the plane (120) are :  1.0 , 0.5 , inf\n",

        "Miller indices of the plane (220) are :  0.5 , 0.5 , inf\n"

       ]

      }

     ],

     "prompt_number": 3

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex3.3:pg-52"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "# Example 3.3: miller indices\n",

      " \n",

      "x=1/2.0;#\n",

      "x1=1/x;#\n",

      "r2=0;#\n",

      "r3=0;#\n",

      "x10=-1;#\n",

      "x2=1.0/x10;#\n",

      "r4=0;#\n",

      "r5=0;#\n",

      "print\"miller indices (Case 1) of the given plane are \",x1,\" : \",r2,\" : \",r3\n",

      "print\"miller indices (Case 2) of the given plane are \",x2,\" : \",r3,\" : \",r4 \n"

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "miller indices (Case 1) of the given plane are  2.0  :  0  :  0\n",

        "miller indices (Case 2) of the given plane are  -1.0  :  0  :  0\n"

       ]

      }

     ],

     "prompt_number": 7

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex3.4:pg-52"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "# Example 3.4: miller indices\n",

      " \n",

      "a=0.529;#\n",

      "b=1;#\n",

      "c=0.477;#\n",

      "a1=0.264;#\n",

      "b1=1;#\n",

      "c1=0.238;#\n",

      "r1=round(a/a1);#\n",

      "r2=b/b1;#\n",

      "r3=round(c/c1);#\n",

      "print\"miller indices of the given plane are \",r1,\" : \",r2,\" : \",r3\n"

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "miller indices of the given plane are  2.0  :  1  :  2.0\n"

       ]

      }

     ],

     "prompt_number": 8

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex3.5:pg-53"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "#Example 3.5: miller indices\n",

      " \n",

      "#given data \n",

      "x1=1;#\n",

      "x2=1;#\n",

      "x3=0;#\n",

      "h1=1/x1#\n",

      "h2=1/x2;#\n",

      "h3=inf;#\n",

      "print\"Miller indices of the plane (110) are: \",h1,\",\",h2,\",\",h3\n",

      "x11=1;#\n",

      "x21=1;#\n",

      "x31=1;#\n",

      "h11=1/x11;#\n",

      "h21=1/x21;#\n",

      "h31=1/x31;#\n",

      "print\"Miller indices of the plane (111) are : \",h11,\",\",h21,\",\",h31\n",

      "\n"

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "Miller indices of the plane (110) are:  1 , 1 , inf\n",

        "Miller indices of the plane (111) are :  1 , 1 , 1\n"

       ]

      }

     ],

     "prompt_number": 9

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex3.9:pg-58"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "# Example 3.9: atoms per unit cell\n",

      " \n",

      "c=8;#corners\n",

      "f=6;#faces\n",

      "nf=(1/2.0)*f;#no. of atoms in all six faces\n",

      "nc=(1/8.0)*c;#no. of atoms in all corners\n",

      "ta=nf+nc;#\n",

      "print ta,\"are total number of atoms \"\n"

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "4.0 are total number of atoms \n"

       ]

      }

     ],

     "prompt_number": 10

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex3.10:pg-61"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "#Example 3.10 : largest diameter\n",

      "import math \n",

      "#given data :\n",

      "\n",

      "a=3.61; # edge length in angstrum\n",

      "r=(a*math.sqrt(2))/4;\n",

      "d=2*r;\n",

      "print round(d,4),\"= largest diameter,d(angstrom) \"\n"

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "2.5527 = largest diameter,d(angstrom) \n"

       ]

      }

     ],

     "prompt_number": 15

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex3.11:pg-62"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "#Example 3.11 : volume change in percentage\n",

      "import math\n",

      "#given data :\n",

      "r_bcc=0.1258; # in nm\n",

      "r_fcc=0.1292;# in nm\n",

      "a_bcc=(r_bcc*4)/math.sqrt(3);\n",

      "a_fcc=(r_fcc*4)/math.sqrt(2);\n",

      "v_fcc=(a_fcc)**3;# in nmn**3\n",

      "v_bcc=(a_bcc)**3; # in nm**3\n",

      "V=((v_fcc-v_bcc)/v_bcc)*100;\n",

      "print round(V,2),\"=volume change in percentage,V(%) \""

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "99.01 =volume change in percentage,V(%) \n"

       ]

      }

     ],

     "prompt_number": 17

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex3.12:pg-64"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "\n",

      "#Example 3.12 : number of atom/mm**2\n",

      " \n",

      "\n",

      "#given data :\n",

      "a=3.03*10**-7; # lattice constant in mm\n",

      "A=1/a**2;# for 100 planes \n",

      "B=0.707/a**2;#for(110) planes\n",

      "C=0.58/a**2;# for(111) planes\n",

      "print round(A,-11),\"=number of atoms for (100) plane \"\n",

      "print round(B,-10),\"=number of atoms for (110) plane \"\n",

      "print round(C,-11),\"=number of atoms for (111) plane \"\n"

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "1.09e+13 =number of atoms for (100) plane \n",

        "7.7e+12 =number of atoms for (110) plane \n",

        "6.3e+12 =number of atoms for (111) plane \n"

       ]

      }

     ],

     "prompt_number": 5

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex3.13:pg-66"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "\n",

      "#Example 3.13 : number of atom/mm**2 of planes\n",

      " \n",

      "#given data :\n",

      "\n",

      "a=2.87*10**-7; # lattice constant in mm\n",

      "A=1/a**2;# for 100 planes \n",

      "B=1.414/a**2;#for(110) planes\n",

      "C=1.732/a**2;# for(111) planes\n",

      "print round(A,-11),\"=number of atoms for (100) plane \"\n",

      "print round(B,-11),\"=number of atoms for (110) plane \"\n",

      "print round(C,-11),\"=number of atoms for (111) plane \"\n"

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "1.21e+13 =number of atoms for (100) plane \n",

        "1.72e+13 =number of atoms for (110) plane \n",

        "2.1e+13 =number of atoms for (111) plane \n"

       ]

      }

     ],

     "prompt_number": 41

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex3.14:pg-69"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "\n",

      "#Example 3.14 : number of atom/mm**2 surface area\n",

      " \n",

      "#given data :\n",

      "a=4.93*10**-7; # lattice constant in mm\n",

      "A=2/a**2;# for 100 planes \n",

      "B=1.414/a**2;#for(110) planes\n",

      "C=2.31/a**2;# for(111) planes\n",

      "print round(A,-11),\"=number of atoms for (100) plane \"\n",

      "print round(B,-11),\"=number of atoms for (110) plane \"\n",

      "print round(C,-11),\"=number of atoms for (111) plane \"\n",

      "\n"

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "8.2e+12 =number of atoms for (100) plane \n",

        "5.8e+12 =number of atoms for (110) plane \n",

        "9.5e+12 =number of atoms for (111) plane \n"

       ]

      }

     ],

     "prompt_number": 42

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex3.15:pg-69"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "#Example 3.15 : planar density\n",

      " \n",

      "#given data :\n",

      "\n",

      "a=0.143*10**-6; # atomic radius in mm\n",

      "A=2.31/(a**2);# for(111) planes\n",

      "print round(A,-10),\"= atom,A(atoms/mm**2) \"\n",

      "# answer is wrong in book\n"

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "1.1296e+14 = atom,A(atoms/mm**2) \n"

       ]

      }

     ],

     "prompt_number": 18

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex3.16:pg-71"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "#Example 3.16 : volume\n",

      " \n",

      "import math\n",

      "#given data :\n",

      "a=0.2665; # in mm\n",

      "c=0.4947;# in mm\n",

      "V=(3*math.sqrt(3)*a**2*c)/2.0;\n",

      "print round(V,4),\"=volume,V(mm**3) \"\n"

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "0.0913 =volume,V(mm**3) \n"

       ]

      }

     ],

     "prompt_number": 51

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex3.17:pg-72"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "\n",

      "#Example 3.17 : find the packing efficiency and lattice parameter\n",

      " \n",

      "\n",

      "#given data :\n",

      "r=1.22# in angstrum\n",

      "a=(4*r)/math.sqrt(3);\n",

      "efficiency=(math.pi*math.sqrt(3))/8;\n",

      "print round(efficiency,2),\"=efficiency  \"\n",

      "print round(a,2),\"= lattice parameter,a(angstrom) \"\n"

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "0.68 =efficiency  \n",

        "2.82 = lattice parameter,a(angstrom) \n"

       ]

      }

     ],

     "prompt_number": 53

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex3.18:pg-73"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "#Example 3.18 : interplanar distance\n",

      "import math \n",

      "#given data :\n",

      "h=1;\n",

      "k=1;\n",

      "l=1;\n",

      "#d=a/math.sqrt(h**2+k**2+l**2)\n",

      "dBYa=1/math.sqrt(h**2+k**2+l**2);\n",

      "print \"Interplaner distance in (Angstrom) is a*\",round(dBYa,3)\n"

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "Interplaner distance in (Angstrom) is a* 0.577\n"

       ]

      }

     ],

     "prompt_number": 19

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex3.19:pg-74"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "#Example 3.19 : spacing\n",

      "import math\n",

      "#given data :\n",

      "h1=2;\n",

      "k1=0;\n",

      "l1=0;\n",

      "h2=2;\n",

      "k2=2;\n",

      "l2=0;\n",

      "h3=1;\n",

      "k3=1;\n",

      "l3=1;\n",

      "r=1.246;\n",

      "a=(4*r)/math.sqrt(2);# in angstrum\n",

      "#d=a/math.sqrt(h**2+k**2+l**2)\n",

      "d1=a/math.sqrt(h1**2+k1**2+l1**2);\n",

      "d2=a/math.sqrt(h2**2+k2**2+l2**2);\n",

      "d3=a/math.sqrt(h3**2+k3**2+l3**2);\n",

      "print round(d1,2),\"=d_200 spacind,d1(angstrom)  \"\n",

      "print round(d2,2),\"=d_220 spacind,d2(angstrom)  \"\n",

      "print round(d3,2),\"=d_111 spacind,d3(angstrom)  \"\n"

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "1.76 =d_200 spacind,d1(angstrom)  \n",

        "1.25 =d_220 spacind,d2(angstrom)  \n",

        "2.03 =d_111 spacind,d3(angstrom)  \n"

       ]

      }

     ],

     "prompt_number": 57

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex3.20:pg-74"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "#Example 3.20 : interplaner spacing d_220\n",

      "import math \n",

      "\n",

      "#given data :\n",

      "a=0.316;# in nm\n",

      "h=2;\n",

      "k=2;\n",

      "l=0;\n",

      "d=a/math.sqrt(h**2+k**2+l**2);\n",

      "print round(d,3),\"= inter planer spacing d_220,d(nm)  \"\n",

      "# answer is wrong in book\n"

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "0.112 = inter planer spacing d_220,d(nm)  \n"

       ]

      }

     ],

     "prompt_number": 21

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex3.21:pg-74"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "# Example 3.21: interplanar spacing d220\n",

      " \n",

      "import math\n",

      "a=1;#constant assume\n",

      "a1=[1,0,0];#lattice planes\n",

      "a2=[1,1,0];#lattice planes\n",

      "a3=[1,1,1];#lattice planes\n",

      "d100=a/(math.sqrt(a1[0]+a1[1]**2+a1[2]**2));#interplanar distance between (100)planes\n",

      "d110=a/(math.sqrt(a2[0]**2+a2[1]**2+a2[2]**2));#interplanar distance between (110)planes\n",

      "d111=a/(math.sqrt(a3[0]**2+a3[1]**2+a3[2]**2));#interplanar distance between (111)planes\n",

      "print \"ratio of interplanar distances is \",d100,\":\",round(d110,2),\":\",round(d111,2)\n"

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "ratio of interplanar distances is  1.0 : 0.71 : 0.58\n"

       ]

      }

     ],

     "prompt_number": 63

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex3.22:pg-75"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "# Example 3.22: perpendicular distance\n",

      "import math \n",

      "a=1;#constant assume\n",

      "a1=[1,1,1];#lattice planes\n",

      "a2=[2,2,2];#lattice planes\n",

      "d1=a/(math.sqrt(a1[0]**2+a1[1]**2+a1[2]**2));#perpendicular distance between origin and (111)planes\n",

      "d2=a/(math.sqrt(a2[0]**2+a2[1]**2+a2[2]**2));#perpendicular distance between origin and (222)planes\n",

      "d22 = d1-d2;#perpendicular distance between the planes (111) and (222)\n",

      "print round(d22,2),\"= perpendicular distance between the planes (111) and (222)\"\n",

      "\n",

      "# a is assumed to be 1\n"

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "0.29 = perpendicular distance between the planes (111) and (222)\n"

       ]

      }

     ],

     "prompt_number": 65

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex3.23:pg-76"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "# Example 3.23: angle between planes (122) and (111)\n",

      "import math\n",

      "a=1;# assume\n",

      "a1=[1,2,2];#lattice planes\n",

      "a2=[1,1,1];#lattice planes\n",

      "d1=a/(math.sqrt(a1[0]**2+a1[1]**2+a1[2]**2));#perpendicular distance between origin and (111)planes\n",

      "d2=a/(math.sqrt(a2[0]**2+a2[1]**2+a2[2]**2));#perpendicular distance between origin and (222)planes\n",

      "cphi= ((a1[0]*a2[0])+(a1[1]*a2[1])+(a1[2]*a2[2]))*(d1*d2);#\n",

      "d=math.degrees(math.acos((cphi)));# in degree\n",

      "d1=math.floor(d);#\n",

      "d2=d-d1;#\n",

      "print\"angle between planes (122) and (111) is \",d1,\" degree \",round(60*d2),\" minutes\"\n",

      "\n",

      "\n"

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "angle between planes (122) and (111) is  15.0  degree  48.0  minutes\n"

       ]

      }

     ],

     "prompt_number": 72

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex3.24:pg-77"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "#Example 3.24 : concentration of iron\n",

      " \n",

      "\n",

      "#given data :\n",

      "d=7.87;\n",

      "N=6.023*10**23; # avogadro's number\n",

      "A=55.85;# atomic weight\n",

      "I=A/N;# mass of iron atom\n",

      "atom=d/I;\n",

      "print round(atom,-20),\"= number of atoms(atoms/cm**3)  \"\n"

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "8.49e+22 = number of atoms(atoms/cm**3)  \n"

       ]

      }

     ],

     "prompt_number": 83

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex3.25:pg-77"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "#Example 3.25 : lattice constant\n",

      " \n",

      "#given data :\n",

      "\n",

      "n=2;\n",

      "A=55.8;\n",

      "N=6.023*10**26; # avogadro's number in /kg-mole\n",

      "b=7.87*10**3;# in kg/m**3\n",

      "a=((A*n)/(N*b))**(1/3.0);\n",

      "print round(a*10**10,3),\"= lattice constant,a(angstrom)\"\n"

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "2.866 = lattice constant,a(angstrom)\n"

       ]

      }

     ],

     "prompt_number": 85

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex3.26:pg-77"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "#Example 3.26 : density\n",

      "import math\n",

      "#given data :\n",

      "\n",

      "n=4;\n",

      "N=6.023*10**23; # avogadro's number\n",

      "r=1.278*10**-8;# in cm\n",

      "A=63.5;\n",

      "a=(r*4)/math.sqrt(2);# in cm\n",

      "b=(A*n)/(a**3*N);\n",

      "print round(b,2),\"= density of copper,b(g/cc) \"\n"

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "8.93 = density of copper,b(g/cc) \n"

       ]

      }

     ],

     "prompt_number": 87

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex3.27:pg-77"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "#Example 3.27 : number of atoms\n",

      " \n",

      "#given data :\n",

      "n=4;\n",

      "N=6.023*10**23; # avogadro's number\n",

      "A=55.85;\n",

      "a=2.9*10**-8;\n",

      "b=7.87;#density in g/cc\n",

      "#a**3=(A*n)/(N*b)\n",

      "n=round((a**3*N*b)/A);\n",

      "print n,\"= number of atoms,n \"\n"

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "2.0 = number of atoms,n \n"

       ]

      }

     ],

     "prompt_number": 88

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex3.28:pg-78"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "#Example 3.28 : lattice constant\n",

      " \n",

      "#given data :\n",

      "d=6250;#density\n",

      "N=6.02*10**23;#avogadro's number\n",

      "n=4;\n",

      "m=60.2*10**-3;# atomic mass\n",

      "M=(n*m)/N;\n",

      "V=M/d;\n",

      "a=V**(1/3.0)*10**9;\n",

      "print a,\"= the lattice constant,a(nm) \"\n",

      "#ANSWER IS WRONG IN THE TEXT BOOK\n"

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "0.4 = the lattice constant,a(nm) \n"

       ]

      }

     ],

     "prompt_number": 89

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex3.29:pg-78"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "#Example 3.29 : the number of atoms\n",

      " \n",

      "#given data :\n",

      "d=7.87;#in g/cm**3\n",

      "A=55.85;\n",

      "a=2.9*10**-8;# in cm\n",

      "N=6.02*10**23;#avogadro's number\n",

      "n=(d*a**3*N)/A;\n",

      "print round(n),\"= the number of atom,n \"\n"

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "2.0 = the number of atom,n \n"

       ]

      }

     ],

     "prompt_number": 90

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex3.30:pg-83"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "# Example 3.30: calculate the number of vacancies in the copper\n",

      "import math \n",

      "B=1.38*10**-23;#boltzman constant in J/atom-K\n",

      "B1=8.62*10**-5;# bolzman constant in ev/atom-K\n",

      "Qv=0.9;# eV/atom\n",

      "t=27;# room temperatyre in degree celsius\n",

      "pcu=8.4;#in g/cm**3\n",

      "Acv=63.5;# in g/mol\n",

      "T=t+273;#temperture in kelvin\n",

      "Nv=6.023*10**23;#\n",

      "P=8.4;#\n",

      "Ns=(Nv*P)/Acv;# number of regular lattice sites\n",

      "Nv1=Ns*math.exp(-Qv/(B1*T));#\n",

      "print \"{:.1e}\".format(Nv1),\"is number of vacancies in copper in vacancies/cm**3\"\n",

      "#answer is wrong in the textbook\n"

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "6.1e+07 is number of vacancies in copper in vacancies/cm**3\n"

       ]

      }

     ],

     "prompt_number": 23

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex3.31:pg-86"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "#Example 3.31 : interplanar spacing\n",

      "import math \n",

      "#given data :\n",

      "\n",

      "theta=20.3;#in degree\n",

      "lamda=1.54;# in angstrum\n",

      "n=1.0;\n",

      "a=math.sin(math.radians(theta))\n",

      "d=lamda/(2*a);\n",

      "print round(d,2),\"= interplanar spacing,d(angstrom) \"\n"

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "2.22 = interplanar spacing,d(angstrom) \n"

       ]

      }

     ],

     "prompt_number": 101

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex3.32:pg-86"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "#Example 3.32 : interatomic spacing\n",

      "import math \n",

      "#given data :\n",

      "\n",

      "theta=30;#in degree\n",

      "lamda=1.54;# in angstrum\n",

      "n=1;\n",

      "a=math.sin(math.radians(theta))\n",

      "d=lamda/(2*a);\n",

      "print d,\"=interatomic spacing,d(angstrom) \"\n"

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "1.54 =interatomic spacing,d(angstrom) \n"

       ]

      }

     ],

     "prompt_number": 102

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex3.33:pg-87"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "#Example 3.33 : number of per order\n",

      "import math \n",

      "#given data :\n",

      "\n",

      "theta=90;#in degree\n",

      "lamda=1.54;# in angstrum\n",

      "a=math.sin(math.radians(theta))\n",

      "d=1.181;\n",

      "n=(2*d*a)/lamda;\n",

      "print round(n,2),\"= number of order,n \"\n"

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "1.53 = number of order,n \n"

       ]

      }

     ],

     "prompt_number": 106

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex3.34:pg-87"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "# Example 3.34: size of unit cell\n",

      "import math \n",

      "n=1.0;#\n",

      "a=1.0;#assume\n",

      "h=0.58;#wavelnegth in armstrong\n",

      "th=9.5;#reflection angle in degree\n",

      "a1=[2.0,0,0];#miller indices\n",

      "d200=a/(math.sqrt(a1[0]**2+a1[1]**2+a1[2]**2));#interplanar distance between (200)planes\n",

      "a=((n*h)/(2*d200*math.sin(math.radians(th))));#zsize of unit cell\n",

      "print round(a,3),\"= size of unit cell in \u00c4\"\n",

      "#amswer is wrong in the textbook\n"

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "3.514 = size of unit cell in \u00c4\n"

       ]

      }

     ],

     "prompt_number": 36

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex3.35:pg-87"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "# Example 3.35: bragg angle\n",

      "import math\n",

      "n=1;#\n",

      "a=3.57;#in \u00c4\n",

      "h=0.54;#wavelnegth in \u00c4 \n",

      "a1=[1,1,1];#miller indices\n",

      "d111=a/(math.sqrt(a1[0]**2+a1[1]**2+a1[2]**2));#interplanar distance between (111)planes\n",

      "snd=((n*h)/(2*d111));#\n",

      "th=math.degrees(math.asin(snd));# bragg angle in degree\n",

      "d1=math.floor(th);#\n",

      "d2=th-math.floor(d1);#\n",

      "print\"angle between planes (122) and (111) is \",d1,\" degree \",round(60*d2),\" minutes\"\n",

      "#wavelength is given wrong in example it is 0.54\u00c4 and it is taken as 1.54\u00c4\n"

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "angle between planes (122) and (111) is  7.0  degree  32.0  minutes\n"

       ]

      }

     ],

     "prompt_number": 113

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex3.36:pg-88"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "# Example 3.36: interplanner spacing and miller indices\n",

      " \n",

      "a=3.16;# in \u00c4\n",

      "h=1.54;# in \u00c4\n",

      "n=1;#\n",

      "th=20.3;# in degree\n",

      "d=((n*h)/(2*math.sin(math.radians(th))));# interplanner spacing in \u00c4\n",

      "x=a/d;#\n",

      "y=x**2;#\n",

      "print round(d,2),\"= interplanner spacing in \u00c4 \"\n",

      "print \"miller indices are (110) , (011) or (101)\"\n"

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "2.22 = interplanner spacing in \u00c4 \n",

        "miller indices are (110) , (011) or (101)\n"

       ]

      }

     ],

     "prompt_number": 115

    },

    {

     "cell_type": "heading",

     "level": 2,

     "metadata": {},

     "source": [

      "Ex3.37:pg-88"

     ]

    },

    {

     "cell_type": "code",

     "collapsed": false,

     "input": [

      "# Example 3.36: interplanner spacing and diffraction angle\n",

      "import math \n",

      "a=.2866;# in \u00c4\n",

      "h=0.1542;# in nm\n",

      "n=1.0;#\n",

      "a1=[2.0,1.0,1.0];#miller indices\n",

      "d211=a/(math.sqrt(a1[0]**2+a1[1]**2+a1[2]**2));#interplanar distance between (211)planes\n",

      "snd=((n*h)/(2*d211));#\n",

      "th=math.degrees(math.asin(snd));# bragg angle in degree\n",

      "d1=math.floor(th);#\n",

      "d2=th-math.floor(d1);#\n",

      "print\"angle between planes (122) and (111) is \",d1,\" degree \",round(60*d2),\" minutes\"\n",

      "print round(d211,2),\"=interplanner spacing in \u00c4 \"\n",

      "#answer is wrong in the textbook\n"

     ],

     "language": "python",

     "metadata": {},

     "outputs": [

      {

       "output_type": "stream",

       "stream": "stdout",

       "text": [

        "angle between planes (122) and (111) is  41.0  degree  13.0  minutes\n",

        "0.12 =interplanner spacing in \u00c4 \n"

       ]

      }

     ],

     "prompt_number": 121

    }

   ],

   "metadata": {}

  }

 ]

}