{
 "metadata": {
  "name": "",
  "signature": "sha256:a5e82465bfb623eb9318715f7f52014da580babc1cb20ec72de42ac065345041"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Ch-5 : Microwave tubes Klystrons"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Pages Number: 288 Example 5.1"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division \n",
      "from math import sqrt, pi\n",
      "#Given\n",
      "f=10e9  #Hz\n",
      "v=9e3  #V\n",
      "i=40e-3  #A\n",
      "l=3  #cm\n",
      "l1=l/100  #m\n",
      "G=2e-6  #mho\n",
      "bet=0.92 \n",
      "j1x=0.582 \n",
      "x=1.841 \n",
      "ebym=1.7e11  #J\n",
      "\n",
      "#Maximum voltage\n",
      "w=2*pi*f \n",
      "v0x=sqrt(2*ebym) \n",
      "thet=(w*l1)/(v0x*sqrt(v)) \n",
      "\n",
      "av=(bet**2*thet*i*j1x)/(x*v*G) \n",
      "print 'Maximum voltage:%0.3f'%av,'V'\n",
      "\n",
      "#Power Gain\n",
      "ic=2*i*j1x \n",
      "v2=(bet*ic)/G \n",
      "pout=bet*ic*v2 \n",
      "pin=2*i*v \n",
      "\n",
      "#Efficiency\n",
      "eet=pout/pin \n",
      "print 'Power gain: %0.3f'%(eet*100), '%'\n",
      "\n",
      "#Answer for effciency comes out to be wrong, it is calculted wrongly in book"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Maximum voltage:20.262 V\n",
        "Power gain: 127.420 %\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Page Number: 288 Example 5.2"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "#Given\n",
      "l=2  #cm\n",
      "l1=l/100 #m\n",
      "f=5e9  #Hz\n",
      "i=25e-3  #A\n",
      "n=21/4  \n",
      "e=1.6e-19 \n",
      "m=9.1e-31 \n",
      "thetag=0 \n",
      "bet=1 \n",
      "j1x=0.582 \n",
      "x=1.841 \n",
      "\n",
      "#(i) Beam Voltage\n",
      "v0=(m*l1*l1*f*f)/(2*e*n*n) \n",
      "print 'Beam voltage: %0.3f'%v0, 'V'\n",
      "\n",
      "#(ii) Input voltage\n",
      "v1=x*v0/(pi*bet*n) \n",
      "print 'Input voltage: %0.3f'%v1,'V'\n",
      "\n",
      "#(iii) Output voltage\n",
      "v2=0.25*v0 \n",
      "print 'Output voltage %0.3f'%v2,'V'\n",
      "\n",
      "#(iv) Power output\n",
      "pmax=i*v0*j1x \n",
      "print 'Maximum power output: %0.3f'%pmax, 'W'\n",
      "\n",
      "#(v) Efficiency\n",
      "eet=j1x*bet*v2/v0 \n",
      "print 'Efficiency:' ,eet*100,'%'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Beam voltage: 1031.746 V\n",
        "Input voltage: 115.164 V\n",
        "Output voltage 257.937 V\n",
        "Maximum power output: 15.012 W\n",
        "Efficiency: 14.55 %\n"
       ]
      }
     ],
     "prompt_number": 20
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Page Number:  289 Example 5.3"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import sin\n",
      "#Given\n",
      "r0=45e3  #W\n",
      "j0=25e-3  #A\n",
      "V=1500  #V\n",
      "f=5e9  #hz\n",
      "d=1  #mm\n",
      "d1=d/1000  #m\n",
      "l=3.5  #cm\n",
      "l1=l/100  #m\n",
      "rsh=32e3  #ohms\n",
      "j1x=0.582 \n",
      "x=1.841 \n",
      "\n",
      "#(i) Input gap voltage\n",
      "w=2*pi*f \n",
      "v0=(5.93e5*sqrt(V)) \n",
      "thetag=(w*d1)/v0 \n",
      "bet=sin(thetag/2)/(thetag/2) \n",
      "theta0=(w*l1)/v0 \n",
      "v1=(2*V*x)/(bet*theta0) \n",
      "print 'Input gap voltage: %0.3f'%v1\n",
      "\n",
      "#(ii) Voltage gain\n",
      "av=(bet**2*theta0*j1x*rsh)/(r0*x) \n",
      "print 'Voltage gain %0.3f'% av"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Input gap voltage: 124.871\n",
        "Voltage gain 9.186\n"
       ]
      }
     ],
     "prompt_number": 22
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Page Number: 290 Example 5.4"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import cos\n",
      "#Given\n",
      "V=1000   #V\n",
      "r0=40e3  #ohm\n",
      "i0=25e-3  #A\n",
      "f=3e9  #Hz\n",
      "d=1  #mm\n",
      "d1=d/1000  #m\n",
      "l=4  #cm \n",
      "l1=4/100  #m\n",
      "j1x=0.582 \n",
      "x=1.841 \n",
      "rsh=30e3  #ohm\n",
      "\n",
      "#(i) Input gap voltage\n",
      "w=2*pi*f \n",
      "v0=(5.93e5*sqrt(V)) \n",
      "thetag=(w*d1)/v0 \n",
      "bet=sin(thetag/2)/(thetag/2) \n",
      "theta0=(w*l1)/v0 \n",
      "vmax=(2*V*x)/(bet*theta0) \n",
      "print 'Input gap voltage: %0.3f'%vmax, 'V'\n",
      "\n",
      "#(ii) Voltage gain\n",
      "av=(bet*bet*theta0*j1x*rsh)/(r0*x) \n",
      "print 'Voltage gain: %0.3f'%av\n",
      "\n",
      "#(iii) Efficiency\n",
      "v2=bet*2*i0*j1x*rsh \n",
      "eet=(bet*2*i0*j1x*v2)/(2*i0*V) \n",
      "print 'Efficiency: %0.3f'%(eet*100),'%'\n",
      "\n",
      "#(iv) Beam loading conductance\n",
      "gbl=(i0/(2*V))*((bet*bet)-(bet*cos(thetag/2))) \n",
      "print 'Beam loading conductance:%0.3e'%gbl\n",
      "\n",
      "#Answer for beam loading conductance is calculated wrong in book"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Input gap voltage: 95.547 V\n",
        "Voltage gain: 8.757\n",
        "Efficiency: 46.672 %\n",
        "Beam loading conductance:9.835e-07\n"
       ]
      }
     ],
     "prompt_number": 27
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Page Number: 291 Example 5.5"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "#Given\n",
      "f=3e9  #hz\n",
      "v=900  #V\n",
      "i=30e-3  #A\n",
      "d=4  #cm\n",
      "d1=d/100  #m\n",
      "gap=1  #mm\n",
      "gap1=1/1000  #m\n",
      "rsh=40e3  #ohm\n",
      "x=1.841 \n",
      "j1x=0.582 \n",
      "r=40e3  #ohm\n",
      "ebym=1.758e11  #J\n",
      "\n",
      "#(i) Electron velocity\n",
      "v0=sqrt(2*ebym*v) \n",
      "print 'Electron velocity: %0.3f'%v0,'m/s'\n",
      "\n",
      "#(ii) Electron transit time\n",
      "t=d1/v0 \n",
      "print 'Electron transit time: %0.3f'%t,'s'\n",
      "\n",
      "#(iii) Input voltage gap\n",
      "w=2*pi*f \n",
      "theta0=(w*d1)/v0 \n",
      "thetag=(w*gap1)/v0 \n",
      "bet=sin(thetag/2)/(thetag/2) \n",
      "v2=(2*v*x)/(bet*theta0) \n",
      "print 'Input voltage gap: %0.3f'%v2, 'V'\n",
      "\n",
      "#(iv) Voltage gain\n",
      "av=(bet**2*theta0*j1x*rsh)/(x*r) \n",
      "print 'Voltage gain: %0.3f'%av\n",
      "\n",
      "#Values of v and f are changed in question and answer, hence vaules used in answer are taken.\n",
      "#Also second part has not been done in book"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Electron velocity: 17788760.496 m/s\n",
        "Electron transit time: 0.000 s\n",
        "Input voltage gap: 81.964 V\n",
        "Voltage gain: 12.192\n"
       ]
      }
     ],
     "prompt_number": 28
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Page Number: 292 Example 5.6"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import sqrt, log10 \n",
      "#Given\n",
      "f=8e9  #hz\n",
      "i=2.5  #A\n",
      "v=20e3  #V\n",
      "bet=1 \n",
      "amp=10*sqrt(2)  #V\n",
      "rsh=10e3  #ohm\n",
      "rsho=30e3  #ohm\n",
      "dc=1e-6  #c/m**3\n",
      "rf=0.5 \n",
      "e=1.6e-19 \n",
      "ee=8.854e-12 \n",
      "m=9.1e-31  #kg\n",
      "\n",
      "#(i) Induced current\n",
      "w=2*pi*f \n",
      "wq=rf*sqrt((e*dc)/(m*ee)) \n",
      "\n",
      "#Amplitude of induced current\n",
      "ic=(i*w*(bet**2)*amp)/(2*v*wq) \n",
      "print 'Induced current: %0.3f'%ic,'A'\n",
      "\n",
      "#Induced voltage\n",
      "icrms=ic/sqrt(2) \n",
      "v2rms=icrms*rsho \n",
      "print 'Induced voltage: %0.3f'%v2rms,'V'\n",
      "\n",
      "#(ii) Power gain\n",
      "pg=(((i*w)**2)*(bet**4)*rsh*rsho)/(4*((v*wq)**2)) \n",
      "pgdb=10*log10(pg) \n",
      "print 'Power gain: %0.3f'%pgdb,'dB'\n",
      "\n",
      "#(iii) Electronic efficiency\n",
      "eeta=((icrms**2)*rsho)/(i*v) \n",
      "print 'Electronic efficiency: %0.3f'%(eeta*100),'%'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Induced current: 0.631 A\n",
        "Induced voltage: 13376.164 V\n",
        "Power gain: 57.755 dB\n",
        "Electronic efficiency: 11.928 %\n"
       ]
      }
     ],
     "prompt_number": 29
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Page Number: 294 Example 5.7"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "#Given\n",
      "f=3e9  #hz\n",
      "l=4  #cm\n",
      "l1=4/100  #m\n",
      "d=0.1  #cm\n",
      "d1=d/100  #m\n",
      "V=900  #V\n",
      "i0=30e-3  #A\n",
      "rsh=25e3 #ohm\n",
      "x=1.841 \n",
      "j1x=0.582 \n",
      "\n",
      "#(i) Input voltage for maximum output\n",
      "v0=0.593e6*sqrt(V) \n",
      "w=2*pi*f \n",
      "theta0=w*l1/v0  #rad\n",
      "thetag=w*d1/v0  #rad\n",
      "bet=sin(thetag/2)/(thetag/2) \n",
      "v1max=2*V*x/(bet*theta0)  #v\n",
      "print 'Input voltage for maximum output: %0.3f'%v1max,'V'\n",
      "\n",
      "#(ii) Voltage gain\n",
      "r0=V/i0 #ohm\n",
      "av=((bet**2)*theta0*j1x*rsh)/(x*r0) #V\n",
      "print 'Voltage gain: %0.3f'%av, 'V'\n",
      "\n",
      "#(iii) Efficiency\n",
      "ic=2*i0*j1x  #A\n",
      "v2=bet*ic*rsh  #V\n",
      "eet=bet*ic*v2/(2*i0*V) \n",
      "print 'Efficiency: %0.3f'%(eet*100), '%'\n",
      "\n",
      "#(iv) Beam loading conductance\n",
      "gb=(i0/(V*2))*(bet**2-(bet*cos(thetag/2))) #ohm\n",
      "print 'Beam loading conductance: %0.3e'%gb,'ohm'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Input voltage for maximum output: 81.969 V\n",
        "Voltage gain: 10.159 V\n",
        "Efficiency: 51.366 %\n",
        "Beam loading conductance: 1.446e-06 ohm\n"
       ]
      }
     ],
     "prompt_number": 30
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Page Number: 295 Example 5.8"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "#Given\n",
      "f=5e9  #hz\n",
      "v0=10e3  #V\n",
      "d=1  #mm\n",
      "d1=d/1000  #m\n",
      "v1=100  #V\n",
      "\n",
      "#(i) Gap transit time\n",
      "vv0=0.593e6*sqrt(v0) #m/sec\n",
      "tau=d1/vv0 #sec\n",
      "print 'Gap transit time: %0.3e'%tau,'sec'\n",
      "\n",
      "#Gap transit angle\n",
      "w=2*pi*f \n",
      "thetag=w*tau #rad\n",
      "print 'Gap transit angle: %0.3f'%thetag, 'rad'\n",
      "\n",
      "#(ii) Beam coupling coefficient\n",
      "betin=sin(thetag/2)/(thetag/2) \n",
      "print 'Beam coupling coefficient: %0.3f'%betin\n",
      "\n",
      "#(iii) Velocity of electron leaving buncher gap\n",
      "vig=vv0*(1+((betin*v1)/(2*v0))) #m/sec\n",
      "print 'Velocity of electron leaving buncher gap: %0.3f'%vig, 'm/sec'\n",
      "\n",
      "#(iv) Depth of modulation\n",
      "m=betin*v1/v0 \n",
      "print 'Depth of modulation: %0.3f'%m"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Gap transit time: 1.686e-11 sec\n",
        "Gap transit angle: 0.530 rad\n",
        "Beam coupling coefficient: 0.988\n",
        "Velocity of electron leaving buncher gap: 59593044.746 m/sec\n",
        "Depth of modulation: 0.010\n"
       ]
      }
     ],
     "prompt_number": 33
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Page Number: 296 Example 5.9"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "#Given\n",
      "f=10e9  #hz\n",
      "v0=15e3  #V\n",
      "i0=2.5e-3  #A\n",
      "d=1  #cm\n",
      "d1=d/100  #m\n",
      "vrms=10  #V\n",
      "bet=1 \n",
      "p=1e-8  #C/m**3\n",
      "rf=0.6 \n",
      "e=1.6e-19 \n",
      "m=9.1e-31 \n",
      "ee=8.854e-12 \n",
      "\n",
      "#(i) DC electron beam phase cobstant\n",
      "vv0=(0.593e6*sqrt(v0)) \n",
      "w=2*pi*f \n",
      "bete=w/vv0  #rad/m\n",
      "print 'DC electron beam phase constant: %0.3f'%bete,'rad/m'\n",
      "\n",
      "#(ii) Reduced plasma frequency and reduced plasma phase constant\n",
      "wq=rf*sqrt(e*p/(m*ee)) #rad/m\n",
      "print 'Reduced plasma frequency: %0.3f'%wq,'rad/m'\n",
      "betq=wq/vv0 #rad/sec\n",
      "print 'Reduced plasma phase constant: %0.3f'%betq,'rad/sec'\n",
      "\n",
      "#(iii) Gap transit time\n",
      "tau=d1/vv0 #sec\n",
      "vtg=vv0*(1+(bet*vrms*sin(w*tau)/(2*v0))) #m/sec\n",
      "print 'Gap transit time: %0.3f'%vtg, 'm/sec'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "DC electron beam phase constant: 865.126 rad/m\n",
        "Reduced plasma frequency: 8455139.683 rad/m\n",
        "Reduced plasma phase constant: 0.116 rad/sec\n",
        "Gap transit time: 72644284.673 m/sec\n"
       ]
      }
     ],
     "prompt_number": 37
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Page Number: 296 Example 5.10"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "#Given\n",
      "f=4e9 #hz\n",
      "v0=10e3 #V\n",
      "i0=0.75 #A\n",
      "v1=2  #V\n",
      "bet=1 \n",
      "rsh=10e3 #ohm\n",
      "p=5e-5 #C/m**3\n",
      "r=0.6 \n",
      "rsht=4e3 #ohm\n",
      "e=1.6e-19 \n",
      "m=9.1e-31 \n",
      "ee=8.854e-12 \n",
      "\n",
      "#(i) Induced current and voltage in output cavity\n",
      "w1=sqrt(e*p/(m*ee)) #rad/sec\n",
      "w=2*pi*f \n",
      "wq=0.5*w1 #rad/sec\n",
      "rr=w/wq \n",
      "\n",
      "i4=((i0**3)*(rr**3)*(bet**6)*v1*(rsh**2))/(8*(v0**3))  #A\n",
      "print 'Induced current: %0.3f'%i4,'A'\n",
      "v4=i4*rsht #V\n",
      "print 'Induced voltage: %0.3f'%(v4/1000), 'kV'\n",
      "\n",
      "#(ii) Power output\n",
      "pout=(i4**4)*rsht #W\n",
      "print 'Power output: %0.3f'%pout, 'W'\n",
      "\n",
      "#Answer for Pout should be 13.43 kW but it is given as 10.89kW as value of I4 is calculated as 1.289 but it comes out to be 1.35"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Induced current: 1.354 A\n",
        "Induced voltage: 5.415 kV\n",
        "Power output: 13438.135 W\n"
       ]
      }
     ],
     "prompt_number": 40
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Page Number: 297 Example 5.9"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "#Given\n",
      "f=8e9 #hz\n",
      "v0=500 #V\n",
      "l=1.2 #mm\n",
      "l1=l/1000 #m\n",
      "rsh=18e3 #ohm\n",
      "ebym=1.759e11 \n",
      "ee=8.854e-12 \n",
      "\n",
      "#(i) Repeller voltage\n",
      "n=1+(3/4) \n",
      "v11=(ebym*n*n)/(8*(l1**2)*(f**2)) \n",
      "vr=sqrt(v0/v11)-v0 \n",
      "print 'Repeller voltage: %0.3f'%vr,'V'\n",
      "\n",
      "#(ii) Required dc current\n",
      "v2=200 #V\n",
      "j1x=0.582 \n",
      "i=v2/(2*rsh*j1x) #A\n",
      "print 'Required dc current: %0.3f'%(i*1000), 'mA'\n",
      "\n",
      "#Answer for repeller voltage is calculated wrong in book"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Repeller voltage: 327.238 V\n",
        "Required dc current: 9.546 mA\n"
       ]
      }
     ],
     "prompt_number": 42
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Page Number: 298 Example 5.12"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "#Given\n",
      "f=9e9 #hz\n",
      "v0=361 #V\n",
      "i0=30e-3 #A\n",
      "l=0.1 #cm\n",
      "l1=l/100 #m\n",
      "x=2.408 \n",
      "j1x=0.582 \n",
      "ebym=1.759e11 \n",
      "\n",
      "#Maximum power output\n",
      "n=1 \n",
      "pout=2*i0*v0*x*j1x/(2*pi*(n+(3/4))) #W\n",
      "print 'Maximum power output: %0.3f'%pout,'W'\n",
      "\n",
      "#Operating repeller voltage\n",
      "vr=((6.744e-6*sqrt(v0)*l1*f)/(n+(3/4)))-v0 #v\n",
      "print 'Operating repeller voltage: %0.3f'%vr,'V'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Maximum power output: 2.761 W\n",
        "Operating repeller voltage: 297.985 V\n"
       ]
      }
     ],
     "prompt_number": 44
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Page Number: 298 Example 5.13"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "#Given\n",
      "f=9e9 #hz\n",
      "v0=250 #V\n",
      "l=0.5 #cm\n",
      "l1=l/100 #m\n",
      "\n",
      "#Bandwidth\n",
      "n=3 \n",
      "df=(n+(3/4))/(6.774e-6*l1*sqrt(v0)) #hz\n",
      "print 'Bandwidth: %0.3f'%(df/10**6),'Mhz'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Bandwidth: 7.002 Mhz\n"
       ]
      }
     ],
     "prompt_number": 45
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Page Number: 299 Example 5.14"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "#Given\n",
      "f=10e9 #hz\n",
      "v0=600 #V\n",
      "vr=250 #V\n",
      "ebym=1.759e11 \n",
      "\n",
      "#Repeller space\n",
      "n=1 \n",
      "l=sqrt((ebym*(n+(3/4))**2*(vr+v0)**2)/(8*f**2*v0)) #m\n",
      "print 'Repeller space: %0.3f'%(l*1000),'mm'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Repeller space: 0.900 mm\n"
       ]
      }
     ],
     "prompt_number": 46
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Page Number: 299 Example 5.15"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "#Given\n",
      "v0=300 #V\n",
      "i0=20e-3 #A\n",
      "v1=40 #V\n",
      "n=2 \n",
      "x=2.408 \n",
      "j1x=0.52 \n",
      "\n",
      "#(i) Input power\n",
      "pin=i0*v0 #W\n",
      "print 'Input power:' ,pin,'W'\n",
      "\n",
      "#(ii) Output power\n",
      "pout=(2*v0*i0*x*j1x)/((2*pi*n)-(pi/2)) #W\n",
      "print 'Output power: %0.3f'%pout, 'W'\n",
      "\n",
      "#Efficiency\n",
      "eet=pout/pin \n",
      "print 'Efficiency: %0.3f'%(eet*100), '%'\n",
      "\n",
      "#Answer for output power in book is 0.7 which is wrong, it should be 1.3W\n",
      "#Hence answer of efficiency also changes"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Input power: 6.0 W\n",
        "Output power: 1.367 W\n",
        "Efficiency: 22.776 %\n"
       ]
      }
     ],
     "prompt_number": 47
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Page Number: 300 Example 5.16"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "#Given\n",
      "f=10e9 #hz\n",
      "v0=600 #V\n",
      "l=0.1 #cm\n",
      "l1=l/100 #m\n",
      "bet=0.9 \n",
      "ebym=1.759e11 \n",
      "n=2 \n",
      "j1x=0.575 #from standard table\n",
      "\n",
      "\n",
      "#(i) Repeller voltage\n",
      "vr=((6.744e-6*sqrt(v0)*l1*f)/(n-(1/4)))-v0 #V\n",
      "print 'Repeller voltage:',round(vr), 'V'\n",
      "\n",
      "#(ii) Bunching parameter\n",
      "v1=200 #V\n",
      "x=bet*v1*2*pi*(n-(1/4))/(2*v0) \n",
      "print 'Bunching parameter: %0.3f'%x\n",
      "\n",
      "#(iii) Required DC current\n",
      "rsh=20e3 #ohm\n",
      "i=v1/(2*rsh*j1x) #A\n",
      "print 'Required DC current: %0.3f'%(i*1000),'mA'\n",
      "\n",
      "#(iv) Electronic efficiency\n",
      "eet=2*x*j1x/(2*pi*(n-(1/4))) \n",
      "print 'Electronic efficiency:',eet*100, '%'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Repeller voltage: 344.0 V\n",
        "Bunching parameter: 1.649\n",
        "Required DC current: 8.696 mA\n",
        "Electronic efficiency: 17.25 %\n"
       ]
      }
     ],
     "prompt_number": 48
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Page Number: 301 Example 5.17"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      " \n",
      "#Given\n",
      "f=10e9 #hz\n",
      "v0=300 #V\n",
      "j0=0.3 #A/cm\n",
      "i0=45e-3 #A\n",
      "\n",
      "rb=sqrt(i0/(pi*j0)) #mm\n",
      "print 'Electron beam radius: %0.3f'%(rb*10),'mm'\n",
      "r=rb*(120/100) #mm\n",
      "print 'Radius of cathode disc:%0.3f'%(r*10),'mm'\n",
      "d=sqrt(2.335e-6*(300)**(3/2)/j0) #mm\n",
      "print 'Cathode anode spacing: %0.3f'%(d*10),'mm'\n",
      "#Anode hole has to be 15% larger than cathode disc\n",
      "ra=r*1.15 #mm\n",
      "print 'Anode hole: %0.3f'%(ra*10),'mm'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Electron beam radius: 2.185 mm\n",
        "Radius of cathode disc:2.622 mm\n",
        "Cathode anode spacing: 2.011 mm\n",
        "Anode hole: 3.015 mm\n"
       ]
      }
     ],
     "prompt_number": 49
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Page Number: Example 5.18"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import tan, exp\n",
      "#Given\n",
      "f=9e9 #hz\n",
      "v0=300 #V\n",
      "vr=125 #V\n",
      "bet=0.9 \n",
      "c=3e8  #m/s\n",
      "w=2*pi*f \n",
      "br=2.18 #mm\n",
      "e0=8.854e-12 \n",
      "ebym=1.7e11 \n",
      "\n",
      "#From sin(theta)/theta table, thetag is found out to be\n",
      "thetag=0.25*pi  \n",
      "d=(2*thetag*0.593e6*sqrt(v0))/w \n",
      "print 'Distance: %0.3f'%(d*1000),'mm'\n",
      "\n",
      "#Axial cavity length\n",
      "l=c/(10*f) #m\n",
      "print 'Axial cavity length: %0.3f'%(l*1000),'mm'\n",
      "\n",
      "#Ratio of outer to inner conductor\n",
      "a=1.5*br \n",
      "a1=a/1000 \n",
      "x=d/(w*e0*a1*a1*60*tan((w*l)/c)) \n",
      "bbya=exp(x) \n",
      "print 'Ratio of outer to inner conductor: %0.3f'%bbya\n",
      "\n",
      "#radii of outer and inner conductor\n",
      "print 'Radius of outer conductor:',a, 'mm'\n",
      "\n",
      "b=1.52*a #mm\n",
      "print 'Radius of inner conductor:' ,b,'mm'\n",
      "\n",
      "#Repeller spacing\n",
      "lopt=sqrt(ebym*(19/4)**2*(v0+vr)**2/(8*f**2*v0)) #m\n",
      "print 'Repeller spacing: %0.3f'%(lopt*1000),'mm'\n",
      "\n",
      "#Answer for radii of outer and inner conductor have wrong calculations in book\n",
      "#Also ratio of outer to inner conductor is also calculated wrong"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Distance: 0.285 mm\n",
        "Axial cavity length: 3.333 mm\n",
        "Ratio of outer to inner conductor: 3.396\n",
        "Radius of outer conductor: 3.27 mm\n",
        "Radius of inner conductor: 4.9704 mm\n",
        "Repeller spacing: 1.888 mm\n"
       ]
      }
     ],
     "prompt_number": 50
    }
   ],
   "metadata": {}
  }
 ]
}