import math
#variable declaration
Lambda2 = 1520.0*10**-9 #spectral bandwidth(nHz)
Lambda1 = 1420.0*10**-9
C = 3.0*10**8 #free space velocity(m/s)
delta_Lambda1=100.0*10**-9 #spectral band(nm)
delta_Lambda2=105.0*10**-9
#calculation
delta_v1= C*delta_Lambda1 /(Lambda1**2) #optical bandwidth(Hz)
delta_v2= C*delta_Lambda2/(Lambda2**2)
#result
print "Usable spectral band for 100 nm = ",round(delta_v1*10**-12,1),"THz"
print "Usable spectral band for 100 nm = ",round(delta_v2*10**-12),"THz"
import math
#variable declaration
c=3.0*pow(10,8) #free space velocity(m/s)
delta_lambda=0.8*pow(10,-9) #spectral band (meter)
lam_bda=1550*pow(10,-9) #wavwlenth (meter)
#calculation
delta_v=(c*delta_lambda)/lam_bda**2 #Mean freqency spacing(GHz)
#result
print "Mean freqency spacing = " , round(delta_v*(pow(10,-9))),"GHz"
import math
#variable declaration
p0=200.0*pow(10,-6) #input optical power level (watts)
p1=90.0*pow(10,-6) #output power at port-1
p2=85.0*pow(10,-6) #output power at port-2
p3=6.3*pow(10,-9) #output power at port-3
#calculation
coupling_ratio=(p2/(p1+p2))*100 #Coupling ratio(%)
Excess_loss=10*(math.log10(p0/(p1+p2))) #Excess loss(dB)
Insertion_loss_0_1=10*(math.log10(p0/p1)) #Insertion loss(dB)
Insertion_loss_0_2=10*(math.log10(p0/p2))
Return_loss = 10*(math.log10(p3/p0)) #Return loss(dB)
#result
print "Coupling ratio = " , round(coupling_ratio,1) , "%"
print "Excess loss = " , round(Excess_loss,2) , "dB"
print "Insertion loss (port0 to port1 = " , round(Insertion_loss_0_1,2), "dB"
print "Insertion loss (port0 to port2 = " , round(Insertion_loss_0_2,2), "dB"
print "Return loss = " , round(Return_loss), "dB"
import math
#variable declaration
k = 0.6/(10**-3) #Coupling coefficint (per mm)
m = 1 #mode=1
#calculation
L = ((math.pi)*(m+1))/(2*k) #coupling length(mm)
#result
print "Coupling length L = ",round(L*(10**3),2),"mm"
import math
#variable declaration
Power_Lost = 5.0/100.0 #lost power%
FT = 1-Power_Lost #power coupled
N = 32
#calculation
Excess_Loss = -10*(math.log10(FT**(math.log10(N)/math.log10(2)))) #Excess Loss(dB)
Splitting_Loss = -10*math.log10(N) #Splitting Loss(dB)
Total_Loss = (-Excess_Loss) + Splitting_Loss
#result
print "Excess Loss = " , round(Excess_Loss,1) ,"dB"
print "Splitting Loss = " , round(abs(Splitting_Loss)) ,"dB"
print "Total Loss experienced in Star Couplers = " , round(-Total_Loss,1) , "dB"
import math
#variable declaration
delta_lambda=0.08*pow(10,-9) #wavelength spacing (nm)
lam_bda=1550*pow(10,-9) #wavelength (meters)
neff=1.5 #effective refractive index in the waveguide
c=3*10**8 #free space velocity(m/s)
#calculation
delta_v1=10*10**9 #Frequency sepration
delta_l1=c/(2*neff*delta_v1) #Waveguide length(mm)
#result
print "Waveguide length1 diffrence = " , round(delta_l1*10**3) ,"mm"
import math
#variable declaration
delta_lambda=0.08*pow(10,-9) #wavelength spacing (nm)
lam_bda=1550*pow(10,-9) #wavelength (meters)
neff=1.5 #effective refractive index in the waveguide
c=3*10**8 #free space velocity(m/s)
#calculation
delta_v2=130*10**9 #Frequency sepration
delta_l2=c/(2*neff*delta_v2) #Waveguide length(mm)
#result
print "Waveguide length2 diffrence = " , round(delta_l2*10**3,2) ,"mm"
import math
#variable declaration
kl=1.0 #coupling coeffiecint and length
k2=2.0
k3=3.0
#calculation
rmax1=math.tanh(kl)**2 #peak reflectivity Rmax
rmax2=math.tanh(k2)**2
rmax3=math.tanh(k3)**2
#result
print "For k1 Rmax = " , round(rmax1*100) ,"%"
print "For k2 Rmax = " , round(rmax2*100) ,"%"
print "For k3 Rmax = " ,round(rmax3*100) ,"%"
import math
#variable declaration
L=0.5 #length (cm)
lam_bda_brg = 1530*10**-9 #reflaaction wavelength(nm)
n_eff = 1.48 #mode effective index of core
delta_n = 2.5*10**-4
etta = 0.82 #efficiency(%)
#calculation
k = (math.pi*delta_n*etta)/(lam_bda_brg) #coupling coefficint
delta_lambda = (lam_bda_brg**2)*(math.sqrt(((k/100*L)**2)+math.pi**2))/(math.pi*n_eff*L) #bandwidth
#result
print "Coupling coefficint = ", round(k/100,1), "1/cm"
print "Total bandwidth = ", round(delta_lambda*10**11,2),"nm"
import math
#variable declaration
lambda_c=1550*pow(10,-9) #wavelength(nm)
nc=1.45 #refrective index of grating array waveguide
ns=1.45 #refrective index of teh star coupler
ng=1.47 #group index of grating array waveguide
x=5*10**-6 #spacing between input waveguide(um)
d=5*10**-6 #spacing between output waveguide(um)
m=1 #mode
lf=10*10**-3 #distance between Tx to Rx
#calculation
delta_l=m*lambda_c/nc #waveguide length diffrence(um)
delta_lambda=(x/lf)*(ns*d/m)*(ns/ng) #channel spacing(nm)
#result
print "Waveguide length diffrence = " , round(delta_l*10**6,3), "um"
print "Channel spacing interms of wavelength = " , round(delta_lambda*10**9,2) ,"nm"
import math
#variable declaration
nc=1.45 #refractive index
Lambda_C = 1550.5*pow(10,-9) #center wavelength(nm)
delta_Lambda = 32.2*pow(10,-9) #free spectral range(nm)
c=3*10**8 #free space velocity(m/s)
#calculation
delta_L = Lambda_C**2/(nc*delta_Lambda) #length diffrence(um)
#result
print "Length diffrence between adjacent array waveguide = " , round(delta_L*10**6,2) , "um"
import math
#variable declaration
Lam_bda = 1550*pow(10,-9) #DBR laser wavelength(nm)
delta_neff = 0.0065 #index change
#calculation
delta_Lambda_tune = Lam_bda*delta_neff #tuning range (meter)
delta_Lambda_signal = 0.02*pow(10,-9) #spectral width(meter)
delta_Lambda_channel = 10*delta_Lambda_signal #channal width
N = delta_Lambda_tune/delta_Lambda_channel #The number of channels
#result
print "Tuning wavelength = " , round(delta_Lambda_tune*10**9) , "nm"
print "The number of channels that can operate in this tuning range is N = " , round(N)