In [4]:

```
import math
#(a) Calculate the input gap voltage to give maximum voltage V2
#For maximum V2, J1(X) must be maximum.This means J1(X)=0.582 at X=1.841.
X=1.841 #bunching parameter
J1X=0.582
V0=10**3 #dc voltage in Volt
v0=0.593*(10**6)*(sqrt(V0)) #The electron velocity just leaving the cathode
f=3*(10**9) #operating frequency in Hertz
d=1*(10**-3) #Gap spacing in either cavity in meter
w=(2*math.pi*f) #angular frequency in Hertz
Og=(w*d)/v0 #calculation of gap transit angle in radians
Bi=(math.sin(Og/2))/(Og/2) #value of Bi is wrong in book because of calculation mistake
Bo=Bi #value of Bo is wrong in book
L=4*(10**-2) #Spacing between the two cavities in meter
O0=(w*L)/v0 #DC transit angle between the cavaties in radians
V1max=(2*V0*X)/(round(Bi,3)*int(O0))
print"The maximum input voltage V1 (in Volts) is =",round(V1max,1),"V" #value of Bi used in book for calculation of V1 is wrong so answer is wrong in book
#(b) Calculate the voltage gain
R0=40*(10**3) #in Ohms
Rsh=30*(10**3) #Effective shunt impedance excluding beam loading in Ohms
Av=((round(Bo,3)**2)*int(O0)*J1X*Rsh)/(R0*X) #voltage gain
print"The voltage gain,neglecting the beam loading in the output cavity is =",round(Av,3) #answer is wrong in book as the value of Bo used is wrong
#(c)Calculate the efficiency of the amplifier
I0=25*(10**-3) #in ampere
I2=2*I0*J1X
V2=round(Bo,3)*I2*Rsh
efficiency=(round(Bo,3)*I2*int(V2))/(2*I0*V0)
efficiency=100*efficiency
print"The efficiency of the amplifier,neglecting beam loading =",round(efficiency,1),"%" #calculation mistake in book
#(d)Calculate the beam loading conductance
G0=25*(10**-6) #G0=I0/V0 is the DC beam conductance in mho
Og=round(Og)
GB=(G0/2)*((round(Bo,3)**2)-(round(Bo,3)*math.cos(Og/2)))
print"The beam loading conductance GB (in mho) is =","{:.1e}".format(GB),"mho" #answer is wrong in book as the value of Bo in book is wrong
RB=1/GB
print"Then the beam loading resistance RB (ohm)is =","{:.2e}".format(RB),"ohms"
print('In comparasion with RL and Rsho or the effective shunt resistance Rsh,the beam loading resistance is like an open circuit and thus can be neglected in the preceding calculations')
```

In [6]:

```
import math
#(a) Calculate the dc electron velocity
V0=14.5*(10**3) #beam voltage in Volt
v0=0.593*(10**6)*sqrt(V0) #dc electron velocity
print"The dc electron velocity(in m/s)is =","{:.2e}".format(v0),"m/s"
#(b) Calculate the dc phase constant
f=(10*(10**9)) #operating frequency in Hertz
Be=(2*math.pi*f)/v0 #angular frequency in Hertz
print"The dc phase constant(in rads/m) is =","{:.2e}".format(Be),"rads/m"
#(c)Calculate the plasma frequency
po=1*(10**-6) #dc electron charge density in C/m**3
wp=sqrt((1.759*(10**11)*po)/(8.854*(10**-12)))
print"The plasma frequency(in rad/s)is =","{:.2e}".format(wp),"rad/s"
#(d) Calculate the reduced plasma frequency for R=0.4
R=0.4
wq=R*wp
print"The reduced plasma frequency for R=0.4 (in rad/s) is =","{:.2e}".format(wq),"rad/s"
#(e)Calculate the dc beam current density
J0=po*v0
print"The dc beam current density(in A/m2) is =",round(J0,1),"A/m2"
#(f) Calculate the instantaneous beam current density
p=1*(10**-8) #RF charge density in C/m**3
v=1*(10**5) #velocity perturbation in m/s
J=(p*v0)-(po*v)
print"The instantaneous beam current density (in A/m2) is =",round(J,3),"A/m2"
```

In [7]:

