{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 3: Metallic Crystal Structure"
     ]
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 3.1 Page No: 44"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "from sympy import Symbol\n",
      "\n",
      "R=Symbol('R')   \n",
      "a=2*R*round(math.sqrt(2),2)\n",
      "V=a**3\n",
      "\n",
      "print\"Volume is\",V,\"  m**3\"\n",
      "print\"which is also equal to 16*sqrt(2)*R**3\"\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Volume is 22.425768*R**3   m**3\n",
        "which is also equal to 16*sqrt(2)*R**3\n"
       ]
      }
     ],
     "prompt_number": 30
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 3.2 Page No: 44"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "n=4\n",
      "R=1        #say\n",
      "\n",
      "a=2*R*math.sqrt(2)\n",
      "Vc=a**3\n",
      "Vs=n*4*math.pi*R**3/3.0\n",
      "APF=Vs/Vc\n",
      "\n",
      "print\"Atomic packing fraction is\",round(APF,2)\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Atomic packing fraction is 0.74\n"
       ]
      }
     ],
     "prompt_number": 37
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 3.3 Page No: 45"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "R=1.28*10**-8        #Atomic radius in cm\n",
      "A_Cu=63.5            #Atomic wt of copper\n",
      "n=4                  #For FCC\n",
      "Na=6.023*10**23       #Avogadro no.\n",
      "\n",
      "a=2*R*math.sqrt(2)\n",
      "Vc=a**3\n",
      "den=n*A_Cu/(Vc*Na)\n",
      "\n",
      "print\"Density is  \",round(den,2),\"g/cm**3\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Density is   8.89 g/cm**3\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 3.6 Page No: 52"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "a=1/2.0\n",
      "b=1\n",
      "c=0\n",
      "\n",
      "x=[2*a,2*b,2*c]\n",
      "\n",
      "print\"The intercept for the given plane is\",x\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The intercept for the given plane is [1.0, 2, 0]\n"
       ]
      }
     ],
     "prompt_number": 44
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 3.8 Page No: 55"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "du=1\n",
      "dv=1\n",
      "dw=1\n",
      "\n",
      "u=(2*du-dv)/3.0\n",
      "v=(2*dv-du)/3.0\n",
      "t=-(u+v)\n",
      "w=dw\n",
      "\n",
      "x=[3*u,3*v,3*t,3*w]\n",
      "print\"The indices for the given directions are\",x\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The indices for the given directions are [1.0, 1.0, -2.0, 3]\n"
       ]
      }
     ],
     "prompt_number": 41
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 3.9 Page No: 56"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "a=-1\n",
      "b=1/2.0\n",
      "\n",
      "\n",
      "l=0      #Reciprocal of infinity\n",
      "m=1/a\n",
      "n=1/b\n",
      "x=[l,m,n]\n",
      "\n",
      "print\"The intercept for the given plane is\",x\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The intercept for the given plane is [0, -1, 2.0]\n"
       ]
      }
     ],
     "prompt_number": 37
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 3.11 Page No: 59"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "h=1        #Reciprocal of intersection point\n",
      "k=-1\n",
      "l=1\n",
      "i=-(h+k)\n",
      "\n",
      "x=[h,k,i,l]\n",
      "\n",
      "print\"The indices of plane are\",x\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The indices of plane are [1, -1, 0, 1]\n"
       ]
      }
     ],
     "prompt_number": 31
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Example 3.12 Page No: 70"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "a=0.2866           #Lattice parameter in nm\n",
      "h=2\n",
      "k=2\n",
      "l=0\n",
      "\n",
      "import math\n",
      "d_hkl=a/(math.sqrt(h**2+k**2+l**2))\n",
      "\n",
      "lam=0.1790     #Wavelength in nm\n",
      "n=1\n",
      "theta=math.asin(n*lam/(2*d_hkl))\n",
      "\n",
      "print\"(a)Interplanar spacing is  \",round(d_hkl,4),\"nm\"\n",
      "print\"(b)Diffraction angle is  \",round(2*theta*(180/math.pi),1),\"degree\"\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a)Interplanar spacing is   0.1013 nm\n",
        "(b)Diffraction angle is   124.1 degree\n"
       ]
      }
     ],
     "prompt_number": 25
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [],
     "language": "python",
     "metadata": {},
     "outputs": []
    }
   ],
   "metadata": {}
  }
 ]
}