import math
from __future__ import division
#initialisation of variables
tau_r=12*10**-9; #radiative recombination time in s
tau_nr=35*10**-9; #non-radiative recombination time in s
n1=3.5; #refractive index of semiconductor
n2=1; #refractive index of air
d=0.4*10**-6; #active later thickness in m
V=8; #recombination velocity
#CALCULATIONS
eta_int=1/(1+(tau_r/tau_nr)); #internal quantum efficiency
tau=1/((tau_r**-1)+(tau_nr**-1)+(2*V/d)); #total recombination time in s
f=math.sqrt(3)/(2*3.14*tau); #bandwidth in Hz
F3=((n1-n2)**2/(n1+n2)**2); #fresnel reflection
eta_ext=eta_int*(1-F3); #external quantum efficiency
#RESULTS
print"internal quantum efficiency=",round(eta_int,5); #The answers vary due to round off error
print"total recombination time =",round(tau*1e9,5),"ns"; #multiplication by 1e9 to convert unit from s to ns//The answers vary due to round off error
print"bandwidth =",round(f*1e-6,5),"MHz"; #multiplication by 1e-6 to convert unit from Hz to MHz///The answers vary due to round off error
print"fresnel reflection=",round(F3,5); #The answers vary due to round off error
print"external quantum efficiency=",round(eta_ext,5); #The answers vary due to round off error
import math
from __future__ import division
#initialisation of variables
lambda1=1.3; #wavelength of laser in um
w=5; #active layer width in um
d=2; #active layer thickness in um
n1=3.5; #refractive index of core
n2=3.49; #refractive index of cladding
#CALCULATIONS
k0=2*3.14/lambda1; #propagation constant
row=0.3; #confinement factor
neff=math.sqrt(n2**2+row); #effective refractive index
D=k0*d*(math.sqrt(n1**2-n2**2)); #normalized thickness
W=k0*w*(math.sqrt(neff**2-n2**2)); #normalized width// the answer given in textbook is wrong
Wlat=w*(math.sqrt(2*math.log(2)))*(0.32+2.1*(W**-1.5)); #Full width lateral at half maximum in um/ the answer given in textbook is wrong
Wtra=d*(math.sqrt(2*math.log(2)))*(0.32+2.1*(D**-1.5)); #Full width transverse at half maximum in um/ the answer given in textbook is wrong
#RESULTS
print"Normalized thickness=",round(D,5); #The answers vary due to round off error
print"Normalized width =",round(W,5); #multiplication by 1e9 to convert unit from s to ns/// the answer given in textbook is wrong
print"Full width lateral at half maximum =",round(Wlat,5),"um"; #multiplication by 1e-6 to convert unit from Hz to MHz//// the answer given in textbook is wrong
print"Full width transverse at half maximum =",round(Wtra,5),"um"; #multiplication by 1e-6 to convert unit from Hz to MHz//// the answer given in textbook is wrong
import math
from __future__ import division
#initialisation of variables
Eg=1.3; #band gap energy in eV
l=0.4; #cavity length in mm
R1=0.5; #reflectivities on ends
R2=0.5; #reflectivities on ends
alpha=3; #loss coefficient in /mm
current_density=30*10**5; #current density in amp/m^2
area=0.2*0.5*10**-6; #laser active area in m^2
#CALCULATIONS
lambda1=1.24/Eg; #emission wavelength in um
gth=alpha+(1/(2*l))*math.log(1/(R1*R2)); #Threshold Gain
threshold_current=current_density*area; #threshold current in A
#RESULTS
print"Emission wavelength =",round(lambda1,5),"nm"; #multiplication by 1e3 to convert unit from um to nm
print"Threshold Gain=",round(gth,5),"/mm";
print"Threshold current =",round(threshold_current*1e3,5),"mA"; #for converting unit from A to mA
import math
from __future__ import division
#initialisation of variables
lamda=0.85*10**-6; #wavelength of operation in m
delta_lamda=36*10**-9; #spectral width in m
#CALCULATIONS
fractional_width=delta_lamda/lamda; #fractional width
#RESULTS
print"Fractional width=", round(fractional_width*100,5),"percent"; #multiplication by 100 to represent information in percentage