{
 "metadata": {
  "name": "",
  "signature": "sha256:be9a21f00f98f6eae4cb352ab1396adae89de508dceae8166d48e690d1fe887a"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "8: X-Rays"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example number 8.1, Page number 210"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#importing modules\n",
      "import math\n",
      "from __future__ import division\n",
      "\n",
      "#Variable declaration\n",
      "theta = 15;        #angle of reflection(degrees)\n",
      "d = 2.5;           #atomic spacing(angstrom)\n",
      "n = 1;        #first order\n",
      "\n",
      "#Calculation\n",
      "d = d*10**-10;          #atomic spacing(m)\n",
      "theta = theta*math.pi/180;         #angle of reflection(radian)\n",
      "lamda = 2*d*math.sin(theta)/n;          #wavelength of X-rays(m)\n",
      "\n",
      "#Result\n",
      "print \"wavelength of X-rays is\",round(lamda/1e-10,3),\"*10**-10 m\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "wavelength of X-rays is 1.294 *10**-10 m\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example number 8.2, Page number 211"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#importing modules\n",
      "import math\n",
      "from __future__ import division\n",
      "\n",
      "#Variable declaration\n",
      "two_theta = 20;        #angle of reflection(degrees)\n",
      "d = 2.82;           #atomic spacing(angstrom)\n",
      "n = 1;        #first order\n",
      "\n",
      "#Calculation\n",
      "theta = two_theta/2;\n",
      "theta = theta*math.pi/180;         #angle of reflection(radian)\n",
      "lamda = 2*d*math.sin(theta)/n;          #wavelength of X-rays(angstrom)\n",
      "lamda = math.ceil(lamda*10**4)/10**4;   #rounding off to 4 decimals\n",
      "\n",
      "#Result\n",
      "print \"wavelength of X-rays is\",lamda,\"angstrom\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "wavelength of X-rays is 0.9794 angstrom\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example number 8.3, Page number 211"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#importing modules\n",
      "import math\n",
      "from __future__ import division\n",
      "\n",
      "#Variable declaration\n",
      "lamda = 10;       #wavelength(pm)\n",
      "phi = 45;         #scattering angle(degrees)\n",
      "h = 6.62*10**-34;     #planck's constant(m**2 kg/s)\n",
      "m0 = 9.1*10**-31;          #mass(kg)\n",
      "c = 3*10**8;        #velocity of light(m/s)\n",
      "ev = 6.24*10**18;         #conversion factor from J to eV\n",
      "\n",
      "#Calculation\n",
      "phi = phi*math.pi/180;         #scattering angle(radian)\n",
      "a = h/(m0*c);         #value of constant(m)\n",
      "a = a*10**12;         #value of constant(pm)\n",
      "lamda_dash = lamda+(a*(1-math.cos(phi)));      #wavelength of X-rays(pm)\n",
      "lamda_dash = math.ceil(lamda_dash*10**2)/10**2;   #rounding off to 2 decimals\n",
      "lamdadash = lamda+(2*a);       #maximum wavelength of scattered x-rays(pm)\n",
      "lamdadash = math.ceil(lamdadash*10)/10;   #rounding off to 1 decimal\n",
      "KE = h*c*((1/lamda)-(1/lamdadash))/(10**-12);          #maximum kinetic energy(J)\n",
      "KE = KE*ev;           #maximum kinetic energy(eV)\n",
      "KE = KE*10**-3;          #maximum kinetic energy(KeV)\n",
      "KE = math.ceil(KE*10)/10;   #rounding off to 1 decimal\n",
      "\n",
      "#Result\n",
      "print \"wavelength of X-rays scattered is\",lamda_dash,\"pm\"\n",
      "print \"maximum wavelength of scattered x-rays is\",lamdadash,\"pm\"\n",
      "print \"maximum kinetic energy is\",KE,\"KeV\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "wavelength of X-rays scattered is 10.72 pm\n",
        "maximum wavelength of scattered x-rays is 14.9 pm\n",
        "maximum kinetic energy is 40.8 KeV\n"
       ]
      }
     ],
     "prompt_number": 21
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example number 8.4, Page number 212"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#importing modules\n",
      "import math\n",
      "from __future__ import division\n",
      "\n",
      "#Variable declaration\n",
      "h = 6.62*10**-34;     #planck's constant(m**2 kg/s)\n",
      "m0 = 9.1*10**-31;          #mass(kg)\n",
      "c = 3*10**8;        #velocity of light(m/s)\n",
      "phi = 180;         #scattering angle(degrees)\n",
      "\n",
      "#Calculation\n",
      "phi = phi*math.pi/180;         #scattering angle(radian)\n",
      "a = h/(m0*c);         #value of constant(m)\n",
      "a = a*10**10;         #value of constant(angstrom)\n",
      "delta_lamda = a*(1-math.cos(phi));        #change in wavelength(angstrom)\n",
      "delta_lamda = math.ceil(delta_lamda*10**4)/10**4;   #rounding off to 4 decimals\n",
      "\n",
      "#Result\n",
      "print \"change in wavelength of photon is\",delta_lamda,\"angstrom\"\n",
      "print \"answer in the book varies due to rounding off errors\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "change in wavelength of photon is 0.0485 angstrom\n",
        "answer in the book varies due to rounding off errors\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example number 8.5, Page number 212"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#importing modules\n",
      "import math\n",
      "from __future__ import division\n",
      "\n",
      "#Variable declaration\n",
      "h = 6.62*10**-34;     #planck's constant(m**2 kg/s)\n",
      "m0 = 9.1*10**-31;          #mass(kg)\n",
      "c = 3*10**8;        #velocity of light(m/s)\n",
      "phi = 90;         #scattering angle(degrees)\n",
      "\n",
      "#Calculation\n",
      "phi = phi*math.pi/180;         #scattering angle(radian)\n",
      "a = h/(m0*c);         #value of constant(m)\n",
      "a = a*10**10;         #value of constant(angstrom)\n",
      "lamda = a*(1-math.cos(phi));        #wavelength(angstrom)\n",
      "lamda = math.ceil(lamda*10**5)/10**5;   #rounding off to 5 decimals\n",
      "E = h*c/(lamda*10**-10);          #energy of photon(J)\n",
      "\n",
      "#Result\n",
      "print \"wavelength of the photon is\",lamda,\"angstrom\"\n",
      "print \"energy of the incident photon is\",round(E/1e-14,4),\"*10**-14 J\"\n",
      "print \"answer for energy of incident photon is wrong in the book\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "wavelength of the photon is 0.02425 angstrom\n",
        "energy of the incident photon is 8.1897 *10**-14 J\n",
        "answer for energy of incident photon is wrong in the book\n"
       ]
      }
     ],
     "prompt_number": 14
    }
   ],
   "metadata": {}
  }
 ]
}