{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#Crystal Structures"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example 1.1, Page number 1.36"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "a= 5.43 Angstorm\n",
      "density = 6.88 kg/m**3\n",
      "#Answer given in the textbook is wrong\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#variable declaration\n",
    "d=2.351                 #bond lenght\n",
    "N=6.02*10**26           #Avagadro number\n",
    "n=8                     #number of atoms in unit cell\n",
    "A=28.09                 #Atomin mass of silicon\n",
    "m=6.02*10**26           #1mole\n",
    "\n",
    "#Calculations\n",
    "a=(4*d)/math.sqrt(3)\n",
    "p=(n*A)/((a*10**-10)*m)    #density\n",
    "\n",
    "#Result\n",
    "print \"a=\",round(a,2),\"Angstorm\"\n",
    "print \"density =\",round(p*10**16,2),\"kg/m**3\"\n",
    "print\"#Answer given in the textbook is wrong\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example 1.2, Page number 1.36"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "radius of largest sphere is 0.154700538379252*r\n",
      "maximum radius of sphere is 0.414213562373095*r\n"
     ]
    }
   ],
   "source": [
    " import math\n",
    "from __future__ import division\n",
    "from sympy import Symbol\n",
    "\n",
    "#Variable declaration\n",
    "r=Symbol('r')\n",
    "\n",
    "#Calculation\n",
    "a1=4*r/math.sqrt(3);\n",
    "R1=(a1/2)-r;           #radius of largest sphere\n",
    "a2=4*r/math.sqrt(2);\n",
    "R2=(a2/2)-r;       #maximum radius of sphere\n",
    "\n",
    "#Result\n",
    "print \"radius of largest sphere is\",R1\n",
    "print \"maximum radius of sphere is\",R2    \n",
    "   "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example 1.3, Page number 1.37"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "a1= 2.905 Angstrom\n",
      "Unit cell volume =a1**3 = 24.521 *10**-30 m**3\n",
      "Volume occupied by one atom = 12.26 *10**-30 m**3\n",
      "a2= 3.654 Angstorm\n",
      "Unit cell volume =a2**3 = 48.8 *10**-30 m**3\n",
      "Volume occupied by one atom = 12.2 *10**-30 m**3\n",
      "Volume Change in % = 0.493\n",
      "Density Change in % = 0.5\n",
      "Thus the increase of density or the decrease of volume is about 0.5%\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#variable declaration\n",
    "r1=1.258            #Atomic radius of BCC\n",
    "r2=1.292            #Atomic radius of FCC\n",
    "\n",
    "#calculations\n",
    "a1=(4*r1)/math.sqrt(3)       #in BCC\n",
    "b1=((a1)**3)*10**-30         #Unit cell volume\n",
    "v1=(b1)/2                    #Volume occupied by one atom\n",
    "a2=2*math.sqrt(2)*r2         #in FCC\n",
    "b2=(a2)**3*10**-30                   #Unit cell volume\n",
    "v2=(b2)/4                    #Volume occupied by one atom  \n",
    "v_c=((v1)-(v2))*100/(v1)     #Volume Change in % \n",
    "d_c=((v1)-(v2))*100/(v2)     #Density Change in %\n",
    "\n",
    "#Results\n",
    "print \"a1=\",round(a1,3),\"Angstrom\" \n",
    "print \"Unit cell volume =a1**3 =\",round((b1)/10**-30,3),\"*10**-30 m**3\"\n",
    "print \"Volume occupied by one atom =\",round(v1/10**-30,2),\"*10**-30 m**3\"\n",
    "print \"a2=\",round(a2,3),\"Angstorm\"\n",
    "print \"Unit cell volume =a2**3 =\",round((b2)/10**-30,3),\"*10**-30 m**3\"\n",
    "print \"Volume occupied by one atom =\",round(v2/10**-30,2),\"*10**-30 m**3\"\n",
    "print \"Volume Change in % =\",round(v_c,3)\n",
    "print \"Density Change in % =\",round(d_c,2)\n",
    "print \"Thus the increase of density or the decrease of volume is about 0.5%\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "##Example 1.4, Page number 1.38"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "a= 0.563 *10**-9 metre\n",
      "spacing between the nearest neighbouring ions = 0.2814 nm\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#variable declaration\n",
    "n=4     \n",
    "M=58.5                  #Molecular wt. of NaCl\n",
    "N=6.02*10**26           #Avagadro number\n",
    "rho=2180                #density\n",
    "\n",
    "#Calculations\n",
    "a=((n*M)/(N*rho))**(1/3)    \n",
    "s=a/2\n",
    "\n",
    "#Result\n",
    "print \"a=\",round(a/10**-9,3),\"*10**-9 metre\"\n",
    "print \"spacing between the nearest neighbouring ions =\",round(s/10**-9,4),\"nm\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##Example 1.5, Page number 1.38"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "lattice constant, a= 0.36 nm\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#variable declaration\n",
    "n=4     \n",
    "A=63.55                 #Atomic wt. of NaCl\n",
    "N=6.02*10**26           #Avagadro number\n",
    "rho=8930                #density\n",
    "\n",
    "#Calculations\n",
    "a=((n*A)/(N*rho))**(1/3)      #Lattice Constant\n",
    "\n",
    "#Result\n",
    "print \"lattice constant, a=\",round(a*10**9,2),\"nm\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "##Example 1.6, Page number 1.39"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Density of iron = 8805.0 kg/m**-3\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "#variable declaration\n",
    "r=0.123                  #Atomic radius\n",
    "n=4\n",
    "A=55.8                   #Atomic wt\n",
    "a=2*math.sqrt(2) \n",
    "N=6.02*10**26           #Avagadro number\n",
    "\n",
    "#Calculations\n",
    "rho=(n*A)/((a*r*10**-9)**3*N)\n",
    "\n",
    "#Result\n",
    "print \"Density of iron =\",round(rho),\"kg/m**-3\""
   ]
  }
 ],
 "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
}