{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 9 - Structure and Properties of Matter"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3 - pg 290"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Miller indices of the plane are :  6.0 3.0 2.0\n"
     ]
    }
   ],
   "source": [
    "#pg 290\n",
    "#calculate the miller indices\n",
    "#Given :\n",
    "#Intercepts\n",
    "ix = 1./3 ; #along x-axis\n",
    "iy = 2./3; # along y-axis\n",
    "iz =1.; # along z-axis\n",
    "#calculations\n",
    "#Reciprocals\n",
    "rx = 1./ix;\n",
    "ry = 1./iy;\n",
    "rz = 1./iz;\n",
    "#Conversion\n",
    "x = rx*2;\n",
    "y = ry*2;\n",
    "z = rz*2;\n",
    "#results\n",
    "print \"Miller indices of the plane are : \",x,y,z\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 7 - pg 296"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " Since, r/a = 0.432   and r = 0.432 *a  Crystal Structure : BCC\n"
     ]
    }
   ],
   "source": [
    "#pg296\n",
    "#calculate the r/a and Crystal Structure\n",
    "#Given:\n",
    "import math\n",
    "n = 1.;\n",
    "theta = 30.; # angle in degrees\n",
    "lambd = 1.67; # wavelength in A\n",
    "r = 1.25; # atomic radius in A\n",
    "#calculations\n",
    "#Bragg's Law : 2*d*sin(theta) = n*lambd , d= d111\n",
    "d111 = (n*lambd)/(2*math.sin(theta/57.3));\n",
    "#plane (111)\n",
    "h =1;k=1;l=1;\n",
    "#dhkl = a/sqrt(h**2 + k**2 + l**2)\n",
    "a = d111*math.sqrt(h**2 + k**2 + l**2); # in A\n",
    "ratio = r/a;\n",
    "#results\n",
    "print\" Since, r/a =\",round(ratio,3),\"  and r =\",round(ratio,3),\"*a  Crystal Structure : BCC\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 8 - pg 297"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " Density of silver (kg/m^3) =  10613.57\n"
     ]
    }
   ],
   "source": [
    "#pg 297\n",
    "#calculate the density of silver\n",
    "#Given:\n",
    "import math\n",
    "n = 1.;\n",
    "theta = 30.; #angle in degrees\n",
    "lambd = 2.88 ; # wavelength in A\n",
    "M = 108.; # atomic weight in kg\n",
    "Z = 4.; # unit cell of silver is FCC\n",
    "Na = 6.023*10**26 ;# Avogadro constant in kmole\n",
    "#calculations\n",
    "#Bragg's Law : 2*d*sin(theta) = n*lambd , d = d110\n",
    "d110 = (n*lambd)/(2*math.sin(theta/57.3)); # in A\n",
    "#plane (110)\n",
    "h =1;k=1;l=0;\n",
    "#dhkl = a/sqrt(h**2 + k**2 + l**2)\n",
    "a = d110*math.sqrt(h**2 + k**2 + l**2); # in A\n",
    "#1 A = 1.0*10**-10 m\n",
    "rho = (Z*M)/(Na*(a*10**-10)**3); # density in kg/m**3\n",
    "#results\n",
    "print\" Density of silver (kg/m^3) = \",round(rho,2)\n"
   ]
  }
 ],
 "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
}
