{
 "metadata": {
  "name": "",
  "signature": "sha256:e2b0ac834d11aa0d2e0651bedb17bfa5de0bc6fec9d0616725df423273a3348a"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter2:X-RAY DIFFRACTION"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Eg1:pg-70"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "V=25*10**3     #potential difference in Volt\n",
      "h=6.63*10**-34 #planck constant in joule-sec\n",
      "c=3*10**8      #speed of light in m/sec\n",
      "e=1.6*10**-19  #charge of electron in coulomb\n",
      "theta=radians(15.8) #glancing angle for NaCl crystal for CuKa line\n",
      "d=2.82         #for NaCl\n",
      "lamda=2*d*sin(theta) \n",
      "print \"wavelength of CuKa line=\",round(lamda,4),\"Angstrom\"\n",
      "lamda_min=(h*c/(e*V))*10**10\n",
      "print \"wavelength of X-Ray photon at shortest limit=\",round(lamda_min,4),\"Angstrom\"\n",
      "theta_1=degrees(math.asin(lamda_min/(2*d)))\n",
      "print \"glancing angle for photons at the shortest wavelength limit=\",round(theta_1,2),\"degree\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "wavelength of CuKa line= 1.5357 Angstrom\n",
        "wavelength of X-Ray photon at shortest limit= 0.4972 Angstrom\n",
        "glancing angle for photons at the shortest wavelength limit= 5.06 degree\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Eg2:pg-70"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "theta=radians(30) #glancing angle in radians\n",
      "d=1.87            #spacing between lattice planes in angstrom\n",
      "n=2               #for second order reflection\n",
      "lamda=2*d*sin(theta)/n\n",
      "print \"wavelength of X-Rays=\",lamda,\"Angstrom\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "wavelength of X-Rays= 0.935 Angstrom\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Eg3:pg-70"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "lamda=0.36*10**-8 #wavelength in cm\n",
      "theta=radians(4.8)#glancing angle in radians\n",
      "n=1               #for first order diffraction\n",
      "d=n*lamda/(2*sin(theta))\n",
      "print \"interplanar separation of atomic planes in crystal=\",\"{:.2e}\".format(d),\"cm\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "interplanar separation of atomic planes in crystal= 2.15e-08 cm\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Eg4:pg-71"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "lamda=2.6*10**-10  #wavelength in meter\n",
      "theta=radians(20)  #in radians\n",
      "n=2                #for second order diffraction\n",
      "d=n*lamda/(2*sin(theta))\n",
      "print \"spacing constant of the crystal=\",round(d*10**10,2),\"Angstrom\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "spacing constant of the crystal= 7.6 Angstrom\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Eg5:pg-71"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "d=2.82*10**-10  #spacing in meter\n",
      "n=2             #for second order\n",
      "sin_theta=1     #maximum value of sin(theta)\n",
      "lamda_max=2*d*sin_theta/n\n",
      "print \"longest wavelength=\",lamda_max*10**10,\"Angstrom\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "longest wavelength= 2.82 Angstrom\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Eg6:pg-71"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "lamda=0.842   #wavelength in angstrom\n",
      "theta_1=8+(35./60)  #1' = (1/60)\u00ba = 0.01666667\u00ba\n",
      "theta_3=math.asin(round(3*sin(radians(theta_1)),2))\n",
      "print \"glancing angle for 3rd order reflection=\",round(math.degrees(theta_3),1),\"degrees\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "glancing angle for 3rd order reflection= 26.7 degrees\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Eg7:pg-71"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "lamda=0.97        #wavelength of first X-ray beam in angstrom\n",
      "theta=radians(60) #angle of reflection in radians\n",
      "n=3               #for third order reflection\n",
      "d=n*lamda/(2*sin(theta))\n",
      "n_1=1             #for first order reflection\n",
      "theta_1=radians(30) #angle of reflection in radians\n",
      "lamda_1=2*d*sin(theta_1)\n",
      "print \"wavelength of the second X-ray beam=\",round(lamda_1,2),\"Angstrom\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "wavelength of the second X-ray beam= 1.68 Angstrom\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Eg8:pg-72"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "lamda=0.30    #wavelength in angstrom\n",
      "d=0.5         #lattice spacing in angstrom\n",
      "n=2           #for second order diffraction\n",
      "theta=math.asin(n*lamda/(2*d))\n",
      "print \"For second order maxima, angle=\",round(math.degrees(theta),2),\"degrees\"\n",
      "n=3           #for third order diffraction\n",
      "theta=math.asin(n*lamda/(2*d))\n",
      "print \"For third order maxima, angle=\",round(math.degrees(theta),2),\"degrees\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "For second order maxima, angle= 36.87 degrees\n",
        "For third order maxima, angle= 64.16 degrees\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Eg9:pg-72"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "d=2.82*10**-8    #lattice spacing in cm \n",
      "c=3*10**10       #speed of light in cm/sec\n",
      "e=1.6*10**-19    #charge on electron in coulomb\n",
      "v=9045           #voltage in volt\n",
      "theta=radians(14)#angle in radians\n",
      "n=1              #first order\n",
      "lamda=2*d*sin(theta)/n\n",
      "h=(e*v*lamda/c)*10**7  #since 1 joule=10**7 erg\n",
      "print \"h=\",\"{:.2e}\".format(h),\"erg-sec\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "h= 6.58e-27 erg-sec\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Eg10:pg-72"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "do=2.82       #lattice spacing in angstrom\n",
      "theta=radians(10) #angle in radians\n",
      "lamda=2*do*round(sin(theta),4)\n",
      "print \"wavelength=\",round(lamda,4),\"Angstrom\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "wavelength= 0.9791 Angstrom\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Eg11:pg-72"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "d=0.4086*10**-10  #lattice spacing in meter\n",
      "h=6.6*10**-34     #planck constant in joule-sec\n",
      "m=9.1*10**-31     #mass of electron in Kg\n",
      "n=1               #first order\n",
      "theta=radians(65) #glancing angle in radians\n",
      "lamda=2*d*sin(theta)/n\n",
      "print \"wavelength=\",\"{:.3e}\".format(lamda),\"m\"\n",
      "v=h/(m*lamda)\n",
      "print \"velocity of electron=\",\"{:.3e}\".format(v),\"m/sec\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "wavelength= 7.406e-11 m\n",
        "velocity of electron= 9.793e+06 m/sec\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Eg12:pg-73"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "h=6.62*10**-34  #planck constant in joule-sec\n",
      "e=1.6*10**-19   #charge on electron in coulomb\n",
      "m=9*10**-31     #mass of electron in Kg\n",
      "v=344           #voltage in volt\n",
      "n=1             #first order\n",
      "theta=radians(60)#glancing angle in radians\n",
      "lamda=h/sqrt(2*m*e*v)\n",
      "d=n*lamda/(2*sin(theta))\n",
      "print \"spacing of the crystal=\",round(d*10**10,2),\"Angstrom\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "spacing of the crystal= 0.38 Angstrom\n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Eg13:pg-73"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "#given that\n",
      "lamda=1.32*10**-10    #wavelength in meter\n",
      "theta_deg=9           #angle fraction in degree\n",
      "theta_min=30          #angle fraction in minute\n",
      "theta =theta_deg+(theta_min/60.) # Total angle\n",
      "for n in range(1,5):\n",
      "    d = lamda/(n*2*math.sin(theta*math.pi/180)) # Inter layer spacing\n",
      "    print \"If order is %d then spacing is\"%(n),\"{:.2e}\".format(d),\"meter\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "If order is 1 then spacing is 4.00e-10 meter\n",
        "If order is 2 then spacing is 2.00e-10 meter\n",
        "If order is 3 then spacing is 1.33e-10 meter\n",
        "If order is 4 then spacing is 1.00e-10 meter\n"
       ]
      }
     ],
     "prompt_number": 15
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Eg14:pg-74"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "# given that\n",
      "theta1_deg = 5 # Absolut degree part of angle for first angle\n",
      "theta1_min = 23# remainder minute part of angle for first angle\n",
      "theta2_deg = 7 # Absolut degree part of angle for second angle\n",
      "theta2_min = 37# remainder minute part of angle for second angle\n",
      "theta3_deg = 9 # Absolut degree part of angle for third angle\n",
      "theta3_min = 22# remainder minute part of angle for third angle\n",
      "\n",
      "val1 = math.sin((theta1_deg+ theta1_min/60.)*math.pi/180)# Sin value for first angle\n",
      "val2 = math.sin((theta2_deg+ theta2_min/60.)*math.pi/180) #Sin value for second angle\n",
      "val3 = math.sin((theta3_deg+ theta3_min/60.)*math.pi/180)#Sin value for third angle\n",
      "ratio_21 = val2/val1\n",
      "ratio_31 = val3/val1\n",
      "print \"Interatomic layer separation ratios in crystal are as 1 : %f : %f\"%(ratio_21,ratio_31)\n",
      "print \"Above relation shows that crystal has a simple cubic crystal structure.\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Interatomic layer separation ratios in crystal are as 1 : 1.412775 : 1.734750\n",
        "Above relation shows that crystal has a simple cubic crystal structure.\n"
       ]
      }
     ],
     "prompt_number": 16
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Eg15:pg-82"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "h=6.63*10**-34  #planck constant in joule-sec\n",
      "c=3*10**8       #speed of light in m/sec\n",
      "mo=9.1*10**-31  #mass of electron in Kg\n",
      "theta=radians(180)#scattering angle in radians\n",
      "d_lamda=h*(1-math.cos(theta))/(mo*c)\n",
      "print \"change in wavelength of photon=\",round(d_lamda*10**10,4),\"Angstrom\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "change in wavelength of photon= 0.0486 Angstrom\n"
       ]
      }
     ],
     "prompt_number": 17
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Eg16:pg-82"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "#given that\n",
      "E=100.         # Energy of X ray beam in KeV\n",
      "theta=30       # Scattering angle in degree\n",
      "mo=9.1*10**-31 # mass of electron in kg\n",
      "c=3*10**8      # Speed of light in m/s\n",
      "E_rest=(mo*c**2)/(1.6e-19*1e3) # Rest mass energy in KeV\n",
      "k=(1/E)+ ((1-math.cos(radians(theta)))/(E_rest))\n",
      "k=int(k*10000)*10**-4\n",
      "del_e=E-1/k   # Energy of recoiled electron\n",
      "print \"Energy of recoiled electrons is \",round(del_e,2),\"KeV\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Energy of recoiled electrons is  1.96 KeV\n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Eg17:pg-82"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "#given that\n",
      "lamda=1         # wavelength in angstrom\n",
      "h=6.63*10**-34  # Planck's constant in joule-sec\n",
      "mo=9.1*10**-31  # mass of electron in kg\n",
      "c=3*10**8       # speed of light in m/sec\n",
      "theta=90        # scattering angle in degree\n",
      "d_lambda=h*(1-math.cos(radians(90)))/(mo*c) # calculation of compton shift \n",
      "print \"compton shift is \",round(d_lambda*1e10,4),\"Angstrom\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "compton shift is  0.0243 Angstrom\n"
       ]
      }
     ],
     "prompt_number": 20
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Eg18:pg-83"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "#given that\n",
      "lamda=0.015        #wavelength in angstrom\n",
      "h=6.63*10**-34     #Planks constant in joule-sec\n",
      "mo=9.1*10**-31     #mass of electron in kg\n",
      "c=3*10**8          #speed of light in m/sec\n",
      "theta=60           #scattering angle in degree\n",
      "d_lambda=h*(1-math.cos(theta*math.pi/180))*1e10/(mo*c) \n",
      "lambda_n=lamda+d_lambda\n",
      "print \"Wavelength of the scattered X-ray is \",round(lambda_n,3),\"Angstrom\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Wavelength of the scattered X-ray is  0.027 Angstrom\n"
       ]
      }
     ],
     "prompt_number": 21
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Eg19:pg-83"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "#given that\n",
      "lamda=1        # wavelength in angstrom\n",
      "h=6.63*10**-34 # Planck's constant in joule-sec\n",
      "mo=9.1*10**-31 # mass of electron in kg\n",
      "c=3*10**8      # speed of light in m/sec\n",
      "theta=90       # scattering angle in degree\n",
      "d_lambda= h*(1-math.cos(radians(90)))*1e10/(mo*c) # calculation of wavelength shift in angstrom\n",
      "lambda_n=lamda+d_lambda # Calculation of wavelength of scattered beam in angstrom\n",
      "K_E=h*c*(lambda_n-lamda)*1e10/(1.6e-19*lambda_n*lamda)# Calculation of K.E of recoiled electron in eV\n",
      "phi=math.atan(round((lamda/lambda_n),2))# calculation of Direction of the recoiled electron\n",
      "print \"Wavelength of the scattered beam is \",round(lambda_n,4),\"Angstrom\"\n",
      "print \"Kinetic Energy imparted to the recoiled electron is \",round(K_E),\"eV\"\n",
      "print \"Direction of the recoiled electron is \",round(degrees(phi),1),\"degree\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Wavelength of the scattered beam is  1.0243 Angstrom\n",
        "Kinetic Energy imparted to the recoiled electron is  295.0 eV\n",
        "Direction of the recoiled electron is  44.4 degree\n"
       ]
      }
     ],
     "prompt_number": 22
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Eg20:pg-84"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "#given that\n",
      "lamda=1        # wavelength in angstrom\n",
      "h=6.63*10**-34 # Planck's constant in joule-sec\n",
      "mo=9.1*10**-31 # mass of electron in kg\n",
      "c=3*10**8      # speed of light in m/sec\n",
      "theta=90       # scattering angle in degree\n",
      "d_lambda= h*(1-math.cos(radians(90)))*1e10/(mo*c) # calculation of compton shift in angstrom\n",
      "lambda_n=lamda+d_lambda # Calculation of wavelength of scattered beam in angstrom\n",
      "K_E=h*c*(lambda_n-lamda)*1e10/(1.6e-19*lambda_n*lamda)# Calculation of K.E of recoiled electron in eV\n",
      "print \"Compton shift is \",round(d_lambda,4),\"Angstrom\"\n",
      "print \"Kinetic Energy imparted to the recoiled electron is \",round(K_E),\"eV\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Compton shift is  0.0243 Angstrom\n",
        "Kinetic Energy imparted to the recoiled electron is  295.0 eV\n"
       ]
      }
     ],
     "prompt_number": 23
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Eg21:pg-84"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "h=6.63*10**-34 # Planck's constant in joule-sec\n",
      "mo=9.1*10**-31 # mass of electron in kg\n",
      "c=3*10**8      # speed of light in m/sec\n",
      "E=0.88*10**6   #energy of gamma-rays in eV\n",
      "theta=180      #scattering angle in degree for maximum energy of recoiled electron\n",
      "lamda=h*c*10**10/(E*1.6*10**-19)\n",
      "d_lamda_max=h*(1-math.cos(radians(theta)))*1e10/(mo*c)\n",
      "lamda_n=lamda+d_lamda_max\n",
      "K_E_max=h*c*d_lamda_max*1e10/(1.6e-19*lamda_n*lamda)\n",
      "print \"Maximum energy of compton recoil electrons is \",round(K_E_max*10**-6,3),\"MeV\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Maximum energy of compton recoil electrons is  0.682 MeV\n"
       ]
      }
     ],
     "prompt_number": 24
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Eg22:pg-85"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "h=6.62*10**-34 # Planck's constant in joule-sec\n",
      "mo=9.0*10**-31 # mass of electron in kg\n",
      "c=3*10**8      # speed of light in m/sec\n",
      "theta=90       # scattering angle in degree \n",
      "lamda=h*(1-math.cos(radians(theta)))*1e10/(mo*c)\n",
      "d_lamda=lamda  # compton shift \n",
      "E=h*c/(round(lamda,4)*1e-10)\n",
      "print \"Wavelength of incident photon is \",round(lamda,4),\"Angstrom\"\n",
      "print \"Energy of incident photon is \",\"{:.3e}\".format(E),\"joule\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Wavelength of incident photon is  0.0245 Angstrom\n",
        "Energy of incident photon is  8.106e-14 joule\n"
       ]
      }
     ],
     "prompt_number": 25
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Eg23:pg-85"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "h=6.63*10**-34 # Planck's constant in joule-sec\n",
      "mo=9.1*10**-31 # mass of electron in kg\n",
      "c=3*10**8      # speed of light in m/sec\n",
      "theta=90       # scattering angle in degree \n",
      "d_lamda=h*(1-math.cos(radians(theta)))*1e10/(mo*c)\n",
      "print \"Percentage change in energy when photon is:\"\n",
      "#(a) for microwave photon\n",
      "lamda=3*10**8  #wavelength of microwave photon in Angstrom\n",
      "energy_change=d_lamda*100/(lamda+d_lamda)\n",
      "print \"A microwave photon= \",\"{:.1e}\".format(energy_change),\"%\"\n",
      "\n",
      "#(b) for visible light photon\n",
      "lamda=5000     #wavelength of visible light photon in Angstrom\n",
      "energy_change=d_lamda*100/(lamda+d_lamda)\n",
      "print \"A visible light photon= \",\"{:.2e}\".format(energy_change),\"%\"\n",
      "\n",
      "#(c) for X-ray photon\n",
      "lamda=1        #wavelength of X-ray photon in Angstrom\n",
      "energy_change=d_lamda*100/(lamda+d_lamda)\n",
      "print \"An X-ray photon= \",round(energy_change,1),\"%\"\n",
      "\n",
      "#(d) for gamma-ray photon\n",
      "lamda=0.0124   #wavelength of gamma-ray photon in Angstrom\n",
      "energy_change=d_lamda*100/(lamda+d_lamda)\n",
      "print \"A gamma-ray photon= \",int(energy_change),\"%\"\n",
      "print \"Hence, the compton effect is dominant only in the gamma-ray region and shorter X-ray region.It is not observable in the visible region and microwave region\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Percentage change in energy when photon is:\n",
        "A microwave photon=  8.1e-09 %\n",
        "A visible light photon=  4.86e-04 %\n",
        "An X-ray photon=  2.4 %\n",
        "A gamma-ray photon=  66 %\n",
        "Hence, the compton effect is dominant only in the gamma-ray region and shorter X-ray region.It is not observable in the visible region and microwave region\n"
       ]
      }
     ],
     "prompt_number": 28
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Eg24:pg-86"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "lamda=2        # wavelength in angstrom\n",
      "h=6.62*10**-34 # Planck's constant in joule-sec\n",
      "mo=9.1*10**-31 # mass of electron in kg\n",
      "c=3*10**8      # speed of light in m/sec\n",
      "theta=45       # scattering angle in degree\n",
      "d_lamda=h*(1-math.cos(radians(theta)))*1e10/(mo*c) \n",
      "lamda_n=lamda+d_lamda \n",
      "f=d_lamda/lamda_n # Calculation of fraction of energy lost by photon \n",
      "print \"Fraction of energy lost by photon is \",round(f,4)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Fraction of energy lost by photon is  0.0035\n"
       ]
      }
     ],
     "prompt_number": 30
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Eg25:pg-87"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math \n",
      "C_W=0.0242     #compton wavelength of electron in Angstrom\n",
      "theta=45       # scattering angle in degree\n",
      "d_lamda=C_W*(1-math.cos(radians(theta)))\n",
      "lamda= d_lamda\n",
      "print \"Wavelength= \",round(lamda,3),\"Angstrom\"\n",
      "#answer is incomplete in book as only wavelength is calculated and no region is specified\n",
      "print \"Hence, such a photon lie in the Gamma-ray region of electromagnetic spectrum.\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Wavelength=  0.007 Angstrom\n",
        "Hence, such a photon lie in the Gamma-ray region of electromagnetic spectrum.\n"
       ]
      }
     ],
     "prompt_number": 31
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Eg26:pg-87"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "h=6.6*10**-34  # Planck's constant in joule-sec\n",
      "mo=9.1*10**-31 # mass of electron in kg\n",
      "c=3*10**8      # speed of light in m/sec\n",
      "E=510*10**3    # energy of gamma-rays in eV\n",
      "theta=90       # scattering angle in degree \n",
      "lamda=h*c/(E*1.6*10**-19)\n",
      "d_lamda=h*(1-math.cos(radians(theta)))/(mo*c)\n",
      "lamda_n=lamda+d_lamda\n",
      "Er=h*c*d_lamda/(lamda_n*lamda)\n",
      "phi=math.atan(lamda/lamda_n)\n",
      "print \"Wavelength of scattered radiation is \",\"{:.3e}\".format(lamda_n),\"meter\"\n",
      "print \"Energy of recoil electron is \",\"{:.3e}\".format(Er),\"joule\"\n",
      "print \"Direction of the recoil electron is \",round(degrees(phi),2),\"degree\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Wavelength of scattered radiation is  4.844e-12 meter\n",
        "Energy of recoil electron is  4.073e-14 joule\n",
        "Direction of the recoil electron is  26.61 degree\n"
       ]
      }
     ],
     "prompt_number": 32
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Eg27:pg-88"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "h=6.63*10**-34 # Planck's constant in joule-sec\n",
      "mo=9.1*10**-31 # mass of electron in kg\n",
      "c=3*10**8      # speed of light in m/sec\n",
      "E=510*10**3    # energy of gamma-rays in eV\n",
      "theta=90       # scattering angle in degree \n",
      "lamda=h*c/(E*1.6*10**-19)\n",
      "d_lamda=h*(1-math.cos(radians(theta)))/(mo*c)\n",
      "lamda_n=lamda+d_lamda\n",
      "print \"Wavelength of scattered radiation is \",round(lamda_n*10**10,4),\"Angstrom\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Wavelength of scattered radiation is  0.0487 Angstrom\n"
       ]
      }
     ],
     "prompt_number": 33
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Eg28:pg-88"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "h=6.62*10**-34 # Planck's constant in joule-sec\n",
      "mo=9.1*10**-31 # mass of electron in kg\n",
      "c=3*10**8      # speed of light in m/sec\n",
      "theta=180      # scattering angle in degree for minimum energy of incident photon\n",
      "lamda_max=h*(1-math.cos(radians(theta)))/(mo*c)\n",
      "E_min=h*c/lamda_max\n",
      "print \"Minimum energy of incident photon is \",int(round(E_min/(1.6*10**-16))),\"KeV\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Minimum energy of incident photon is  256 KeV\n"
       ]
      }
     ],
     "prompt_number": 34
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [],
     "language": "python",
     "metadata": {},
     "outputs": []
    }
   ],
   "metadata": {}
  }
 ]
}