'''Find-
a)bulk recombination life time
b)internal quantum efficiency
c)internal power level'''
#Variable declaration
lamda = 1310*10**-9 #operating wavelength(m)
Tr = 30. #radiative recombination times(ns)
Tnr = 100. #non-radiative recombination times(ns)
i = 40*10**-3 #injected current(A)
h = 6.62*10**-34 #Planck's constant
c = 3*10**8 #speed of light(m/s)
e = 1.6*10**-19 #charge of an electron(C)
#Calculations
#Part a
T = 1/(1/Tr+1/Tnr)
#Part b
Nint = T/Tr
#Part c
Pint = (Nint*h*c*i)/(e*lamda)
#Results
print "a)Bulk recombination life time =",round(T,2),"ns"
print "b)Internal quantum efficiency =",round(Nint,3)
print "c)Internal power level =",round((Pint/1E-3),2),"mW(Calculation mistake in textbook)"
'''Find the power radiated by an LED'''
#Variable declaration
lamda = 670*10**-9 #operating wavelength(m)
h = 6.62*10**-34 #Planck's constant
c = 3*10**8 #speed of light(m/s)
i = 50*10**-3 #injected current(mA)
Nint = 3./100 #quantum efficiency
e = 1.6*10**-19 #charge of an electron(C)
#Calculations
P = (Nint*h*c*i)/(lamda*e)
#Result
print "Power radiated =",round((P/1E-3),4),"mW(Calculation mistake in textbook)"
'''Find the non-radiative recombination time'''
#Variable declaration
lamda = 890.*10**-9 #operating wavelength(m)
Tr = 100. #radiative recombination times(ns)
T = 130. #bulk-radiative recombination times(ns)
i = 14.*10**-3 #injected current(mA)
#Calculation
Tnr = 1/(1/Tr-1/T)
#Result
print "The non-radiative recombination time is",round(Tnr,1),"ns"
'''Calculate the power internally generated within the device'''
#Variable declaration
lamda = 0.87*10**-6 #operating wavelength(m)
h = 6.62*10**-34 #Planck's constant
c = 3*10**8 #speed of light(m/s)
i = 40*10**-3 #injected current(mA)
Nint = 0.625 #quantum efficiency
e = 1.6*10**-19 #charge of an electron(C)
#Calculations
P = (Nint*h*c*i)/(lamda*e)
#Result
print "Power radiated =",round((P/1E-3),2),"mW"
'''Estimate the optical power emitted into air'''
from sympy import *
#Variable declaration
F = 0.68 #transmission factor
nx = 3.6 #refractive index of GaAs
n = 1 #refractive index of air
#Calculations
Pint = Symbol('Pint')
Pe = round(((F*n**2)/(4*F*nx**2)),4)*Pint
#Result
print "Optical power emitted =",Pe
'''Find -
a)coupling efficiency
b)optical loss relative to power emitted from LED'''
import math
#Variable declaration
NA = 0.2 #numerical paerture
n = 1.4 #refractive index of core
#Calculations
#Part a
Nc = NA**2
#Part b
Loss = -math.log10(Nc)
#Results
print "a)Coupling efficiency =",Nc
print "b)Optical loss =",round(Loss,2),"dB(Calculation mistake in textbook)"
'''Calculate the optical power coupled into the fiber'''
import math
#Variable declaration
r = 0.01 #Fresnel reflection coefficient
NA = 0.15 #numerical aperture
Rd = 30 #radiance(s/r-cm^2)
i = 40 #drive current(mA)
R = 50./2*10**-4 #radius(cm)
#Calculations
A = math.pi*R**2 #area
Pc = math.pi*(1-r)*A*Rd*NA**2
#Result
print "Optical power coupled into the fiber =",round((Pc/1E-6),1),"uW"
'''Find the overall power conversion efficiency'''
#Variable declaration
Pc = 150*10**-6 #optical power(W)
If = 25*10**-3 #forward current(A)
Vf = 2.5 #forward voltage(V)
#Calculation
P = If*Vf
Npc = (Pc/P)*100
#Result
print "The overall power conversion efficiency is",round(Npc,2),"%"
'''Find the output power when device is modulated'''
import math
#Variable declaration
Pdc = 300*10**-6 #optical o/p power(W)
f = 20*10**6 #frequency(Hz)
Ti = 5*10**-9 #recombination life time(sec)
#Calculation
w = 2*math.pi*f
Pe = Pdc*(1+((w*Ti)**2))**-0.5
#Result
print "Output power of the device =",round((Pe/1E-6),2),"uW"
'''Find-
a)internal quantum efficiency and internal power level
b)power emiited from device'''
#Variable declaration
lamda = 1310*10**-9 #operating wavelength(m)
Tr = 25. #radiative recombination times(ns)
Tnr = 90. #non-radiative recombination times(ns)
i = 35*10**-3 #injected current(A)
n = 3.5 #refractive index
h = 6.625*10**-34 #Planck's constant
c = 3*10**8 #speed of light(m/s)
q = 1.6*10**-19 #charge of an electron(C)
#Calculations
#Part a
T = 1/(1/Tr+1/Tnr)
Nint = T/Tr
Pint = (Nint*h*c*i)/(q*lamda)
#Part b
P = Pint/(n*(n+1)**2)
#Results
print "a)Internal quantum efficiency =",round(Nint,3)
print " Internal power level =",round((Pint/1E-3),2),"mW(Calculation mistake in textbook)"
print "b)Power emitted from device =",round((P/1E-3),3),"mW"
'''Find the transmission factor'''
#Varible declaration
I = 37 #drive current(mA)
V = 1.6 #potential difference(V)
Nep = 0.75 #power efficiency(%)
Pint = 30 #optical power(mW)
nx = 3.46 #refractive index of InP
n = 1 #refractive index of air
#Calculations
P = I*V
Pe = (P*Nep)/100
F = (Pe*4*nx**2)/(Pint*n**2)
#Result
print "Transmission factor =",round(F,1)
'''Calculate the external power efficiency'''
#Variable declaration
lamda = 0.85*10**-6 #operating wavelength(m)
Nint = 60./100 #internal quantum efficiency
i = 20*100**-3 #forward current(A/s)
v = 1 #potential difference(V)
F = 0.68 #transmission factor
nx = 3.6 #refractive index of GaAs
n = 1 #refractive index of air
h = 6.625*10**-34 #Planck's constant
c = 3*10**8 #speed of light(m/s)
e = 1.6*10**-19 #charge of an electron(C)
#Calculations
Pint = (Nint*h*c*i)/(e*lamda)
Pe = (Pint*F*v)/(4*nx**2)
Nep = (Pe/(i*v))*100
#Result
print "External power efficiency =",round(Nep,2),"%"
'''Calculate the ratio of stimulated emission rate to spontaneous emission rate'''
import math
#Variable declaration
lamda = 0.5*10**-6 #operating wavelength(m)
T = 1000 #temperature(K)
c = 3*10**8 #speed of light(m/s)
h = 6.625*10**-34 #Planck's constant
k = 1.38*10**-23 #Boltman's constant
#Calculations
f = c/lamda
r = 1/(math.exp((h*f)/(k*T))-1)
#Result
print "Ratio = ",round((r/1E-13),2),"*10^-13"
'''Find the optical spacing between mirrors'''
#Variable declaration
lamda = 0.5*10**-6 #operating wavelength(m)
n = 1.38 #refractive index of laser
T = 1000 #temperature(K)
q = 1.3*10**4 #longitudnal modes
#Calculation
L = (lamda*q)/(2*n)
#Result
print "The optical spacing between mirrors is",round((L/1E-3),1),"*10^-3 m(Calculation mistake in textbook)"
'''Find the number of longitudnal modes and their frequency seperation'''
#Variable declaration
lamda = 0.55*10**-6 #operating wavelength(m)
n = 1.78 #refractive index of laser
L = 4*10**-2 #crystal length(m)
c = 3*10**8 #speed of light(m/s)
#Calculation
q = (2*n*L)/lamda
Sf = c/(2*n*L)
#Result
print "The number of longitudnal modes are",round((q/1E+5),1),"*10^5"
print "The frequency seperations is",round((Sf/1E+9),1),"GHz"
'''Find the optical gain'''
import math
#Variable declaration
R1 = 0.32
R2 = R1
alpha = 10*10**-2 #cm
L = 500*10**-6 #m
#Calculation
gth = alpha+((math.log(1/(R1*R2)))/(2*L))
#Result
print "Optical gain =",round((gth/1E+2),1),"cm^-1(Calculation mistake in textbook)"
'''Find frequency and wavelength spacing'''
#Variable declaration
lamda = 850*10**-9 #operating wavelength(m)
n = 3.7 #refractive index of laser
L = 500*10**-6 #length(m)
c = 3*10**8 #speed of light(m/s)
#Calculations
Sf = c/(2*n*L)
Sl = lamda**2/(2*L*n)
#Results
print "Frequency =",round(Sf/1E+9),"GHz"
print "Wavelength spacing =",round((Sl/1E-9),3),"nm"
'''Find the radiative minority carrier lifetimes in GaAs nd Si'''
#Variable declaration
Br1 = 7.21*10**-10 #for GaAs
Br2 = 1.79*10**-15 #for Si
N = 10**18 #hole concentration(/cm^3)
#Calculations
#For GaAs
Tr = (Br1*N)**-1
#For Si
Tt = (Br2*N)**-1
#Results
print "The radiative minority carrier lifetimes in GaAs is",round((Tr/1E-9),1),"ns"
print "The radiative minority carrier lifetimes in Si is",round((Tt/1E-9),1),"ns"
'''Calculate the threshold density'''
import math
#Varaible declaration
B = 21*10**-3 #gain factor(A/cm^3)
alpha = 10 #loss coefficent(/cm)
L = 250*10**-6 #optical cavity length(m)
r = 0.32 #reflectivity
#Calculation
Jth = (alpha+(1/L)*math.log(1/r))/B
#Result
print "Threshold density =",round((Jth/1E+3),2),"*10^3 A/cm^2(Calculation mistake in textbook)"
'''Find the external power efficiency of the device'''
#Variable declaration
Nt = 18./100 #total efficiency
Eg = 1.43 #bandgap energy(eV)
V = 2.5 #voltage(V)
#Calculation
Next = ((Nt*Eg)/V)*100
#Result
print "External power efficiiency =",round(Next),"%"
'''Estimate the ratio of threshold current densities'''
import math
#Variable declaration
T1 = 293. #tempearute(K)
T2 = 353. #K
To = 160. #K
#Calculations
#At 20C
Jth1 = math.exp(T1/To)
#At 80C
Jth2 = math.exp(T2/To)
Jth = Jth2/Jth1
#Result
print "Ratio of current densities =",round(Jth,2)
'''Calculate the optical emission wavelength'''
#Varaible declaraion
Eg = 1.43 #bandgap energy(eV)
h = 6.625*10**-34 #Planck's constant
c = 3*10**8 #speed of light(m/s)
e = 1.602*10**-19 #charge of an electron
#Calculations
lamda = (h*c)/(Eg*e)
#Result
print "Wavelength =",round(lamda/1e-6,3),"um"
'''Find the threshold coefficient gain'''
#Variable declaration
L = 0.5 #cavity length(mm)
alpha = 1.5 #loss coefficent
R1 = 0.35 #refractivities
R2=R1
T = 0.8 #confinement factor
#Calculation
gth = alpha+((math.log(1/(R1*R2)))/(2*L))
t = gth/T
#Result
print "Threshold coeeficient =",round(t,2),"mm^-1"
'''Find the cavity length and no. of longitudnal modes'''
#Variable declaration
lamda = 0.87*10**-6 #operating wavelength(m)
n = 3.6 #refractive index of laser
Sf = 278.*10**9 #frequency(Hz)
c = 3*10**8 #speed of light(m/s)
#Calculations
L = c/(2*n*Sf)
x = (2*n*L)/lamda
#Results
print "Cavity length =",round((L/1E-2),4),"cm"
print "No. of longitudnal modes =",round((x/1E+3),2),"*10^3"
#Answers are calculated incorrectly in the textbook
'''Find the internal quantum efficiency'''
#Variable declaration
n = 3.6 #refractive index of laser
L = 500*10**-6 #cavity length(mm)
alpha = 20 #loss coefficent(/cm)
Nd = 45./100 #differential quantum efficiency
#Calculations
r1 = ((n-1)/(n+1))**2
r2=r1
Ni = Nd*(1+((2*alpha*L)/(math.log(1/(r1*r2)))))
#Result
print "Internal quantum efficiency =",round((Ni*100),2),"%(Calculation mistake in textbook)"
'''Estimate the no. of longitudnal modes and frequency seperation'''
#Variable declaration
lamda = 0.5*10**-6 #operating wavelength(m)
n = 1.5 #refractive index of laser
L = 7*10**-2 #crystal length(m)
c = 3*10**8 #speed of light(m/s)
#Calculation
q = (2*n*L)/lamda
Sf = c/(2*n*L)
#Result
print "The number of longitudnal modes are",round((q/1E+5),1),"*10^5"
print "The frequency seperations is",round((Sf/1E+9),2),"GHz"
'''find the length of optical cavity and no. of longitudnal modes'''
#Variable declaration
lamda = 0.87*10**-6 #operating wavelength(m)
n = 3.6 #refractive index of laser
Sf = 278.*10**9 #frequency(Hz)
c = 2.99*10**8 #speed of light(m/s)
#Calculations
L = c/(2*n*Sf)
x = (2*n*L)/lamda
#Results
print "Cavity length =",round((L/1E-6),1),"um"
print "No. of longitudnal modes =",round((x),2)
'''Find hole concentration'''
#Variable declaration
Tr = 1*10**-9 #minority carrier lifetime(sec)
Br = 2.39*10**-10
#Calculation
P = 1/(Tr*Br)
#Result
print "Hole concentration =",round((P/1E+18),2),"*10^18 cm^-3"
'''Find the gain factor'''
#Variable declaration
L = 50*10**-6 #cavity length(m)
w = 15 #width(/cm)
Ith = 50*10**-3 #threshold current(A)
r1 = 0.3 #reflectivity
r2=r1
alpha = 10 #loss coefficient(/cm)
#Calculations
Jth = Ith/(L*w)
B = (1/Jth)*(alpha+((1/(2*L))*math.log(1/(r1*r2))))
#Result
print "Gain factor =",round((B/1E+2),2),"*10^2 cm/A"
'''Find the internal quantum efficiency'''
#Variable declaration
n = 3.6 #refractive index of laser
L = 500*10**-6 #cavity length(mm)
alpha = 20 #loss coefficent(/cm)
N = 22.5/100 #external quantum efficiency
#Calculations
r1 = ((n-1)/(n+1))**2
r2=r1
Ni = N/(1/((1+((2*alpha*L)/(math.log(1/(r1*r2)))))))
ni=N*(1+((2*alpha*L*10**-4)/(math.log(1/(r1*r2)))))
#Result
print "Internal quantum efficiency =",round((Ni*100),2),"%(Calculation mistake in textbook)"
"""
Example 5.31 is same as example 5.14
Example 5.32 is same as example 5.16
Example 5.33 is same as example 5.18
Example 5.34 is same as example 5.19
Example 5.35 is same as example 5.21
"""