{
 "metadata": {
  "name": "",
  "signature": "sha256:ad2a8335720a8ceacd5db30334fb790c6a4c8fa5b69e23fcad6e232d80ed69c2"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "2: Crystal Structure"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example number 2.1, Page number 29"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#importing modules\n",
      "import math\n",
      "from __future__ import division\n",
      "\n",
      "#Variable declaration\n",
      "d=6.5*10**3;                 #density of silver bromide(Kg/m**3)\n",
      "m=187.8;                     #molecular weight of silver bromide\n",
      "\n",
      "#Calculation\n",
      "M=(4*m)/(6.022*10**26);       #mass of ion in unit cell(kg)\n",
      "#d=mass of ions in unit cell/volume of unit cell\n",
      "a=((M/d)**(1/3))*10**10;        #lattice parameter(Angstrom)\n",
      "\n",
      "#Result\n",
      "print \"The lattice parameter is\",round(a,2),\"Angstrom\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The lattice parameter is 5.77 Angstrom\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example number 2.2, Page number 29"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#importing modules\n",
      "import math\n",
      "from __future__ import division\n",
      "\n",
      "#Variable declaration\n",
      "r=2.3;                            #atomic radius(Angstrom)\n",
      "\n",
      "#Calculation\n",
      "a=(4*r)/math.sqrt(3);     \n",
      "fv=((a)**3-(2*(4/3)*math.pi*r**3))*10**-30;    #free volume(m**3)\n",
      "\n",
      "#Result\n",
      "print \"The free volume per unit cell is\",round(fv*10**30,1),\"*10**-30 m**3\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The free volume per unit cell is 47.9 *10**-30 m**3\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example number 2.3, Page number 29"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#importing modules\n",
      "import math\n",
      "from __future__ import division\n",
      "\n",
      "#Variable declaration\n",
      "k=8.625*10**-5;                          #Boltzmann constant(eV/K)\n",
      "#n1000/n500=ln[n1000/n500]=Ev/1000k\n",
      "Ev=1.08;                                #average energy required to create a vacancy(eV)\n",
      "\n",
      "#Calculation\n",
      "N=math.exp(Ev/(1000*k));                     #ratio of vacancies\n",
      "\n",
      "#Result\n",
      "print \"The ratio of vacancies is\",round(N/10**5,1),\"*10**5\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The ratio of vacancies is 2.7 *10**5\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example number 2.4, Page number 29"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#importing modules\n",
      "import math\n",
      "from __future__ import division\n",
      "\n",
      "#Variable declaration\n",
      "#n500=N*exp(-Ev/500k)\n",
      "k=8.625*10**-5;                            #Boltzmann constant(eV/K)\n",
      "Ev=0.95;                                  #average energy required to create a vacancy\n",
      "\n",
      "#Calculation\n",
      "n=math.exp(-Ev/(500*k));                        #n500/N\n",
      "\n",
      "#Result\n",
      "print \"The ratio of number of vacancies to the number of atoms is\",round(n*10**10,1),\"*10**-10\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The ratio of number of vacancies to the number of atoms is 2.7 *10**-10\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example number 2.5, Page number 30"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#importing modules\n",
      "import math\n",
      "from __future__ import division\n",
      "\n",
      "#Variable declaration\n",
      "h=1;\n",
      "k=1;\n",
      "l=1;\n",
      "#d(hkl)=a/sqrt(h^2+k^2+l^2) where \"a\" is the lattice parameter\n",
      "r=0.18;     #atomic radius(nm)\n",
      "\n",
      "#Calculation\n",
      "d111=(2*math.sqrt(2)*r)/math.sqrt((h**2)+(k**2)+(l**2));     #spacing(nm)\n",
      "\n",
      "#Result\n",
      "print \"The spacing of (111) planes in a monoatomic structure is\",round(d111,2),\"nm\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The spacing of (111) planes in a monoatomic structure is 0.29 nm\n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example number 2.6, Page number 30"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#importing modules\n",
      "import math\n",
      "from __future__ import division\n",
      "\n",
      "#Variable declaration\n",
      "M=200;                               #atomic weight \n",
      "a=5;                                #lattice parameter(angstrom)\n",
      "Na=6.022*(10**26);\n",
      "\n",
      "#Calculation\n",
      "rho=(2*M)/(Na*(a*10**-10)**3);         #density of the structure(kg/m**3)\n",
      "\n",
      "#Result\n",
      "print \"The density of the bcc structure is\",round(rho/10**3,2),\"*10**3 kg/m**3\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The density of the bcc structure is 5.31 *10**3 kg/m**3\n"
       ]
      }
     ],
     "prompt_number": 17
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example number 2.7, Page number 30"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#importing modules\n",
      "import math\n",
      "from __future__ import division\n",
      "\n",
      "#Variable declaration\n",
      "#Free volume=a^3-[(4/3)*pi*r^3];for sc,a=2r\n",
      "#Therefore free volume =(2r)^3-[(4/3)*pi*r^3]\n",
      "fv=30.48*10**-30;                            #free volume per unit cell(m**3)\n",
      "\n",
      "#Calculation\n",
      "r=(fv/(8-(4/3)*math.pi))**(1/3)*(10**10);          #atomic radius(angstrom) \n",
      "\n",
      "#Result\n",
      "print \"The atomic radius is\",round(r),\"Angstrom\" "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The atomic radius is 2.0 Angstrom\n"
       ]
      }
     ],
     "prompt_number": 21
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example number 2.8, Page number 30"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#importing modules\n",
      "import math\n",
      "from __future__ import division\n",
      "\n",
      "#Variable declaration\n",
      "#free volume=a^3-[2*(4/3)*pi*r^3]\n",
      "#for bcc a=4r/3^(1/3)\n",
      "fv=61.72*(10**-30);                          #free volume(m**3)\n",
      "\n",
      "#Calculation\n",
      "a=-(fv/(1-math.pi*math.sqrt(3))/8)**1/3*10**31;           #lattice parameter(angstrom)\n",
      "\n",
      "#Result\n",
      "print \"The lattice parameter is\",round(a,2),\"Angstrom\"\n",
      "print \"answer in the book varies due to rounding off errors\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The lattice parameter is 5.79 Angstrom\n",
        "answer in the book varies due to rounding off errors\n"
       ]
      }
     ],
     "prompt_number": 24
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example number 2.9, Page number 30"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#importing modules\n",
      "import math\n",
      "from __future__ import division\n",
      "\n",
      "#Variable declaration\n",
      "rho=9000;                         #density(kg/m**3)\n",
      "w=65;                             #atomic weight\n",
      "v=1;                              #volume(m**3)\n",
      "a=1.4;                            #average number of free electrons per atom\n",
      "\n",
      "#Calculation\n",
      "n=(rho*v)/(w/(6.022*10**26));      #number of atoms\n",
      "rhoe=n*a;                          #density of free electrons per atom(electrons/m**3)\n",
      "\n",
      "#Result\n",
      "print \"The density of free electrons is\",round(rhoe/10**29,3),\"*10**29 electrons/m**3\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The density of free electrons is 1.167 *10**29 electrons/m**3\n"
       ]
      }
     ],
     "prompt_number": 26
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example number 2.10, Page number 31"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#importing modules\n",
      "import math\n",
      "from __future__ import division\n",
      "\n",
      "#Variable declaration\n",
      "h=1;\n",
      "k=0;\n",
      "l=1;\n",
      "d101=0.5;            #spacing of (101) plane\n",
      "\n",
      "#Calculation\n",
      "#d101=a/sqrt((h^2)+(k^2)+(l^2))\n",
      "a=d101*math.sqrt(2)      #lattice parameter(Angstrom)\n",
      "\n",
      "#Result\n",
      "print \"The lattice parameter is\",round(a,1),\"Angstrom\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The lattice parameter is 0.7 Angstrom\n"
       ]
      }
     ],
     "prompt_number": 28
    }
   ],
   "metadata": {}
  }
 ]
}