{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#3: Crystal Physics"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 3.1, Page number 57"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "miller indices of 1st plane is ( 0.0 2.0 0.0 )\n",
      "miller indices of 2nd plane is ( 1.0 2.0 0.0 )\n",
      "miller indices of 3rd plane is ( 2.0 2.0 0.0 )\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "x1=float('inf');        #numerical intercept on X axis\n",
    "y1=1/2;         #numerical intercept on Y axis\n",
    "z1=float('inf');        #numerical intercept on Z axis\n",
    "x2=1;        #numerical intercept on X axis\n",
    "y2=1/2;         #numerical intercept on Y axis\n",
    "z2=float('inf');        #numerical intercept on Z axis\n",
    "x3=1/2;        #numerical intercept on X axis\n",
    "y3=1/2;         #numerical intercept on Y axis\n",
    "z3=float('inf');        #numerical intercept on Z axis\n",
    "\n",
    "#Calculation\n",
    "p1=1/x1;    #The miller indices of x-axis\n",
    "q1=1/y1;    #The miller indices of y-axis\n",
    "r1=1/z1;    #The miller indices of z-axis\n",
    "p2=1/x2;    #The miller indices of x-axis\n",
    "q2=1/y2;    #The miller indices of y-axis\n",
    "r2=1/z2;    #The miller indices of z-axis\n",
    "p3=1/x3;    #The miller indices of x-axis\n",
    "q3=1/y3;    #The miller indices of y-axis\n",
    "r3=1/z3;    #The miller indices of z-axis\n",
    "\n",
    "#Result\n",
    "print \"miller indices of 1st plane is (\",p1,q1,r1,\")\"\n",
    "print \"miller indices of 2nd plane is (\",p2,q2,r2,\")\"\n",
    "print \"miller indices of 3rd plane is (\",p3,q3,r3,\")\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 3.3, Page number 60"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The interplanar distance is 6.3589 *10**-11 m\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "h=3;     #miller indices with respect to x axis\n",
    "k=1;     #miller indices with respect to y axis\n",
    "l=1;     #miller indices with respect to z axis\n",
    "a=2.109*10**-10;    #lattice constant of plane in a simple cubic lattice(m)\n",
    "\n",
    "#Calculation\n",
    "d=(a/(math.sqrt(h**2+k**2+l**2)));      #The interplanar distance(m)\n",
    "\n",
    "#Result\n",
    "print \"The interplanar distance is\",round(d*10**11,4),\"*10**-11 m\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 3.4, Page number 60"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The lattice constant is 4.0447 *10**-10 m\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "h=1;    #miller indices with respect to x axis\n",
    "k=1;    #miller indices with respect to y axis\n",
    "l=0;    #miller indices with respect to z axis\n",
    "d=2.86*10**-10;    #the distance between miller indices(m)\n",
    "\n",
    "#Calculation\n",
    "a=(d*(math.sqrt(h**2+k**2+l**2)));     #The lattice constant(m)\n",
    "\n",
    "#Result\n",
    "print \"The lattice constant is\",round(a*10**10,4),\"*10**-10 m\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 3.6, Page number 61"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The ratio of intercepts on the three axis by ( 1 1 1 ) plane is 1.0 : 1.0 : 1.0\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "h=1;    #miller indices of x-axis\n",
    "k=1;    #miller indices of y-axis\n",
    "l=1;    #miller indices of z-axis\n",
    "\n",
    "#Calculation\n",
    "p=1/h;    #intercept on x-axis\n",
    "q=1/k;    #intercept on y-axis\n",
    "r=1/l;    #intercept on z-axis\n",
    "\n",
    "#Result\n",
    "print \"The ratio of intercepts on the three axis by (\",h,k,l,\") plane is\",p,\":\",q,\":\",r"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 3.7, Page number 61"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The inter planar spacing distance in 1st plane is 2.0347 *10**-10 m\n",
      "The inter planar spacing distance in 2nd plane is 1.7621 *10**-10 m\n",
      "The inter planar spacing distance in 3rd plane is 1.246e-10 m\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "r=1.246*10**-10;     #atomic radius of Fcc crystal(m)\n",
    "h1=1;     #miller indices with respect to x axis in 1st plane\n",
    "k1=1;     #miller indices with respect to y axis in 1st plane\n",
    "l1=1;     #miller indices with respect to z axis in 1st plane\n",
    "h2=2;     #miller indices with respect to x axis in 2nd plane\n",
    "k2=0;     #miller indices with respect to y axis in 2nd plane\n",
    "l2=0;     #miller indices with respect to z axis in 2nd plane\n",
    "h3=2;     #miller indices with respect to x axis in 3rd plane\n",
    "k3=2;     #miller indices with respect to y axis in 3rd plane\n",
    "l3=0;     #miller indices with respect to z axis in 3rd plane\n",
    "\n",
    "#Calculation\n",
    "a=(4*r)/math.sqrt(2);     #The lattice constant in a FCC crystal(m)\n",
    "d1=(a/(math.sqrt(h1**2+k1**2+l1**2)));     #inter planar spacing distance in 1st plane(m)\n",
    "d2=(a/(math.sqrt(h2**2+k2**2+l2**2)));     #inter planar spacing distance in 2nd plane(m)\n",
    "d3=(a/(math.sqrt(h3**2+k3**2+l3**2)));     #inter planar spacing distance in 3rd plane(m)\n",
    "\n",
    "#Result\n",
    "print \"The inter planar spacing distance in 1st plane is\",round(d1*10**10,4),\"*10**-10 m\"\n",
    "print \"The inter planar spacing distance in 2nd plane is\",round(d2*10**10,4),\"*10**-10 m\"\n",
    "print \"The inter planar spacing distance in 3rd plane is\",d3,\"m\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 3.8, Page number 62"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The inter planar spacing distance in 1st plane is a* 1.0 m\n",
      "The inter planar spacing distance in 2nd plane is a* 0.707 m\n",
      "The inter planar spacing distance in 3rd plane is a* 0.577 fm\n",
      "Ratio of interplanar distance of three planes d100:d110:d111= 1.0 : 0.707 : 0.577\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "a=1;    #assume\n",
    "h1=1;   #miller indices with respect to x axis in 1st plane\n",
    "k1=0;   #miller indices with respect to y axis in 1st plane\n",
    "l1=0;   #miller indices with respect to z axis in 1st plane\n",
    "h2=1;   #miller indices with respect to x axis in 2nd plane\n",
    "k2=1;   #miller indices with respect to y axis in 2nd plane\n",
    "l2=0;   #miller indices with respect to z axis in 2nd plane\n",
    "h3=1;   #miller indices with respect to x axis in 3rd plane\n",
    "k3=1;   #miller indices with respect to y axis in 3rd plane\n",
    "l3=1;   #miller indices with respect to z axis in 3rd plane\n",
    "\n",
    "#Calculation\n",
    "x1=math.sqrt(h1**2+k1**2+l1**2);\n",
    "d100=a/x1;    #inter planar spacing distance in 1st plane(m)\n",
    "x2=math.sqrt(h2**2+k2**2+l2**2);\n",
    "d110=a/x2;    #inter planar spacing distance in 2nd plane(m)\n",
    "x3=math.sqrt(h3**2+k3**2+l3**2);\n",
    "d111=a/x3;    #inter planar spacing distance in 3rd plane(m)\n",
    "\n",
    "#Result\n",
    "print \"The inter planar spacing distance in 1st plane is a*\",d100,\"m\"\n",
    "print \"The inter planar spacing distance in 2nd plane is a*\",round(d110,3),\"m\"\n",
    "print \"The inter planar spacing distance in 3rd plane is a*\",round(d111,3),\"fm\"\n",
    "print \"Ratio of interplanar distance of three planes d100:d110:d111=\",(1/x1),\":\",round((1/x2),3),\":\",round((1/x3),3)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 3.9, Page number 62"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The miller indices of the plane is (h k l)=( 3.0 6.0 1.0 )\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "p=1;   #x-intercept of the plane\n",
    "q=1/2;  #y-intercept of the plane\n",
    "r=3;    #z-intercept of the plane\n",
    "\n",
    "#Calculation\n",
    "h=(1/p)*3;     #miller indices with respect to x axis\n",
    "k=(1/q)*3;     #miller indices with respect to y axis\n",
    "l=(1/r)*3;     #miller indices with respect to z axis\n",
    "\n",
    "#Result\n",
    "print \"The miller indices of the plane is (h k l)=(\",h,k,l,\")\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 3.10, Page number 63"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The inter planar d-spacing distance is 2.814 angstrom\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "a=2.814;     #the lattice constant of a simple cubic system(angstrom)\n",
    "h1=1;        #miller indices with respect to x axis\n",
    "k1=0;        #miller indices with respect to y axis\n",
    "l1=0;        #miller indices with respect to z axis\n",
    "\n",
    "#Calculation\n",
    "d=a/math.sqrt(h1**2+k1**2+l1**2);     #inter planar d spacing distance(angstrom)\n",
    "\n",
    "#Result\n",
    "print \"The inter planar d-spacing distance is\",d,\"angstrom\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 3.11, Page number 63"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The miller indices of the set of parallel lines is ( 2.0 2.0 3.0 )\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "OA=0.025;    #The unit cell makes intercepts on a(nm)\n",
    "OB=0.02;     #The unit cell makes intercepts on b(nm)\n",
    "OC=0.01;     #The unit cell makes intercepts on c(nm)\n",
    "a=0.05;      #The unit cell edge of an orthorhombic crystal(nm)\n",
    "b=0.04;      #The unit cell edge of an orthorhombic crystal(nm)\n",
    "c=0.03;    #The unit cell edge of an orthorhombic crystal(nm)\n",
    "\n",
    "#Calculation\n",
    "p=a/OA;    #miller indices with respect to x axis\n",
    "q=b/OB;    #miller indices with respect to y axis\n",
    "r=c/OC;    #miller indices with respect to z axis\n",
    "\n",
    "#Result\n",
    "print \"The miller indices of the set of parallel lines is (\",p,q,r,\")\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 3.12, Page number 63"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The miller indices are 2 1 2\n",
      "The miller indices are 1 2 1\n",
      "The miller indices are 1 0 3.0\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "a=0.424;    #value of one axial unit\n",
    "b=1;       #value of second axial unit\n",
    "c=0.367;    #value of third axial unit\n",
    "i1=0.212;   #value at x-intercept\n",
    "j1=1;      #value at y-intercept\n",
    "k1=0.183;    #value at z-intercept\n",
    "i2=0.848;    #value at x-intercept\n",
    "j2=1;       #value at y-intercept\n",
    "k2=0.732;    #value at z-intercept\n",
    "i3=0.424;    #value at x-intercept\n",
    "k3=0.123;    #value at z-intercept\n",
    "\n",
    "#Calculation\n",
    "p1=1/(i1/a);     #miller indices at x-intercept\n",
    "q1=1/(j1/b);     #miller indices at y-intercept\n",
    "r1=1/(k1/c);     #miller indices at z-intercept\n",
    "p2=1/(i2/a)*2;    #miller indices at x-intercept\n",
    "q2=1/(j2/b)*2;    #miller indices at y-intercept\n",
    "r2=1/(k2/c)*2;    #miller indices at z-intercept\n",
    "p3=1/(i3/a);      #miller indices at x-intercept\n",
    "q3=0;             #miller indices at y-intercept\n",
    "r3=1/(k3/c);      #miller indices at z-intercept\n",
    "\n",
    "#Result\n",
    "print \"The miller indices are\",int(p1),int(q1),int(r1)\n",
    "print \"The miller indices are\",int(p2),int(q2),int(r2)\n",
    "print \"The miller indices are\",int(p3),int(q3),round(r3)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 3.13, Page number 65"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Miller indices are (1/infinite 1/ 2 1/ 7 )= 0 7 2\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "OB=2;    #The intercept made by the parrell line ,OB=2b\n",
    "OC=7;    #The intercept made by the parrell line ,OC=2c\n",
    "#OA=infinite  The intercept made by the parrell line ,OB=2b\n",
    "\n",
    "#Calculation\n",
    "A=0;     #miller indice along x-axis\n",
    "B=1/OB;     #miller indice along y-axis\n",
    "C=1/OC;     #miller indice along z-axis\n",
    "X=(B*(OC*OB));   #taking L.C.M\n",
    "Y=(C*(OC*OB));   #taking L.C.M\n",
    "\n",
    "#Result\n",
    "print \"Miller indices are (1/infinite 1/\",OB,\"1/\",OC,\")=\",A,int(X),int(Y)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 3.14, Page number 75"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The atomic radius of copper is 1.273 angstrom\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "a=3.6;     #lattice parameter of copper(angstrom)\n",
    "\n",
    "#Calculation\n",
    "r=(a*math.sqrt(2))/4;     #The atomic radius of copper(angstrom)\n",
    "\n",
    "#Result\n",
    "print \"The atomic radius of copper is\",round(r,3),\"angstrom\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 3.15, Page number 76"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The inter planar d-spacing distance is 1.1011 angstrom\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "a=4.12;     #the lattice constant of a simple cubic system(angstrom)\n",
    "h1=3;     #miller indices with respect to x axis\n",
    "k1=2;    #miller indices with respect to y axis\n",
    "l1=1;    #miller indices with respect to z axis\n",
    "\n",
    "#Calculation\n",
    "d=a/math.sqrt(h1**2+k1**2+l1**2);    #inter planar d spacing distance(angstrom)\n",
    "\n",
    "#Result\n",
    "print \"The inter planar d-spacing distance is\",round(d,4),\"angstrom\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 3.16, Page number 76"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The density of copper is 8934 Kg/m^3\n",
      "answer varies due to rounding off errors\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "n=4;    #no.of atoms in FCC structure\n",
    "A=63.54;    #Atomic weight of copper\n",
    "r=1.278*10**-10;   #atomic radius(m)\n",
    "N=6.023*10**26;    #Avogadro's Number(per Kg mol)\n",
    "\n",
    "#Calculation\n",
    "a=(4*r/math.sqrt(2));    #The lattice constant(m)\n",
    "d=A*n/(N*a**3);    #The density of copper(Kg/m^3)\n",
    "\n",
    "#Result\n",
    "print \"The density of copper is\",int(d),\"Kg/m^3\"\n",
    "print \"answer varies due to rounding off errors\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 3.17, Page number 76"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The ratio of interplanar distance between successive lattice planes in a simple cubic lattice is d100:d110:d111= 1 : 0.707 : 0.577\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "h1=1;    #miller indices with respect to x axis in 1st plane\n",
    "k1=0;    #miller indices with respect to y axis in 1st plane\n",
    "l1=0;    #miller indices with respect to z axis in 1st plane\n",
    "h2=1;    #miller indices with respect to x axis in 2nd plane\n",
    "k2=1;    #miller indices with respect to y axis in 2nd plane\n",
    "l2=0;    #miller indices with respect to z axis in 2nd plane\n",
    "h3=1;    #miller indices with respect to x axis in 3rd plane\n",
    "k3=1;    #miller indices with respect to y axis in 3rd plane\n",
    "l3=1;    #miller indices with respect to z axis in 3rd plane\n",
    "a=1;     #The lattice constant in a in a simple cubic lattice(m)\n",
    "\n",
    "#Calculation\n",
    "d100=a/math.sqrt(h1**2+k1**2+l1**2);    #inter planar spacing distance in 1st plane(m)\n",
    "d110=a/math.sqrt(h2**2+k2**2+l2**2);    #inter planar spacing distance in 2nd plane(m)\n",
    "d111=a/math.sqrt(h3**2+k3**2+l3**2);    #inter planar spacing distance in 3rd plane(m)\n",
    "\n",
    "#Result\n",
    "print \"The ratio of interplanar distance between successive lattice planes in a simple cubic lattice is d100:d110:d111=\",int(d100),\":\",round(d110,3),\":\",round(d111,3)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 3.18, Page number 76"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The distance between two adjacent atoms is 2.81 *10**-10 m\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "x=23;     #atomic weight of sodium\n",
    "y=35.45;   #atomic weight of chloride\n",
    "AW=58.45;    #atomic weight of sodium chloride(NaCl)\n",
    "n=4;    #no.of atoms in FCC structure\n",
    "d=2.18*10**6;   #density of NaCl crystal of FCC structure(kg/m^3)\n",
    "N=6.023*10**23;    #Avogadro's Number(per Kg mol)\n",
    "\n",
    "#Calculation\n",
    "a=(n*AW/(d*N))**(1/3);   #The lattice constant(m)\n",
    "r=a/2;    #The distance between two adjacent atoms(m)\n",
    "\n",
    "#Result\n",
    "print \"The distance between two adjacent atoms is\",round(r*10**10,2),\"*10**-10 m\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 3.19, Page number 77"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The atomic radius of Fe which has BCC structure is 1.242 angstrom\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "n=2;    #no.of atoms in BCC structure\n",
    "d=7.86*10**6;    #density of iron of FCC structure(kg/m^3)\n",
    "AW=55.85;      #atomic weight of Fe\n",
    "N=6.023*10**23;   #Avogadro's Number(per Kg mol)\n",
    "\n",
    "#Calculation\n",
    "a=(n*AW/(d*N))**(1/3);    #The lattice constant(m)\n",
    "r=a*math.sqrt(3)*10**10/4;     #The atomic radius of Fe which has BCC structure(angstrom)\n",
    "\n",
    "#Result\n",
    "print \"The atomic radius of Fe which has BCC structure is\",round(r,3),\"angstrom\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 3.20, Page number 77"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The lattice constant is 6.6 angstrom\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "n=4;    #no.of atoms in FCC structure\n",
    "d=2.7*10**3;   #density of potassium bromide(Kg/m^3)\n",
    "AW=119;    #molecular weight of KBr\n",
    "N=6.023*10**26;   #Avagadro's number(Kg mol)\n",
    "\n",
    "#Calculation\n",
    "a=((n*AW/(d*N))**(1/3))*10**10;      #The lattice constant(angstrom)\n",
    "\n",
    "#Result\n",
    "print \"The lattice constant is\",round(a,1),\"angstrom\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 3.21, Page number 78"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Number of atoms per unit cell of a crystal is 2.0\n",
      "If n=2,the crystal system is body centered cubic\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "d=9.6*10**2;    #density of crystal(Kg/m^3)\n",
    "AW=23;     #molecular weight of the crystal\n",
    "N=6.023*10**26;   #Avagadro's number(per Kg mol)\n",
    "a=4.3*10**-10;    #lattice constant(m)\n",
    "\n",
    "#Calculation\n",
    "n=d*N*a**3/AW;    #Number of atoms per unit cell of a crystal\n",
    "\n",
    "#Result\n",
    "print \"Number of atoms per unit cell of a crystal is\",round(n)\n",
    "print \"If n=2,the crystal system is body centered cubic\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 3.22, Page number 78"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The volume of cell is 2.128 *10**-29 m^3\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "r=1.2*10**-10;    #atomic radius of crystal of BCC structure(m)\n",
    "\n",
    "#Calculation\n",
    "a=4*r/math.sqrt(3);     #lattice constant of BCC structure(m)\n",
    "V=a**3;     #The volume of cell(m^3)\n",
    "\n",
    "#Result\n",
    "print \"The volume of cell is\",round(V*10**29,3),\"*10**-29 m^3\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 3.23, Page number 78"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The planar atomic density is 6.25e+12 atoms/mm^2\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "a=4*10**-7;    #lattice constant of the crystal(mm)\n",
    "h1=1;    #miller indices with respect to x axis in 1st plane\n",
    "k1=0;    #miller indices with respect to y axis in 1st plane\n",
    "l1=0;    #miller indices with respect to z axis in 1st plane\n",
    "\n",
    "#Calculation\n",
    "n=4*(1/4);     #Number of atoms contained in a plane per unit cell\n",
    "A=a**2;     #Area of the plane(mm^2)\n",
    "d=n/A;      #The planar atomic density(atoms/mm^2)\n",
    "\n",
    "#Result\n",
    "print \"The planar atomic density is\",d,\"atoms/mm^2\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 3.24, Page number 79"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The lattice constant is 4.0 *10**-10 m\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "n=4;     #no.of atoms in Face centered cubic lattice\n",
    "d=6250;    #density of potassium bromide(Kg/m^3)\n",
    "AW=60.2;   #molecular weight of crysal with face centered cubic lattice\n",
    "N=6.023*10**26;    #Avagadro's number(per Kg mol)\n",
    "\n",
    "#Calculation\n",
    "a=((n*AW/(d*N))**(1/3));     #The lattice constant(m)\n",
    "\n",
    "#Result\n",
    "print \"The lattice constant is\",round(a*10**10),\"*10**-10 m\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 3.25, Page number 79"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The change in volume percentage is 0.49326\n",
      "answer varies due to rounding off errors\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "r1=0.1258*10**-9;     #atomic radii of the iron atom in BCC structure(m)\n",
    "r2=0.1292*10**-9;    #atomic radii of the iron atom in FCC structure(m)\n",
    "T=910;    #metallic iron changes from BCC to FCC(C)\n",
    "\n",
    "#Calculation\n",
    "a1=(4*r1/math.sqrt(3));     #lattice constant of BCC structure(m)\n",
    "v1=a1**3/2;     #The volume occupied by one BCC atom(m^3)\n",
    "a2=4*r2/math.sqrt(2);    #lattice constant of FCC structure(m)\n",
    "v2=a2**3/4;     #The volume occupied by one FCC atom(m^3)\n",
    "V=((v1-v2)/v1)*100;    #The change in volume percentage\n",
    "\n",
    "#Result\n",
    "print \"The change in volume percentage is\",round(V,5)\n",
    "print \"answer varies due to rounding off errors\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 3.26, Page number 80"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The Number of unit cells is 4.70419 *10**22\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "a=0.405*10**-9;     #lattice constant of unit cell of aluminium which is face centered cubic(m)\n",
    "s=25*10**-2;      #Side of aluminium foil(m)\n",
    "t=0.005*10**-2;    #Thickness of aluminium foil(m)\n",
    "\n",
    "#Calculation\n",
    "ar=s**2;      #area of aluminium foil(m^2)\n",
    "V=ar*t;       #volume of the aluminium foil(m^3)\n",
    "v=a**3;       #volume of the unit cell(m^3)\n",
    "n=(V/v);      #Number of unit cells\n",
    "\n",
    "#Result\n",
    "print \"The Number of unit cells is\",round(n/10**22,5),\"*10**22\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example number 3.27, Page number 81"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The Volume of the unit cell of Magnesium which has HCP structure is 1.0 *10**-28 m^3\n",
      "answer given in the book is wrong\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "r=0.1605*10**-9;      #radius of magnesium atom which has HCP structure(m)\n",
    "\n",
    "#Calculation\n",
    "a=2*r;       #lattice constant of magnesium which has HCP structure(m)\n",
    "c=a*math.sqrt(8/3);     #height of the HCP structure(m)\n",
    "V=3*math.sqrt(3)*(a**2)*c/3;      #Volume of the unit cell of Magnesium which has HCP structure(m^3)\n",
    "\n",
    "#Result\n",
    "print \"The Volume of the unit cell of Magnesium which has HCP structure is\",round(V*10**28),\"*10**-28 m^3\"\n",
    "print \"answer given in the book is wrong\""
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}