from math import sqrt
from math import sin
from math import exp
from math import pi
n1=1.5 #Refraction index of glass/air interface
n2=1 #Refraction index of air
c1=1*2*3.14*n2
s1=(sin(pi/3))**2 #By equation 8.8
s2=(n1/n2)**2
s3=(s1*s2)-1
s4=sqrt(s3)
s5=s4*c1
#assuming wavelength = field distance
F=exp(-1*s5) #Where F is the field decay factor
F=round(F,4) #Rounding out the value to equivalent figure
#at theta1=42 degrees
c1=1*2*3.14*n2
theta1=0.733038
#ta1=theta1*(180/math.pi)
#heta1=round(theta1,1)
s1=(sin(theta1))**2 #By equation 8.8
s2=(n1/n2)**2
s3=(s1*s2)-1
s4=sqrt(s3)
c4=s4*c1
#assuming wavelength = field distance
F1=exp(-1*c4)#where F1 is the field decay factor at 42 degrees
F1=round(F1,3)
print "The Field Decay factor at 60 degrees is "+str(F)
print "The Field Decay factor at 42 degrees is "+str(F1)
from math import sqrt
w=100*(10**-6) #Thickness of the WG
n1=1.48
n2=1.46
l=1*(10**-6) #Wavelength of light
PI=3.14
V=((PI*w)/l)*sqrt((n1**2)-(n2**2))
V1=(2*V)/PI
#from equation 8.15
N=2*(1+abs(V1)) #Where N is the total number of possible modes
N=round(N,0)
N=N-1
print "The Total number of possible Modes is "+str(N)
from math import sqrt
n1=1.48 #Given refraction index
n2=1.46
l=1*(10**-6) #Wavelength
#from equation 8.16
d=l*(1/(2*sqrt((n1**2)-(n2**2))))
print "The Waveguide core thickness must be less than %.2e meter"%(d)
from math import sqrt
n1=1.48 #Given refraction index
n2=1.46
l=900*(10**-9) #Wavelength in meter
r=100*(10**-6) #Core radius in meter
PI=3.14
V=(2*PI*r*sqrt((n1**2)-(n2**2)))/l #Where V is a given Parameter
V=round(V,1)
N=(V**2)/2 #Where N is the Number of Modes
N=round(N,1)
print "The Given V Parameter is "+str(V)
print "The Number of Modes able to propagate in a fiber is "+str(N)
from math import asin
from math import degrees
from math import sqrt
n1=1.48
n2=1.46 #Given refraction Index
no=1
theta=asin(n2/n1)
theta1=degrees(theta)
#Using equation 8.22
delta=((n1**2)-(n2**2))/(2*(n1**2))
delta=round(delta,4)
#using expression of 8.22a
delta1=(n1-n2)/n1
delta1=round(delta1,4)
NA=sqrt((n1**2)-(n2**2))
NA=round(NA,3)
a=asin(NA) #where a is another fiber parameter
a1=degrees(a)
a1=round(a1,2)
print "The Delta Parameter is "+str(delta)+" & "+str(delta1)
print "The Numerical aperture is "+str(NA)
print "The fiber acceptance angle is "+str(a1)+" degrees"
n1=1.48 #Given refractive index
n2=1.46
L=1*(10**3) #length of fiber
c=3*(10**8) #speed of light
#Using equation 8.24
t=((l*n1)/(c*n2))*(n1-n2) #where t is the time difference due tp intermodal dispersion
print "The Time difference due to Intermodal dispersion is %.2e seconds"%(t)
n1=1.48 #Given refraction index
n2=1.46
l=10**3 #length of the fiber
c=3*(10**8) #Speed of light
delta=((n1**2)-(n2**2))/(2*(n1**2)) #Where delta is one of the fiber parameter
delta=round(delta,4)
t=(l*n1*(delta**2))/(c*8) #where t is the minimum pulse broadening
print "The Delta Paramter is "+str(delta)
print "The Minimum Pulse Broadening is %.2e seconds"%(t)
n1=1.48 #Given refraction indices
n2=1.46
NA=0.242
l=1.5*(10**-6) #Wavelength of radiation
#From equation 8.27
a=(2.405*l)/(2*3.14*NA) #where a is the maximum core radius
print "The Maximum Core Radius is less than or is %.2e meter"%(a)
#With NA=0.1
NA=0.1
a=(2.405*l)/(2*3.14*NA) #where a is the maximum core radius
print "The Maximum Core radius is less than or is %.2e meter"%(a)
#At V=2 The Diameter would 9.5 micro meter
V=2
#From equation 8.29a
w=0.65+(1.619*(V**(-1.5)))+(2.879*(V**-6))
w=round(w,3)
print "The Mode Field Irradiance Diameter is "+str(w)
#Answer is a bit Miscalculated here
%matplotlib inline
import math
from matplotlib.pyplot import plot,suptitle,xlabel,ylabel
X = [0,0.25,0.5,0.75,1,1.25,1.5,1.55,1.75,2,2.5]
V = [1,0.08,0.07,0.04,0.02,0.0,-0.007,-0.015,-0.03,-0.04,-0.06]
plot(X,V);
xlabel("Wavelength in micrometer")
ylabel("D (Dimensionless Quantity)")
suptitle("Fig 8.26")
l=10.0**3 #length of the fiber
w1=850.0*(10**-9) #Given Wavelength
lw=50.0*(10**-9) #Linewidth in meter
w2=1550.0*(10**-9) #Given Wavelength 2
lw2=3.0*(10**-9) #Linewidth 2 in meter
c=3.0*(10**8) #Speed of light
print""
print "From Figure 8.26 We can calculate the dimensionless quantity "
d1=2.14*(10**-2) #For w1 after observation
d2=-1.02*(10**-2) #For w2 after observation
#From equation 8.34
t1=(l/c)*d1*(lw/w1) #Where t1 is the material dispersion effects for w1
t2=(l/c)*d2*(lw2/w2) #Where t2 is the material dispersion effects for w2
print " "
print " (a) The Material Dispersion Effect Parameter for the LED is %.2e seconds"%(t1)
print " (b) The Material Dispersion Effect Paramter for the Laser is %.2e seconds"%(-1*t2)
from math import exp
from math import log10
l=1*(10**-6) #Given Wavelength
l1=10**3 #length of the fiber
n=1.45 #Refractive Index
p=0.286
B=7*(10**-11)
T=1400 #Temperature in kelvin
PI=3.14
k=1.38*(10**-23) #Boltzman Constant
#From equation 8.38
ar=((8*(PI**3))/(3*(l**4)))*((n**8)*B*T*k*(p**2)) #Where ar is the attenuation due to raleigh scattering in per meter
ar=round(ar,6)
print "The Attenuation due to Raleigh Scattering in a silica fiber is "+str(ar)+" /m"
i1=(ar*-1*l1)
j=exp(i1)
Loss=-10*log10(j) #Where Loss is the given loss generated from attenuation
Loss=round(Loss,2)
print "The Total loss due to Attenuation is "+str(Loss)+" db/km"
#at a wavelength of 1.55 micro meter we have
l=1.55*(10**-6) #new Wavelength
ar=((8*(PI**3))/(3*(l**4)))*((n**8)*B*T*k*(p**2)) #Where ar is the attenuation due to raleigh scattering in per meter
ar=round(ar,6)
print "The Attenuation due to Raleigh Scattering in a silica fiber is "+str(ar)+" /m"
Loss=-10*log10(exp(ar*-1*l1)) #Where Loss is the given loss generated from attenuation
Loss=round(Loss,2)
print "The Total loss due to Attenuation is "+str(Loss)+" db/km"
from math import log10
n=1.48 #Refraction index of fiber
n0=1 #refraction index between the fibers in air
#From equation 8.39
Rf=(((n-1)/(n+1))**2) #Where Rf is the fraction of light
Rf=round(Rf,4)
Tf=((1-Rf)**2) #Where Tf is the total transmission for each face due to fresnals reflection
Tf=round(Tf,4)
L=-10*log10(Tf) #where L is the Transmission Loss
L=round(L,2)
print "The Fraction of light reflected back at each end is "+str(Rf)
print "The Total Transmission for each face due to Fresnals Reflection is "+str(Tf)
print "The Total Transmission loss is "+str(L)+" db"
from math import acos
from math import log10
from math import sqrt
l=0.1 #where l=D/2a and occurs due to lateral misalignment where D is the lateral displacement and a is the fiber core radius
PI=3.14
#From equation 8.40
T=(2/PI)*(acos(l)-l*(sqrt(1-(l**2))))
L=-10*log10(T) #Where L is the Transmission loss
L=round(L,2)
#taking tha calculation of Fresnels loss from above example also we have
LT=L+0.332
print "The Total Transmission loss is "+str(L)+" db"
print "The Total Transmission loss including Fresnels loss is "+str(LT)+" db"
from math import log10
d1=200*(10**-6) #in meter
d2=250*(10**-6) #in meter
# d2 & d1 where d1 is the core diameter and d2 is the core+cladding diameter
#The Mixing rod has a diameter of 3d2
d3=3*d2
#Given Power Levels P1=(B*3.14*(3d2**2))/4 & P2=(B*3.14*(d1**2)/)/4 where B is a constant
L=-10*log10((d1**2)/(d3**2)) #Where L is the Insertion Loss
Le=-10*log10((7*(d1**2))/(d3**2)) #Where Le is the Excess loss
L=round(L,1)
Le=round(Le,2)
print "The Insertion loss is "+str(L)+" db"
print "The Excess Loss is "+str(Le)+" db"