import math
#Variable declaration
Pi=120*10**-6 #mean i/p power in uW
Po=3*10**-6 #mean o/p power in uW
L=8 #length of fibre in Km
a1=2 #loss in dB
L1=10 #length of fibre in Km
loss=9 #loss in dB
#Calculation
SA=10*math.log10(Pi/Po) #overall signal attenuation
a=SA/L #signal attenuation per kilometer
al=a1*L1
SA1=al+loss #signal attenuation for the 10KM link
P=10**(2.9) #i/o power ratio, 2.9 is numeric value
#Result
print'Overall signal attenuation = ',round(SA),'dB'
print'Signal attenuation per kilometer = ',round(a),'dB Km^-1'
print'Overall signal attenuation for the 10KM link = ',round(SA1),'dB'
print'Numeric value for i/o power ratio = %.1f' %P
import math
#Variable declaration
Tf=1400 #tempreture in kelvin
K=1.381*10**-23 #Boltzmann’s constant
Bc=7*10**-11 #isothermal compressibility
n=1.46 #refractive index
p=0.286 #refractive index
h1=0.63*10**-6 #wavelength
h2=10**-6 #wavelength
h3=1.3*10**-6 #wavelength
L=10**3 #length in km
#Calculation
a=(8*math.pi**3*n**8*p**2*Bc*K*Tf)/3
yr=a/h1**4 #Rayleigh scattering coefficient
Lk=math.exp(-yr*L) #transmission loss factor
At=10*math.log10(Lk**-1) #attenuation due to Rayleigh scattering
yr1=a/h2**4 #Rayleigh scattering coefficient
Lk1=math.exp(-yr1*L) #transmission loss factor
At1=10*math.log10(Lk1**-1) #attenuation due to Rayleigh scattering
yr2=a/h3**4 #Rayleigh scattering coefficient
Lk2=math.exp(-yr2*L) #transmission loss factor
At2=10*math.log10(Lk2**-1) #attenuation due to Rayleigh scattering
#Result
print'Attenuation due to Rayleigh scattering (in 0.63 μm)= %.1f dB km^-1'%(At)
print'Attenuation due to Rayleigh scattering (in 1.0 μm)= %.1f dB km^-1'%(At1)
print'Attenuation due to Rayleigh scattering (in 1.30 μm)= %.1f dB km^-1'%(At2)
#Variable declaration
d=6 #diameter in μm
h=1.3 #wavelength in μm
adb=0.5 #attenuation in dB
v=0.6
#Calculation
Pb=4.4*10**-3*d**2*h**2*adb*v #for SBS
Pr=5.9*10**-2*d**2*h*adb #for SRS
#result
print'Threshold optical power for SBS = %.1f mW'%(Pb*1000)
print 'Threshold optical power for SRS = %.2f W'%Pr
import math
#Variable declaration
n1=1.5 #refractive index
h=0.82*10**-6 #operating wavelength
delta=0.03 #relative refractive index difference
delta1=0.003 #relative refractive index difference
h1=1.55*10**-6 #operating wavelength
a=4*10**-6 #radius of core
#Calculation
n2=(n1**2)-(2*delta*n1**2) #refractive index
Rc=(3*n1**2*h)/(4*math.pi*(n1**2-n2)**0.5) #multimode fiber critical radius of curvature
n21=(n1**2)-(2*delta1*n1**2) #refractive index
hc=(2*math.pi*a*n1*math.sqrt(2*delta1))/(2.405) #cutoff wavelength for the single-mode fiber
b=20*h1/math.sqrt(0.043)
c=(2.748-(0.996*h1/hc))**-3
Rcs=b*c #critical radius of curvature for the single-mode
#Result
print'Multimode fiber critical radius of curvature = %.2f um'%(Rc*10**6) #value given in the textbook is wrong
print'Single-mode fiber critical radius of curvature = %.2f um'%(Rcs*10**3) #value given in the textbook is wrong
import math
#Variable declaration
t=0.1*10**-6 #total pulse time
d=15 #distance in Km
#Calculation
Bt=1/(2*t) #Maximum Bandwidth
D=t/d #Pulse Dispersion
Bop=Bt*d #Bandwidth-length product
#Result
print'Maximum Bandwidth = %d Mhz'%(Bt/10**6)
print'Pulse Dispersion = %.2f ns per Km'%(D*10**9)
print'Bandwidth-length product = %d Mhz Km'%(Bop/10**6)
import math
#Variable declaration
b=0.025 #material dispersion
c=2.998 #speed of light (x 10^8)
h=85*10**6 #wavelength dispersion parameter
#Calculation
M=b/(c*h) #Material dispersion parameter
s=M*20 #RMS pulse broadening (1 Km)
#Result
print'Material dispersion parameter = %.1f ps n/m K/m'%(M*10**12)
print'RMS pulse broadening (1 Km) = %.2f ns K/m'%(s*10**9)
import math
#Variable declaration
h=0.85*10**-6 #wavelength
b=0.0012 #relative spectral width
M=98.1*10**-12 #material dispersion parameter
#Calculation
sh=b*h #relative spectral width
sm=sh*M*10**9 #RMS pulse braodening
#Result
print'RMS pulse braodening (1 Km) = %.2f ns K/m'%(sm*10**9)
import math
#Variable declaration
L=6000 #optical link
n1=1.5 #core refractive index
delt=0.01 #relative refractive index difference
c=2.998*10**8 #speed of light
#Calculation
Ts=(L*n1*delt)/c #Delay difference
sc=(L*n1*delt)/(2*math.sqrt(3)*c) #RMS pulse broadening
Bt=1/(2*Ts)
Btm=0.2/sc #Maximum bit rate using RMS pulse broadening
Bop=Btm*L #Bandwidth-length product
#Result
print'(a) Delay difference = %d ns' %(Ts*10**9)
print'(b) RMS pulse broadening = %.1f ns' %(sc*10**9)
print'(c) Maximum bit rate using RMS pulse broadening = %.1f Mbit/s'%(Btm/10**6)
print'(d) Bandwidth-length product = %.1f Mhz km'%(Bop/10**9)
import math
#Variable declaration
sc=86.7 #RMS pulse broadening
L1=6 #optical link
L=10**3 #for 1 Km
n1=1.5 #core refractive index
delt=0.01 #relative refractive index difference
c=3*10**8 #speed of light
#Calculation
d=sc/L1 #for multimode step index fiber
sg=(L*n1*delt**2)/(20*math.sqrt(3)*c) #gradient index fiber
#Result
print'RMS pulse broadening for multimode step index fiber = %.1f ns K/m'%(d)
print'RMS pulse broadening for gradient index fiber = %.1f ps K/m'%(sg*10**12)
import math
#Variable declaration
sh=50 #rms spectral width
L=1 #1 Km
M=250*10**-12 #material dispersion parameter
L1=10**3
NA=0.3 #numerical aperture
n1=1.45 #refractive index
c=2.998*10**8 #speed of light
#Calculation
sm=sh*L*M #rms pulse broadening
ss=(L1*NA**2)/(4*math.sqrt(3)*n1*c) #rms pulse broadening per kilometer
st=math.sqrt(sm**2+ss**2) #total rms pulse broadening per kilometer
Bop=0.2/st #bandwidth–length product
#Result
print'(a) Total RMS pulse broadening per Km = %.1f ns K/m'%(st*10**9)
print'(b) Bandwidth length product = %.1f Mhz Km'%(Bop*10**-6)
#Variable declaration
h=1280 #wavelength in nm
S0=0.09*10**-12 #dispersion slope
h0=1310 #zero dispersion wavlength in nm
h1=1550 #wavelength in nm
Dm=13.5*10**-12 #material dispersion wavelength in m
Dp=0.4*10**-12 #profile dispersion wavelength in m
#Calculation
a=h*S0/4
b=1-((h0*h**-1)**4)
Dt=a*b
Dt1=(h1*S0/4)*(1-(h0*h1**-1)**4)
Dw=Dt1-(Dm+Dp)
#Result
print'Total first order dispersion (1280 nm) = %.1f nm^-1 km^-1'%(Dt*10**12)
print'Total first order dispersion (1550 nm) = %.1f ps n/m K/m'%(Dt1*10**12)
print'Waveguide dispersion at wavelength 1.55um = %.1f ps n/m K/m'%(Dw*10**12)
import math
#Variable declaration
h=0.9*10**-6 #peak wavelength
Lb=0.09 #beat length
s=10**-9 #spectral linewidth
#Calculation
Bf=h/Lb #modal birefringence
Lbc=h**2/(Bf*s) #coherence length
Bxy=(2*math.pi)/Lb #difference between propagation constant
#Result
print'Modal birefringence, Bf = %.1f x 10^-5' %(Bf*10**5)
print'Coherence length, Lf = %.1f m' %Lbc
print'Difference between propagation constant = %.1f' %Bxy
#Variable declaration
h=1.3*10**-6 #fibers operating wavelength
Ls=0.7*10**-3 #beat length
L=80 #beat length
#Calculation
Bf=h/Ls #Fiber birefringence (0.7mm)
Bf1=h/L #Fiber birefringence (80m)
#Result
print'Fiber birefringence (0.7mm) = %.2f x 10^-3'%(Bf*1000)
print'Fiber birefringence (80m) = %.2f x 10^-8'%(Bf1*10**8)
import math
#Variable declaration
L=3.5*10**3 #length of fiber
a=2*10**-3 #tanh(h*L)
#Calculation
h=a/L #mode coupling parameter
#Result
print'Mode coupling parameter = %.1f x 10^-7 m^-1'%(h*10**7)