{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 6: X-rays"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.1, Page 369"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import *\n",
      "\n",
      "#Variable declaration\n",
      "i = 2e-003;  # Current through X-ray tube, A\n",
      "e = 1.6e-019;  # Charge on an electron, C\n",
      "V = 12.4e+003;  # Potential difference applied across X-ray tube, V \n",
      "m0 = 9.1e-031;  # Rest mass of the electron, Kg \n",
      "\n",
      "#Calculations&Results\n",
      "n = i/e;    # Number of electrons striking the target per second\n",
      "print \"The number of electrons striking the target per sec = %4.2e electrons\"%n\n",
      "v = sqrt(2*e*V/m0);  # Velocity of the electrons, m/s\n",
      "print \"The speed with which electrons strike the target = %4.2e m/s\"%v\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The number of electrons striking the target per sec = 1.25e+16 electrons\n",
        "The speed with which electrons strike the target = 6.60e+07 m/s\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.2, Page 370"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import *\n",
      "\n",
      "#Variable declaration\n",
      "e = 1.6e-019;  # Charge on an electron, C\n",
      "V = 13.6e+003;  # Potential difference applied across X-ray tube, V \n",
      "m0 = 9.1e-031;  # Rest mass of the electron, Kg \n",
      "\n",
      "#Calculations\n",
      "v = sqrt(2*e*V/m0);  # Velocity of the electron, m/s \n",
      "\n",
      "#Result\n",
      "print \"The maximum speed with which the electrons strike the target = %4.2e m/s\"%v\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The maximum speed with which the electrons strike the target = 6.92e+07 m/s\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.3, Page 370"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import *\n",
      "\n",
      "#Variable declaration\n",
      "d = 2.82e-010;  # Spacing of the rock-salt, m \n",
      "n = 2;  # Order of diffraction\n",
      "\n",
      "#Calculations\n",
      "theta = pi/2;    # Angle of diffraction, radian\n",
      "# Braggs equation for X-rays of wavelength lambda is n*lambda = 2*d*sin(theta), solving for lambda\n",
      "lamda = 2*d*sin(theta)/n;    # Wavelength of X-ray using Bragg's law, m\n",
      "\n",
      "#Result\n",
      "print \"The longest wavelength that can be analysed by a rock-salt crystal = %4.2f angstrom\"%(lamda/1e-010)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The longest wavelength that can be analysed by a rock-salt crystal = 2.82 angstrom\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.4, Page 371"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import *\n",
      "\n",
      "#Variable declaration\n",
      "lamda = 3e-011;  # Wavelength of the X-ray, m\n",
      "d = 5e-011;  # Lattice spacing, m \n",
      "\n",
      "#Calculations&Results\n",
      "# Bragg's equation for X-rays of wavelength lambda is n*lambda = 2*d*sin(theta), solving for thetas\n",
      "for n in range(2,4):\n",
      "    theta = degrees(asin((n*lamda)/(2*d)));    \n",
      "    print \"For n = %d, theta = %.1f degrees\"%(n, theta)\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "For n = 2, theta = 36.9 degrees\n",
        "For n = 3, theta = 64.2 degrees\n"
       ]
      }
     ],
     "prompt_number": 18
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.5, Page 371"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import *\n",
      "\n",
      "#Variable declaration\n",
      "lamda = 3.6e-011;  # Wavelength of X-rays, m\n",
      "n = 1;    # Order of diffraction\n",
      "theta = 4.8;    # Angle of diffraction, degrees\n",
      "\n",
      "#Calculations\n",
      "# Braggs equation for X-rays is n*lambda = 2*d*sin(theta), solving for d\n",
      "d = n*lamda/(2*sin(theta*pi/180));    # Interplanar spacing, m\n",
      "\n",
      "#Result\n",
      "print \"The interplanar separation of atomic planes in the crystal = %4.2f angstrom\"%(d/1e-010)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The interplanar separation of atomic planes in the crystal = 2.15 angstrom\n"
       ]
      }
     ],
     "prompt_number": 19
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.6, Page 371"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "lambda1 = 0.71;  # Wavelength of k alpha line in molybdenum, angstrom\n",
      "Z1 = 42;        # Atomic number of Mo\n",
      "Z2 = 29;        # Atomic number of Cu\n",
      "\n",
      "#Calculations\n",
      "# Wavelength of characteristic X-ray for K-alpha spectral line is given by \n",
      "# 1/lambda = 3/4*R*(Z-1)^2 then\n",
      "lambda2 = lambda1*(Z1-1)**2/(Z2-1)**2;    # The wavelength of K alpha radiation in copper, m\n",
      "\n",
      "#Result\n",
      "print \"The wavelength of K-alpha radiation in copper = %4.2f angstrom\"%lambda2\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The wavelength of K-alpha radiation in copper = 1.52 angstrom\n"
       ]
      }
     ],
     "prompt_number": 20
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.7, Page 372"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import *\n",
      "\n",
      "#Variable declaration\n",
      "phi = pi/2;    # Scattering angle, degrees\n",
      "m0 = 9.1e-031;  # Rest mass of an electron, kg\n",
      "h =  6.62e-034;  # Planck's constant, J-s\n",
      "c = 3e+008;  # Speed of light in vacuum, m/s \n",
      "E = 8.16e-014;  # Energy of gamma radiation, J\n",
      "\n",
      "#Calculations\n",
      "lamda = h*c/(E*1e-010);    # Wavelength of incident photon, angstrom \n",
      "lambda_prime = lamda+h*(1-cos(phi*pi/180))/(m0*c*1e-010);    # Wavelength of scattered photon, angstrom\n",
      "\n",
      "#Result\n",
      "print \"The wavelength of radiation at 90 degrees = %6.4f angstrom\"%(lambda_prime+lamda)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The wavelength of radiation at 90 degrees = 0.0487 angstrom\n"
       ]
      }
     ],
     "prompt_number": 56
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.8, Page 372"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import *\n",
      "\n",
      "#Variable declaration\n",
      "phi = 90;    # Scattering angle, radian\n",
      "m0 = 9.1e-031;  # Rest mass of the electron, kg\n",
      "h =  6.62e-034;  # Planck's constant, J-s\n",
      "c = 3e+008;  # Speed of light in vacuum, m/s \n",
      "lamda = 1.00 ;  # Wavelength of incident photon,in angstrom\n",
      "\n",
      "#Calculations\n",
      "del_lambda = (h*(1-round(cos(degrees(phi))))/(m0*c))/10**-10;    # Compton shift, angstrom\n",
      "\n",
      "#Result\n",
      "print \"The Compton shift = %.4f angstrom\"%del_lambda\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The Compton shift = 0.0242 angstrom\n"
       ]
      }
     ],
     "prompt_number": 54
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.9, Page 373"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import *\n",
      "\n",
      "#Variable declaration\n",
      "phi = pi/2;       # Scattering angle, radian\n",
      "m0 = 9.1e-031;  # Rest mass of the electron, kg\n",
      "h =  6.62e-034;  # Planck's constant, J-s\n",
      "c = 3e+008;  # Speed of light in vacuum, m/s \n",
      "\n",
      "#Calculations\n",
      "# As Compton shift = del_lambda = lambda, so\n",
      "lamda = h*(1-cos(phi))/(m0*c*1e-010);    # Wavelength of incident photon, angstrom\n",
      "\n",
      "#Result\n",
      "print \"The wavelength of incident radiation = %6.4f angstrom\"%lamda\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The wavelength of incident radiation = 0.0242 angstrom\n"
       ]
      }
     ],
     "prompt_number": 55
    }
   ],
   "metadata": {}
  }
 ]
}