{
 "metadata": {
  "name": "",
  "signature": "sha256:be1bff093c78fabbeb6fefe6e4abb0ea03e38b876fbc4829ed2c2e8b1df1e947"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Crystallography"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example number 6.1, Page number 185"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "#importing modules\n",
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "r=0.071;      #radius in nm\n",
      "N=6.022*10**26;    \n",
      "\n",
      "#Calculation\n",
      "r=r*10**-9;        #converting r from nm to m\n",
      "#mass of carbon atom m = 12/N\n",
      "m=12/N;\n",
      "#mass of diamond M = 8*mass of one carbon atom\n",
      "M=8*m;\n",
      "#volume of diamond V = (8*r/sqrt(3))^3\n",
      "V=(8*r/math.sqrt(3))**3;\n",
      "d=M/V;    #density in kg/m^3\n",
      "d=math.ceil(d*100)/100;   #rounding off to 2 decimals\n",
      "\n",
      "#Result\n",
      "print(\"density of diamond in kg/m^3 is\",d);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "('density of diamond in kg/m^3 is', 4520.31)\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example number 6.2, Page number 185"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "#importing modules\n",
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "aBCC=0.332;      #lattice constant in nm\n",
      "aHCP=0.296;      #lattice constant in nm\n",
      "c=0.468;      #c in nm\n",
      "\n",
      "#Calculation\n",
      "aBCC=aBCC*10**-9;     #converting nm to m\n",
      "Vbcc=aBCC**3;\n",
      "aHCP=aHCP*10**-9;     #converting nm to m\n",
      "c=c*10**-9;     #converting nm to m\n",
      "Vhcp=6*(math.sqrt(3)/4)*aHCP**2*c;\n",
      "V=Vhcp-Vbcc;\n",
      "Vch=(V*100)/Vbcc;\n",
      "Vch=math.ceil(Vch*100)/100;   #rounding off to 2 decimals\n",
      "\n",
      "#Result\n",
      "print(\"percentage change in volume is\",Vch);\n",
      "\n",
      "#answer given in the book is wrong"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "('percentage change in volume is', 191.12)\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example number 6.3, Page number 186"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "#importing modules\n",
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "r=1.278;     #atomic radius of Cu in Angstrom\n",
      "A=63.54;     #atomic weight of Cu\n",
      "n=4;     #for FCC n=4\n",
      "Na=6.022*10**26;\n",
      "\n",
      "#Calculation\n",
      "r=r*10**-10;    #converting atomic radius from Angstrom to m\n",
      "a=2*math.sqrt(2)*r;     \n",
      "rho=(n*A)/(Na*a**3);\n",
      "rho=math.ceil(rho*100)/100;   #rounding off to 2 decimals\n",
      "\n",
      "#Result\n",
      "print(\"density of Cu in kg/m^3 is\",rho);\n",
      "\n",
      "#answer given in the book is wrong"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "('density of Cu in kg/m^3 is', 8935.92)\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example number 6.4, Page number 186"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "#importing modules\n",
      "import math\n",
      "import numpy as np\n",
      "\n",
      "#Variable declaration\n",
      "rho=2180;     #density of NaCl in kg/m^3\n",
      "wNa=23;      #atomic weight of Na\n",
      "wCl=35.5;      #atomic weight of Cl\n",
      "n=4;   #for FCC n=4\n",
      "Na=6.022*10**26;\n",
      "\n",
      "#Calculation\n",
      "A=wNa+wCl;     #molecular weight of NaCl\n",
      "x=np.reciprocal(3.);\n",
      "a=((n*A)/(Na*rho))**x;\n",
      "\n",
      "#Result\n",
      "print(\"interatomic distance in NaCl in m is\",a); \n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "('interatomic distance in NaCl in m is', 5.6278114346454509e-10)\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example number 6.5, Page number 187"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "#importing modules\n",
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "a=0.42;    #lattice constant in nm\n",
      "h1=1;\n",
      "k1=0;\n",
      "l1=1;    #indices of the plane (101)\n",
      "h2=2;\n",
      "k2=2;\n",
      "l2=1;    #indices of the plane (221)\n",
      "\n",
      "#Calculation\n",
      "a=a*10**-9;    #converting from nm to m\n",
      "d1=a/math.sqrt((h1**2)+(k1**2)+(l1**2));     #interplanar spacing for plane (101)\n",
      "d1=d1*10**9;    #converting from m to nm\n",
      "d1=math.ceil(d1*10**5)/10**5;   #rounding off to 5 decimals\n",
      "d2=a/math.sqrt((h2**2)+(k2**2)+(l2**2));     #interplanar spacing for plane (221)\n",
      "d2=d2*10**9;    #converting from m to nm\n",
      "\n",
      "#Result\n",
      "print(\"interplanar spacing for (101) in nm is\",d1);\n",
      "print(\"interplanar spacing for (221) in nm is\",d2);\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "('interplanar spacing for (101) in nm is', 0.29699)\n",
        "('interplanar spacing for (221) in nm is', 0.14)\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example number 6.6, Page number 187"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "#Variable declaration\n",
      "h1=1;\n",
      "k1=0;\n",
      "l1=2;    #indices for plane (102)\n",
      "h2=2;\n",
      "k2=3;\n",
      "l2=1;    #indices for plane (231)\n",
      "h3=3;\n",
      "k3=-1;\n",
      "l3=2;    #indices for plane (31'2)\n",
      "\n",
      "#Calculation\n",
      "#intercepts made by the plane is a/h, b/k, c/l\n",
      "#for plane (102) intercepts are a/1=a, b/0=infinite, c/2\n",
      "#for plane (231) intercepts are a/2, b/3, c/1=c\n",
      "#for plane (31'2) intercepts are a/3=a, b/-1=-b, c/2\n",
      "\n",
      "#Result\n",
      "print(\"for plane (102) intercepts are a/1=a, b/0=infinite, c/2\");\n",
      "print(\"for plane (231) intercepts are a/2, b/3, c/1=c\");\n",
      "print(\"for plane (312) intercepts are a/3=a, b/-1=-b, c/2\");\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "for plane (102) intercepts are a/1=a, b/0=infinite, c/2\n",
        "for plane (231) intercepts are a/2, b/3, c/1=c\n",
        "for plane (312) intercepts are a/3=a, b/-1=-b, c/2\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example number 6.7, Page number 188"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "#importing modules\n",
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "u1=1;\n",
      "v1=1;\n",
      "w1=1;    #indices for plane (111)\n",
      "u2=2;\n",
      "v2=1;\n",
      "w2=2;    #indices for plane (212)\n",
      "\n",
      "#Calculation\n",
      "A=u1*u2+v1*v2+w1*w2;    \n",
      "B1=math.sqrt((u1**2)+(v1**2)+(w1**2));\n",
      "B2=math.sqrt((u2**2)+(v2**2)+(w2**2));\n",
      "B=A/(B1*B2);\n",
      "B=math.ceil(B*10**4)/10**4;   #rounding off to 4 decimals\n",
      "theta=math.acos(B);    #angle in radian\n",
      "theta=theta*57.2957795;     #converting radian to degrees\n",
      "theeta=math.ceil(theta*10**3)/10**3;   #rounding off to 3 decimals\n",
      "deg=int(theta);     #converting to degrees\n",
      "t=60*(theta-deg);\n",
      "mi=int(t);        #converting to minutes\n",
      "sec=60*(t-mi);      #converting to seconds\n",
      "sec=math.ceil(sec*10**2)/10**2;   #rounding off to 2 decimals\n",
      "\n",
      "#Result\n",
      "print(\"angle between the planes in degrees is\",theeta);\n",
      "print(\"angle between the planes is\",deg,\"degrees\",mi,\"minutes\",sec,\"seconds\");\n",
      "\n",
      "#answer given in the book is wrong"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "('angle between the planes in degrees is', 15.783)\n",
        "('angle between the planes is', 15, 'degrees', 46, 'minutes', 57.85, 'seconds')\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example number 6.8, Page number 188"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example number 6.9, Page number 189"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "#importing modules\n",
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "d=0.2338;     #interplanar distance in nm\n",
      "h=-1;\n",
      "k=1;\n",
      "l=1;   #indices of the plane (1'11)\n",
      "\n",
      "#Calculation\n",
      "d=d*10**-9;       #converting from nm to m\n",
      "a=d*math.sqrt((h**2)+(k**2)+(l**2));\n",
      "a=a*10**9;      #converting lattice constant from m to nm\n",
      "a=math.ceil(a*10**5)/10**5;   #rounding off to 5 decimals\n",
      "\n",
      "#Result\n",
      "print(\"lattice constant in nm is\",a);\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "('lattice constant in nm is', 0.40496)\n"
       ]
      }
     ],
     "prompt_number": 15
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example number 6.10, Page number 189"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "#importing modules\n",
      "import math\n",
      "\n",
      "#variable declaration\n",
      "h1=1;\n",
      "k1=0;\n",
      "l1=0;    #indices for plane (100)\n",
      "h2=1;\n",
      "k2=1;\n",
      "l2=0;    #indices for plane (110)\n",
      "h3=1;\n",
      "k3=1;\n",
      "l3=1;    #indices for plane (111)\n",
      "\n",
      "#Calculation\n",
      "#d=a/math.sqrt((h**2)+(k**2)+(l**2))\n",
      "#d100=a/math.sqrt((h1**2)+(k1**2)+(l1**2))\n",
      "x1=math.sqrt((h1**2)+(k1**2)+(l1**2));\n",
      "#d100=a/x1 = a/1 = a\n",
      "#d110=a/math.sqrt((h2**2)+(k2**2)+(l2**2))\n",
      "x2=math.sqrt((h2**2)+(k2**2)+(l2**2));\n",
      "x2=math.ceil(x2*10**4)/10**4;   #rounding off to 4 decimals\n",
      "#d110=a/x2 = a/sqrt(2)\n",
      "#d111=a/math.sqrt((h3**2)+(k3**2)+(l3**2))\n",
      "x3=math.sqrt((h3**2)+(k3**2)+(l3**2));\n",
      "x3=math.ceil(x3*10**4)/10**4;   #rounding off to 4 decimals\n",
      "#d111=a/x3 = a/sqrt(3)\n",
      "#hence d100:d110:d111=a:a/sqrt(2):a/sqrt(3)\n",
      "#multiplying RHS by sqrt(6) we get d100:d110:d111=sqrt(6):sqrt(3):sqrt(2)\n",
      "\n",
      "#Result\n",
      "print(\"value of x1 is\",x1);\n",
      "print(\"value of x2 is\",x2);\n",
      "print(\"value of x3 is\",x3);\n",
      "print(\"d100:d110:d111=sqrt(6):sqrt(3):sqrt(2)\");"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "('value of x1 is', 1.0)\n",
        "('value of x2 is', 1.4143)\n",
        "('value of x3 is', 1.7321)\n",
        "d100:d110:d111=sqrt(6):sqrt(3):sqrt(2)\n"
       ]
      }
     ],
     "prompt_number": 16
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example number 6.11, Page number 190"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "#variable declaration\n",
      "h=2;\n",
      "k=3;\n",
      "l=1;    #indices for plane (231)\n",
      "\n",
      "#Calculation\n",
      "#intercepts made by the plane is a/h, b/k, c/l\n",
      "#for a cubic unit cell, a=b=c\n",
      "#for plane (231) intercepts are a/2, a/3, a/1 = a\n",
      "#ratio of the intercepts is 1/2:1/3:1\n",
      "#LCM is 6. multiplying by LCM, we get ratio l1:l2:l3 = 3:2:6\n",
      "\n",
      "#Result\n",
      "print(\"l1:l2:l3 = 3:2:6\");"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "l1:l2:l3 = 3:2:6\n"
       ]
      }
     ],
     "prompt_number": 17
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example number 6.12, Page number 190"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "#variable declaration\n",
      "h=1;\n",
      "k=2;\n",
      "l=3;    #indices for plane (123)\n",
      "l1=0.8;       #l1 in armstrong\n",
      "a=0.8;       #a in armstrong\n",
      "b=1.2;       #b in armstrong\n",
      "c=1.5;       #c in armstrong\n",
      "\n",
      "#Calculation\n",
      "#intercepts made by the plane is a/h, b/k, c/l\n",
      "#for plane (123) intercepts are a/1 = a, b/2, c/3\n",
      "#ratio of the intercepts l1:l2:l3 = a:b/2:c/3\n",
      "#thus 0.8:l2:l3 = 0.8:1.2/2:1.5/3\n",
      "l2=1.2/2;     #l2 in armstrong\n",
      "l3=1.5/3;     #l3 in armstrong\n",
      "\n",
      "#Result\n",
      "print(\"value of l2 in armstrong is\",l2);\n",
      "print(\"value of l3 in armstrong is\",l3);"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "('value of l2 in armstrong is', 0.6)\n",
        "('value of l3 in armstrong is', 0.5)\n"
       ]
      }
     ],
     "prompt_number": 18
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example number 6.13, Page number 191"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "#Result\n",
      "print(\"in simple cubic unit cell nearest neighbour distance is a\");\n",
      "print(\"in body centered cubic unit cell nearest neighbour distance is sqrt(3)*a/2\");\n",
      "print(\"in face centered cubic unit cell nearest neighbour distance is a/sqrt(2)\");"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "in simple cubic unit cell nearest neighbour distance is a\n",
        "in body centered cubic unit cell nearest neighbour distance is sqrt(3)*a/2\n",
        "in face centered cubic unit cell nearest neighbour distance is a/sqrt(2)\n"
       ]
      }
     ],
     "prompt_number": 19
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example number 6.14, Page number 191"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "#importing modules\n",
      "import math\n",
      "\n",
      "#variable declaration\n",
      "a=2.04;     #lattice parameter in armstrong\n",
      "h=2;\n",
      "k=1;\n",
      "l=2;    #indices for plane (212)\n",
      "\n",
      "#Calculation\n",
      "a=a*10**-10;    #converting from armstrong to m\n",
      "d=a/math.sqrt((h**2)+(k**2)+(l**2));\n",
      "d=d*10**10;    #converting from m to armstrong\n",
      "d=math.ceil(d*10**3)/10**3;   #rounding off to 3 decimals\n",
      "\n",
      "#Result\n",
      "print(\"interplanar distance in armstrong is\",d);\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "('interplanar distance in armstrong is', 0.681)\n"
       ]
      }
     ],
     "prompt_number": 20
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example number 6.15, Page number 191"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "#importing modules\n",
      "import math\n",
      "\n",
      "#variable declaration\n",
      "r=1.278;      #radius of Cu in armstrong\n",
      "M=63.54;     #atomic weight of Cu\n",
      "rho=8980;    #density in kg/m^3\n",
      "Na=6.022*10**26;\n",
      "\n",
      "#Calculation\n",
      "r=r*10**-10;    #radius in m\n",
      "a=math.sqrt(8)*r;\n",
      "n=(rho*Na*a**3)/M;\n",
      "\n",
      "#Result\n",
      "print(\"interatomic distance in m is\",a);\n",
      "print(\"number of atoms per Cu unit cell is\",int(n));"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "('interatomic distance in m is', 3.6147298654256317e-10)\n",
        "('number of atoms per Cu unit cell is', 4)\n"
       ]
      }
     ],
     "prompt_number": 21
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example number 6.16, Page number 192"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "#variable declaration\n",
      "a=0.429;\n",
      "b=1;\n",
      "c=0.379;    #intercepts of an orthorhombic crystal\n",
      "\n",
      "#Calculation\n",
      "#ratio of intercepts are 0.214:1:0.188 = (a/0.429)*0.214:1:(c/0.379)*0.188 = a/2:b:c/2\n",
      "#thus the coefficients are 1/2:1:1/2. inverses are 2,1,2.\n",
      "#thus miller indices for the first plane are (212)\n",
      "#ratio of intercepts are 0.858:1:0.754 = (a/0.429)*0.0.858:1:(c/0.379)*0.754 = 2a:b:2c\n",
      "#thus the coefficients are 2:1:2. inverses are 1/2,1,1/2. LCM is 2. multiplying with LCM we get 1,2,1\n",
      "#thus miller indices for the second plane are (121)\n",
      "#ratio of intercepts are 0.429:infinite:0.126 = (a/0.429)*0.429:infinite:(c/0.379)*0.126 = a:infiniteb:c/3\n",
      "#thus the coefficients are 1:infinte:1/3. inverses are 1,0,3.\n",
      "#thus miller indices for the third plane are (103)\n",
      "\n",
      "#Result\n",
      "print(\"miller indices for the first plane are (212)\");\n",
      "print(\"miller indices for the second plane are (121)\");\n",
      "print(\"miller indices for the third plane are (103)\");\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "miller indices for the first plane are (212)\n",
        "miller indices for the second plane are (121)\n",
        "miller indices for the third plane are (103)\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example number 6.17, Page number 193"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "#importing modules\n",
      "import math\n",
      "import numpy as np\n",
      "\n",
      "#variable declaration\n",
      "h1=1;\n",
      "k1=0;\n",
      "l1=0;    #indices of the first plane (100)\n",
      "h2=1;\n",
      "k2=1;\n",
      "l2=0;    #indices of the second plane (110)\n",
      "h3=1;\n",
      "k3=1;\n",
      "l3=1;    #indices of the third plane (111)\n",
      "\n",
      "#Calculation\n",
      "n_1=np.reciprocal(4.);\n",
      "n_2=np.reciprocal(2.);\n",
      "n_3=np.reciprocal(6.);\n",
      "n1=(n_1*4)+1;    #number of atoms per unit cell in (100)\n",
      "#number of atoms per m^2 is 2/a**2. but a=sqrt(8)*r.\n",
      "#hence number of atoms per m^2 is 1/(4*r**2)\n",
      "n2=(n_1*4)+(2*n_2);   #number of atoms per unit cell in (110)\n",
      "#number of atoms per m^2 is 1/a*sqrt(2)*a. but a=sqrt(8)*r.\n",
      "#hence number of atoms per m^2 is 1/(8*sqrt(2)*r**2)\n",
      "n3=(n_3*3)+(3*n_2);   #number of atoms per unit cell in (111)\n",
      "#number of atoms per m^2 is 2/(sqrt(3)/4)*a**2. but a=4*r.\n",
      "#hence number of atoms per m^2 is 1/(2*sqrt(3)*r**2)\n",
      "\n",
      "#Result\n",
      "print(\"number of atoms per unit cell in (100)\",n1);\n",
      "print(\"number of atoms per m^2 is 1/(4*r**2)\");\n",
      "print(\"number of atoms per unit cell in (110)\",n2);\n",
      "print(\"number of atoms per m^2 is 1/(8*sqrt(2)*r**2)\");\n",
      "print(\"number of atoms per unit cell in (111)\",n3);\n",
      "print(\"number of atoms per m^2 is 1/(2*sqrt(3)*r**2)\");\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "('number of atoms per unit cell in (100)', 2.0)\n",
        "number of atoms per m^2 is 1/(4*r**2)\n",
        "('number of atoms per unit cell in (110)', 2.0)\n",
        "number of atoms per m^2 is 1/(8*sqrt(2)*r**2)\n",
        "('number of atoms per unit cell in (111)', 2.0)\n",
        "number of atoms per m^2 is 1/(2*sqrt(3)*r**2)\n"
       ]
      }
     ],
     "prompt_number": 22
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example number 6.18, Page number 194"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "#importing modules\n",
      "import math\n",
      "\n",
      "#variable declaration\n",
      "r=0.97;    #radius of Na+ ion in armstrong\n",
      "R=1.81;    #radius of Cl- ion in armstrong\n",
      "\n",
      "#Calculation\n",
      "#atomic packing factor=packing density PD\n",
      "#PD=Volume of atoms/Volume of unit cell\n",
      "#volume of unit cell=a**3\n",
      "#volume of atoms=number of atoms*volume of 1 atom = 4*(4/3)*math.pi*r**3\n",
      "#but r=a/sqrt(8). hence PD = 4*(4/3)*math.pi*(a/(2*sqrt(2)))**3*(1/a**3) = 0.74\n",
      "#atomic packing factor = 0.74\n",
      "r=r*10**-10;   #radius of Na+ ion in m\n",
      "R=R*10**-10;   #radius of Cl- ion in m\n",
      "Vna = (4*4*math.pi*r**3)/3;    #volume of Na atoms\n",
      "Vcl = (4*4*math.pi*R**3)/3;    #volume of Cl atoms \n",
      "V=(2*(r+R))**3;      #volume of unit cell\n",
      "IPF=(Vna+Vcl)/V;     #ionic packing factor\n",
      "IPF=math.ceil(IPF*10**4)/10**4;   #rounding off to 4 decimals\n",
      "\n",
      "#Result\n",
      "print(\"atomic packing factor = 0.74\");\n",
      "print(\"ionic packing factor of NaCl crystal is\",IPF);"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "atomic packing factor = 0.74\n",
        "('ionic packing factor of NaCl crystal is', 0.6671)\n"
       ]
      }
     ],
     "prompt_number": 24
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [],
     "language": "python",
     "metadata": {},
     "outputs": []
    }
   ],
   "metadata": {}
  }
 ]
}