'''Determine maximum thickness of film'''
import math
#Variable declaration
n1 = 3.5 #core refractive index
n2 = 3.0 #cladding refractive index
v = 6 #no. of modes
lamda = 1.5 #propagating wavelength(um)
#Calculations
theta_c = math.degrees(math.asin(n2/n1))
h = (2*math.pi*v*lamda)/(2*math.pi*n1*math.cos(math.radians(theta_c)))
#Result
print "The thickness of the film should be less than",round(h),"um"
'''find the angle of acceptance and crtitical angle'''
import math
#Variable declaration
n1 = 1.53 #core refractive index
n2 = 1.48 #cladding refractive index
n0 = 1 #refractive index for air
#calculations
theta_a = math.degrees(math.asin(((n1**2-n2**2)**0.5)/n0))
theta_c = math.degrees(math.asin(n2/n1))
#Result
print "Angle of acceptance =",round(theta_a,2),"degrees"
print "Critical angle =",round(theta_c,2),"degrees"
'''Determine the numerical aperture'''
import math
#Variable declaration
v = 26.6 #frequency(Hz)
lamda = 1.3 #propagating wavelength(um)
a = 25 #core radius(um)
#Calculation
NA = (v*lamda)/(2*math.pi*a)
#Result
print "Numerical aperture =",round(NA,2)
'''Determine the numerical aperture'''
import math
#Variable declaration
n1 = 1.4675 #core refractive index
n2 = 1.4622 #cladding refractive index
#Calculation
NA = math.sqrt(n1**2-n2**2)
#Result
print "Numerical aperture =",round(NA,3)
'''Determine cut-off wavelength for step index fiber'''
import math
#Variable declaration
n1 = 1.5 #core refractive index
n2 = 1.47 #cladding refractive index
a = 4 #core radius(um)
#Calculation
lamda_c = (2*math.pi*a*((n1**2-n2**2)**0.5))/2.405
#Result
print "The cut-off wavelength is",round(lamda_c,2),"um"
'''Determine maximum diameter of the core for single mode fiber'''
import math
#Variable declaration
n1 = 1.55 #core refractive index
n2 = 1.48 #cladding refractive index
lamda = 1.55 #wavelength(um)
#Calculations
a = (2.405*lamda)/(2*math.pi*(n1**2-n2**2)**0.5)
d = 2*a #diameter
#Result
print "Maximum diameter of the core is",round(d,2),"um"
'''Determine the number of modes propagating'''
import math
#Variable declaration
n1 = 1.48 #core refractive index
n2 = 0.01 #cladding refractive index
a = 25 #core radius(um)
lamda = 0.84 #Wavelength(um)
#Calculation
m = 2*(2*math.pi/lamda)**2*(a**2/2)*(n1**2-n2**2)
v = math.sqrt(2*m)
#Result
print "Number of modes =",v, "(Calculation mistake in textbook while calculating 'm'. Hence, the answer differs)"
'''Determine the number of modes for multimode fiber and calculate the same when lamda is changed to 1.3um'''
import math
#Variable declaration
n1 = 1.475 #core refractive index
n2 = 1.472 #cladding refractive index
a = 20 #core radius(um)
lamda = 0.85 #Wavelength(um)
#Calculation
v = (2*math.pi*a*math.sqrt((n1**2-n2**2)))/lamda
M1 = v**2/2
lamda2 = 1.3 #um
v2 = (2*math.pi*a*math.sqrt((n1**2-n2**2)))/lamda2
M2 = v2**2/2
#Results
print "Number of modes when lamda is changed =",round(M1) #v is calculated wrongly in the book and answer for case a M not given
print "Number of modes when lamda is changed =",round(M2)
'''Determine the numerical aperture'''
import math
#Variable declaration
n1 = 1.5 #core refractive index
n2 = 1.48 #cladding refractive index
#Calculation
NA = math.sqrt(n1**2-n2**2)
#Result
print "Numerical aperture =",round(NA,5)
'''Determine core radius, NA and maximum acceptance angle'''
import math
#Variable declaration
n1 = 1.450 #core refractive index
n2 = 1.447 #cladding refractive index
lamda = 1.3 #Wavelength(um)
#Calculation
v = 2.405
a = (v*lamda)/(2*math.pi*math.sqrt((n1**2-n2**2)))
NA = math.sqrt(n1**2-n2**2)
theta_max = math.degrees(math.asin(NA))
#Results
print "Core radius =",round(a,3),"um"
print "Numerical aperture =",round(NA,4)
print "Maximum acceptance angle =",round(theta_max,3),"degrees"
'''Determine critical angle at core cladding interface, NA and acceptance angle'''
import math
#Variable declaration
n1 = 1.50 #core refractive index
n2 = 1.47 #cladding refractive index
#calculations
theta_c = math.degrees(math.asin(n2/n1))
NA = math.sqrt(n1**2-n2**2)
theta_a = math.degrees(math.asin(NA))
#Result
print "Critical angle at core cladding interface =",round(theta_c,1),"degrees"
print "Numerical aperture =",round(NA,2)
print "Maximum acceptance angle =",round(theta_a,1),"degrees"
'''Determine the acceptance angle for skew rays'''
#Variable declaration
NA = 0.4 #numerical aperture
#Since skew rays change direction by 100 degrees at each reflection,
r = 50 #degrees
#Calculations
theta_as = math.degrees(math.asin(NA/math.cos(math.radians(r))))
#print
print "Acceptance angle =",round(theta_as,1),"degrees"
'''Determine normalized frequency and number of guided modes'''
import math
#Variable declaration
n1 = 1.48 #core refractive index
lamda = 0.85 #wavelength(um)
a = 80/2 #core radius(um)
delta = 1.5/100 #relative index difference
#Calculations
v = (2*math.pi*a*n1*(2*delta)**0.5)/lamda
M = v**2/2
#Results
print "Normalized frequency =",round(v,1),"Hz"
print "Number of guided modes =",round(M)
'''Determine cut off value for normalized frequency and maximum core radius'''
import math
#Variable declaration
n1 = 1.5 #core refractive index
lamda = 1.3 #wavelength(um)
delta = 1./100. #relative index difference
alpha = 2
#Calculations
v = 2.4*(1+2/alpha)**0.5
a = (v*lamda)/(2*math.pi*n1*(2*delta)**0.5)
#Results
print "Cut off value for normalized frequency =",round(v,2)
print "Maximum core radius =",round(a,2),"um"
'''Determine cut-off wavelength for step index fiber'''
import math
#Variable declaration
n1 = 1.46 #core refractive index
a = 4.5 #core radius(um)
delta = 0.25/100
#Calculation
lamda_c = (2*math.pi*a*n1*(2*delta)**0.5)/2.405
#Result
print "The cut-off wavelength is",round(lamda_c,3),"um"
'''Determine the numerical aperture and acceptance angle'''
import math
#Variable declaration
n1 = 1.45 #core refractive index
n2 = 1.4 #cladding refractive index
#Calculation
NA = math.sqrt(n1**2-n2**2)
theta_m = math.degrees(math.asin(NA))
#Result
print "Numerical aperture =",round(NA,4)
print "Acceptance angle =",round(theta_m,2),"degrees"
'''Calculate cladding index, crtical internal reflection angle, external critical acceptance angle and numerical aperture'''
import math
#Variable declaration
n1 = 1.5 #core refractive index
delta = 0.0005
#Calculations
n2 = n1*(1-delta)
theta_c = math.degrees(math.asin(n2/n1))
n0 = 1 #refractive index for air
theta_m = math.degrees(math.asin(((n1**2-n2**2)**0.5)/n0))
NA = n1*math.sqrt(2*delta)
#Results
print "Cladding index =",round(n2,5)
print "Crtical internal reflection angle =",round(theta_c,1),"degrees"
print "External critical acceptance angle =",round(theta_m,2),"Degrees"
print "Numerical aperture =",round(NA,4)
'''Determine acceptance angle for fiber in water'''
#Variable declaration
NA = 0.20 #numerical aperture
n2 = 1.59 #cladding refractive index
n0 = 1.33 #refractive index for water
#Calculations
n1 = math.sqrt(NA**2+n2**2)
NA = math.sqrt(n1**2-n2**2)/n0
theta_m = math.degrees(math.asin(NA))
#Result
print "Acceptance angle for fiber in water =",round(theta_m,1),"degrees"
'''Determine the numerical aperture and acceptance angle'''
import math
#Variable declaration
n1 = 1.55 #core refractive index
n2 = 1.51 #cladding refractive index
#Calculation
delta = (n1-n2)/n1
NA = 2*math.sqrt(delta)
theta_m = math.degrees(math.asin(NA))
#Result
print "Numerical aperture =",round(NA,4)
print "Acceptance angle =",round(theta_m,2),"degrees"
print "\nCalculation mistakes in textbook. Hence, the answers differ."
'''Determine normalized frequency'''
#Variable declaration
n = 1.45 #core refractive index
lamda = 0.1 #wavelength(um)
a = 60/2 #core radius(um)
NA = 0.16 #numerical aperture
#Calculations
v = (2*math.pi*a*NA)/lamda
#Results
print "Normalized frequency =",round(v,1),"(Calculation mistake in textbook)"
'''Calculate NA and multi path dospersion per unit length'''
#Variable declaration
c = 3.*10**8 #speed of light in vacuum(m/s)
v = 2.*10**8 #speed of light in core(m/s)
theta_c = 75 #cricial angle(degrees)
#Calculations
n1 = c/v
n2 = n1*math.sin(math.radians(theta_c))
NA = math.sqrt(n1**2-n2**2)
delta_n = n1-n2
md = (n1/n2)*(delta_n/c) #multipath dispersion
#Results
print "Numerical aperture =",round(NA,2)
print "Multi path dospersion per unit length =",round((md/1E-9),3),"*10^-9 s/m"
'''Determine maximum thickness of guide slab'''
#Variable declaration
n1 = 3.6 #core refractive index
n2 = 3.56 #cladding refractive index
lamda = 0.85 #wavelength(um)
#For TE10 mode,
m = 1
n = 0
vc = 2.405 #for planar guide
#Calculation
a = (vc*lamda)/(2*math.pi*math.sqrt(n1**2-n2**2))
#Result
print "Maximum thickness of guide slab =",round(a,3),"um"
'''Calculate diameter of core'''
import math
#Variable declaration
n1 = 1.5 #core refractive index
lamda = 1.3*10**-6 #wavelength(um)
delta = 1./100. #relative index difference
M = 1100
#Calculations
V = math.sqrt(2*M)
a = (V*lamda)/(2*math.pi*n1*(2*delta)**0.5)
d = 2*a
#Result
print "Diameter =",round(d/1E-5,2),"um(Calculation mistake in textbook)"
'''Determine critical angle and numerical aperture'''
#Variable declaration
n1 = 1.50 #core refractive index
n2 = 1.46 #cladding refractive index
#Calculation
theta_c = math.degrees(math.asin(n2/n1))
NA = math.sqrt(n1**2-n2**2)
#Result
print "Critical angle =",round(theta_c,2),"degrees"
print "Numerical aperture =",round(NA,2)
'''Determine the acceptance angle for skew rays'''
#Variable declaration
NA = 0.344 #numerical aperture
#Since skew rays change direction by 100 degrees at each reflection,
gamma = 100/2 #degrees
#Calculations
#For meridional rays
theta_a = math.degrees(math.asin(NA))
#For speed rays
theta_as = math.degrees(math.asin(NA/math.cos(math.radians(gamma))))
#print
print "Acceptance angle for meridional rays =",round(theta_a,2),"degrees"
print "Acceptance angle for speed rays =",round(theta_as,2),"degrees"
'''Calculate the no. of guided modes and cut-off value of normalized frequency'''
import math
#Variable declaration
n1 = 1.5 #core refractive index
lamda = 1.55 #wavelength(um)
delta = 1.3/100. #relative index difference
alpha = 1.90 #index profile
a = 40/2 #core radius(um)
#Calculations
Mg = (alpha/(alpha+2))*((n1*2*math.pi*a)/lamda)**2*delta
Vc = 2.405*math.sqrt(1+2/alpha)
#Results
print "Number of guided modes =",round(Mg)
print "Cut-off value of normalized frequency =",round(Vc,2)