# chapter5 - Optical fiber connection : splicing¶

## Example 5.2.1, page 5-2¶

In :
from __future__ import division
from numpy import sqrt, pi, log10
n1=1.47         #refractive index of fiber
n=1         #refractive index of air
r=((n1-n)/(n1+n))**2     #computing fraction of light reflected
loss=-10*log10(1-r)     #loss
total_loss=2*loss
print "r = %.3f, which means %.1f percent of the transimitted light is reflected at one interface" %(r,r*100)
print "Total loss is %.3f dB" %(total_loss)
#answer in the book for total loss of fiber is wrong.

r = 0.036, which means 3.6 percent of the transimitted light is reflected at one interface
Total loss is 0.320 dB


## Example 5.2.2, page 5-4¶

In :
from numpy import arccos
n1=1.47         #refractive index of fiber
n=1         #refractive index of air
d=40*10**-6     #core diameter
y=4*10**-6      #lateral dispalcement
eta_lateral = (16*(n1/n)**2)/(pi*(1+(n1/n))**4)*(2*arccos(y/(2*a))-(y/a)*(1-(y/(2*a))**2)**0.5)      #computing eta_lateral with air gap
loss=-10*log10(eta_lateral)         #computing loss when air gap is present
eta_lateral1=(2*arccos(y/(2*a))-(y/a)*(1-(y/(2*a))**2)**0.5)/pi        #computing eta_lateral without air gap
loss1=-10*log10(eta_lateral1)       #computing loss when air gap is not present
print "loss with air gap is %.2f dB.\nloss with no air gap is %.2f dB." %(loss,loss1)
#answer in the book for loss with air gap is wrong

loss with air gap is 0.91 dB.
loss with no air gap is 0.59 dB.


## Example 5.2.3, page 5-5¶

In :
n1=1.48         #refractive index of fiber
n=1         #refractive index of air
theta=10    #angle in degree
NA1=0.3
NA2=0.6
eta_angular1= (16*(n1/n)**2)/((1+(n1/n))**4)*(1-((n*theta*pi/180)/(pi*NA1)))    #computing eta angular
eta_angular2= (16*(n1/n)**2)/((1+(n1/n))**4)*(1-((n*theta*pi/180)/(pi*NA2)))    #computing eta angular
loss1=-10*log10(eta_angular1)       #computing loss
loss2=-10*log10(eta_angular2)       #computing loss
print "\nLoss when NA is %.1f is %.2f dB.\nLoss when NA is %.1f is %.2f dB." %(NA1,loss1,NA2,loss2)

Loss when NA is 0.3 is 1.22 dB.
Loss when NA is 0.6 is 0.75 dB.


## Example 5.4.1, page 5-15¶

In :
from numpy import exp
d=1*10**-6      #lateral displacement
W=4.95*10**-6   #MFD
Lsm_lat= -10*log10(exp(-(d/W)**2))       #computing loss
print "Insertion loss is %.2f dB." %(Lsm_lat)

Insertion loss is 0.18 dB.


## Example 5.4.2, page 5-15¶

In :
lamda=1.3*10**-6    #wavelength
theta=1         #angle in degree
W=4.95*10**-6       #MFD
Lsm_ang= -10*log10(exp(-(pi*n2*W*(theta*pi/180)/lamda)**2))       #computing loss
print "Insertion loss is %.2f dB." %(Lsm_ang)

Insertion loss is 0.41 dB.


## Example 5.6.1, page 5-28¶

In :
p1=50*10**-6
p2=0.003*10**-6
p3=25*10**-6
p4=26.5*10**-6
EL=10*log10(p1/(p3+p4))         #computing excess loss
IL13=10*log10(p1/p3)      #computing insertion loss
IL14=10*log10(p1/p4)      #computing insertion loss
ct=10*log10(p2/p1)      #computing cross talk
sr=(p3/(p3+p4))*100     #computing split ratio
print """Excess loss is %.2f dB.
Insertion loss from port 1 to port 3 is %.2f dB.
Insertion loss from port 1 to port 4 is %.2f dB.
cross talk is %.2f dB.\nSplit ratio is %.2f percent""" %(EL,IL13,IL14,ct,sr  )
#Printing and calculation error in the book.Minus sign is not printed in the answer of excess loss.
#P1 is taken 25 instead of 50 while calculating cross talk.

Excess loss is -0.13 dB.
Insertion loss from port 1 to port 3 is 3.01 dB.
Insertion loss from port 1 to port 4 is 2.76 dB.
cross talk is -42.22 dB.
Split ratio is 48.54 percent


## Example 5.6.2, page 5-29¶

In :
N=16        #Number of ports
Pin=1*10**-3    #input power
Pout=12*10**-6  #output power
split_loss=10*log10(N)      #computing split loss
excess_loss=10*log10(Pin/(Pout*N))      #computing excess loss
total_loss=split_loss+excess_loss       #computing total loss
insertion_loss= 10*log10(Pin/Pout)      #computing insertion loss
print "Total loss is %.2f dB.\nInsertion loss is %.2f dB." %(total_loss,insertion_loss)
#answer in the book for Total loss & insertion loss are wrong.

Total loss is 19.21 dB.
Insertion loss is 19.21 dB.