```
import math
#(a) Calculate the dc electron velocity
V0=18*(10**3) #beam voltage in Volt
v0=0.593*(10**6)*sqrt(V0)
print"The dc electron velocity(in m/s)is =","{:.2e}".format(v0),"m/s"
#(b) Calculate the dc electron phase constant
f=(10*(10**9)) #Operating frequency in Hertz
w=2*math.pi*f #angular frequency in Hertz
Be=w/v0
print"The dc electron phase constant(in rads/m) is =","{:.3e}".format(Be),"rads/m"
#(c) Calculate the plasma frequency
po=1*(10**-8) #dc electron beam current density in C/m**3
wp=sqrt((1.759*(10**11)*po)/(8.854*(10**-12)))
print"The plasma frequency(in rad/s) is =","{:.2e}".format(wp),"rad/s"
#(d) Calculate the reduced plasma frequency for R=0.5
R=0.5
wq=R*wp
print"The reduced plasma frequency for R=0.5 (in rad/s)is =","{:.2e}".format(wq),"rad/s"
#(e) Calculate the reduced plasma phase constant
Bq=wq/v0
print"The reduced plasma phase constant(in rad/m) is =",round(Bq,3),"rad/m"
#(f) Calculate the transit time across the input gap
d=1*(10**-2) #gap distance in m
t=d/v0
t=t*(10**9)
print"The transit time across the input gap(in ns) is =",round(t,4),"ns"
#(g) Calculate the electron velocity leaving the input gap
V1=10 #signal voltage in Volt
Bi=1.0 #beam coupling coefficient
Vt1=v0*(1+(((Bi*V1)/(2*V0))*math.sin(w*round(t,4)*(10**-9))))
print"the electron velocity leaving the input gap(in m/s)is =","{:.2e}".format(v0),"+","{:.2e}".format(v0*(((Bi*V1)/(2*V0))*math.sin(w*round(t,4)*(10**-9)))),"m/s =","{:.2e}".format(Vt1),"m/s"
```

In [8]:

```
import math
#(a)Calculate the plasma frequency
po=1*(10**-6) #dc electron beam current density in C/m**3
e0=8.854*(10**-12) #permittivity of free space in F/m
wp=sqrt((1.759*(10**11)*po)/e0)
print"The plasma frequency(in rad/s)is =","{:.2e}".format(wp),"rad/s"
#(b) Calculate the reduced plasma frequency for R=0.5
R=0.5
f=8*(10**9) #operating frequency in Hertz
w=2*math.pi*f #angular frequency in Hertz
wq=R*wp
print"The reduced plasma frequency for R=0.5(in rad/s)is =","{:.2e}".format(wq),"rad/s"
#(c) Calculate the induced current in the output cavity
V0=20*(10**3) #beam voltage in Volt
I0=2 #beam current in ampere
V1=10 #Signal voltage in Volt
Bo=1 #Beam coupling coefficient
I2=(I0*w*(Bo**2)*V1)/(2*V0*wq)
print"The induced current in the output cavity(in Ampere)is =",round(I2,4),"A"
#(d) Calculate the induced voltage in the output cavity
Rshl=30*(10**3) #total shunt resistance including load in Volt
V2=round(I2,3)*Rshl
V2=V2/1000 #in KV
print"The induced voltage in the output cavity(in KV)is =",V2,"KV"
#(e) Calculate the output power delivered to the load
Rsh=10*(10**3) #shunt resistance of the cavity
Rshl=30*(10**3) #total shunt resistance including load
Pout=(round(I2,3)**2)*Rshl
Pout=Pout/1000
print"The output power delivered to the load(in KW)is =",round(Pout,2),"KW"
#(f) Calculate the power gain
powergain=(((I0*w)**2)*(Bo**4)*Rsh*Rshl)/(4*((V0*wq)**2))
powergain=10*math.log10(powergain) #powergain in dB
print"The power gain is =",round(powergain,1),"dB"
#(g) Calculate the electronic efficiency
n=(Pout*1000)/(I0*V0)
n=n*100
print"The electronic efficiency (in %)is =",round(n,1),"%"
```

In [9]:

```
import math
#(a) Calculate the plasma frequency
po=5*(10**-5) #dc electron beam current density in C/m**3
wp=sqrt((1.759*(10**11)*po)/(8.854*(10**-12)))
print"The plasma frequency(in rad/s)is =","{:.2e}".format(wp),"rad/s"
#(b) Calculate the reduced plasma frequency for R=0.6
R=0.6
f=4*(10**9) #operating frequency in Hertz
w=2*math.pi*f #angular frequency in Hertz
wq=R*wp
print"The reduced plasma frequency for R=0.6(in rad/s)is =","{:.2e}".format(wq),"rad/s"
#(c) Calculate the induced current in the output cavity
Rsh=10*(10**3) #shunt resistance of the cavity in Ohms
Rshl=5*(10**3) #total shunt resistance including load in Ohms
V0=10*(10**3) #beam voltage in volt
I0=0.7 #beam current in ampere
V1=2 #Signal voltage in volt
Bo=1 #Beam coupling coefficient
I4=(((I0*w)**3)*(Bo**6)*V1*(Rsh**2))/(8*((V0*wq)**3))
print"The induced current in the output cavity(in Ampere)is =",round(I4,4),"A"
#(d) Calculate the induced voltage in the output cavity
V4=I4*Rshl
V4=V4/1000 #in KV
print"The induced voltage in the output cavity(in KV)is =",round(V4,2),"KV"
#(e) Calculate the output power delivered to the load
Pout=(I4**2)*Rshl
Pout=Pout/1000 #in KW
print"The output power delivered to the load(in KW)is =",round(Pout,2),"KW"
```

