from __future__ import division
from math import sqrt, pi, log10
# Calculation of incident optical power.
#Given data
lamda=1.3*10**-6# # Wavelength
B=6*10**6# # Bandwidth
S=10**5# # Total system margin
n=1# # Efficiency
v=3*10**14#
h=6.62*10**-34# # Planck constant
# Incident optical power
P=(2*S*v*h*B)/n#
P1=10*log10(P/10**-3)#
print"Incident optical power = %0.1f nW "%(P1)#
# The answers vary due to round off error
# Calculation of maximum repeater spacing of a)ASK hetrodyne b)PSK homodyne
#Given data
S=0.2# # Split loss
c=3*10**8# # velocity of light
lamda=1.55*10**-6# # Wavelength
B1=50*10**6# # Speed of communication
h=6.63*10**-34 # Planck constant
B2=1*10**9# # Speed of communication
# a)Maximum repeater spacing for ASK hetrodyne
P1=(36*h*c*B1)/lamda#
P1=10*log10(P1/10**-3)#
s1=4-P1#
R1=s1/S#
P2= (36*h*c*B2)/lamda#
P2=10*log10(P2/10**-3)#
s2=4-P2#
R2=s2/S#
#b)Maximum repeater spacing for PSK homodyne
K1= (9*h*c*B1)/lamda#
K1=10*log10(K1/10**-3)#
K1=4-K1#
R3=K1/S#
K2= (9*h*c*B2)/lamda#
K2=10*log10(K2/10**-3)#
K2=4-K2#
R4=K2/S#
print"Maximum repeater spacing = %0.3f km "%(R1)#
print"Maximum repeater spacing = %0.3f km "%(R2)#
print"Maximum repeater spacing = %0.3f km "%(R3)#
print"Maximum repeater spacing = %0.3f km "%(R4)#
# The answers vary due to round off error
# Calculation of incident optical power.
#Given data
h=6.62*10**-34# # Planck constant
c=3*10**8# # velocity of light
lamda=1.55*10**-6# # Wavelength
B=400*10**6# # Speed of communication
# Maximum repeater spacing
P=(36*h*c*B)/lamda#
P=10*log10(P/10**-3)#
print"Incident optical power = %0.3f nW "%(P)#
# The answers vary due to round off error
# Calculation of optical power budget.
#Given data
M=-10# # Mean optical power
S=-25# # Split loss
TS=7# # Total system margin
SP=1.4# # Split loss
C=1.6# # Connector loss
SM=4# # Safety margin
# Net margin between LED and receiver
N=M-S#
# Total system loss
T=TS+SP+C+SM#
# Excess power margin
E=N-T#
print"Excess power margin = %0.0f dB "%(E)#
# The answers vary due to round off error
# Calculation of viability of digital link.
#Given data
M=-10# # Mean optical power
S=-41# # Receiver sensitivity
TS=18.2# # Total system margin
SP=3# # Split loss
C=1.5# # Connector loss
SM=6# # Safety margin
# Net margin between LED and receiver
N=M-S#
# Total system loss
T=TS+SP+C+SM#
# Excess power margin
E=N-T#
print"Excess power margin = %0.1f dB "%(E)#
# The answers vary due to round off error
# Calculation of signal to noise ratio.
#Given data
h=6.62*10**-34# # Planck constant
c=3*10**8# # velocity of light
lamda=1.55*10**-6# # Wavelength
B=400*10**6# # Speed of communication
s=2#
# S/N ratio
sn=(s*4.24)/(2**(1/2))#
i=(sn)**2#
print"Incident optical power = %0.2f nW "%(i)#
# The answer is wrong in the book
# Calculation of a)Bit rate of communication system b)Bit duration c)Time period
#Given data
f=8*10**3# # Power launched in port 1
P2=0.082*10**-6# # Power launched in port 2
P3=47*10**-6# # Power launched in port 3
P4=52*10**-6# # Power launched in port 4
# a)Bit rate of communication system
c=32*8#
B=f*c#
B=B*10**-6#
# b)Bit duration
D=1/B#
D=D*10*10**2#
P=8*D#
# c)Time period
T=32*P#
T=T*10**-3#
print"Bit rate of communication system = %0.3f Mb/s "%(B)#
print"Bit duration = %0.0f ns "%(D)#
print"Time period = %0.0f micro sec "%(T)#
# The answers vary due to round off error