import math
#Variable declaration
zm=20.7 #average number of photons
h=6.626*10**-34 #plancks constant
f=2.998*10**14 #frequency in hertz
n=1 #for ideal detector
Bt=10**7 #bit rate
#Calculation
po=zm*h*f*Bt/(2*n) #output power in binary
pod=10*math.log10(po) #output power in dBW
pod1=10*math.log10(po*10**3) #output power in dBm
#Result
print'Minimum incident optical power = %.1f dBW'%(pod)
print' = %.1f dBm'%(pod1)
import math
#Variable declaration
sn=50/10 #signal to noise ratio in dB
f=2.998*10**14 #frequency in hertz
n=1 #for an ideal detector
B=5*10**6 #bandwidth
h=6.626*10**-34 #plancks constant
#Calculation
SN=10**(sn)
po=SN*f*2*h*B/n #incident optical power
pdb=10*math.log10(po*10**3) #incident optical power in dB
#Result
print'Incident optical power = %.1f nW '%(po*10**9)
print' in dB = %.1f dBm'%(pdb)
import math
#Variable declaration
po=200*10**-9 #incident optical power in W
e=1.602*10**-19 #1 electron volt
h=0.9*10**-6 #operating wavelength
h1=6.626*10**-34 #plancks constant
c=2.998*10**8 #speed of light
K=1.38*10**-23 #boltzman constant
T=293 #tempreture in kelvin
n=0.6 #quantum efficiency
B=5*10**6 #post-detection bandwidth
ib=3*10**-9 #dark current in ampere
Rl=4*10**3 #load resistance
#Calculation
ip=n*po*e*h/(h1*c) #photocurrent
i2=2*e*B*(ib+ip) #total shot noise current
i2rms=math.sqrt(i2) #RMS value
it=4*K*T*B/Rl #thermal noise current
itrms=math.sqrt(it) #RMS value
#Result
print'RMS shot noise current = %.2f x10^-10 A'%(i2rms*10**10)
print'RMS thermal noise current = %.2f x10^-9 A'%(itrms*10**9)
import math
#Variable declaration
ip=87.1*10**-9 #photocurrent
its=1.44*10**-19 #rms shot noise current
it=2.02*10**-17 #rms thermal noise current
fd=0.3 #frequency in 3 dB
#Calculation
f=10**(fd)
sn=ip**2/(its+(it*f)) #signal to noise ratio
snr=10*math.log10(sn) #signal to noise ratio in dB
#Result
print'SNR at output = %.2f dB'%snr
import math
#Variable declaration
B=8*10**6 #post detection bandwidth
Cd=6*10**-12 #capacitance in farad
Ca=12*10**-12 #input capacitance in farad
#Calculation
Rl=1/(2*math.pi*Cd*B) #maximum load resistance
B1=1/(2*math.pi*Rl*Ca) #maximum bandwidth
#Result
print'Maximu load resistance = %.2f KΩ'%(Rl*10**-3)
print'Maximum bandwidth = %.1f MHz'%(B1*10**-6)
import math
#Variable declaration
B=50*10**6 #post detection bandwidth
Cd=5*10**-12 #capacitance in farad
e=1.602*10**-19 #1 electron volt
K=1.38*10**-23 #boltzman constant
T=291 #tempreture in kelvin
ib=10**-7 #photocurrent before gain
x=0.3
#Calculation
Rl=1/(2*math.pi*Cd*B) #maximum value of the load resistor
a=2*e*B*ib #shot noise
b=4*K*T*B/Rl #thermal noise
sn=ib**2/(a+b) #SNR, when M = 1,
snd=10*math.log10(sn) #SNR in dB
Mop=((4*K*T)/(x*e*Rl*ib))**0.435
sn1=(Mop**2*ib**2)/((2*e*B*ib*Mop**2.3)+b) #SNR, when M = Mop,
sdb=10*math.log10(sn1) #SNR in dB
#Result
print'SNR (M=1) = %.2f dB'%(snd)
print'SNR (M=Mop) = %.1f dB'%(sdb)
import math
#Variable declaration
e=1.602*10**-19 #1 electron volt
K=1.38*10**-23 #boltzman constant
T=120 #tempreture in kelvin
B=10**7 #post detection bandwidth
sn=3.5 #SNR/10
fn=0.1 #noise figure/10
Rl=10**4 #load resistance
#Calculation
sn1=10**(sn)
fn1=10**(fn)
a=12*K*T*B*fn1/Rl
b=((4*K*T*fn1)/(1.1*e*Rl))**0.667
Ip=(sn1*a/b)**0.75 #minimum photocurrent
Mop=((4*K*T*fn1)/(e*Ip*1.1*10**3))**0.334 #optimum avalanche multiplication factor
#Result
print'Optimum avalanche multiplication factor = %.1f '%(Mop)
import math
#Variable declaration
r1=4*10**6 #effective input resistance in ohm
r2=8*10**6 #resistance in ohm
ct=6*10**-12 #total capacitance in farad
K=1.38*10**-23 #boltzman constant
T=300 #tempreture in kelvin
Rf=10**5 #feedback resitor
G=400 #open loop gain
#Calculation
Rt=(r1**2)/r2 #total effective load resistance
B=1/(2*math.pi*Rt*ct) #maximum bandwidth
i2=4*K*T/Rt #for highimpedance config
B1=G/(2*math.pi*Rf*ct) #maximum bandwidth for transimpedance config
it=4*K*T/(Rf) #for transimpedance
#transimpedance configuration factor of 20 greater than that obtained high-input-impedance configuration.
n=it/i2
ndb=10*math.log10(n)
#Result
print'(a) Maximum bandwidth = %.2f x10^4 Hz'%(B*10**-4)
print'(b) Mean square thermal noise current (high impedance config)= %.2f x10^-27 A^2 Hz^-1'%(i2*10**27)
print'\n(c) Maximum bandwidth for transimpedance = %.2f X 10^6 Hz'%(B1*10**-8)
print' Mean square thermal noise current (transimpedance config) = %.2f x10^-25 A^2 Hz^-1'%(it*10**25)
print' Ratio of these noise power = %d dB'%ndb