from __future__ import division
x=0.07
Eg=1.424+1.266*x+0.266*x**2
lamda=1.24/Eg #computing wavelength
print "Wavlength is %.3f micrometer." %lamda
n=1.7 #refractive index
L=5*10**-2 #distance between mirror
c=3*10**8 #speed of light
lamda=0.45*10**-6 #wavelength
k=2*n*L/lamda #computing number of modes
delf=c/(2*n*L) #computing mode separation
delf=delf*10**-9
print "Number of modes are %.2e.\nFrequency separation is %.2f GHz."%(k,delf)
from __future__ import division
tr=50 #radiative recombination lifetime
tnr=85 #non-radiative recombination lifetime
h=6.624*10**-34 #plank's constant
c=3*10**8 #speed of light
q=1.6*10**-19 #charge of electron
i=35*10**-3 #current
lamda=0.85*10**-6 #wavelength
t=tr*tnr/(tr+tnr) #computing total recombination time
eta=t/tr #computing internal quantum efficiency
Pint=eta*h*c*i/(q*lamda) #computing internally generated power
Pint=Pint*10**3
print "Total recombinaiton time is %.2f ns.\nInternal quantum efficiency is %.3f.\nInternally generated power is %.2f mW." %(t,eta,Pint)
#answer in the book for Internal quantum efficiency & Internally generated power is wrong.
from numpy import sqrt, pi
f1=10*10**6 #frequency
f2=100*10**6
t=4*10**-9
Pdc=280*10**-6 #optincal output power
w1=2*pi*f1 #computing omega
Pout1=Pdc*10**6/(sqrt(1+(w1*t)**2)) #computing output power
w2=2*pi*f2 #computing omega
Pout2=Pdc*10**6/(sqrt(1+(w2*t)**2)) #computing output power
print """Ouput power at 10 MHz is %.2f microwatt.
Ouput power at 100 MHz is %.2f microwatt.
Conclusion when device is drive at higher frequency the optical power reduces.""" %(Pout1,Pout2)
BWopt = sqrt(3)/(2*pi*t)
BWelec = BWopt/sqrt(2)
BWopt=BWopt*10**-6
BWelec=BWelec*10**-6
print "3 dB optical power is %.2f MHz.\n3 dB electrical power is %.2f MHz." %(BWopt,BWelec)
#calculation error. In the book square term in the denominater is not taken.
#answers in the book are wrong.
n1=3.5 #refractive index
n=1 #refractive index of air
F=0.69 #transmission factor
eta = 100*(n1*(n1+1)**2)**-1 #computing eta
print "eta external is %.1f percent i.e. small fraction of intrnally generated opticalpower is emitted from the device." %eta
r= 100*F*n**2/(4*n1**2) #computing ratio of Popt/Pint
print "Popt/Pint is %.1f percent" %r
#printing mistake at final answer.
from numpy import log, exp
beta0=1.85*10**7
T=293 #temperature
k=1.38*10**-23 #Boltzman constant
Ea=0.9*1.6*10**-19
theta=0.65 #thershold
betar=beta0*exp(-Ea/(k*T))
t=-log(theta)/betar
print "Degradation rate is %.1e per hour.\nOperating lifetime is %.1e hour." %(betar,t)
#answer in the book for Degradation rate & Operating lifetime is wrong.