In [10]:

```
import math
#(a) Calculate the value of the repeller voltage
V0=600 #beam voltage in volt
n=2 #mode=2
fr=9*(10**9) #operating frequency in Hertz
w=2*math.pi*fr #angular frequency in Hertz
L=1*(10**-3) #in meter
em=1.759*(10**11) #em=e/m is the charge to mass ratio of electron
x=((em)*(((2*math.pi*n)-(math.pi/2))**2))/(8*(w**2)*(L**2)) #x=V0/(V0+Vr)**2
y=V0/x #y=(V0+Vr)**2
z=sqrt(y) #z=V0+Vr
Vr=z-V0
print"The value of the repeller voltage(volts)is =",int(round(Vr)),"V"
#(b)Calculate the direct current necessary to give a microwave gap voltage of 200V
#Assume that Bo=1
#V2 = I2*Rsh = 2*I0*J1(X)*Rsh
V2=200 #gap voltage in volt
Rsh=15*(10**3) #shunt resistance of te cavity in ohms
X=1.841 #bunching parameter
J1X=0.582
I0 = V2/(2*J1X*Rsh)
I0=I0*1000 #in mA
print"The direct current necessary to give a microwave gap voltage of 200V(in mA)is =",round(I0,2),"mA"
#(c) Calculate the electronic efficiency
efficiency=(2*X*J1X)/((2*math.pi*n)-(math.pi/2))
efficiency=efficiency*100
print"The electronic efficiency(in %)is =",round(efficiency,2),"%"
```

In [15]:

```
import math
#(a) Calculate the gain parameter
I0=30*(10**-3) #Beam current in ampere
V0=3*(10**3) #Beam voltage in volt
Z0=10 #characteristic impedance of the helix in ohms
C=(((I0*Z0)/(4*V0))**(1/3.0))
print"The gain parameter is =","{:.2e}".format(C)
#(b) Calculate the output power gain in dB
N=50 #Crcular length
Ap=-9.54+(47.3*N*round(C,4))
print"The output power gain (in dB) is =",round(Ap,2),"dB"
#(c) Calculate the four propagation constants
f=10*(10**9) #frequency in Hertz
V0=3*(10**3) #beam voltage in volt
w=2*(math.pi)*f #nagular frequency in Hertz
v0=0.593*(10**6)*sqrt(V0)
Be=w/v0
Be=int(Be/10)
Be=Be*10
r1=(-1*Be*round(C,4)*(round((sqrt(3)/2),2)))+1j*Be*(1+(round(C,4)/2))
X=round(r1.real,2)
Y=int(r1.imag)
r1=X+1j*Y
print"The four propagation constants are:"
print"\nThe first propagtaion constant is =",r1 #value of imaginary part is wrong in book
r2=(Be*round(C,4)*(round((sqrt(3)/2),2)))+1j*Be*(1+(round(C,4)/2))
X=round(r2.real,2)
Y=int(r2.imag)
r2=X+1j*Y
print"The second propagtaion constant is =",r2 #value of imaginary part is wrong in book
r3=1j*Be*(1-round(C,4))
print"The third propagtaion constant is =",r3 #answer is wrong in book
r4=(-1*1j*Be*(1-((C**3)/4)))
r4=0+1j*round(r4.imag)
print"The fourth propagtaion constant is =",r4
```

In [16]:

```
#(a) Calculate the number of electrons returned per second
Ir=0.85 #returned current in ampere
q=1.6*(10**-19) #electronic charge in C
Nr=Ir/q
print"The number of electrons returned (per second) is =","{:.2e}".format(Nr),"electrons/s"
#(b)Calculate the Energy associated with these returning electrons in 20ms
V=-11*(10**3) #overdepreesion collector voltage in volt
V=-1*V
t=20*(10**-3) #in seconds
W=V*Nr*t
print"The Energy associated with these returning electrons in 20ms(in eV) is =","{:.3e}".format(W),"eV"
#(c) Calculate the Power for returning electrons
P=V*Ir
P=P/1000 #in KW
print"The Power for returning electrons(in KW)is =",P,"KW"
#(d) Calculate the Heat in calories associated with the returning electrons(a factor for converting joules to calories is 0.238)
t=20*(10**-3) #in seconds
H=0.238*P*1000*t
print"The Heat associated with the returning electrons(in calories)is =",round(H,2),"calories"
#(e) Calculate the temperature
mass=250*(10**-3) #mass of heated iron pole piece in gram
specific_heat=0.108
T=round(H,2)/(mass*specific_heat)
print"The temperature(in degree Celsius)is =",round(T,2),"degree celsius"
#(f) Calculate whether the output iron pole piece is melted
print"The output iron pole piece is melted"
```