{
 "metadata": {
  "name": "",
  "signature": "sha256:177e44357417b2cfb0b476ada5b36a934225ade51d50763b09586ba8679f08fc"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 4:Crystal Diffraction"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.1 , Page no:75"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "from __future__ import division\n",
      "\n",
      "#given\n",
      "lambda1=2.6; #in Angstrom (wavelength)\n",
      "theta=20; #in Degree (angle)\n",
      "n=2;\n",
      "\n",
      "#calculate\n",
      "lambda1=lambda1*1E-10; #since lambda is in Angstrom\n",
      "#Since 2dsin(theta)=n(lambda)\n",
      "#therefore d=n(lambda)/2sin(theta)\n",
      "d=n*lambda1/(2*math.sin(math.radians(theta)));\n",
      "\n",
      "#result\n",
      "print\"The spacing constant is d=\",d,\"m\";\n",
      "print\"\\t\\t\\td=\",d*10**10,\"Angstrom\";"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The spacing constant is d= 7.60189144042e-10 m\n",
        "\t\t\td= 7.60189144042 Angstrom\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.2 , Page no:75"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "from __future__ import division\n",
      "\n",
      "#given\n",
      "h=1;k=1;l=0; #miller indices\n",
      "a=0.26; #in nanometer (lattice constant)\n",
      "lambda1=0.065; #in nanometer (wavelength)\n",
      "n=2; #order\n",
      "\n",
      "#calculate\n",
      "d=a/math.sqrt(h**2+k**2+l**2); #calculation of interlattice spacing\n",
      "#Since 2dsin(theta)=n(lambda)\n",
      "#therefore we have\n",
      "theta=math.asin(n*lambda1/(2*d));\n",
      "theta1=theta*180/3.14;\n",
      "\n",
      "#result\n",
      "print\"The glancing angle is =\",round(theta1,2),\"degree\";\n",
      "print \"Note: there is slight variation in the answer due to round off error\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The glancing angle is = 20.72 degree\n",
        "Note: there is slight variation in the answer due to round off error\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.3 , Page no:75"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "from __future__ import division\n",
      "\n",
      "#given\n",
      "d=3.04E-10; #in mm (spacing constant)\n",
      "lambda1=0.79; #in Angstrom (wavelength)\n",
      "n=3; #order\n",
      "\n",
      "#calculate\n",
      "#Since 2dsin(theta)=n(lambda)\n",
      "#therefore we have\n",
      "lambda2=lambda1*1E-10; #since lambda is in angstrom\n",
      "theta=math.asin(n*lambda2/(2*d));\n",
      "theta1=theta*180/3.14;\n",
      "\n",
      "#result\n",
      "print\"The glancing angle is\",round(theta1,3),\"degree\";\n",
      "print \"Note: In question the value of d=3.04E-9 cm but in solution is using d=3.04E-10 m. So I have used d=3.04E-10 cm as used in the solution\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The glancing angle is 22.954 degree\n",
        "Note: In question the value of d=3.04E-9 cm but in solution is using d=3.04E-10 m. So I have used d=3.04E-10 cm as used in the solution\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.4 , Page no:76"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "from __future__ import division\n",
      "\n",
      "#given\n",
      "d=0.282; #in nanometer (spacing constant)\n",
      "n=1; #order\n",
      "theta=8.35; #in degree (glancing angle)\n",
      "\n",
      "#calculate\n",
      "d=d*1E-9; #since d is in nanometer\n",
      "#Since 2dsin(theta)=n(lambda)\n",
      "#therefore we have\n",
      "lambda1=2*d*math.sin(math.radians(theta))/n; \n",
      "lambda_1=lambda1*1E10; #changing unit from m to Angstrom\n",
      "theta_1=90; #in degree (for maximum order theta=90)\n",
      "n_max=2*d*math.sin(math.radians(theta_1))/lambda1; #calculation of maximum order. \n",
      "\n",
      "#result\n",
      "print\"The wavelength  =\",lambda1,\"m\";\n",
      "print\"\\t\\t=\" ,round(lambda_1,3),\"Angstrom\";\n",
      "print\"The maximum order possible is n=\",round(n_max);\n",
      "print \"Note: In question value of theta=8 degree and 35 minutes but solution uses theta=8.35 degree.So I am using theta=8.35 degree\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The wavelength  = 8.19038939236e-11 m\n",
        "\t\t= 0.819 Angstrom\n",
        "The maximum order possible is n= 7.0\n",
        "Note: In question value of theta=8 degree and 35 minutes but solution uses theta=8.35 degree.So I am using theta=8.35 degree\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.5 , Page no:76"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "from __future__ import division\n",
      "\n",
      "#given\n",
      "theta=6; #in degree (glancing angle)\n",
      "p=2170; #in Kg/m^3 (density)\n",
      "M=58.46; #Molecular weight of NaCl\n",
      "N=6.02E26; #in Kg-molecule (Avogadro's number)\n",
      "n=1; #order\n",
      "XU=1E-12; #since 1X.U.= 1E-12m\n",
      "\n",
      "#calculate\n",
      "d=(M/(2*N*p))**(1/3); #calclation of lattice constant\n",
      "#Since 2dsin(theta)=n(lambda)\n",
      "#therefore we have\n",
      "lambda1=2*d*math.sin(math.radians(theta))/n; #calculation of wavelength\n",
      "lambda2=lambda1/XU;\n",
      "\n",
      "#result\n",
      "print\"The spacing constant is d=\",d,\"m\";\n",
      "print\"The wavelength is =\",lambda1,\"m\";\n",
      "print\"\\t\\t  =\",lambda2,\"X.U\";"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The spacing constant is d= 2.81789104396e-10 m\n",
        "The wavelength is = 5.89099640962e-11 m\n",
        "\t\t  = 58.9099640962 X.U\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.6 , Page no:77"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "from __future__ import division\n",
      "\n",
      "#given\n",
      "h=1;k=1;l=1; #miller indices\n",
      "a=5.63; #in Angstrom  (lattice constant)\n",
      "theta=27.5; #in degree (Glancing angle)\n",
      "n=1; #order\n",
      "H=6.625E-34; #in J-s (Plank's constant)\n",
      "c=3E8; #in m/s (velocity of light)\n",
      "e=1.6E-19; #charge of electron\n",
      "\n",
      "#calculate\n",
      "d=a/math.sqrt(h**2+k**2+l**2); #calculation for interplanar spacing\n",
      "#Since 2dsin(theta)=n(lambda)\n",
      "#therefore we have\n",
      "lambda1=2*d*math.sin(math.radians(theta))/n; #calculation for wavelength\n",
      "E=H*c/(lambda1*1E-10); #calculation of Energy\n",
      "E1=E/e; #changing unit from J to eV\n",
      "\n",
      "#result\n",
      "print\"The lattice spacing is d=\",round(d,2),\"Angstrom\";\n",
      "print\"The wavelength is =\",round(lambda1),\"Angstrom\";\n",
      "print\"The energy of X-rays is E=\",E,\"J\";\n",
      "print\"\\t\\t\\tE=\",E1,\"eV\";\n",
      "print \"Note: c=3E8 m/s but in solution c=3E10 m/s \""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The lattice spacing is d= 3.25 Angstrom\n",
        "The wavelength is = 3.0 Angstrom\n",
        "The energy of X-rays is E= 6.62100284311e-16 J\n",
        "\t\t\tE= 4138.12677695 eV\n",
        "Note: c=3E8 m/s but in solution c=3E10 m/s \n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.7 , Page no:77"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "from __future__ import division\n",
      "\n",
      "#given\n",
      "V=344; #in V (accelerating voltage)\n",
      "theta=60; #in degree (glancing angle)\n",
      "m=9.1E-31; #in Kg (mass of electron)\n",
      "h=6.625e-34; #in J-s (Plank's constant)\n",
      "n=1; #order\n",
      "e=1.6E-19; #charge on electron\n",
      "\n",
      "#calculate\n",
      "#Since K=m*v^2/2=e*V\n",
      "#therefore  v=sqrt(2*e*V/m)\n",
      "#since lambda=h/(m*v)\n",
      "#therefore we have lambda=h/sqrt(2*m*e*V)\n",
      "lambda1=h/math.sqrt(2*m*e*V); #calculation of lambda\n",
      "lambda2=lambda1*1E10; #changing unit from m to Angstrom\n",
      "#Since 2dsin(theta)=n(lambda)\n",
      "#therefore we have\n",
      "d=n*lambda2/(2*math.sin(math.radians(theta)));\n",
      "\n",
      "#result\n",
      "print\"The wavelength is =\",lambda1,\"m\";\n",
      "print\"\\t\\t  =\",round(lambda2,2),\"Angstrom\";\n",
      "print\"The interplanar spacing  is  d=\",round(d,2),\"Angstrom\";"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The wavelength is = 6.61928340764e-11 m\n",
        "\t\t  = 0.66 Angstrom\n",
        "The interplanar spacing  is  d= 0.38 Angstrom\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.8 , Page no:78"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "from __future__ import division\n",
      "\n",
      "#given\n",
      "K=0.02; #in eV (kinetic energy)\n",
      "d=2.0; #in Angstrom (Bragg's spacing)\n",
      "m=1.00898; #in amu (mass of neutron)\n",
      "amu=1.66E-27; #in Kg (1amu=1.66E-27 Kg)\n",
      "h=6.625e-34; #in J-s (Plank's constant)\n",
      "n=1; #order\n",
      "e=1.6E-19; #charge on electron\n",
      "\n",
      "#calculate\n",
      "#Since K=m*v^2/2\n",
      "#therefore  v=sqrt(2*K/m)\n",
      "#since lambda=h/(m*v)\n",
      "#therefore we have lambda=h/sqrt(2*m*K)\n",
      "m=m*amu; #changing unit from amu to Kg\n",
      "K=K*e; #changing unit to J from eV\n",
      "lambda1=h/math.sqrt(2*m*K); #calculation of lambda\n",
      "lambda2=lambda1*1E10; #changing unit from m to Angstrom\n",
      "theta=math.asin(n*lambda2/(2*d)); #calculation of angle of first order diffraction maximum\n",
      "theta1=theta*180/3.14;\n",
      "#result\n",
      "print\"The wavelength is =\",lambda1,\"m\";\n",
      "print\"\\t    \\t  =\",round(lambda2),\"Angstrom\";\n",
      "print\"The angle of first order diffraction maximum is \",round(theta1),\"Degree\";"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The wavelength is = 2.02348771817e-10 m\n",
        "\t    \t  = 2.0 Angstrom\n",
        "The angle of first order diffraction maximum is  30.0 Degree\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 4.9 , Page no:79"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#given\n",
      "lambda1=0.586; #in Angstrom (wavelength of X-rays)\n",
      "n1=1; n2=2; n3=3; #orders of diffraction\n",
      "theta1=5+(58/60); #in degree (Glancing angle for first order of diffraction)\n",
      "theta2=12+(01/60); #in degree (Glancing angle for second order of diffraction)\n",
      "theta3=18+(12/60); #in degree (Glancing angle for third order of diffraction)\n",
      "\n",
      "#calculate\n",
      "K1=math.sin(math.radians(theta1));\n",
      "K2=math.sin(math.radians(theta2));\n",
      "K3=math.sin(math.radians(theta3));\n",
      "#Since 2dsin(theta)=n(lambda)\n",
      "#therefore we have\n",
      "d1=n1*lambda1/(2*K1);\n",
      "d2=n2*lambda1/(2*K2);\n",
      "d3=n3*lambda1/(2*K3);\n",
      "d1=d1*1E-10; #changing unit from Angstrom to m\n",
      "d2=d2*1E-10; #changing unit from Angstrom to m\n",
      "d3=d3*1E-10; #changing unit from Angstrom to m\n",
      "d=(d1+d2+d3)/3;\n",
      "\n",
      "#result\n",
      "print\"The value of sine of different angle of diffraction is \\nK1=\",K1;\n",
      "print\"K2=\",K2;\n",
      "print\"K3=\",K3;\n",
      "#Taking the ratios of K1:K2:K3\n",
      "#We get K1:K2:K3=1:2:3\n",
      "#Therefore we have\n",
      "print\"Or we have K1:K2:K3=1:2:3\";\n",
      "print\"Hence these angles of incidence are for Ist, 2nd and 3rd order reflections respectively\";\n",
      "print\"The spacing constants are \\nd1=\",d1;\n",
      "print\"d2=\",d2;\n",
      "print\"d3=\",d3;\n",
      "print\"The mean value of crystal spacing is d=\",d,\"m\";"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value of sine of different angle of diffraction is \n",
        "K1= 0.103949856225\n",
        "K2= 0.208196213621\n",
        "K3= 0.312334918512\n",
        "Or we have K1:K2:K3=1:2:3\n",
        "Hence these angles of incidence are for Ist, 2nd and 3rd order reflections respectively\n",
        "The spacing constants are \n",
        "d1= 2.81866671719e-10\n",
        "d2= 2.81465253286e-10\n",
        "d3= 2.81428667722e-10\n",
        "The mean value of crystal spacing is d= 2.81586864243e-10 m\n"
       ]
      }
     ],
     "prompt_number": 9
    }
   ],
   "metadata": {}
  }
 ]
}