{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Ch-3 Electron Ballistics"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3.1 : Page 225"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Speed of the electron, v =sqrt(2*q*V/m) = 4.19e+07 m/s\n",
      "The kinetic energy = q x V = 5000 eV\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt\n",
    "q=1.6*10**-19 #charge of electron\n",
    "V=5000 #potential difference\n",
    "m=9.1*10**-31 #mass of electron\n",
    "v=sqrt(2*q*V/m) #speed of electron\n",
    "print \"Speed of the electron, v =sqrt(2*q*V/m) = %0.2e m/s\"% v\n",
    "ke=(q*V)/(1.6*10**-9) #kinetic energyin eV\n",
    "x1=ke*10**10\n",
    "print \"The kinetic energy = q x V = %0.f eV\"%x1"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3.2 Page 225"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Mass of the charged particle = 1000 times the mass of an electron = 9.10e-28 kg\n",
      "The charge of the partical = 1.6*10**-19 C\n",
      "Therefore, The velocity, v = sqrt(2*q*V/me) = 5.93e+05 m/s\n",
      "Kinetic energy = q x V = 1000.00 eV\n"
     ]
    }
   ],
   "source": [
    "me=1000*9.1*10**-31\n",
    "print \"Mass of the charged particle = 1000 times the mass of an electron = %0.2e kg\"%me\n",
    "print \"The charge of the partical = 1.6*10**-19 C\"\n",
    "q=1.6*10**-19 #charge of the particle\n",
    "V=1000 #potential difference\n",
    "format(8)\n",
    "v=sqrt(2*q*V/me)\n",
    "print \"Therefore, The velocity, v = sqrt(2*q*V/me) = %0.2e m/s\"%v\n",
    "ke=(q*V)/(1.6*10**-19)  # in eV\n",
    "print \"Kinetic energy = q x V = %0.2f eV\"%ke"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3.3 : Page 226"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Therefore, E = V / d = 5.83e+04 \n",
      "    ax = qE / m = 1.03e+16 m/s**2\n",
      "We know that,\n",
      "       x = vox*t + 0.5*a*t**2\n",
      "      vx = vox + ax*t\n",
      "(i) Consider x = 3*10**-3 m\n",
      "3*10**-3 = 3*10**6*t + 5.13*10**15*t**2\n",
      "Solving this equation,\n",
      "t = 5.26e-10 seconds \n",
      "vx = 8.40e+06 m/s \n",
      "(ii) Consider x = 6*10**-6 m\n",
      "t**2+(5.85*10**-10)*t-(1.17*10**-18) = 0\n",
      "Solving this equation,\n",
      "t = 8.28e-10 seconds \n",
      "vx = 1.15e+07 m/s\n"
     ]
    }
   ],
   "source": [
    "d=6*10**-3\n",
    "q=1.6*10**-19\n",
    "m=9.1*10**-31\n",
    "vax=3*10**6\n",
    "E=350/d\n",
    "print \"Therefore, E = V / d = %0.2e \"%E\n",
    "ax=q*E/m\n",
    "print \"    ax = qE / m = %0.2e m/s**2\"%ax\n",
    "print \"We know that,\"\n",
    "print \"       x = vox*t + 0.5*a*t**2\"\n",
    "print \"      vx = vox + ax*t\"\n",
    "print \"(i) Consider x = 3*10**-3 m\"\n",
    "print \"3*10**-3 = 3*10**6*t + 5.13*10**15*t**2\"\n",
    "print \"Solving this equation,\"\n",
    "from sympy import symbols, solve\n",
    "t=symbols('t')\n",
    "p1=(5.13*10**15)*t**2+(3*10**6)*t-3*10**-3\n",
    "t1=solve(p1,t)\n",
    "ans1=t1[1]\n",
    "print \"t = %0.2e seconds \"%ans1\n",
    "vx=(3*10**6)+((1.026*10**16)*(5.264*10**-10))\n",
    "print \"vx = %0.2e m/s \"%vx\n",
    "print \"(ii) Consider x = 6*10**-6 m\"\n",
    "print \"t**2+(5.85*10**-10)*t-(1.17*10**-18) = 0\"\n",
    "print \"Solving this equation,\"\n",
    "t=symbols('t')\n",
    "p2=t**2+(5.85*10**-10)*t-1.17*10**-18\n",
    "t2=solve(p2, t)\n",
    "ans2=t2[1]\n",
    "print \"t = %0.2e seconds \"%ans2\n",
    "vx1=(3*10**6)+((8.28*10**-10)*(1.026*10**16))\n",
    "print \"vx = %0.2e m/s\"%vx1"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3.4 : Page 227"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(i)The electron starts from rest at plate A, therefore, the initial velocity is zero. The velocity of electron on reaching plate B is\n",
      "v = sqrt(2*q*V/m) = 8.39e+06 m/s\n",
      "(ii)Time taken by the electron to travel from plate A to plate B can be calculated from the average velocity of the electron in transit.The average velocity is,\n",
      "vaverage = (Initial velocity + Final velocity) / 2 = 4.19e+06 m/s\n",
      "Therefore, time taken for travel is,\n",
      "Time = Separation between the plates / Average velocity = 7.16e-10 seconds\n",
      "(iii)Kinetic energy of the electron on reaching the plate B is\n",
      "Kinetic energy = q V = 3.20e-17 Joules\n"
     ]
    }
   ],
   "source": [
    "V=200\n",
    "m=9.1*10**-31\n",
    "format(8)\n",
    "v=sqrt(2*q*V/m)\n",
    "print \"(i)The electron starts from rest at plate A, therefore, the initial velocity is zero. The velocity of electron on reaching plate B is\"\n",
    "print \"v = sqrt(2*q*V/m) = %0.2e m/s\"%v\n",
    "iv=0 #initial velocity\n",
    "fv=8.38*10**6 #final velocity\n",
    "va=(iv+fv)/2 #average velocity of electron in transit\n",
    "print \"(ii)Time taken by the electron to travel from plate A to plate B can be calculated from the average velocity of the electron in transit.The average velocity is,\"\n",
    "print \"vaverage = (Initial velocity + Final velocity) / 2 = %0.2e m/s\"%va\n",
    "sp=3*10**-3 #separation between the plates\n",
    "time=sp/va\n",
    "print \"Therefore, time taken for travel is,\"\n",
    "print \"Time = Separation between the plates / Average velocity = %0.2e seconds\"%time\n",
    "ke=q*V\n",
    "print \"(iii)Kinetic energy of the electron on reaching the plate B is\"\n",
    "print \"Kinetic energy = q V = %0.2e Joules\"%ke"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3.5 : Page 228"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The speed acquired by electron due to the applied voltage is\n",
      "v = sqrt(vinitial**2+(2*q*V/m)) = 1.03e+07 m/s\n",
      "The average velocity,\n",
      "vaverage = (vinitial + vfinal) / 2 = 5.66e+06  m/s\n",
      "Therefore, time for travel = seperation between plates / vaverage = 1.41e-09 seconds\n"
     ]
    }
   ],
   "source": [
    "vinitial=1*10**6\n",
    "q=1.6*10**-19\n",
    "V=300\n",
    "m=9.1*10**-31\n",
    "vfinal=10.33*10**6\n",
    "sp=8*10**-3 #separation between plates\n",
    "v=sqrt(vinitial**2+(2*q*V/m))\n",
    "print \"The speed acquired by electron due to the applied voltage is\"\n",
    "print \"v = sqrt(vinitial**2+(2*q*V/m)) = %0.2e m/s\"%v\n",
    "va=(vinitial+vfinal)/2\n",
    "print \"The average velocity,\"\n",
    "print \"vaverage = (vinitial + vfinal) / 2 = %0.2e  m/s\"%va\n",
    "time=sp/va\n",
    "print \"Therefore, time for travel = seperation between plates / vaverage = %0.2e seconds\"%time"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3.6 : Page 229"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The electric field intensity,\n",
      "E = -5t / d*10*-9 = -5t / 10**-9*1*10**-2 = 5*10**11*t (for 0 < t < t1)\n",
      "  = 0     (for t1 < t < infinity)\n",
      "(i) The position of the electron after 1ns,\n",
      "     d(um) = (5*10**11)*(1.76*10**11)*((1*10**-9)**3/6) = 14.67 um\n",
      "(ii) The rest of the distance to be covered by the electron = 0.8cm - 14.7 um = 0.80\n",
      "Since, the potential difference drops to zero volt, after 1ns, the electron will travel the distance of 0.799 cm with a constant velocity of\n",
      "vx = (5*10**11)*(q/m)*(t**2/2) = 4.40e+04 m/s\n",
      "Therefore, the time t2 = d / vx = 1.81e-07 seconds\n",
      "The total time of transit of electron from cathode to anode = 1.82e-07 seconds\n"
     ]
    }
   ],
   "source": [
    "d=(5*10**11*1.76*10**11)*(((1*10**-9)**3)/6)\n",
    "x1=d*10**6\n",
    "print \"The electric field intensity,\"\n",
    "print \"E = -5t / d*10*-9 = -5t / 10**-9*1*10**-2 = 5*10**11*t (for 0 < t < t1)\"\n",
    "print \"  = 0     (for t1 < t < infinity)\"\n",
    "print \"(i) The position of the electron after 1ns,\"\n",
    "print \"     d(um) = (5*10**11)*(1.76*10**11)*((1*10**-9)**3/6) = %0.2f um\"%x1\n",
    "x2=0.8-(d*10**2)\n",
    "print \"(ii) The rest of the distance to be covered by the electron = 0.8cm - 14.7 um = %0.2f\"%x2\n",
    "print \"Since, the potential difference drops to zero volt, after 1ns, the electron will travel the distance of 0.799 cm with a constant velocity of\"\n",
    "vx=(5*10**11*1.76*10**11)*(((1*10**-9)**2)/2)\n",
    "print \"vx = (5*10**11)*(q/m)*(t**2/2) = %0.2e m/s\"%vx\n",
    "x3=(x2/vx)*10**-2\n",
    "print \"Therefore, the time t2 = d / vx = %0.2e seconds\"%x3\n",
    "x4=(1*10**-9)+x3\n",
    "print \"The total time of transit of electron from cathode to anode = %0.2e seconds\"%x4"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3.7 : Page 230"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The velocity of the electron is = sqrt(2qVa/m) = 3.75e+06 m/s\n",
      "The time taken for one revolution is T = 2*pi*m / B*q = 3.93e-11 seconds\n",
      "The pitch = T*v*cos(theta) = 1.28e-04 meters\n",
      "Thus, the electron has travelled = 1.28e-04 meters\n"
     ]
    }
   ],
   "source": [
    "from math import pi\n",
    "q=1.6*10**-19\n",
    "Va=40\n",
    "m=9.1*10**-31\n",
    "B=0.91\n",
    "ve=sqrt(2*q*Va/m)\n",
    "print \"The velocity of the electron is = sqrt(2qVa/m) = %0.2e m/s\"%ve\n",
    "tt=(2*pi*m)/(B*q)\n",
    "print \"The time taken for one revolution is T = 2*pi*m / B*q = %0.2e seconds\"%tt\n",
    "p=tt*ve*(sqrt(3)/2) #cos(30)=sqrt(3)/2\n",
    "print \"The pitch = T*v*cos(theta) = %0.2e meters\"%p\n",
    "print \"Thus, the electron has travelled = %0.2e meters\"%p"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3.8 : Page 231"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(i) The velocity of the charged particle before entering the field is,\n",
      "v = sqrt(2aV/m) * sqrt(2(3q)V/2m) = sqrt(6qV/2m) = 5.14e+06 m/s\n",
      "(ii) The radius of the helical path is\n",
      "r = Mvsine(theta) / QB = 2mvsine(theta) / 3qB = 0.41 mm\n",
      "(iii) Time for one revolution,\n",
      "T = 2*pi*M / B*Q = 2*pi*(2m) / B(3q) = 1.19e-09 seconds\n"
     ]
    }
   ],
   "source": [
    "from math import radians as rdn, sin\n",
    "radians=rdn(25)\n",
    "q=1.6*10**-19\n",
    "m=9.1*10**-31\n",
    "V=50\n",
    "Q=3*q\n",
    "M=2*m\n",
    "v=sqrt(2*Q*V/M)\n",
    "print \"(i) The velocity of the charged particle before entering the field is,\"\n",
    "print \"v = sqrt(2aV/m) * sqrt(2(3q)V/2m) = sqrt(6qV/2m) = %0.2e m/s\"%v\n",
    "B=0.02\n",
    "r=(M*v*sin(radians))/(Q*B)\n",
    "r1=r*10**3\n",
    "print \"(ii) The radius of the helical path is\"\n",
    "print \"r = Mvsine(theta) / QB = 2mvsine(theta) / 3qB = %0.2f mm\"%r1\n",
    "T=(2*pi*M)/(B*Q)\n",
    "print \"(iii) Time for one revolution,\"\n",
    "print \"T = 2*pi*M / B*Q = 2*pi*(2m) / B(3q) = %0.2e seconds\"%T"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3.9 : Page 232"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Given,     T = 35.5/B *10**-12 s, B = 0.01 Wb/m**3, Va = 900V\n",
      "Therefore, T = 3.55*10**-9 s\n",
      "Velocity,  v(m/s) = sqrt(2qVa/m) = 1.78e+07 m/s\n",
      "Radius,  r(mm) = mv/qB = v/(q/m)B = 10.11 mm\n"
     ]
    }
   ],
   "source": [
    "print \"Given,     T = 35.5/B *10**-12 s, B = 0.01 Wb/m**3, Va = 900V\"\n",
    "print \"Therefore, T = 3.55*10**-9 s\"\n",
    "T = 3.55*10**-9\n",
    "Va=900\n",
    "v=sqrt(2*(1.76*10**11)*900)\n",
    "print \"Velocity,  v(m/s) = sqrt(2qVa/m) = %0.2e m/s\"%v\n",
    "r=(17.799*10**6)/(0.01*1.76*10**11)\n",
    "x1=r*10**3\n",
    "print \"Radius,  r(mm) = mv/qB = v/(q/m)B = %0.2f mm\"%x1"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3.10 : Page 232"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(i) The velocity of the electron, v = 1.45e+07 m/s\n",
      "(ii) ma = qE\n",
      "Thus, acceleration, a(m/s)= qE / m = (q/m)(Vd/d) = 4.40e+14 m/s\n",
      "(iii) The deflection on the screen, D(cm)= ILVd / 2Vad = 1.46 cm\n",
      "(iv) Deflection sensitivity(cm/V)= D / Vd = 0.07 cm/V\n"
     ]
    }
   ],
   "source": [
    "Va=600\n",
    "l=3.5\n",
    "d=0.8\n",
    "L=20\n",
    "Vd=20\n",
    "format(9)\n",
    "q=1.6*10**-19\n",
    "m=9.1*10**-31\n",
    "v=sqrt(2*q*Va/m)\n",
    "print \"(i) The velocity of the electron, v = %0.2e m/s\"%v\n",
    "a=(q/m)*(Vd/d)\n",
    "a1=a*10**2\n",
    "print \"(ii) ma = qE\"\n",
    "print \"Thus, acceleration, a(m/s)= qE / m = (q/m)(Vd/d) = %0.2e m/s\"%a1\n",
    "D=(l*L*Vd)/(2*Va*d)\n",
    "print\"(iii) The deflection on the screen, D(cm)= ILVd / 2Vad = %0.2f cm\"% D\n",
    "Ds=D/Vd\n",
    "print  \"(iv) Deflection sensitivity(cm/V)= D / Vd = %0.2f cm/V\"%Ds"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3.11 : Page 233"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(i) The velocity of the beam, v = sqrt(2qVa / m) = 1.68e+07 m/s\n",
      "(ii) The deflection of the beam, D = lLVd / 2dVa\n",
      "Therefore, the voltage that must be applied to the plates, Vd = 20.00 V\n"
     ]
    }
   ],
   "source": [
    "q=1.6*10**-19\n",
    "m=9.1*10**-31\n",
    "Va=800\n",
    "l=2\n",
    "d=0.5\n",
    "L=20\n",
    "D=1\n",
    "v=sqrt(2*q*Va/m)\n",
    "print \"(i) The velocity of the beam, v = sqrt(2qVa / m) = %0.2e m/s\"%v\n",
    "Vd=(D*2*d*Va)/(l*L)\n",
    "print \"(ii) The deflection of the beam, D = lLVd / 2dVa\"\n",
    "print \"Therefore, the voltage that must be applied to the plates, Vd = %0.2f V\"%Vd"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3.12 : Page 234"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(i) Velocity of beam, v = sqrt(2qVa/m) = 1.88e+07 m/s\n",
      "(ii) Deflection sensitivity = D/Vd\n",
      "where  D = l*L*Vd / 2*Va*d = 0.01 cm\n",
      "Therefore, the deflection sensitivity = 4.00e-04 cm/V\n",
      "(iii) To find the angle of deflection, theta :\n",
      "  tan(theta) = D/L-l\n",
      "Therefore,  theta = tan**-1(D/L-l) = 0.032 degrees\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "from math import degrees, atan\n",
    "v=sqrt((2*(1.6*10**-19)*1000)/(9.1*10**-31))\n",
    "print \"(i) Velocity of beam, v = sqrt(2qVa/m) = %0.2e m/s\"%v\n",
    "D=((2*10**-2)*(20*10**-2)*25)/(2*1000*(0.5*10**-2))\n",
    "print \"(ii) Deflection sensitivity = D/Vd\"\n",
    "print \"where  D = l*L*Vd / 2*Va*d = %0.2f cm\"%D\n",
    "ds=D/25\n",
    "print \"Therefore, the deflection sensitivity = %0.2e cm/V\"%ds\n",
    "theta=degrees(atan(1/1800))\n",
    "print \"(iii) To find the angle of deflection, theta :\"\n",
    "print \"  tan(theta) = D/L-l\"\n",
    "print \"Therefore,  theta = tan**-1(D/L-l) = %0.3f degrees\"%theta"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3.13 : Page 235"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The electron starts moving in the +y direction, but, since acceleration is along the -y direction, its velocity isreduced to zero at time t=t''\n",
      "v0y = v0 * cos(theta) = 1.50e+05 m/s\n",
      "ay = qE / m = 1.60e+14 m/s**2\n",
      "t'' = v0y / ay = 0.94 ns\n"
     ]
    }
   ],
   "source": [
    "from math import cos\n",
    "v0=3*10**5\n",
    "E=910\n",
    "theta=60\n",
    "m=9.109*10**-31\n",
    "q=1.6*10**-19\n",
    "print \"The electron starts moving in the +y direction, but, since acceleration is along the -y direction, its velocity isreduced to zero at time t=t''\"\n",
    "v0y=v0*cos(theta*pi/180)\n",
    "print \"v0y = v0 * cos(theta) = %0.2e m/s\"%v0y\n",
    "ay=(q*E)/m\n",
    "print \"ay = qE / m = %0.2e m/s**2\"%ay\n",
    "tdash=v0y/ay\n",
    "x1=tdash*10**9\n",
    "print \"t'' = v0y / ay = %0.2f ns\"%x1"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3.14 : Page 235"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The deflection of the spot,\n",
      "D = (IBL/sqrt(Va))*sqrt(q/2m) = 0.42 cm\n"
     ]
    }
   ],
   "source": [
    "D=(((2*10**-2)*(1*10**-4)*(20*10**-2))/sqrt(800))*sqrt((1.6*10**-19)/(2*9.1*10**-31))\n",
    "x1=D*10**2\n",
    "print \"The deflection of the spot,\"\n",
    "print \"D = (IBL/sqrt(Va))*sqrt(q/2m) = %0.2f cm\"%x1"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 3.15 : Page 236"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The magnetostatic deflection, D = (IBL/sqrt(Va))*sqrt(q/2m)\n",
      "The electrostatic deflection, D = lLVd / 2dVa\n",
      "For returning the beam back to the centre, the electrostatic deflection and the magnetostatic deflection must be equal, i.e.,\n",
      "(IBL/sqrt(Va))*sqrt(q/2m) = lLVd / 2dVa\n",
      "Therefore,\n",
      "Vd = dB*sqrt(2*Va*q/m) = 33.55 V\n"
     ]
    }
   ],
   "source": [
    "print \"The magnetostatic deflection, D = (IBL/sqrt(Va))*sqrt(q/2m)\"\n",
    "print \"The electrostatic deflection, D = lLVd / 2dVa\"\n",
    "print \"For returning the beam back to the centre, the electrostatic deflection and the magnetostatic deflection must be equal, i.e.,\"\n",
    "print \"(IBL/sqrt(Va))*sqrt(q/2m) = lLVd / 2dVa\"\n",
    "print \"Therefore,\"\n",
    "Vd=(1*10**-2*2*10**-4)*sqrt((2*800*1.6*10**-19)/(9.1*10**-31))\n",
    "print \"Vd = dB*sqrt(2*Va*q/m) = %0.2f V\"%Vd"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}