from math import exp
T=2000 # In Kelvin
v=5*(10**14) #Frequency In Hertz
h=6.6*(10**-34) #Plancks Constant
k=1.38*(10**-23) #Boltzman Constant
#From Equation 5.9b
R=exp((h*v)/(k*T))-1
R=round(R,2)
print "The Ratio of rates of spontaneous & stimulated emission is "+str(R)
from math import exp
T=300 #Given Room Temperature in kelvin
l=550*(10**-9) #Average Wavelength of Visible Radiation
h=6.6*(10**-34) #Plancks Constant
c=3*(10**8) #Speed Of light
k=1.38*(10**-23) #Boltzman Constant
e=1.6*(10**-19) #Charge of a Electron
E=(h*c)/l #Where E is the given Energy Difference
E1=E/e
#From Equation 5.4 & given that g1=g2
N=exp((-1*E)/(k*T)) #Where N is the ratio of N2 and N1
print "The Given Energy Difference of the Two Levels is "+str(E1)+" eV"
print "The Relative Population of the Energy Levels is %.2e"%(N)
#For NdYAG
t=230*(10**-6) #Spontaneous Lifetime
l=1.06*(10**-6) #Wavelength in meter
n=1.82 #Refractive Index
w=3*(10**12) #Linewidth in Hertz
h=6.6*(10**-34) #Plancks Constant
PI=3.14
#From equation 5.8
B21=(l**3)/(8*PI*h*t*(n**3)) #Where B21 is the Einstein Coefficient
#From equation 5.18
k=1
kvs=(k*l*w)/(B21*h*n) #Small Signal Gain Coefficient per meter cube
print "Small Signal Gain Coefficient is %.2e /meter cube"%(kvs)
n2=3.6 #Refractive Index for GaAs
n1=1 #Refractive Index for Air
#From Fresnels Equation
R=((n2-n1)/(n2+n1))**2
R=round(R,2)
print "The Reflectance at a GaAs/Air Interface is "+str(R)
from math import log1p
#For GaAs Junction
l=0.84*(10**-6) #Wavelength in meter
w=1.45*(10**13) #Linewidth in Hertz
y=3.5*(10**3) #Loss Coefficient per meter
n=3.6 #Refractive Index for GaAs
q=1 #Quantam Efficiency
le=300*(10**-6)#length in meter
d=2*(10**-6)
R=0.32 #Reflectance
c=3*(10**8) #Speed of light in m/s
e=1.6*(10**-19) #Charge of electron
#From Equation 5.17
v=c/l #Frequency
k=y+((1/(2*le))*log1p(1/(R*R)))#Where k is the threshold gain
k=round(k,0)
#From Equation 5.39
J=(8*3.14*w*e*(n**2)*d*k*(v**2))/(c**2)
J=round(J,2)
print "The Threshold Gain is "+str(k)+" /m"
print "The Threshold Current Density is "+str(J)+" A/mm square"
i=10*(10**-3) #Current in ampere
V=2500
P=5*(10**-3) #optical Output
E=P/(i*V) #Where E is the overall Power Efficiency
E=E*100
print "The Overall Power Efficiency is "+str(E)+" Percent"