import math
#variable declaration
Z1 = 1.0 #distance (km)
Z2 = 2.0 #distance (km)
alpha_in_dB_per_km = 3.0 #loss(dB/km)
#calculation
R1 = (alpha_in_dB_per_km *Z1)/10.0
R2 = (alpha_in_dB_per_km *Z2)/10.0
P0_Pz1 = (10**R1) #power loss at 1 km
P0_Pz2 = (10**R2) #power loss at 2 km
Pz_P01 = 1-(1/P0_Pz1)
Pz_P02 = 1-(1/P0_Pz2)
#result
print "Optical signal power decresed for 1km = " , round(Pz_P01*100,0) , "%"
print "Optical signal power decresed for 2km = " , round(Pz_P02*100,0) , "%"
import math
#variable declaration
Pin = 200*10**-6 #power launched into the fiber(uW)
alpha = 0.4 #attenuation (dB/KM)
z = 30 #optical fiber length 30 KM
#calculation
Pin_dBm = 10*(math.log10(Pin/10**-3)) #input power (dBm)
Pout_dBm = 10*(math.log10(Pin/10**-3))-alpha*z #output power(dBm)
Pout = 10**(Pout_dBm/10)
#result
print "Input power = " , round(Pin_dBm,1),"dBm"
print "Output power = " , round(Pout_dBm,1),"dBm"
print "Output power = " , round(Pout*10**3,1),"um"
import math
#variable declaration
alpha_0 = 1.64 #attenuation at Lam_bda_0 in dB/KM
Lam_bda_0 = 850*10**-9 #wavelength 850 nm
Lam_bda1 = 1310*10**-9 #wavelength 1350 nm
Lam_bda2 = 1550*10**-9 #waavelength 1550 nm
#calculation
alpha_Lambda1 = alpha_0*((Lam_bda_0/Lam_bda1)**4) #rayleigh scattering loss1(dB/Km)
alpha_Lambda2 = alpha_0*((Lam_bda_0/Lam_bda2)**4) #rayleigh scattering loss2(dB/Km)
#result
print "Rayleigh scattering loss alpha at 1310 nm = " , round(alpha_Lambda1,3),"dB/Km"
print "Rayleigh scattering loss alpha at 1550 nm = " , round(alpha_Lambda2,3),"dB/Km"
import math
#variable declaration
alpha = 2 #graded index profile
n2 = 1.5 #cladding
Lam_bda = 1.3*10**-6 #wavelength
R = 0.01 #bend radius of curvature
a = 25*10**-6 #core radius
delta = 0.01 #core cladding index profile
k = 4.83*10**6 #propagation constant
#calculation
no_of_modes= -10000.0 #number of modes decreased by 50% in greded index fibre
part1 = (alpha+2)/(2*alpha*delta)
part2 = (1-no_of_modes)/part1 #Right side of equation
part3 = (2*a/R)+math.floor((3/(2*n2*k*R))**(2/3))*100 #left side of equation
#result
print "From equation part2 =",round(part2,1),"= part3 =",round(part3,1)
print "Radius of curvature = ", round(R*100,1),"cm"
import math
#variable declaration
C = 3*10**8 #free space velocity(m/s)
n1 = 1.48 #core refractive index
n2 = 1.465 #cladding refractive index
delta = 0.01 #index difference
L = 10**3 #fiber length (Km)
#calculation
deltaT = (L*(n1**2)/(C*n2))*delta #pulse broadening(ns/Km)
#result
print "Pulse broadening = " , round((deltaT/L)*10**12,0),"ns/Km"
import math
#variable declaration
n1 = 1.48 #core refractive index
n2 = 1.465 #cladding refractive index
delta = 0.01 #index difference
C =3*(10**8) #free space velcotiy(m/s)
#calculation
BL = (n2/(n1**2))*(C/delta) #bit rate distance product(Mb/s-km)
#result
print "Bandwidth distance at pulse spreding of 50ns/km = " , round(BL*10**-9),"Mb/s-km"
import math
#variable declaration
Lamda = 800*10**-9 #Wavelength (m)
sigma_Lamda_LED = 40*10**-9 #spectral width (m)
mat_dispersion = 0.00011 #material dispersion
#calculation
pulse_spread = sigma_Lamda_LED*mat_dispersion #pulse spread(ns/km)
#result
print "Material dispersion =" ,round(pulse_spread*10**12,1),"ns/km"
import math
#variable declaration
n2 = 1.48 #index of cladding
delta = 0.002 #index difference
Lam_bda = 1320*10**-9 #Wavelength (nm)
V_dVb_dV = 0.26 #The value in square brackets for v = 2.4
C =3*10**8 #velocity of light in free space
#calculation
Dwg_Lamda = -(((n2*delta)/C)*(1/Lam_bda))*V_dVb_dV #waveguide dispersion(ps/nm*km)
#result
print "Waveguide dispersion = " ,round(Dwg_Lamda*10**6,1),"ps/(nm*km)"