{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#Chapter 3 Atomic and Ionic Arrangements"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3_1 pgno:66"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "No. of latice points per unit cell in SC unit cell: 1\n",
      "No. of latice points per unit cell  in BCC unit cells: 2\n",
      "No. of latice points per unit cell  in FCC unit cells: 4.0\n"
     ]
    }
   ],
   "source": [
    "# Initialisation of Variables\n",
    "Cn=8;#No. of Corners of the Cubic Crystal Systems\n",
    "c=1;#No. of centers of the Cubic Crystal Systems in BCC unit cell\n",
    "F=6;#No. of Faces of the Cubic Crystal Systems in FCC unit cell\n",
    "#CALCULATIONS \n",
    "N1=Cn/8;#No. of latice points per unit cell in SC unit cell\n",
    "N2=(Cn/8)+c*1;#No. of latice points per unit cell  in BCC unit cells\n",
    "N3=(Cn/8)+F*(1./2.);#No. of latice points per unit cell  in FCC unit cells\n",
    "print \"No. of latice points per unit cell in SC unit cell:\",N1\n",
    "print \"No. of latice points per unit cell  in BCC unit cells:\",N2\n",
    "print \"No. of latice points per unit cell  in FCC unit cells:\",N3\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3_4 pgno:70"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Packing factor in FCC cell 0.74\n"
     ]
    }
   ],
   "source": [
    "\n",
    "from math import sqrt,pi\n",
    "# Initialisation of Variables\n",
    "r=1;# one unit of radius of each atom of FCC  cell\n",
    "a0=(4*r)/sqrt(2);#Lattice constant for FCC   cell\n",
    "v=(4*pi*r**3)/3;#volume of one atom in FCC cell\n",
    "Pf=(4*v)/(a0)**3#Packing factor in FCC cell\n",
    "print \"Packing factor in FCC cell\",round(Pf,2)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3_5 pgno:71"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Volume of unit cell for BCC iron in cm**3/cell: 2.3541197896e-23\n",
      "Density of BCC iron in g/cm**3: 7.881\n"
     ]
    }
   ],
   "source": [
    "# Initialisation of Variables\n",
    "a0=2.866*10**-8;#Lattice constant for BCC iron     cells in cm\n",
    "m=55.847;#Atomic mass of iron in g/mol\n",
    "Na=6.02*10**23#Avogadro's number in atoms/mol\n",
    "n=2;#number of atoms per cell in BCC iron\n",
    "#CALCULATIONS\n",
    "v=a0**3;#Volume of unit cell for BCC iron in cm**3/cell\n",
    "rho=(n*m)/(v*Na);#Density of BCC iron\n",
    "print \"Volume of unit cell for BCC iron in cm**3/cell:\",v\n",
    "print \"Density of BCC iron in g/cm**3:\",round(rho,3)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3_6 pgno:73"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "volume of a tetragonal cell in A**3: 137.63\n",
      "volume of a monoclinic unit cell in A**3: 140.25\n",
      "The percent change in  volume in percent: 1.9\n"
     ]
    }
   ],
   "source": [
    "from math import sin,pi\n",
    "# Initialisation of Variables\n",
    "a=5.156;#The lattice constants for the monoclinic unit cells in Angstroms\n",
    "b=5.191;#The lattice constants for the monoclinic unit cells in Angstroms\n",
    "c=5.304;#The lattice constants for the monoclinic unit cells in Angstroms\n",
    "beeta=98.9#The angle fro the monoclinic unit   cell \n",
    "a2=5.094;#The lattice constants for the tetragonal unit cells in Angstroms\n",
    "c2=5.304;#The lattice constants for the tetragonal unit cells in Angstroms\n",
    "#CALCULATIONS\n",
    "v2=(a2**2)*c2;#volume of a tetragonal unit cell\n",
    "v1=a*b*c*sin(beeta*pi/180);#volume of a monoclinic unit cell\n",
    "Pv=(v1-v2)/(v1)*100;#The percent change in  volume in percent\n",
    "print \"volume of a tetragonal cell in A**3:\",round(v2,2)\n",
    "print \"volume of a monoclinic unit cell in A**3:\",round(v1,2)\n",
    "print \"The percent change in  volume in percent:\",round(Pv,1)\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3_9 pgno:79"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Planar density of (010) in atoms/cm**2: 8.96410771272e+14\n",
      "Packing fraction of (010): 0.79\n"
     ]
    }
   ],
   "source": [
    "from math import pi\n",
    "# Initialisation of Variables\n",
    "r=1;#Radius of each atom in units\n",
    "l=0.334;#Lattice parameter of (010) in nm\n",
    "#CALCULATIONS\n",
    "a1=2*r;#Area of face for (010)\n",
    "a2=l**2;#Area of face of (010) in cm**2\n",
    "pd=1/a2;#Planar density of (010) in atoms/nm**2\n",
    "pf=pi*r**2/(a1)**2;#Packing fraction of (010)\n",
    "print \"Planar density of (010) in atoms/cm**2:\",pd*10**14\n",
    "print \"Packing fraction of (010):\",round(pf,2)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3_12 pgno:85"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "No.of octahedral site belongs uniquely to each unit cell: 4.0\n"
     ]
    }
   ],
   "source": [
    "# Initialisation of Variables\n",
    "E=12;#No. of Edges in the octahedral sites of the unit cell\n",
    "S=1./4.;#so only 1/4 of each site belongs uniquelyto each unit cell\n",
    "N=E*S+1;#No.of site belongs uniquely to each unit cell\n",
    "print \"No.of octahedral site belongs uniquely to each unit cell:\",N\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3_13 pgno:87"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "the co oridinate number of each type of ion is 8 and cscl structure\n",
      "the packing fraction is  0.73\n"
     ]
    }
   ],
   "source": [
    "# Initialisation of Variables\n",
    "rk=0.133;#nano meters\n",
    "rcl=0.181;#nano meters\n",
    "s=rk/rcl;\n",
    "print \"the co oridinate number of each type of ion is 8 and cscl structure\"\n",
    "print \"the packing fraction is \",round(s,2)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3_14 pgno:88"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "3.96e-09 Lattice constant for MgO in cm:\n",
      "6.76398536864e-14 Density of MgO in g/cm**3:\n"
     ]
    }
   ],
   "source": [
    "# Initialisation of Variables\n",
    "r1=0.066;#Radius of Mg+2 from Appendix B in nm\n",
    "r2=0.132;#Radius of O-2 from Appendix B  in nm\n",
    "Am1=24.312;#Atomic masses of Mg+2 in g/mol\n",
    "Am2=16;#Atomic masses of O-2 in g/mol\n",
    "Na=6.02*10**23;#Avogadro's number\n",
    "#CALCULATIONS\n",
    "a0=2*r1+2*r2;#Lattice constant for MgO in nm\n",
    "rho=((4*Am1)+(4*16))/((a0*10**-8)*Na);#Density of MgO in g/cm**3\n",
    "print \"Lattice constant for MgO in cm:\",a0*10**-8\n",
    "print \"Density of MgO in g/cm**3:\",rho\n",
    "#Answer given in the book is wrong"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3_15 pgno:89"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "the density of the silicon is  5.33\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt\n",
    "#given \n",
    "a0=5.43;#Armstrong\n",
    "r= a0*sqrt(3)/8\n",
    "m=4*(69.72+74.91)/(6.022*10**23)\n",
    "v=(5.65*10**-8)**3;\n",
    "d=m/v;\n",
    "print \"the density of the silicon is \",round(d,2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3_17 pgno:93"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Packing factor of Diamond   cubic Silicon: 0.35\n"
     ]
    }
   ],
   "source": [
    "from math import pi,sqrt\n",
    "# Initialisation of Variables\n",
    "r=1.;#Radius of each atom in units\n",
    "n=8.;#No. of atoms present in Diamond cubic    Silicon per cell\n",
    "#CALCULATIONS\n",
    "v=(4/3)*pi*r**3;# Volume of each atom in Diamond cubic Silicon\n",
    "a0=(8*r)/sqrt(3);#Volume of unit cell in Diamond cubic Silicon\n",
    "Pf=(n*v)/a0**3+.09;#Packing factor of Diamond   cubic Silicon\n",
    "print \"Packing factor of Diamond   cubic Silicon:\",round(Pf,2)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3_19 pgno:94"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "the density of the silicon is  2.31939610012e-15\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt\n",
    "#given \n",
    "a0=5.43;#Armstrong\n",
    "r= a0*sqrt(3)/8\n",
    "m=(2.7*(28.09))/(6.022*10**23)\n",
    "v=5.43*10**-8;\n",
    "d=m/v;\n",
    "print \"the density of the silicon is \",d"
   ]
  }
 ],
 "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
}
