from __future__ import division
from numpy import pi, sqrt, log10
n1=3.4 #refractive index of optical source
n=1.46 #refractive index of silica fiber
r=((n1-n)/(n1+n))**2 #computing Frensel reflection
L=-10*log10(1-r) #computing loss
print "Frensel reflection is %.3f.\nPower loss is %.2f dB." %(r,L)
r=35*10**-6 #radius
R=150 #Lambertian emission pattern
NA=0.2 #Numerical aperture
Pled = pi**2*r**2*R*NA**2
Pled=Pled*10**7
print "Optical power for larger core of 35 micrometer is %.3f mW." %(Pled)
r1=25*10**-6
Pled1=(r1/r)**2*Pled
print "Optical power for smaller core of 25 micrometer is %.2f mW." %(Pled1)
r=25*10**-6 #radius
R=39 #Lambertian emission pattern
NA=0.25 #numerical aperture
a=35*10**-6 #area
Pc1= pi**2*a**2*R*NA**2 #computing coupled power when r<a
Pc1=Pc1*10**7
Pc= pi**2*r**2*R*NA**2 #computing coupled power when r>a
Pc=Pc*10**7
print "Optical power when r>a is %.2f mW.\nOptical power when r<a is %.3f mW." %(Pc,Pc1)
h=6.626*10**-34 #plank's constant
c=3*10**8 #speed of light
e=1.6*10**-19 #charge of electron
q=1.43 #Bandgap energy
lamda=h*c/(q*e)*10**9 #computing wavelength
print "Wavelength is %d nm" %(lamda)
R=0.6 #responsivity
Pin=15 #optical power in microwatt
Ip=R*Pin #computing photocurrent
print "Photocurrent generated is %d microAmpere." %Ip
lamda1=1300*10**-9
lamda2=1600*10**-9
h=6.625*10**-34 #plank's constant
c=3*10**8 #speed of light
q=1.6*10**-19 #charge of electron
eta=90/100 #quantum efficiency
E=0.73 #energy gap in eV
R1=eta*q*lamda1/(h*c)
R2=eta*q*lamda2/(h*c)
lamdac=1.24/E
print "Responsivity at 1300nm is %.2f A/W.\nResponsivity at 1600nm is %.2f A/W.\nCut-off wavelength is %.1f micrometer." %(R1,R2,lamdac)
#R1 is calculated wrong.
lamda=0.8*10**-6
h=6.625*10**-34 #plank's constant
c=3*10**8 #speed of light
q=1.6*10**-19 #charge of electron
ne=1.8*10**11 #electrons collected
np=4*10**11 #photons incident
eta=ne/np #computing quantum efficiency
R=eta*q*lamda/(h*c) #computing responsivity
print "Responsivity of photodiode at 0.8 micrometer is %.3f A/W." %R
#answer in the book is wrong.
E=1.8*10**-19 # Energy of photon
nq=70/100 # Quantum
Ip=3 # current in uA
h=6.625*10**-34 #plank's constant
c=3*10**8 #speed of light
lamda=h*c/E*10**6 # wavelength in micro meter
print "Photodiode operates at %0.2f micro meter" %lamda
q=1.6*10**-19 #charge of electron
R=nq*q/E #computing responsivity
Popt=Ip/R
print "Incident optical power required = %.3f uW." %Popt
h=6.626*10**-34 #plank's constant
c=3*10**8 #speed of light
q=1.6*10**-19 #charge of electron
E=1.35 #energy gap in eV
lamda=h*c/(q*E) #computing wavelength
lamda=lamda*10**6
print "The InP photodetector will stop operation above %.2f micrometer." %(lamda)
#calculation error in the book.
h=6.626*10**-34 #plank's constant
c=3*10**8 #speed of light
eta=65/100 #quantum efficiency
I=2.5*10**-6 #photocurrent
E=1.5*10**-19 #energy of photns
q=1.6*10**-19 #charge of electron
lamda=h*c/E #computing wavelength
R=eta*q*lamda/(h*c) #computing responsivity
Popt=I/R #computing optical power
lamda=lamda*10**6
Popt=Popt*10**6
print "Wavelength is %.3f micrometer.\nResponsivity is %.3f A/W.\nIncident optical power required is %.1f microWatt." %(lamda,R,Popt)
#answer of R(responsivity) in the book is calculated as 0.694 A/W, deviation of 0.001.
ne=3.9*10**6 #electrons collected
np=6*10**6 #photons incident
eta=100*ne/np #computing efficiency
print "Quantum efficiency is %d percent." %(eta)
w=25*10**-6 #width
v=1*10**5 #velocity
r=40*10**-6 #radius
eps=12.5*10**-13
t=w/v #computing drift time
c=eps*3.14*(r)**2/w #computing junction capacitance
c=c*10**16
print "Drift time %.1e sec.\nJunction capacitance %.1f pf." %(t,c)
#calculation error in drift time answer.
w=20*10**-6 #width
v=4*10**4 #velocity
t=w/v #computing drift time
BW=(2*pi*t)**-1 #computing bandwidth
rt=1/BW #computing response time
rt=rt*10**9
print "Maximum response time is %.1f ns." %(rt)
#Calculation error in the book.
lamda=1.4*10**-6
h=6.626*10**-34 #plank's constant
c=3*10**8 #speed of light
q=1.6*10**-19 #charge of electron
eta=65/100 #quantum efficiency
I=10*10**-9 #current
NEP= h*c*sqrt(2*q*I)/(eta*q*lamda)
D=NEP**-1
print "Noise equivalent power is %.3e W.\nSpecific directivity is %.2e." %(NEP,D)
#answers in the book for NEP & D is wrong.
lamda=1300*10**-9
h=6.626*10**-34 #plank's constant
c=3*10**8 #speed of light
q=1.6*10**-19 #charge of electron
eta=90/100 #quantum efficiency
P0=300*10**-9 #optical power
Id=4 #dark current
B=20*10**6 #bandwidth
K=1.39*10**-23 #Boltzman constant
T=298 #temperature
R=1000 #load resister
Ip= 10**9*eta*P0*q*lamda/(h*c)
Its=10**9*(2*q*B*(Ip+Id))
Its=sqrt(Its)
print "rms shot noise current is %.2f nA." %(Its)
It= 4*K*T*B/R
It=sqrt(It)
print "Thermal noise is %.2e A." %(It)
#answer given in book for shot noise & Thermal noise are wrong.
from numpy import floor
lamda=0.85*10**-6
h=6.626*10**-34 #plank's constant
c=3*10**8 #speed of light
q=1.6*10**-19 #charge of electron
eta=75/100 #quantum efficiency
P0=0.6*10**-6 #incident optical power
Im=15*10**2 #avalanche gain
R= eta*q*lamda/(h*c) #computing responsivity
Ip=10**8*P0*R #computing photocurrent
Ip=floor(Ip)
M=Im/Ip #computing multiplication factor
print "Multiplication factor is %d." %(M)
from __future__ import division
lamda=900*10**-9 # Wavelength in m
P0=0.5 # Optical power
Im=10 # Photocurrent
h=6.626*10**-34 #plank's constant
c=3*10**8 #speed of light
q=1.6*10**-19 #charge of electron
eta=65.0/100 #quantum efficiency
R= eta*q*lamda/(h*c) #computing responsivity
Ip=P0*R #computing photocurrent
M=Im/Ip #computing multiplication factor
print "Multiplication factor is %0.2f." %(M)
# Answer is wrong in the textbook.
lamda=900*10**-9
h=6.626*10**-34 #plank's constant
c=3*10**8 #speed of light
q=1.6*10**-19 #charge of electron
eta=65/100 #quantum efficiency
P0=0.5*10**-6 #incident optical power
Im=10*10**2 #avalanche gain
R= eta*q*lamda/(h*c) #computing responsivity
Ip=10**8*P0*R #computing photocurrent
M=Im/Ip #computing multiplication factor
print "Multiplication factor is %d." %(M)
#answer in the book is wrong.
lamda=900*10**-9
h=6.626*10**-34 #plank's constant
c=3*10**8 #speed of light
q=1.6*10**-19 #charge of electron
eta=65/100 #quantum efficiency
P0=0.5*10**-6 #incident optical power
Im=10*10**2 #avalanche gain
R= eta*q*lamda/(h*c) #computong responsivity
Ip=10**8*P0*R #computing photocurrent
M=Im/Ip #computing multiplication factor
print "Multiplication factor is %d." %M