{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 6: Electron Optics"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.1, Page 6.20"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import sqrt\n",
      "\n",
      "# Given \n",
      "V = 500 # voltage across the electrode in eV\n",
      "m = 9e-31 # mass of electron in kg\n",
      "e = 1.6e-19 # charge on an electron in coulomb\n",
      "\n",
      "#Calculations\n",
      "E = e * V\n",
      "v = sqrt((2 * e * V) / m)\n",
      "p = m * v\n",
      "\n",
      "#Result\n",
      "print \"Energy gained by electron = %.e J\\nSpeed of electron = %.2e meter/sec\\nMomentum of electron = %.2e kg-meter/sec\"%(E,v,p)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Energy gained by electron = 8e-17 J\n",
        "Speed of electron = 1.33e+07 meter/sec\n",
        "Momentum of electron = 1.20e-23 kg-meter/sec\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.2, Page 6.20"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given \n",
      "v = 2.5e6 # speed of electron in meter/sec\n",
      "B = 2e-4 # magnetic field in tesla\n",
      "r = 1.76e11 # ratio of charge on electron to the mass of electron in C/kg\n",
      "\n",
      "#Calculations\n",
      "a = (B * r * v)\n",
      "\n",
      "#Result\n",
      "print \"Momentum of acceleration = %.2e meter/square sec.\"%a"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Momentum of acceleration = 8.80e+13 meter/square sec.\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.4, Page 6.21"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "# Given that\n",
      "v = 5.2e6 # speed of electron in meter/sec\n",
      "B = 1.3e-4 # magnetic field in tesla\n",
      "r = 1.76e11 # ratio of charge on electron to the mass of electron in C/kg\n",
      "E = 3.2e-12 # energy of the electron beam in J\n",
      "M = 9e-31 # mass of an electron in kg\n",
      "\n",
      "R = v / (r * B)\n",
      "v_ = sqrt((2 * E) / M )\n",
      "\n",
      "print \"Radius of circle traced by the beam = %.1f cm. \\nSpeed of beam in second case = %.2e meter/sec\"%(R*100,v_)\n",
      "print \"Speed of beam in second case is greater than speed of light so we cannot use above formula.\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Radius of circle traced by the beam = 22.7 cm. \n",
        "Speed of beam in second case = 2.67e+09 meter/sec\n",
        "Speed of beam in second case is greater than speed of light so we cannot use above formula.\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.5, Page 6.22"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given \n",
      "V = 2.500e3 # voltage across the electrode in V\n",
      "E = 3.6e4 # strength of electric field in V/m\n",
      "B = 1.2e-3 # magnetic field in tesla\n",
      "\n",
      "#Calculation\n",
      "r = (E / B)**2 / (2 * V)#calculation for ratio of the charge on an electron to the mass of an electron\n",
      "\n",
      "#Result\n",
      "print \"Ratio of the charge on an electron to the mass of an electron = %.1e C/kg.\"%r"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Ratio of the charge on an electron to the mass of an electron = 1.8e+11 C/kg.\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.6, Page 6.23"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import sqrt\n",
      "\n",
      "# Given \n",
      "M = 9.1e-31 # mass of electron in kg\n",
      "E = 1.6e-15 # energy of electron in J\n",
      "B = 5e-5 # magnetic field in tesla\n",
      "e = 1.6e-19 # charge on an electron in coulomb\n",
      "\n",
      "#Calculations\n",
      "v = sqrt((2 * E) / M)\n",
      "r = (M * v) / (e * B)\n",
      "\n",
      "#Result\n",
      "print \"Larmoure radius = %.2f meter\"%r"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Larmoure radius = 6.75 meter\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.7, Page 6.23"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given \n",
      "Mp = 1.67e-27 # mass of proton in kg\n",
      "v = 3e5 # speed of proton in meter/sec\n",
      "B = 5e-9 # magnetic field in tesla\n",
      "e = 1.6e-19 # charge on a proton in coulomb\n",
      "\n",
      "#Calculation\n",
      "r = (Mp * v) / (e * B)#calculation for Larmour radius\n",
      "\n",
      "#Result\n",
      "print \"Larmour radius = %.2e meter\"%r"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Larmour radius = 6.26e+05 meter\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.8, Page 6.23"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import sqrt, pi\n",
      "\n",
      "# Given \n",
      "M = 6.68e-27 # mass of helium ion in kg\n",
      "E = 1.6e-16 # energy of helium ion in J\n",
      "B = 5e-2 # magnetic field in tesla\n",
      "e = 1.6e-19 # charge on helium ion in coulomb\n",
      "\n",
      "#calculations\n",
      "v = sqrt((2 * E) / M)#calculation for velocity\n",
      "r = (M * v) / (e * B)#calculation for Larmour radius\n",
      "A = pi * r**2#calculation for area traced by the trajectory of helium ion\n",
      "\n",
      "#Result\n",
      "print \"Area traced by the trajectory of helium ion = %.3f square meter\"%A"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Area traced by the trajectory of helium ion = 0.105 square meter\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.9, Page 6.23"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given \n",
      "E = 100 # strength of electric field in V/m\n",
      "B = 1e-3 # magnetic field in tesla\n",
      "\n",
      "#Calculation\n",
      "v = E / B\n",
      "\n",
      "#Result\n",
      "print \"The drift of the guiding center = %.e m/sec\"%v"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The drift of the guiding center = 1e+05 m/sec\n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.10, Page 6.24"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given \n",
      "v = 1e6 # velocity of ion beam in m/sec\n",
      "B = 1 # magnetic field in tesla\n",
      "\n",
      "#Calculation\n",
      "E = B * v\n",
      "\n",
      "#Result\n",
      "print \"Internal electric field = %.e V/m\"%E"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Internal electric field = 1e+06 V/m\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 6.12, Page 6.24"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given \n",
      "r = 1.1 # ratio of new number of turns to the initial number of turns\n",
      "\n",
      "#Calculation\n",
      "r_ = (1 / r)**2\n",
      "\n",
      "#Result\n",
      "print \"Ratio of the new focus length to the initial focus length = %.3f \"%r_"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Ratio of the new focus length to the initial focus length = 0.826 \n"
       ]
      }
     ],
     "prompt_number": 11
    }
   ],
   "metadata": {}
  }
 ]
}