#Chapter 4, Exmaple 1, page 139
#Claculate alpha and No. of electrons emmited
from math import log,e
#Claculate (a)alpha
d2 = 0.01
d1 = 0.005
I2 = 2.7*10**-7
I1 = 2.7*10**-8
alpha = 1/(d2-d1)*log(I2/I1)
#(b)number of electrons emmited from cathode per second
I0 = I1*e**(-alpha*d1)
n0 = I0/(1.6*10**-19)
print"\n Part (a)\n alpha = m^-1",alpha
print"\n Part (b)\n I0 = ",I0
print"\n No of electrons emitted = electrons/s",n0
#Answer may vary due to round off error
#Chapter 4, Exmaple 2, page 140
#Claculate electrode space
from math import log
#based on the values of example 1
d2 = 0.01
d1 = 0.005
I2 = 2.7*10**-7
I1 = 2.7*10**-8
a = 1/(d2-d1)*log(I2/I1) # alpha
#10**9 = %e**a(a*d)
#multiplying log on bith sides log(10**9) = a*d
ad = log(10**9)
print"\n a*d = ",ad
d = ad/a
print"\n electrode space = m",d
#Chapter 4, Exmaple 3, page 140
#Claculate size of developed avalanche
import scipy
from scipy import integrate
a = 4*10**4
b = 15*10**5
#Rewriting equation 4.2
x0=0;x1=0.0005;
def fun1(x):
y=a-b*(x)**0.5
return y
X=scipy.integrate.quad(fun1,x0,x1);
expX=6765.964568
As = expX # Avelanche size
print"\n Avalanche size = m",round(As)
#Answers may vary due to round of error
#Chapter 4, Exmaple 4, page 141
#Claculate distance to produce avalanche
#Rewrite equation 4.2
#using the values of a and b from previous example
#convert integartion to quaderatic equation form
#x=poly(0,"x");
import numpy
p=numpy.array([7.5*10**5, 59.97-4*10**4, 59.97])
r=numpy.roots(p)
#obtaining the roots
print"\n m or m away from the cathode",round(r[0],4),round(r[1],5)
#Answer may vary due to round of error.
#Chapter 4, Exmaple 5, page 141
#Claculate minimum distance to produce avalanche of size 10^19
#Rewriting equation 4.2 and converting it into quadratic equation
#x=poly(0,"x");
import numpy
p=numpy.array([7.5*10**5, 4*10**4, 43.75])
r=numpy.roots(p)
#obtaining the roots
print"\n Minimum distance = m",round(-r[1],4)# other root is disregarded
#Answer may vary due to round of error.
#Chapter 4, Exmaple 7, page 142
#Claculate secondary coefficient
from math import exp
#Using equation 3.15
E = 9*10**3/0.002
T = 11253.7 # m^-7*kPa^-1
B = 273840 # V/mkPa
p = 101.3 # kPa or 1 atm
d = 0.002 # m
alpha = p*T*exp(-B*p/E)
Y = 1/(exp(alpha*d)-1)
print"\n E = V/m",E
print"\n Alpha = m^-1",alpha
print"\n Total secondary coefficient of ionization = ",round(Y,5)
#Answer may vary due to round off error
#Chapter 4, Exmaple 8, page 143
#Claculate first and secondary ionization coefficient
from math import log
from math import exp
#(a)first ionization coefficient
#Using equation 4.7a
d1 = 0.005
a1d1 = log(1.22)
a1 = a1d1/d1
d2 = 0.01504
a2d2 = log(1.82)
a2 = a2d2/d2
d3 = 0.019 # wrong value used in the text
a3d3 = log(2.22)
a3 = a3d3/d3
print"\n Alpha 1 = m^-1",round(a1,1)
print"\n Alpha 2 = m^-1",round(a2,1)
print"\n Alpha 3 = m^-1",round(a3,2)
print"\n From the above results we can understand that ionization mechanism must be acting at d3 "
#secondary ionization coefficient
I = 2.22
e = exp(a1*d3)
Y = (I-e)/(I*(e-1))
print"\n secondary ionization coefficient = ",round(Y,4)
#Answer may vary due to round off error.
#Chapter 4, Exmaple 9, page 144
#Claculate distance and voltage
from math import log
a = 39.8 # alpha
Y = 0.0354 # corfficient
p = 0.133 # kPa
Ep = 12000 # E/P , unit : V/m*kPa
d = (1/a)*(log(1/Y + 1)) # distance
E = Ep*p
V = E*d
print"\n Distance = m",round(d,3)
print"\n E = V/m",E
print"\n Volatge = V",round(V,2)
#Answers may vary due to round off error
#Chapter 4, Exmaple 10, page 144
#Claculate (a)Raether's criterion (b)Meek and Lobe's criterion
from math import log
#(a)Raether's criterion
# as assumed by Raether and based equation 3.3, 3.50, 4.22 and 4.23
d = 0.001 # m
alpha = 10792.2 # m**-1
p = 101.3 #kPa**-1
ap = 106.54 # alpha/p Unit: m**-1*kPa**-1
T = 11253.7 # m**-1*kPa**-1
B = 273840 # V/m*kPa
Ep = 58764.81 # E/p Unit:V/m*kPa
ad = 17.7 + log(d)
E = Ep*p
Vs = E*d*10**-3 #Voltage breakdown
print"\n E = V/m",E
print"\n Voltage breakdown = kV",round(Vs,2)
#(b)Meek and Loeb's criterion
#Using equation 4.11 and based on 4.24 & 4,25
#+ we get Er = 468*10**4 V/m
Er = 468*10**4 # V/m
Vs2 = Er*0.001*10**-3
print"\n Voltage breakdown = kV",Vs2
# Answers may vary due to round of error
#Chapter 4, Exmaple 11, page 146
#Claculate the first Townsend's ionization coefficient
t = 0.2*10**-6 # transit time of electrons in seconds
d = 0.05 # m
ve = d/t
TC = 35*10**-9 # Time constant
a = 1/(ve*TC)
print"\n Electron drift velocity = m/s",ve
print"\n alpha = m**-1",round(a,1)
#Chapter 4, Exmaple 12, page 146
#Travel time and maximum frequency
from math import pi
from math import asin
#(a)Determine the travel time
Ea = 200*(2)**0.5*10**3/0.1
x = 1.4*10**-4*2828.4*10**3/(2*pi*50)
d = 0.1
print"\n Ea = V/m",Ea
print"\n x = *sin(3.14*t)",x
#obtaining t from x
t = asin(d/x)/3.14
print"\n t = ms",t# answer mentioned in the text is wrong
#(b)Determine the maximum frequency
k = 1.4*10**-4
fmax = k*Ea/(2*pi*d)
print"\n fmax = Hz",round(fmax,1)