from math import pi, sqrt, asin
# Given
mu1 = 1.52 # refractive index for core
mu2 = 1.41 # refractive index for cladding
#Calculations
theta_c = asin(mu2 / mu1) * (180 / pi)
NA = sqrt(mu1**2 - mu2**2)
theta_0 = asin(NA) * (180 / pi)
#Result
print "Critical angle = %.2f degree \nNumerical aperture = %.3f\nMaximum incidence angle = %.1f degree"%(theta_c,NA,theta_0)
from math import pi, sqrt, asin
# Given
mu1 = 1.6 # refractive index for core
mu2 = 1.5 # refractive index for cladding
#Calculations
NA = sqrt(mu1**2 - mu2**2)#calculation for numerical aperture
theta_0 = asin(NA) * (180 / pi)#calculation for maximum incidence angle
#Result
print "Numerical aperture = %.3f\nMaximum incidence angle = %.2f degree"%(NA,theta_0)
from math import pi, sqrt, asin
# Given
mu_0 = 1 # refractive index of air
mu1 = 1.5 # refractive index for core
mu2 = 1.48 # refractive index for cladding
#Calculations
theta_c = asin(mu2 / mu1) * (180 / pi)
delta_mu = (mu1 - mu2) / mu1
NA = sqrt(mu1**2 - mu2**2)
theta_0 = asin(NA) * (180 / pi)
#Result
print "Critical angle = %.2f degrees \nNumerical aperture = %.3f \nAcceptance angle = %.2f degrees\nFractional refractive index = %.2f %%"%(theta_c,NA,theta_0,delta_mu*100)
from math import *
# Given
mu1 = 1.62 # refractive index for core
mu2 = 1.52 # refractive index for cladding
#Calculations
NA = sqrt(mu1**2 - mu2**2)
theta_0 = asin(NA) * (180 / pi)
#Results
print "Numerical aperture = %.2f \nMaximum incidence angle = %.1f degrees"%(NA,theta_0)
from math import sqrt
# Given
NA = 0.22 # numerical aperture
delta_mu = 0.012 # fractional refractive index
#Calculations
mu1 = sqrt(NA**2 / (1 - (1 - delta_mu)**2))
mu2 = (1 - delta_mu) * mu1
#Result
print "Refractive index for core = %.3f\nRefractive index for cladding = %.2f"%(mu1,mu2)
from math import pi, sqrt, asin, sin
# Given
d = 0.0064 # diameter of fiber in cm
mu1 = 1.53 # refractive index for core
mu2 = 1.39 # refractive index for clad
L = 90 # length of fiber in cm
mu_0 = 1 # refractive index of air
#calculations
NA = sqrt(mu1**2 - mu2**2)
theta_0 = asin(NA) * (180 / pi)
N1 = L / (d * sqrt((mu1 / (mu_0 * sin(theta_0 * (pi / 180))))**2 - 1))
N2 = L / (d * sqrt((mu1 / (mu_0 * sin(theta_0 * (pi / 360))))**2 - 1))
#Result
print "Numerical aperture = %.2f\nAcceptance angle = %.1f degrees \nNumber of reflections at maximum incidence = %.f \nNumber of reflections in second case = %.f "%(NA,theta_0,N1,N2)
#Incorrect answer in the textbook
from math import pi
# Given
d = 0.05 # diameter of fiber in mm
NA = 0.22 # numerical aperture
l = 8.5e-4 # wavelength of light in mm
#calculations
Vn = (pi * d * NA) / l
Mm = 0.5 * (Vn)**2
#Result
print "The normalized frequency = %.2f\nNumber of guided in the core = %d"%(Vn,Mm)
from math import sqrt, pi
# Given
l = 1.25e-6 #wavelength of light in meter
mu1 = 1.465 # refractive index for core
mu2 = 1.460 # refractive index for cladding
#Calculations
NA = sqrt(mu1**2 - mu2**2)
k = (2.4 * l) / ( pi * NA)
Mm = 0.5 * ((pi * 50e-6 * NA) / l)**2
#Result
print "Diameter of core < %.1e meter,\n number of modes = %d"%(k,Mm)
from math import sqrt, pi
# Given
l = 0.85e-6 #wavelength of light in meter
mu1 = 1.461 # refractive index for core
mu2 = 1.456 # refractive index for clad
d = 4e-5 # diameter of core in meter
#Calculations
NA = sqrt(mu1**2 - mu2**2)
Mm = 0.5 * ((pi * d * NA) / l)**2
#Result
print "Numerical aperture = %.3f\n Number of modes = %d "%(NA,Mm)
from math import sqrt, pi
# Given
mu1 = 3.6 # refractive index for core
mu2 = 3.55 # refractive index for cladding
#Calculations
NA = sqrt(mu1**2 - mu2**2)#calculation for numerical aperture
Mm1 = 0.5 * (pi * 5 * NA)**2#calculation for no. of modes in first case
Mm2 = 0.5 * (pi * 50 * NA)**2#calculation for no. of modes in second case
#Result
print "Number of modes in first case = %d \nNumber of modes in second case = %d"%(Mm1,Mm2)
#Incorrect answer in the textbook
from math import sqrt, pi
# Given
l = 1.25e-6 #wavelength of light in meter
mu1 = 1.46 # refractive index for core
mu2 = 1.457 # refractive index for cladding
#Calculations
NA = sqrt(mu1**2 - mu2**2)#calculation for numerical aperture
k = (2.4 * l) / ( pi * NA)
#Result
print "Maximum diameter of core = %.2f micro meter"%(k*1e6)
from math import log10
# Given
L = 0.1 # length of fiber in km
p = 5e-6 # power of signal in watt
p_ = 1e-6 # power of signal inside the fiber in watt
#Calculation
alpha = (10 * log10(p / p_)) / L#calculation for absorption coefficient
#Result
print "Absorption coefficient = %d dB/km "%alpha
from math import exp
# Given
L = 3 # length of optical fiber in km
l = 6 # losses in dB
p = 5e-3 # input power in watt
#calculations
alpha = (l * 3) / L
p_ = p / (exp((2.303 * alpha * L) / 10))
#Result
print "Output power = %.3f mW "%(p_*1e3)