import math
# Variable Declaration
F = 100*10**9; #reflex klystron operating frequency
n = 3; #integer corresponding to mode
#Calculations
T_c = (n+(3/float(4))) #transit time in cycles
T = T_c/float(F); #transit time in seconds
# Result
print'Transit Time of the electron in the repeller space is %3.1f ps'%(T/float(10**-12));
import math
# Variable Declaration
F = 2*10**9;#reflex klystron operating frequency
Vr = 2000;#Repeller voltage
Va = 500;#Accelarating voltage
n = 1;#integer corresponding to mode
e = 1.6*10**-19;#charge of electron
m = 9.1*10**-31;#mass of electron in kg
s = 2*10**-2;#space b/w exit of gap and repeller electrode
dVr1 = 2; #(change in Vr in percentage
#Calculations
dVr = dVr1*Vr/100; #conversion from percentage to decimal
#dVr/df = ((2*math.pi*s)/((2*math.pi*n)-pi/2))*sqrt(8*m*Va/e));
#let df = dVr/((2*math.pi*s)/((2*math.pi*n)-pi/2))*sqrt(8*m*Va/e));
df = (dVr)/((2*math.pi*s)/((2*math.pi*n)-(math.pi/2))*math.sqrt(8*m*Va/e)); #change in freq as a fun of repeller voltage
# Result
print'Change in frequency is %3.0f MHz'%(df/float(10**6));
import math
# Variable Declaration
# let l = dVr/Vr ; f = df/f ; Vr/f = R
l = 5;#percentage change in repeller voltage
f = 1;#percentage change in operating frequency
R = 1;#ratio of repeller voltage to operating frequency
NR = 1.5;#new ratio of repeller voltage to operating frequency in volts/MHz
e = 1.6*10**-19;#charge of electron
m = 9.1*10**-31;#mass of electron in kg
# Calculations
#dVr/df = ((2*math.pi*s)/((2*math.pi*n)-pi/2))*math.sqrt(8*m*Va/e));
#((df/f)/(dVr/Vr)) = (Vr/f)*((2*math.pi*n)-pi/2)/(2*math.pi*s)*math.sqrt(e/(8*m*Va));
#((df/f)/(dVr/Vr)) = K*(Vr/f);
#where K = (((2*math.pi*n)-math.pi/2)/float((2*math.pi*s))*math.sqrt(e/float((8*m*Va)))
K = (f/float(l))*(1/float(R));
PCF = NR*K*l; #percentage change in frequency when new ratio (Vr/f)=1.5;
# Result
print'Percentage Change in frequency is %3.2f percent'%PCF;
import math
# Variable Declaration
Va = 40*10**3; # Anode voltage of cross field amplifier
Ia = 15; # Anode current in Amp
Pin = 40*10**3; # input power in watts
G = 10; # gain in dB
n = float(40)/100; # overall efficiency converted from percentage to decimal
# Calculations
Gain = (1+(float(Pgen)/Pin))
Pgen = (G-1)*Pin # Generated power
ne = (Pgen/float(Va*Ia)) # electronic efficiency
nc = n/(ne) # circuit efficiency
Pout = Pin+(Pgen*nc) # output power
# Result
print 'Electronic Efficiency is %3.2f' %ne
print 'Output power is %g KW' %(Pout/float(1000));
import math
# Variable Declaration
F = 1*10**9; #two cavity klystron operating frequency
Va = 2500; #Accelarating voltage in volts
e = 1.6*10**-19; #charge of electron
m = 9.1*10**-31; #mass of electron in kg
s = 0.1*10**-2; #input cavity space
#Calculations
u = math.sqrt((2*e*Va)/m); #velocity at which electron beam enters the gap
T = s/u ; #Time spent in the gap
f = T*F; #number of cycles
# result
print'Number of cycles that elase during transit of beam through input gap is %3.3f cycle'%f;
import math
# Given Data
N = 8; #no. of resonators
#Calculations
print'ϕ = (2*π*n)/N \n'; #phase difference
print'ϕ = (n*π)/4\n'; #phase difference
K = N/2; #useful no. of nodes
# Most dominant mode is the one for which phase differnce b/w adjacent resonators is π radians
# Therefore (n*π)/4 = π
n = 4
# Output
print'Number of possible modes of Resonance is %d\n'%N;
print'Number of useful modes of Resonance is %d\n'%K;
print'value of integer n for the most dominant mode is %d'%n;
import math
# Variable Declaration
Va = 1200; #Anode potential
F = 10*10**9; #Operating frequency in Hz
S = 5*10**-2; #spacing b/w 2 cavities
GS = 1*10**-3; #gap spacing in either cavity
e = 1.6*10**-19; #charge of electron
m = 9.1*10**-31; #mass of electron in kg
# Calculations
# Condition of maximum output is (V1/Vo)max = (3.68)/((2*pi*n)-(pi/2);
# (2*pi*n)-(pi/2) = Transit angle b/w two cavities
# V1 = Peak amplitude of RF i/p
# Vo = accelarating potential
Vo = math.sqrt(2*e*Va/m); #velocity of the electrons
T = S/Vo; #Transit time b/w the cavities
TA = 2*math.pi*F*T; #transit angle in radians
V1 = (3.68*Va)/TA;
# Result
print'Required Peak Amplitude of i/p RF signal is %3.2f volts'%V1;
import math
# Given Data
R = 10; # circumference to pitch ratio
e = 1.6*10**-19; # charge of electron
m = 9.1*10**-31; # mass of electron in Kg
c = 3*10**8; # vel. of EM waves in m/s
# Calculations
Vp = c/float(R); # axial phase velocity = free space vel*(pitch/circumference)
Va = (Vp**2 * m)/float((2*e));
# Output
print'Anode Voltage = %3.2f kV' %(Va/float(1000));
print'In practice,the electron beam velocity is kept slightly greater than the axial phase velocity of RF signal';